@vectorize-io/hindsight-control-plane 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +2 -2
  2. package/standalone/.next/BUILD_ID +1 -1
  3. package/standalone/.next/build-manifest.json +2 -2
  4. package/standalone/.next/prerender-manifest.json +3 -3
  5. package/standalone/.next/required-server-files.json +2 -1
  6. package/standalone/.next/server/app/_global-error.html +2 -2
  7. package/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/standalone/.next/server/app/_not-found.html +1 -1
  15. package/standalone/.next/server/app/_not-found.rsc +13 -13
  16. package/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +13 -13
  17. package/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  18. package/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +8 -8
  19. package/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  20. package/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  21. package/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  22. package/standalone/.next/server/app/banks/[bankId]/page_client-reference-manifest.js +1 -1
  23. package/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  24. package/standalone/.next/server/app/dashboard.html +1 -1
  25. package/standalone/.next/server/app/dashboard.rsc +7 -7
  26. package/standalone/.next/server/app/dashboard.segments/_full.segment.rsc +7 -7
  27. package/standalone/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  28. package/standalone/.next/server/app/dashboard.segments/_index.segment.rsc +6 -6
  29. package/standalone/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  30. package/standalone/.next/server/app/dashboard.segments/dashboard/__PAGE__.segment.rsc +2 -2
  31. package/standalone/.next/server/app/dashboard.segments/dashboard.segment.rsc +1 -1
  32. package/standalone/.next/server/app/index.html +1 -1
  33. package/standalone/.next/server/app/index.rsc +6 -6
  34. package/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  35. package/standalone/.next/server/app/index.segments/_full.segment.rsc +6 -6
  36. package/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  37. package/standalone/.next/server/app/index.segments/_index.segment.rsc +6 -6
  38. package/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  39. package/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/standalone/.next/server/chunks/[root-of-the-server]__55ac8836._.js +1 -1
  41. package/standalone/.next/server/chunks/[root-of-the-server]__631bd6ec._.js +1 -1
  42. package/standalone/.next/server/chunks/[root-of-the-server]__6ac69f76._.js +1 -1
  43. package/standalone/.next/server/chunks/[root-of-the-server]__f91a8834._.js +5 -5
  44. package/standalone/.next/server/chunks/hindsight-control-plane_src_instrumentation_ts_7731303b._.js +3 -0
  45. package/standalone/.next/server/chunks/ssr/[root-of-the-server]__d9fd2a9b._.js +5 -5
  46. package/standalone/.next/server/chunks/ssr/_29833292._.js +2 -2
  47. package/standalone/.next/server/chunks/ssr/_3b0b29a6._.js +1 -1
  48. package/standalone/.next/server/instrumentation.js +4 -0
  49. package/standalone/.next/server/pages/404.html +1 -1
  50. package/standalone/.next/server/pages/500.html +2 -2
  51. package/standalone/.next/server/server-reference-manifest.js +1 -1
  52. package/standalone/.next/server/server-reference-manifest.json +1 -1
  53. package/standalone/.next/static/chunks/067bba6d015ee116.js +8 -0
  54. package/standalone/.next/static/chunks/{04aea2b16185be44.js → 2debaaba29d9e00b.js} +1 -1
  55. package/standalone/.next/static/chunks/2f5210a3b1c78e6a.js +7 -0
  56. package/standalone/.next/static/chunks/437466268dbf3b1d.css +2 -0
  57. package/standalone/package.json +2 -2
  58. package/standalone/.next/static/chunks/316bd8365bdce302.js +0 -7
  59. package/standalone/.next/static/chunks/4b7c4be0320dfb6f.js +0 -8
  60. package/standalone/.next/static/chunks/a0feebf613519811.css +0 -2
  61. /package/standalone/.next/static/{4oCWgR5WJkFWvXgXk_iao → oZpZ9tNdrBrqWP5oDlSXO}/_buildManifest.js +0 -0
  62. /package/standalone/.next/static/{4oCWgR5WJkFWvXgXk_iao → oZpZ9tNdrBrqWP5oDlSXO}/_clientMiddlewareManifest.json +0 -0
  63. /package/standalone/.next/static/{4oCWgR5WJkFWvXgXk_iao → oZpZ9tNdrBrqWP5oDlSXO}/_ssgManifest.js +0 -0
@@ -1,8 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,39650,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={assign:function(){return l},searchParamsToUrlQuery:function(){return a},urlQueryToSearchParams:function(){return s}};for(var i in r)Object.defineProperty(n,i,{enumerable:!0,get:r[i]});function a(e){let t={};for(let[n,r]of e.entries()){let e=t[n];void 0===e?t[n]=r:Array.isArray(e)?e.push(r):t[n]=[e,r]}return t}function o(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function s(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.append(n,o(e));else t.set(n,o(r));return t}function l(e,...t){for(let n of t){for(let t of n.keys())e.delete(t);for(let[t,r]of n.entries())e.append(t,r)}return e}},27130,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={formatUrl:function(){return s},formatWithValidation:function(){return c},urlObjectKeys:function(){return l}};for(var i in r)Object.defineProperty(n,i,{enumerable:!0,get:r[i]});let a=e.r(90809)._(e.r(39650)),o=/https?|ftp|gopher|file/;function s(e){let{auth:t,hostname:n}=e,r=e.protocol||"",i=e.pathname||"",s=e.hash||"",l=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:n&&(c=t+(~n.indexOf(":")?`[${n}]`:n),e.port&&(c+=":"+e.port)),l&&"object"==typeof l&&(l=String(a.urlQueryToSearchParams(l)));let u=e.search||l&&`?${l}`||"";return r&&!r.endsWith(":")&&(r+=":"),e.slashes||(!r||o.test(r))&&!1!==c?(c="//"+(c||""),i&&"/"!==i[0]&&(i="/"+i)):c||(c=""),s&&"#"!==s[0]&&(s="#"+s),u&&"?"!==u[0]&&(u="?"+u),i=i.replace(/[?#]/g,encodeURIComponent),u=u.replace("#","%23"),`${r}${c}${i}${u}${s}`}let l=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function c(e){return s(e)}},12994,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={DecodeError:function(){return x},MiddlewareNotFoundError:function(){return N},MissingStaticPage:function(){return w},NormalizeError:function(){return y},PageNotFoundError:function(){return b},SP:function(){return g},ST:function(){return v},WEB_VITALS:function(){return a},execOnce:function(){return o},getDisplayName:function(){return d},getLocationOrigin:function(){return c},getURL:function(){return u},isAbsoluteUrl:function(){return l},isResSent:function(){return h},loadGetInitialProps:function(){return p},normalizeRepeatedSlashes:function(){return f},stringifyError:function(){return j}};for(var i in r)Object.defineProperty(n,i,{enumerable:!0,get:r[i]});let a=["CLS","FCP","FID","INP","LCP","TTFB"];function o(e){let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)}let s=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=e=>s.test(e);function c(){let{protocol:e,hostname:t,port:n}=window.location;return`${e}//${t}${n?":"+n:""}`}function u(){let{href:e}=window.location,t=c();return e.substring(t.length)}function d(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function h(e){return e.finished||e.headersSent}function f(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function p(e,t){let n=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await p(t.Component,t.ctx)}:{};let r=await e.getInitialProps(t);if(n&&h(n))return r;if(!r)throw Object.defineProperty(Error(`"${d(e)}.getInitialProps()" should resolve to an object. But found "${r}" instead.`),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return r}let g="u">typeof performance,v=g&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class x extends Error{}class y extends Error{}class b extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class w extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class N extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function j(e){return JSON.stringify({message:e.message,stack:e.stack})}},22141,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"isLocalURL",{enumerable:!0,get:function(){return a}});let r=e.r(12994),i=e.r(46749);function a(e){if(!(0,r.isAbsoluteUrl)(e))return!0;try{let t=(0,r.getLocationOrigin)(),n=new URL(e,t);return n.origin===t&&(0,i.hasBasePath)(n.pathname)}catch(e){return!1}}},97710,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"errorOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},28830,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={default:function(){return x},useLinkStatus:function(){return b}};for(var i in r)Object.defineProperty(n,i,{enumerable:!0,get:r[i]});let a=e.r(90809),o=e.r(9087),s=a._(e.r(41357)),l=e.r(27130),c=e.r(95629),u=e.r(80286),d=e.r(12994),h=e.r(30717);e.r(14775);let f=e.r(29953),p=e.r(22141),g=e.r(82539);function v(e){return"string"==typeof e?e:(0,l.formatUrl)(e)}function x(t){var n;let r,i,a,[l,x]=(0,s.useOptimistic)(f.IDLE_LINK_STATUS),b=(0,s.useRef)(null),{href:w,as:N,children:j,prefetch:k=null,passHref:C,replace:E,shallow:T,scroll:S,onClick:_,onMouseEnter:A,onTouchStart:D,legacyBehavior:M=!1,onNavigate:P,ref:R,unstable_dynamicOnHover:L,...I}=t;r=j,M&&("string"==typeof r||"number"==typeof r)&&(r=(0,o.jsx)("a",{children:r}));let O=s.default.useContext(c.AppRouterContext),B=!1!==k,F=!1!==k?null===(n=k)||"auto"===n?g.FetchStrategy.PPR:g.FetchStrategy.Full:g.FetchStrategy.PPR,{href:z,as:V}=s.default.useMemo(()=>{let e=v(w);return{href:e,as:N?v(N):e}},[w,N]);if(M){if(r?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});i=s.default.Children.only(r)}let H=M?i&&"object"==typeof i&&i.ref:R,U=s.default.useCallback(e=>(null!==O&&(b.current=(0,f.mountLinkInstance)(e,z,O,F,B,x)),()=>{b.current&&((0,f.unmountLinkForCurrentNavigation)(b.current),b.current=null),(0,f.unmountPrefetchableInstance)(e)}),[B,z,O,F,x]),G={ref:(0,u.useMergedRef)(U,H),onClick(t){M||"function"!=typeof _||_(t),M&&i.props&&"function"==typeof i.props.onClick&&i.props.onClick(t),!O||t.defaultPrevented||function(t,n,r,i,a,o,l){if("u">typeof window){let c,{nodeName:u}=t.currentTarget;if("A"===u.toUpperCase()&&((c=t.currentTarget.getAttribute("target"))&&"_self"!==c||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,p.isLocalURL)(n)){a&&(t.preventDefault(),location.replace(n));return}if(t.preventDefault(),l){let e=!1;if(l({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:d}=e.r(54137);s.default.startTransition(()=>{d(r||n,a?"replace":"push",o??!0,i.current)})}}(t,z,V,b,E,S,P)},onMouseEnter(e){M||"function"!=typeof A||A(e),M&&i.props&&"function"==typeof i.props.onMouseEnter&&i.props.onMouseEnter(e),O&&B&&(0,f.onNavigationIntent)(e.currentTarget,!0===L)},onTouchStart:function(e){M||"function"!=typeof D||D(e),M&&i.props&&"function"==typeof i.props.onTouchStart&&i.props.onTouchStart(e),O&&B&&(0,f.onNavigationIntent)(e.currentTarget,!0===L)}};return(0,d.isAbsoluteUrl)(V)?G.href=V:M&&!C&&("a"!==i.type||"href"in i.props)||(G.href=(0,h.addBasePath)(V)),a=M?s.default.cloneElement(i,G):(0,o.jsx)("a",{...I,...G,children:r}),(0,o.jsx)(y.Provider,{value:l,children:a})}e.r(97710);let y=(0,s.createContext)(f.IDLE_LINK_STATUS),b=()=>(0,s.useContext)(y);("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},51273,(e,t,n)=>{e.e,t.exports=function(){var e=[function(e,t,n){"use strict";function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r},function(e,t,n){"use strict";var r=n(2),i=n(8),a=n(9);function o(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.getSource=function(){return this.source},o.prototype.getTarget=function(){return this.target},o.prototype.isInterGraph=function(){return this.isInterGraph},o.prototype.getLength=function(){return this.length},o.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},o.prototype.getBendpoints=function(){return this.bendpoints},o.prototype.getLca=function(){return this.lca},o.prototype.getSourceInLca=function(){return this.sourceInLca},o.prototype.getTargetInLca=function(){return this.targetInLca},o.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw"Node is not incident with this edge"},o.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},o.prototype.updateLength=function(){var e=[,,,,];this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],1>Math.abs(this.lengthX)&&(this.lengthX=a.sign(this.lengthX)),1>Math.abs(this.lengthY)&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},o.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),1>Math.abs(this.lengthX)&&(this.lengthX=a.sign(this.lengthX)),1>Math.abs(this.lengthY)&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){this.vGraphObject=e}},function(e,t,n){"use strict";var r=n(2),i=n(10),a=n(13),o=n(0),s=n(16),l=n(5);function c(e,t,n,o){null==n&&null==o&&(o=t),r.call(this,o),null!=e.graphManager&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=o,this.edges=[],this.graphManager=e,null!=n&&null!=t?this.rect=new a(t.x,t.y,n.width,n.height):this.rect=new a}for(var u in c.prototype=Object.create(r.prototype),r)c[u]=r[u];c.prototype.getEdges=function(){return this.edges},c.prototype.getChild=function(){return this.child},c.prototype.getOwner=function(){return this.owner},c.prototype.getWidth=function(){return this.rect.width},c.prototype.setWidth=function(e){this.rect.width=e},c.prototype.getHeight=function(){return this.rect.height},c.prototype.setHeight=function(e){this.rect.height=e},c.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},c.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},c.prototype.getCenter=function(){return new l(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},c.prototype.getLocation=function(){return new l(this.rect.x,this.rect.y)},c.prototype.getRect=function(){return this.rect},c.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},c.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},c.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},c.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},c.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},c.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},c.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw"Incorrect edge source!";t.push(r)}}),t},c.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.source!=n&&r.target!=n)throw"Incorrect edge source and/or target";(r.target==e||r.source==e)&&t.push(r)}),t},c.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw"Incorrect incidency!";e.add(n.source)}}),e},c.prototype.withChildren=function(){var e=new Set;if(e.add(this),null!=this.child)for(var t=this.child.getNodes(),n=0;n<t.length;n++)t[n].withChildren().forEach(function(t){e.add(t)});return e},c.prototype.getNoOfChildren=function(){var e=0;if(null==this.child)e=1;else for(var t=this.child.getNodes(),n=0;n<t.length;n++)e+=t[n].getNoOfChildren();return 0==e&&(e=1),e},c.prototype.getEstimatedSize=function(){if(this.estimatedSize==i.MIN_VALUE)throw"assert failed";return this.estimatedSize},c.prototype.calcEstimatedSize=function(){return null==this.child?this.estimatedSize=(this.rect.width+this.rect.height)/2:(this.estimatedSize=this.child.calcEstimatedSize(),this.rect.width=this.estimatedSize,this.rect.height=this.estimatedSize,this.estimatedSize)},c.prototype.scatter=function(){var e,t,n=-o.INITIAL_WORLD_BOUNDARY,r=o.INITIAL_WORLD_BOUNDARY;e=o.WORLD_CENTER_X+s.nextDouble()*(r-n)+n;var i=-o.INITIAL_WORLD_BOUNDARY,a=o.INITIAL_WORLD_BOUNDARY;t=o.WORLD_CENTER_Y+s.nextDouble()*(a-i)+i,this.rect.x=e,this.rect.y=t},c.prototype.updateBounds=function(){if(null==this.getChild())throw"assert failed";if(0!=this.getChild().getNodes().length){var e=this.getChild();if(e.updateBounds(!0),this.rect.x=e.getLeft(),this.rect.y=e.getTop(),this.setWidth(e.getRight()-e.getLeft()),this.setHeight(e.getBottom()-e.getTop()),o.NODE_DIMENSIONS_INCLUDE_LABELS){var t=e.getRight()-e.getLeft(),n=e.getBottom()-e.getTop();this.labelWidth&&("left"==this.labelPosHorizontal?(this.rect.x-=this.labelWidth,this.setWidth(t+this.labelWidth)):"center"==this.labelPosHorizontal&&this.labelWidth>t?(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)):"right"==this.labelPosHorizontal&&this.setWidth(t+this.labelWidth)),this.labelHeight&&("top"==this.labelPosVertical?(this.rect.y-=this.labelHeight,this.setHeight(n+this.labelHeight)):"center"==this.labelPosVertical&&this.labelHeight>n?(this.rect.y-=(this.labelHeight-n)/2,this.setHeight(this.labelHeight)):"bottom"==this.labelPosVertical&&this.setHeight(n+this.labelHeight))}}},c.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},c.prototype.transform=function(e){var t=this.rect.x;t>o.WORLD_BOUNDARY?t=o.WORLD_BOUNDARY:t<-o.WORLD_BOUNDARY&&(t=-o.WORLD_BOUNDARY);var n=this.rect.y;n>o.WORLD_BOUNDARY?n=o.WORLD_BOUNDARY:n<-o.WORLD_BOUNDARY&&(n=-o.WORLD_BOUNDARY);var r=new l(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},c.prototype.getLeft=function(){return this.rect.x},c.prototype.getRight=function(){return this.rect.x+this.rect.width},c.prototype.getTop=function(){return this.rect.y},c.prototype.getBottom=function(){return this.rect.y+this.rect.height},c.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},e.exports=c},function(e,t,n){"use strict";var r=n(0);function i(){}for(var a in r)i[a]=r[a];i.MAX_ITERATIONS=2500,i.DEFAULT_EDGE_LENGTH=50,i.DEFAULT_SPRING_STRENGTH=.45,i.DEFAULT_REPULSION_STRENGTH=4500,i.DEFAULT_GRAVITY_STRENGTH=.4,i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,i.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,i.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,i.COOLING_ADAPTATION_FACTOR=.33,i.ADAPTATION_LOWER_NODE_LIMIT=1e3,i.ADAPTATION_UPPER_NODE_LIMIT=5e3,i.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,i.MAX_NODE_DISPLACEMENT=3*i.MAX_NODE_DISPLACEMENT_INCREMENTAL,i.MIN_REPULSION_DIST=i.DEFAULT_EDGE_LENGTH/10,i.CONVERGENCE_CHECK_PERIOD=100,i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,i.MIN_EDGE_LENGTH=1,i.GRID_CALCULATION_CHECK_PERIOD=10,e.exports=i},function(e,t,n){"use strict";function r(e,t){null==e&&null==t?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r},function(e,t,n){"use strict";var r=n(2),i=n(10),a=n(0),o=n(7),s=n(3),l=n(1),c=n(13),u=n(12),d=n(11);function h(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=a.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,null!=t&&t instanceof o?this.graphManager=t:null!=t&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var f in h.prototype=Object.create(r.prototype),r)h[f]=r[f];h.prototype.getNodes=function(){return this.nodes},h.prototype.getEdges=function(){return this.edges},h.prototype.getGraphManager=function(){return this.graphManager},h.prototype.getParent=function(){return this.parent},h.prototype.getLeft=function(){return this.left},h.prototype.getRight=function(){return this.right},h.prototype.getTop=function(){return this.top},h.prototype.getBottom=function(){return this.bottom},h.prototype.isConnected=function(){return this.isConnected},h.prototype.add=function(e,t,n){if(null==t&&null==n){if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(e)>-1)throw"Node already in graph!";return e.owner=this,this.getNodes().push(e),e}if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw"Source or target not in graph!";if(t.owner!=n.owner||t.owner!=this)throw"Both owners must be this graph!";return t.owner!=n.owner?null:(e.source=t,e.target=n,e.isInterGraph=!1,this.getEdges().push(e),t.edges.push(e),n!=t&&n.edges.push(e),e)},h.prototype.remove=function(e){if(e instanceof s){if(null==e)throw"Node is null!";if(null==e.owner||e.owner!=this)throw"Owner graph is invalid!";if(null==this.graphManager)throw"Owner graph manager is invalid!";for(var t,n=e.edges.slice(),r=n.length,i=0;i<r;i++)(t=n[i]).isInterGraph?this.graphManager.remove(t):t.source.owner.remove(t);var a=this.nodes.indexOf(e);if(-1==a)throw"Node not in owner node list!";this.nodes.splice(a,1)}else if(e instanceof l){var t=e;if(null==t)throw"Edge is null!";if(null==t.source||null==t.target)throw"Source and/or target is null!";if(null==t.source.owner||null==t.target.owner||t.source.owner!=this||t.target.owner!=this)throw"Source and/or target owner is invalid!";var o=t.source.edges.indexOf(t),c=t.target.edges.indexOf(t);if(!(o>-1&&c>-1))throw"Source and/or target doesn't know this edge!";t.source.edges.splice(o,1),t.target!=t.source&&t.target.edges.splice(c,1);var a=t.source.owner.getEdges().indexOf(t);if(-1==a)throw"Not in owner's edge list!";t.source.owner.getEdges().splice(a,1)}},h.prototype.updateLeftTop=function(){for(var e,t,n,r=i.MAX_VALUE,a=i.MAX_VALUE,o=this.getNodes(),s=o.length,l=0;l<s;l++){var c=o[l];e=c.getTop(),t=c.getLeft(),r>e&&(r=e),a>t&&(a=t)}return r==i.MAX_VALUE?null:(n=void 0!=o[0].getParent().paddingLeft?o[0].getParent().paddingLeft:this.margin,this.left=a-n,this.top=r-n,new u(this.left,this.top))},h.prototype.updateBounds=function(e){for(var t,n,r,a,o,s=i.MAX_VALUE,l=-i.MAX_VALUE,u=i.MAX_VALUE,d=-i.MAX_VALUE,h=this.nodes,f=h.length,p=0;p<f;p++){var g=h[p];e&&null!=g.child&&g.updateBounds(),t=g.getLeft(),n=g.getRight(),r=g.getTop(),a=g.getBottom(),s>t&&(s=t),l<n&&(l=n),u>r&&(u=r),d<a&&(d=a)}var v=new c(s,u,l-s,d-u);s==i.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),o=void 0!=h[0].getParent().paddingLeft?h[0].getParent().paddingLeft:this.margin,this.left=v.x-o,this.right=v.x+v.width+o,this.top=v.y-o,this.bottom=v.y+v.height+o},h.calculateBounds=function(e){for(var t,n,r,a,o=i.MAX_VALUE,s=-i.MAX_VALUE,l=i.MAX_VALUE,u=-i.MAX_VALUE,d=e.length,h=0;h<d;h++){var f=e[h];t=f.getLeft(),n=f.getRight(),r=f.getTop(),a=f.getBottom(),o>t&&(o=t),s<n&&(s=n),l>r&&(l=r),u<a&&(u=a)}return new c(o,l,s-o,u-l)},h.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},h.prototype.getEstimatedSize=function(){if(this.estimatedSize==i.MIN_VALUE)throw"assert failed";return this.estimatedSize},h.prototype.calcEstimatedSize=function(){for(var e=0,t=this.nodes,n=t.length,r=0;r<n;r++)e+=t[r].calcEstimatedSize();return 0==e?this.estimatedSize=a.EMPTY_COMPOUND_NODE_SIZE:this.estimatedSize=e/Math.sqrt(this.nodes.length),this.estimatedSize},h.prototype.updateConnected=function(){var e,t,n=this;if(0==this.nodes.length){this.isConnected=!0;return}var r=new d,i=new Set,a=this.nodes[0];for(a.withChildren().forEach(function(e){r.push(e),i.add(e)});0!==r.length;)for(var o=(e=(a=r.shift()).getEdges()).length,s=0;s<o;s++)null==(t=e[s].getOtherEndInGraph(a,this))||i.has(t)||t.withChildren().forEach(function(e){r.push(e),i.add(e)});if(this.isConnected=!1,i.size>=this.nodes.length){var l=0;i.forEach(function(e){e.owner==n&&l++}),l==this.nodes.length&&(this.isConnected=!0)}},e.exports=h},function(e,t,n){"use strict";var r,i=n(1);function a(e){r=n(6),this.layout=e,this.graphs=[],this.edges=[]}a.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},a.prototype.add=function(e,t,n,r,i){if(null==n&&null==r&&null==i){if(null==e)throw"Graph is null!";if(null==t)throw"Parent node is null!";if(this.graphs.indexOf(e)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(e),null!=e.parent)throw"Already has a parent!";if(null!=t.child)throw"Already has a child!";return e.parent=t,t.child=e,e}i=n,r=t,n=e;var a=r.getOwner(),o=i.getOwner();if(null==a||a.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==o||o.getGraphManager()!=this)throw"Target not in this graph mgr!";if(a==o)return n.isInterGraph=!1,a.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(n),null==n.source||null==n.target)throw"Edge source and/or target is null!";if(-1!=n.source.edges.indexOf(n)||-1!=n.target.edges.indexOf(n))throw"Edge already in source and/or target incidency list!";return n.source.edges.push(n),n.target.edges.push(n),n},a.prototype.remove=function(e){if(e instanceof r){if(e.getGraphManager()!=this)throw"Graph not in this graph mgr";if(e!=this.rootGraph&&(null==e.parent||e.parent.graphManager!=this))throw"Invalid parent node!";for(var t,n,a=[],o=(a=a.concat(e.getEdges())).length,s=0;s<o;s++)t=a[s],e.remove(t);var l=[];o=(l=l.concat(e.getNodes())).length;for(var s=0;s<o;s++)n=l[s],e.remove(n);e==this.rootGraph&&this.setRootGraph(null);var c=this.graphs.indexOf(e);this.graphs.splice(c,1),e.parent=null}else if(e instanceof i){if(null==(t=e))throw"Edge is null!";if(!t.isInterGraph)throw"Not an inter-graph edge!";if(null==t.source||null==t.target)throw"Source and/or target is null!";if(-1==t.source.edges.indexOf(t)||-1==t.target.edges.indexOf(t))throw"Source and/or target doesn't know this edge!";var c=t.source.edges.indexOf(t);if(t.source.edges.splice(c,1),c=t.target.edges.indexOf(t),t.target.edges.splice(c,1),null==t.source.owner||null==t.source.owner.getGraphManager())throw"Edge owner graph or owner graph manager is null!";if(-1==t.source.owner.getGraphManager().edges.indexOf(t))throw"Not in owner graph manager's edge list!";var c=t.source.owner.getGraphManager().edges.indexOf(t);t.source.owner.getGraphManager().edges.splice(c,1)}},a.prototype.updateBounds=function(){this.rootGraph.updateBounds(!0)},a.prototype.getGraphs=function(){return this.graphs},a.prototype.getAllNodes=function(){if(null==this.allNodes){for(var e=[],t=this.getGraphs(),n=t.length,r=0;r<n;r++)e=e.concat(t[r].getNodes());this.allNodes=e}return this.allNodes},a.prototype.resetAllNodes=function(){this.allNodes=null},a.prototype.resetAllEdges=function(){this.allEdges=null},a.prototype.resetAllNodesToApplyGravitation=function(){this.allNodesToApplyGravitation=null},a.prototype.getAllEdges=function(){if(null==this.allEdges){var e=[],t=this.getGraphs();t.length;for(var n=0;n<t.length;n++)e=e.concat(t[n].getEdges());e=e.concat(this.edges),this.allEdges=e}return this.allEdges},a.prototype.getAllNodesToApplyGravitation=function(){return this.allNodesToApplyGravitation},a.prototype.setAllNodesToApplyGravitation=function(e){if(null!=this.allNodesToApplyGravitation)throw"assert failed";this.allNodesToApplyGravitation=e},a.prototype.getRoot=function(){return this.rootGraph},a.prototype.setRootGraph=function(e){if(e.getGraphManager()!=this)throw"Root not in this graph mgr!";this.rootGraph=e,null==e.parent&&(e.parent=this.layout.newNode("Root node"))},a.prototype.getLayout=function(){return this.layout},a.prototype.isOneAncestorOfOther=function(e,t){if(null==e||null==t)throw"assert failed";if(e==t)return!0;for(var n,r=e.getOwner();null!=(n=r.getParent());){if(n==t)return!0;if(null==(r=n.getOwner()))break}for(r=t.getOwner();null!=(n=r.getParent());){if(n==e)return!0;if(null==(r=n.getOwner()))break}return!1},a.prototype.calcLowestCommonAncestors=function(){for(var e,t,n,r,i,a=this.getAllEdges(),o=a.length,s=0;s<o;s++){if(t=(e=a[s]).source,n=e.target,e.lca=null,e.sourceInLca=t,e.targetInLca=n,t==n){e.lca=t.getOwner();continue}for(r=t.getOwner();null==e.lca;){for(e.targetInLca=n,i=n.getOwner();null==e.lca;){if(i==r){e.lca=i;break}if(i==this.rootGraph)break;if(null!=e.lca)throw"assert failed";e.targetInLca=i.getParent(),i=e.targetInLca.getOwner()}if(r==this.rootGraph)break;null==e.lca&&(e.sourceInLca=r.getParent(),r=e.sourceInLca.getOwner())}if(null==e.lca)throw"assert failed"}},a.prototype.calcLowestCommonAncestor=function(e,t){if(e==t)return e.getOwner();for(var n=e.getOwner();null!=n;){for(var r=t.getOwner();null!=r;){if(r==n)return r;r=r.getParent().getOwner()}n=n.getParent().getOwner()}return n},a.prototype.calcInclusionTreeDepths=function(e,t){null==e&&null==t&&(e=this.rootGraph,t=1);for(var n,r=e.getNodes(),i=r.length,a=0;a<i;a++)(n=r[a]).inclusionTreeDepth=t,null!=n.child&&this.calcInclusionTreeDepths(n.child,t+1)},a.prototype.includesInvalidEdge=function(){for(var e,t=[],n=this.edges.length,r=0;r<n;r++)e=this.edges[r],this.isOneAncestorOfOther(e.source,e.target)&&t.push(e);for(var r=0;r<t.length;r++)this.remove(t[r]);return!1},e.exports=a},function(e,t,n){"use strict";var r=n(12);function i(){}i.calcSeparationAmount=function(e,t,n,r){if(!e.intersects(t))throw"assert failed";var i=[,,];this.decideDirectionsForOverlappingNodes(e,t,i),n[0]=Math.min(e.getRight(),t.getRight())-Math.max(e.x,t.x),n[1]=Math.min(e.getBottom(),t.getBottom())-Math.max(e.y,t.y),e.getX()<=t.getX()&&e.getRight()>=t.getRight()?n[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(n[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?n[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(n[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var a=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(a=1);var o=a*n[0],s=n[1]/a;n[0]<s?s=n[0]:o=n[1],n[0]=-1*i[0]*(s/2+r),n[1]=-1*i[1]*(o/2+r)},i.decideDirectionsForOverlappingNodes=function(e,t,n){e.getCenterX()<t.getCenterX()?n[0]=-1:n[0]=1,e.getCenterY()<t.getCenterY()?n[1]=-1:n[1]=1},i.getIntersection2=function(e,t,n){var r=e.getCenterX(),i=e.getCenterY(),a=t.getCenterX(),o=t.getCenterY();if(e.intersects(t))return n[0]=r,n[1]=i,n[2]=a,n[3]=o,!0;var s=e.getX(),l=e.getY(),c=e.getRight(),u=e.getX(),d=e.getBottom(),h=e.getRight(),f=e.getWidthHalf(),p=e.getHeightHalf(),g=t.getX(),v=t.getY(),x=t.getRight(),y=t.getX(),b=t.getBottom(),w=t.getRight(),N=t.getWidthHalf(),j=t.getHeightHalf(),k=!1,C=!1;if(r===a)i>o?(n[0]=r,n[1]=l,n[2]=a,n[3]=b):i<o&&(n[0]=r,n[1]=d,n[2]=a,n[3]=v);else if(i===o)r>a?(n[0]=s,n[1]=i,n[2]=x,n[3]=o):r<a&&(n[0]=c,n[1]=i,n[2]=g,n[3]=o);else{var E=e.height/e.width,T=t.height/t.width,S=(o-i)/(a-r),_=void 0,A=void 0,D=void 0,M=void 0,P=void 0,R=void 0;if(-E===S?(r>a?(n[0]=u,n[1]=d):(n[0]=c,n[1]=l),k=!0):E===S&&(r>a?(n[0]=s,n[1]=l):(n[0]=h,n[1]=d),k=!0),-T===S?(a>r?(n[2]=y,n[3]=b):(n[2]=x,n[3]=v),C=!0):T===S&&(a>r?(n[2]=g,n[3]=v):(n[2]=w,n[3]=b),C=!0),k&&C)return!1;if(r>a?i>o?(_=this.getCardinalDirection(E,S,4),A=this.getCardinalDirection(T,S,2)):(_=this.getCardinalDirection(-E,S,3),A=this.getCardinalDirection(-T,S,1)):i>o?(_=this.getCardinalDirection(-E,S,1),A=this.getCardinalDirection(-T,S,3)):(_=this.getCardinalDirection(E,S,2),A=this.getCardinalDirection(T,S,4)),!k)switch(_){case 1:M=l,D=r+-p/S,n[0]=D,n[1]=M;break;case 2:D=h,M=i+f*S,n[0]=D,n[1]=M;break;case 3:M=d,D=r+p/S,n[0]=D,n[1]=M;break;case 4:D=u,M=i+-f*S,n[0]=D,n[1]=M}if(!C)switch(A){case 1:R=v,P=a+-j/S,n[2]=P,n[3]=R;break;case 2:P=w,R=o+N*S,n[2]=P,n[3]=R;break;case 3:R=b,P=a+j/S,n[2]=P,n[3]=R;break;case 4:P=y,R=o+-N*S,n[2]=P,n[3]=R}}return!1},i.getCardinalDirection=function(e,t,n){return e>t?n:1+n%4},i.getIntersection=function(e,t,n,i){if(null==i)return this.getIntersection2(e,t,n);var a=e.x,o=e.y,s=t.x,l=t.y,c=n.x,u=n.y,d=i.x,h=i.y,f=void 0,p=void 0,g=void 0,v=void 0,x=void 0,y=void 0,b=void 0;return(f=l-o,g=a-s,x=s*o-a*l,p=h-u,v=c-d,y=d*u-c*h,0==(b=f*v-p*g))?null:new r((g*y-v*x)/b,(p*x-f*y)/b)},i.angleOfVector=function(e,t,n,r){var i=void 0;return e!==n?(i=Math.atan((r-t)/(n-e)),n<e?i+=Math.PI:r<t&&(i+=this.TWO_PI)):i=r<t?this.ONE_AND_HALF_PI:this.HALF_PI,i},i.doIntersect=function(e,t,n,r){var i=e.x,a=e.y,o=t.x,s=t.y,l=n.x,c=n.y,u=r.x,d=r.y,h=(o-i)*(d-c)-(u-l)*(s-a);if(0===h)return!1;var f=((d-c)*(u-i)+(l-u)*(d-a))/h,p=((a-s)*(u-i)+(o-i)*(d-a))/h;return 0<f&&f<1&&0<p&&p<1},i.findCircleLineIntersections=function(e,t,n,r,i,a,o){var s=(n-e)*(n-e)+(r-t)*(r-t),l=2*((e-i)*(n-e)+(t-a)*(r-t)),c=(e-i)*(e-i)+(t-a)*(t-a)-o*o;if(!(l*l-4*s*c>=0))return null;var u=(-l+Math.sqrt(l*l-4*s*c))/(2*s),d=(-l-Math.sqrt(l*l-4*s*c))/(2*s);return u>=0&&u<=1?[u]:d>=0&&d<=1?[d]:null},i.HALF_PI=.5*Math.PI,i.ONE_AND_HALF_PI=1.5*Math.PI,i.TWO_PI=2*Math.PI,i.THREE_PI=3*Math.PI,e.exports=i},function(e,t,n){"use strict";function r(){}r.sign=function(e){return e>0?1:e<0?-1:0},r.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},r.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=r},function(e,t,n){"use strict";function r(){}r.MAX_VALUE=0x7fffffff,r.MIN_VALUE=-0x80000000,e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(e){return{value:e,next:null,prev:null}},a=function(e,t,n,r){return null!==e?e.next=t:r.head=t,null!==n?n.prev=t:r.tail=t,t.prev=e,t.next=n,r.length++,t},o=function(e,t){var n=e.prev,r=e.next;return null!==n?n.next=r:t.head=r,null!==r?r.prev=n:t.tail=n,e.prev=e.next=null,t.length--,e};e.exports=function(){function e(t){var n=this;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");this.length=0,this.head=null,this.tail=null,null!=t&&t.forEach(function(e){return n.push(e)})}return r(e,[{key:"size",value:function(){return this.length}},{key:"insertBefore",value:function(e,t){return a(t.prev,i(e),t,this)}},{key:"insertAfter",value:function(e,t){return a(t,i(e),t.next,this)}},{key:"insertNodeBefore",value:function(e,t){return a(t.prev,e,t,this)}},{key:"insertNodeAfter",value:function(e,t){return a(t,e,t.next,this)}},{key:"push",value:function(e){return a(this.tail,i(e),null,this)}},{key:"unshift",value:function(e){return a(null,i(e),this.head,this)}},{key:"remove",value:function(e){return o(e,this)}},{key:"pop",value:function(){return o(this.tail,this).value}},{key:"popNode",value:function(){return o(this.tail,this)}},{key:"shift",value:function(){return o(this.head,this).value}},{key:"shiftNode",value:function(){return o(this.head,this)}},{key:"get_object_at",value:function(e){if(e<=this.length()){for(var t=1,n=this.head;t<e;)n=n.next,t++;return n.value}}},{key:"set_object_at",value:function(e,t){if(e<=this.length()){for(var n=1,r=this.head;n<e;)r=r.next,n++;r.value=t}}}]),e}()},function(e,t,n){"use strict";function r(e,t,n){this.x=null,this.y=null,null==e&&null==t&&null==n?(this.x=0,this.y=0):"number"==typeof e&&"number"==typeof t&&null==n?(this.x=e,this.y=t):"Point"==e.constructor.name&&null==t&&null==n&&(n=e,this.x=n.x,this.y=n.y)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.getLocation=function(){return new r(this.x,this.y)},r.prototype.setLocation=function(e,t,n){"Point"==e.constructor.name&&null==t&&null==n?(n=e,this.setLocation(n.x,n.y)):"number"==typeof e&&"number"==typeof t&&null==n&&(parseInt(e)==e&&parseInt(t)==t?this.move(e,t):(this.x=Math.floor(e+.5),this.y=Math.floor(t+.5)))},r.prototype.move=function(e,t){this.x=e,this.y=t},r.prototype.translate=function(e,t){this.x+=e,this.y+=t},r.prototype.equals=function(e){return"Point"==e.constructor.name?this.x==e.x&&this.y==e.y:this==e},r.prototype.toString=function(){return new r().constructor.name+"[x="+this.x+",y="+this.y+"]"},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r){this.x=0,this.y=0,this.width=0,this.height=0,null!=e&&null!=t&&null!=n&&null!=r&&(this.x=e,this.y=t,this.width=n,this.height=r)}r.prototype.getX=function(){return this.x},r.prototype.setX=function(e){this.x=e},r.prototype.getY=function(){return this.y},r.prototype.setY=function(e){this.y=e},r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(e){this.width=e},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(e){this.height=e},r.prototype.getRight=function(){return this.x+this.width},r.prototype.getBottom=function(){return this.y+this.height},r.prototype.intersects=function(e){return!(this.getRight()<e.x||this.getBottom()<e.y||e.getRight()<this.x||e.getBottom()<this.y)},r.prototype.getCenterX=function(){return this.x+this.width/2},r.prototype.getMinX=function(){return this.getX()},r.prototype.getMaxX=function(){return this.getX()+this.width},r.prototype.getCenterY=function(){return this.y+this.height/2},r.prototype.getMinY=function(){return this.getY()},r.prototype.getMaxY=function(){return this.getY()+this.height},r.prototype.getWidthHalf=function(){return this.width/2},r.prototype.getHeightHalf=function(){return this.height/2},e.exports=r},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function i(){}i.lastID=0,i.createID=function(e){return i.isPrimitive(e)?e:(null!=e.uniqueID||(e.uniqueID=i.getString(),i.lastID++),e.uniqueID)},i.getString=function(e){return null==e&&(e=i.lastID),"Object#"+e},i.isPrimitive=function(e){var t=void 0===e?"undefined":r(e);return null==e||"object"!=t&&"function"!=t},e.exports=i},function(e,t,n){"use strict";function r(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}var i=n(0),a=n(7),o=n(3),s=n(1),l=n(6),c=n(5),u=n(17),d=n(29);function h(e){d.call(this),this.layoutQuality=i.QUALITY,this.createBendsAsNeeded=i.DEFAULT_CREATE_BENDS_AS_NEEDED,this.incremental=i.DEFAULT_INCREMENTAL,this.animationOnLayout=i.DEFAULT_ANIMATION_ON_LAYOUT,this.animationDuringLayout=i.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=i.DEFAULT_ANIMATION_PERIOD,this.uniformLeafNodeSizes=i.DEFAULT_UNIFORM_LEAF_NODE_SIZES,this.edgeToDummyNodes=new Map,this.graphManager=new a(this),this.isLayoutFinished=!1,this.isSubLayout=!1,this.isRemoteUse=!1,null!=e&&(this.isRemoteUse=e)}h.RANDOM_SEED=1,h.prototype=Object.create(d.prototype),h.prototype.getGraphManager=function(){return this.graphManager},h.prototype.getAllNodes=function(){return this.graphManager.getAllNodes()},h.prototype.getAllEdges=function(){return this.graphManager.getAllEdges()},h.prototype.getAllNodesToApplyGravitation=function(){return this.graphManager.getAllNodesToApplyGravitation()},h.prototype.newGraphManager=function(){var e=new a(this);return this.graphManager=e,e},h.prototype.newGraph=function(e){return new l(null,this.graphManager,e)},h.prototype.newNode=function(e){return new o(this.graphManager,e)},h.prototype.newEdge=function(e){return new s(null,null,e)},h.prototype.checkLayoutSuccess=function(){return null==this.graphManager.getRoot()||0==this.graphManager.getRoot().getNodes().length||this.graphManager.includesInvalidEdge()},h.prototype.runLayout=function(){var e;return this.isLayoutFinished=!1,this.tilingPreLayout&&this.tilingPreLayout(),this.initParameters(),e=!this.checkLayoutSuccess()&&this.layout(),"during"!==i.ANIMATE&&(e&&!this.isSubLayout&&this.doPostLayout(),this.tilingPostLayout&&this.tilingPostLayout(),this.isLayoutFinished=!0,e)},h.prototype.doPostLayout=function(){this.incremental||this.transform(),this.update()},h.prototype.update2=function(){if(this.createBendsAsNeeded&&(this.createBendpointsFromDummyNodes(),this.graphManager.resetAllEdges()),!this.isRemoteUse){for(var e=this.graphManager.getAllEdges(),t=0;t<e.length;t++)e[t];for(var n=this.graphManager.getRoot().getNodes(),t=0;t<n.length;t++)n[t];this.update(this.graphManager.getRoot())}},h.prototype.update=function(e){if(null==e)this.update2();else if(e instanceof o){if(null!=e.getChild())for(var t=e.getChild().getNodes(),n=0;n<t.length;n++)update(t[n]);null!=e.vGraphObject&&e.vGraphObject.update(e)}else e instanceof s?null!=e.vGraphObject&&e.vGraphObject.update(e):e instanceof l&&null!=e.vGraphObject&&e.vGraphObject.update(e)},h.prototype.initParameters=function(){this.isSubLayout||(this.layoutQuality=i.QUALITY,this.animationDuringLayout=i.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=i.DEFAULT_ANIMATION_PERIOD,this.animationOnLayout=i.DEFAULT_ANIMATION_ON_LAYOUT,this.incremental=i.DEFAULT_INCREMENTAL,this.createBendsAsNeeded=i.DEFAULT_CREATE_BENDS_AS_NEEDED,this.uniformLeafNodeSizes=i.DEFAULT_UNIFORM_LEAF_NODE_SIZES),this.animationDuringLayout&&(this.animationOnLayout=!1)},h.prototype.transform=function(e){if(void 0==e)this.transform(new c(0,0));else{var t=new u,n=this.graphManager.getRoot().updateLeftTop();if(null!=n){t.setWorldOrgX(e.x),t.setWorldOrgY(e.y),t.setDeviceOrgX(n.x),t.setDeviceOrgY(n.y);for(var r=this.getAllNodes(),i=0;i<r.length;i++)r[i].transform(t)}}},h.prototype.positionNodesRandomly=function(e){if(void 0==e)this.positionNodesRandomly(this.getGraphManager().getRoot()),this.getGraphManager().getRoot().updateBounds(!0);else for(var t,n,r=e.getNodes(),i=0;i<r.length;i++)null==(n=(t=r[i]).getChild())||0==n.getNodes().length?t.scatter():(this.positionNodesRandomly(n),t.updateBounds())},h.prototype.getFlatForest=function(){for(var e=[],t=!0,n=this.graphManager.getRoot().getNodes(),i=!0,a=0;a<n.length;a++)null!=n[a].getChild()&&(i=!1);if(!i)return e;var o=new Set,s=[],l=new Map,c=[];for(c=c.concat(n);c.length>0&&t;){for(s.push(c[0]);s.length>0&&t;){var u=s[0];s.splice(0,1),o.add(u);for(var d=u.getEdges(),a=0;a<d.length;a++){var h=d[a].getOtherEnd(u);if(l.get(u)!=h)if(o.has(h)){t=!1;break}else s.push(h),l.set(h,u)}}if(t){var f=[].concat(r(o));e.push(f);for(var a=0;a<f.length;a++){var p=f[a],g=c.indexOf(p);g>-1&&c.splice(g,1)}o=new Set,l=new Map}else e=[]}return e},h.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],n=e.source,r=this.graphManager.calcLowestCommonAncestor(e.source,e.target),i=0;i<e.bendpoints.length;i++){var a=this.newNode(null);a.setRect(new Point(0,0),new Dimension(1,1)),r.add(a);var o=this.newEdge(null);this.graphManager.add(o,n,a),t.add(a),n=a}var o=this.newEdge(null);return this.graphManager.add(o,n,e.target),this.edgeToDummyNodes.set(e,t),e.isInterGraph()?this.graphManager.remove(e):r.remove(e),t},h.prototype.createBendpointsFromDummyNodes=function(){var e=[];e=e.concat(this.graphManager.getAllEdges()),e=[].concat(r(this.edgeToDummyNodes.keys())).concat(e);for(var t=0;t<e.length;t++){var n=e[t];if(n.bendpoints.length>0){for(var i=this.edgeToDummyNodes.get(n),a=0;a<i.length;a++){var o=i[a],s=new c(o.getCenterX(),o.getCenterY()),l=n.bendpoints.get(a);l.x=s.x,l.y=s.y,o.getOwner().remove(o)}this.graphManager.add(n,n.source,n.target)}}},h.transform=function(e,t,n,r){if(void 0==n||void 0==r)return e<=50?(i=9*t/500,a=t/10):(i=9*t/50,a=-8*t),i*e+a;var i,a,o=t;return e<=50?o-=(t-t/n)/50*(50-e):o+=(t*r-t)/50*(e-50),o},h.findCenterOfTree=function(e){var t=[];t=t.concat(e);var n=[],r=new Map,i=!1,a=null;(1==t.length||2==t.length)&&(i=!0,a=t[0]);for(var o=0;o<t.length;o++){var s=t[o],l=s.getNeighborsList().size;r.set(s,s.getNeighborsList().size),1==l&&n.push(s)}var c=[];for(c=c.concat(n);!i;){var u=[];u=u.concat(c),c=[];for(var o=0;o<t.length;o++){var s=t[o],d=t.indexOf(s);d>=0&&t.splice(d,1),s.getNeighborsList().forEach(function(e){if(0>n.indexOf(e)){var t=r.get(e)-1;1==t&&c.push(e),r.set(e,t)}})}n=n.concat(c),(1==t.length||2==t.length)&&(i=!0,a=t[0])}return a},h.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=h},function(e,t,n){"use strict";function r(){}r.seed=1,r.x=0,r.nextDouble=function(){return r.x=1e4*Math.sin(r.seed++),r.x-Math.floor(r.x)},e.exports=r},function(e,t,n){"use strict";var r=n(5);function i(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}i.prototype.getWorldOrgX=function(){return this.lworldOrgX},i.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},i.prototype.getWorldOrgY=function(){return this.lworldOrgY},i.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},i.prototype.getWorldExtX=function(){return this.lworldExtX},i.prototype.setWorldExtX=function(e){this.lworldExtX=e},i.prototype.getWorldExtY=function(){return this.lworldExtY},i.prototype.setWorldExtY=function(e){this.lworldExtY=e},i.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},i.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},i.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},i.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},i.prototype.getDeviceExtX=function(){return this.ldeviceExtX},i.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},i.prototype.getDeviceExtY=function(){return this.ldeviceExtY},i.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},i.prototype.transformX=function(e){var t=0,n=this.lworldExtX;return 0!=n&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/n),t},i.prototype.transformY=function(e){var t=0,n=this.lworldExtY;return 0!=n&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/n),t},i.prototype.inverseTransformX=function(e){var t=0,n=this.ldeviceExtX;return 0!=n&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/n),t},i.prototype.inverseTransformY=function(e){var t=0,n=this.ldeviceExtY;return 0!=n&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/n),t},i.prototype.inverseTransformPoint=function(e){return new r(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=i},function(e,t,n){"use strict";var r=n(15),i=n(4),a=n(0),o=n(8),s=n(9);function l(){r.call(this),this.useSmartIdealEdgeLengthCalculation=i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=i.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=i.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=i.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*i.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=i.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=i.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=i.MAX_ITERATIONS}for(var c in l.prototype=Object.create(r.prototype),r)l[c]=r[c];l.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},l.prototype.calcIdealEdgeLengths=function(){for(var e,t,n,r,o,s,l,c=this.getGraphManager().getAllEdges(),u=0;u<c.length;u++)t=(e=c[u]).idealLength,e.isInterGraph&&(r=e.getSource(),o=e.getTarget(),s=e.getSourceInLca().getEstimatedSize(),l=e.getTargetInLca().getEstimatedSize(),this.useSmartIdealEdgeLengthCalculation&&(e.idealLength+=s+l-2*a.SIMPLE_NODE_SIZE),n=e.getLca().getInclusionTreeDepth(),e.idealLength+=t*i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR*(r.getInclusionTreeDepth()+o.getInclusionTreeDepth()-2*n))},l.prototype.initSpringEmbedder=function(){var e=this.getAllNodes().length;this.incremental?(e>i.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*i.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-i.ADAPTATION_LOWER_NODE_LIMIT)/(i.ADAPTATION_UPPER_NODE_LIMIT-i.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-i.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=i.MAX_NODE_DISPLACEMENT_INCREMENTAL):(e>i.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(i.COOLING_ADAPTATION_FACTOR,1-(e-i.ADAPTATION_LOWER_NODE_LIMIT)/(i.ADAPTATION_UPPER_NODE_LIMIT-i.ADAPTATION_LOWER_NODE_LIMIT)*(1-i.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=i.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.displacementThresholdPerNode=3*i.DEFAULT_EDGE_LENGTH/100,this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},l.prototype.calcSpringForces=function(){for(var e,t=this.getAllEdges(),n=0;n<t.length;n++)e=t[n],this.calcSpringForce(e,e.idealLength)},l.prototype.calcRepulsionForces=function(){var e,t,n,r,a,o=!(arguments.length>0)||void 0===arguments[0]||arguments[0],s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%i.GRID_CALCULATION_CHECK_PERIOD==1&&o&&this.updateGrid(),a=new Set,e=0;e<l.length;e++)n=l[e],this.calculateRepulsionForceOfANode(n,a,o,s),a.add(n);else for(e=0;e<l.length;e++)for(n=l[e],t=e+1;t<l.length;t++)r=l[t],n.getOwner()==r.getOwner()&&this.calcRepulsionForce(n,r)},l.prototype.calcGravitationalForces=function(){for(var e,t=this.getAllNodesToApplyGravitation(),n=0;n<t.length;n++)e=t[n],this.calcGravitationalForce(e)},l.prototype.moveNodes=function(){for(var e=this.getAllNodes(),t=0;t<e.length;t++)e[t].move()},l.prototype.calcSpringForce=function(e,t){var n,r,i,a,o=e.getSource(),s=e.getTarget();if(this.uniformLeafNodeSizes&&null==o.getChild()&&null==s.getChild())e.updateLengthSimple();else if(e.updateLength(),e.isOverlapingSourceAndTarget)return;0!=(n=e.getLength())&&(i=(r=e.edgeElasticity*(n-t))*(e.lengthX/n),a=r*(e.lengthY/n),o.springForceX+=i,o.springForceY+=a,s.springForceX-=i,s.springForceY-=a)},l.prototype.calcRepulsionForce=function(e,t){var n,r,a,l,c,u,d,h=e.getRect(),f=t.getRect(),p=[,,],g=[,,,,];if(h.intersects(f)){o.calcSeparationAmount(h,f,p,i.DEFAULT_EDGE_LENGTH/2),u=2*p[0],d=2*p[1];var v=e.noOfChildren*t.noOfChildren/(e.noOfChildren+t.noOfChildren);e.repulsionForceX-=v*u,e.repulsionForceY-=v*d,t.repulsionForceX+=v*u,t.repulsionForceY+=v*d}else this.uniformLeafNodeSizes&&null==e.getChild()&&null==t.getChild()?(n=f.getCenterX()-h.getCenterX(),r=f.getCenterY()-h.getCenterY()):(o.getIntersection(h,f,g),n=g[2]-g[0],r=g[3]-g[1]),Math.abs(n)<i.MIN_REPULSION_DIST&&(n=s.sign(n)*i.MIN_REPULSION_DIST),Math.abs(r)<i.MIN_REPULSION_DIST&&(r=s.sign(r)*i.MIN_REPULSION_DIST),l=Math.sqrt(a=n*n+r*r),u=(c=(e.nodeRepulsion/2+t.nodeRepulsion/2)*e.noOfChildren*t.noOfChildren/a)*n/l,d=c*r/l,e.repulsionForceX-=u,e.repulsionForceY-=d,t.repulsionForceX+=u,t.repulsionForceY+=d},l.prototype.calcGravitationalForce=function(e){var t,n,r,i,a,o,s,l;n=((t=e.getOwner()).getRight()+t.getLeft())/2,r=(t.getTop()+t.getBottom())/2,i=e.getCenterX()-n,a=e.getCenterY()-r,o=Math.abs(i)+e.getWidth()/2,s=Math.abs(a)+e.getHeight()/2,e.getOwner()==this.graphManager.getRoot()?(o>(l=t.getEstimatedSize()*this.gravityRangeFactor)||s>l)&&(e.gravitationForceX=-this.gravityConstant*i,e.gravitationForceY=-this.gravityConstant*a):(o>(l=t.getEstimatedSize()*this.compoundGravityRangeFactor)||s>l)&&(e.gravitationForceX=-this.gravityConstant*i*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*a*this.compoundGravityConstant)},l.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=2>Math.abs(this.totalDisplacement-this.oldTotalDisplacement)),e=this.totalDisplacement<this.totalDisplacementThreshold,this.oldTotalDisplacement=this.totalDisplacement,e||t},l.prototype.animate=function(){this.animationDuringLayout&&!this.isSubLayout&&(this.notAnimatedIterations==this.animationPeriod?(this.update(),this.notAnimatedIterations=0):this.notAnimatedIterations++)},l.prototype.calcNoOfChildrenForAllNodes=function(){for(var e,t=this.graphManager.getAllNodes(),n=0;n<t.length;n++)(e=t[n]).noOfChildren=e.getNoOfChildren()},l.prototype.calcGrid=function(e){var t=0,n=0;t=parseInt(Math.ceil((e.getRight()-e.getLeft())/this.repulsionRange)),n=parseInt(Math.ceil((e.getBottom()-e.getTop())/this.repulsionRange));for(var r=Array(t),i=0;i<t;i++)r[i]=Array(n);for(var i=0;i<t;i++)for(var a=0;a<n;a++)r[i][a]=[];return r},l.prototype.addNodeToGrid=function(e,t,n){var r=0,i=0,a=0,o=0;r=parseInt(Math.floor((e.getRect().x-t)/this.repulsionRange)),i=parseInt(Math.floor((e.getRect().width+e.getRect().x-t)/this.repulsionRange)),a=parseInt(Math.floor((e.getRect().y-n)/this.repulsionRange)),o=parseInt(Math.floor((e.getRect().height+e.getRect().y-n)/this.repulsionRange));for(var s=r;s<=i;s++)for(var l=a;l<=o;l++)this.grid[s][l].push(e),e.setGridCoordinates(r,i,a,o)},l.prototype.updateGrid=function(){var e,t,n=this.getAllNodes();for(e=0,this.grid=this.calcGrid(this.graphManager.getRoot());e<n.length;e++)t=n[e],this.addNodeToGrid(t,this.graphManager.getRoot().getLeft(),this.graphManager.getRoot().getTop())},l.prototype.calculateRepulsionForceOfANode=function(e,t,n,r){if(this.totalIterations%i.GRID_CALCULATION_CHECK_PERIOD==1&&n||r){var a,o=new Set;e.surrounding=[];for(var s=this.grid,l=e.startX-1;l<e.finishX+2;l++)for(var c=e.startY-1;c<e.finishY+2;c++)if(!(l<0||c<0||l>=s.length||c>=s[0].length)){for(var u=0;u<s[l][c].length;u++)if(a=s[l][c][u],e.getOwner()==a.getOwner()&&e!=a&&!t.has(a)&&!o.has(a)){var d=Math.abs(e.getCenterX()-a.getCenterX())-(e.getWidth()/2+a.getWidth()/2),h=Math.abs(e.getCenterY()-a.getCenterY())-(e.getHeight()/2+a.getHeight()/2);d<=this.repulsionRange&&h<=this.repulsionRange&&o.add(a)}}e.surrounding=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}(o))}for(l=0;l<e.surrounding.length;l++)this.calcRepulsionForce(e,e.surrounding[l])},l.prototype.calcRepulsionRange=function(){return 0},e.exports=l},function(e,t,n){"use strict";var r=n(1),i=n(4);function a(e,t,n){r.call(this,e,t,n),this.idealLength=i.DEFAULT_EDGE_LENGTH,this.edgeElasticity=i.DEFAULT_SPRING_STRENGTH}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];e.exports=a},function(e,t,n){"use strict";var r=n(3),i=n(4);function a(e,t,n,a){r.call(this,e,t,n,a),this.nodeRepulsion=i.DEFAULT_REPULSION_STRENGTH,this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0,this.startX=0,this.finishX=0,this.startY=0,this.finishY=0,this.surrounding=[]}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];a.prototype.setGridCoordinates=function(e,t,n,r){this.startX=e,this.finishX=t,this.startY=n,this.finishY=r},e.exports=a},function(e,t,n){"use strict";function r(e,t){this.width=0,this.height=0,null!==e&&null!==t&&(this.height=t,this.width=e)}r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(e){this.width=e},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(e){this.height=e},e.exports=r},function(e,t,n){"use strict";var r=n(14);function i(){this.map={},this.keys=[]}i.prototype.put=function(e,t){var n=r.createID(e);this.contains(n)||(this.map[n]=t,this.keys.push(e))},i.prototype.contains=function(e){return r.createID(e),null!=this.map[e]},i.prototype.get=function(e){var t=r.createID(e);return this.map[t]},i.prototype.keySet=function(){return this.keys},e.exports=i},function(e,t,n){"use strict";var r=n(14);function i(){this.set={}}i.prototype.add=function(e){var t=r.createID(e);this.contains(t)||(this.set[t]=e)},i.prototype.remove=function(e){delete this.set[r.createID(e)]},i.prototype.clear=function(){this.set={}},i.prototype.contains=function(e){return this.set[r.createID(e)]==e},i.prototype.isEmpty=function(){return 0===this.size()},i.prototype.size=function(){return Object.keys(this.set).length},i.prototype.addAllTo=function(e){for(var t=Object.keys(this.set),n=t.length,r=0;r<n;r++)e.push(this.set[t[r]])},i.prototype.size=function(){return Object.keys(this.set).length},i.prototype.addAll=function(e){for(var t=e.length,n=0;n<t;n++){var r=e[n];this.add(r)}},e.exports=i},function(e,t,n){"use strict";function r(){}r.multMat=function(e,t){for(var n=[],r=0;r<e.length;r++){n[r]=[];for(var i=0;i<t[0].length;i++){n[r][i]=0;for(var a=0;a<e[0].length;a++)n[r][i]+=e[r][a]*t[a][i]}}return n},r.transpose=function(e){for(var t=[],n=0;n<e[0].length;n++){t[n]=[];for(var r=0;r<e.length;r++)t[n][r]=e[r][n]}return t},r.multCons=function(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=e[r]*t;return n},r.minusOp=function(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=e[r]-t[r];return n},r.dotProduct=function(e,t){for(var n=0,r=0;r<e.length;r++)n+=e[r]*t[r];return n},r.mag=function(e){return Math.sqrt(this.dotProduct(e,e))},r.normalize=function(e){for(var t=[],n=this.mag(e),r=0;r<e.length;r++)t[r]=e[r]/n;return t},r.multGamma=function(e){for(var t=[],n=0,r=0;r<e.length;r++)n+=e[r];n*=-1/e.length;for(var i=0;i<e.length;i++)t[i]=n+e[i];return t},r.multL=function(e,t,n){for(var r=[],i=[],a=[],o=0;o<t[0].length;o++){for(var s=0,l=0;l<t.length;l++)s+=-.5*t[l][o]*e[l];i[o]=s}for(var c=0;c<n.length;c++){for(var u=0,d=0;d<n.length;d++)u+=n[c][d]*i[d];a[c]=u}for(var h=0;h<t.length;h++){for(var f=0,p=0;p<t[0].length;p++)f+=t[h][p]*a[p];r[h]=f}return r},e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(11);e.exports=function(){function e(t,n){if(!(this instanceof e))throw TypeError("Cannot call a class as a function");(null!==n||void 0!==n)&&(this.compareFunction=this._defaultCompareFunction);var r=void 0;r=t instanceof i?t.size():t.length,this._quicksort(t,0,r-1)}return r(e,[{key:"_quicksort",value:function(e,t,n){if(t<n){var r=this._partition(e,t,n);this._quicksort(e,t,r),this._quicksort(e,r+1,n)}}},{key:"_partition",value:function(e,t,n){for(var r=this._get(e,t),i=t,a=n;;){for(;this.compareFunction(r,this._get(e,a));)a--;for(;this.compareFunction(this._get(e,i),r);)i++;if(!(i<a))return a;this._swap(e,i,a),i++,a--}}},{key:"_get",value:function(e,t){return e instanceof i?e.get_object_at(t):e[t]}},{key:"_set",value:function(e,t,n){e instanceof i?e.set_object_at(t,n):e[t]=n}},{key:"_swap",value:function(e,t,n){var r=this._get(e,t);this._set(e,t,this._get(e,n)),this._set(e,n,r)}},{key:"_defaultCompareFunction",value:function(e,t){return t>e}}]),e}()},function(e,t,n){"use strict";function r(){}r.svd=function(e){this.U=null,this.V=null,this.s=null,this.m=0,this.n=0,this.m=e.length,this.n=e[0].length;var t=Math.min(this.m,this.n);this.s=function(e){for(var t=[];e-- >0;)t.push(0);return t}(Math.min(this.m+1,this.n)),this.U=function e(t){if(0==t.length)return 0;for(var n=[],r=0;r<t[0];r++)n.push(e(t.slice(1)));return n}([this.m,t]),this.V=function e(t){if(0==t.length)return 0;for(var n=[],r=0;r<t[0];r++)n.push(e(t.slice(1)));return n}([this.n,this.n]);for(var n=function(e){for(var t=[];e-- >0;)t.push(0);return t}(this.n),i=function(e){for(var t=[];e-- >0;)t.push(0);return t}(this.m),a=Math.min(this.m-1,this.n),o=Math.max(0,Math.min(this.n-2,this.m)),s=0;s<Math.max(a,o);s++){if(s<a){this.s[s]=0;for(var l=s;l<this.m;l++)this.s[s]=r.hypot(this.s[s],e[l][s]);if(0!==this.s[s]){e[s][s]<0&&(this.s[s]=-this.s[s]);for(var c=s;c<this.m;c++)e[c][s]/=this.s[s];e[s][s]+=1}this.s[s]=-this.s[s]}for(var u=s+1;u<this.n;u++){if(g=s<a,v=0!==this.s[s],g&&v){for(var d=0,h=s;h<this.m;h++)d+=e[h][s]*e[h][u];d=-d/e[s][s];for(var f=s;f<this.m;f++)e[f][u]+=d*e[f][s]}n[u]=e[s][u]}if(x=s<a)for(var p=s;p<this.m;p++)this.U[p][s]=e[p][s];if(s<o){n[s]=0;for(var g,v,x,y,b,w=s+1;w<this.n;w++)n[s]=r.hypot(n[s],n[w]);if(0!==n[s]){n[s+1]<0&&(n[s]=-n[s]);for(var N=s+1;N<this.n;N++)n[N]/=n[s];n[s+1]+=1}if(n[s]=-n[s],y=s+1<this.m,b=0!==n[s],y&&b){for(var j=s+1;j<this.m;j++)i[j]=0;for(var k=s+1;k<this.n;k++)for(var C=s+1;C<this.m;C++)i[C]+=n[k]*e[C][k];for(var E=s+1;E<this.n;E++)for(var T=-n[E]/n[s+1],S=s+1;S<this.m;S++)e[S][E]+=T*i[S]}for(var _=s+1;_<this.n;_++)this.V[_][s]=n[_]}}var A=Math.min(this.n,this.m+1);a<this.n&&(this.s[a]=e[a][a]),this.m<A&&(this.s[A-1]=0),o+1<A&&(n[o]=e[o][A-1]),n[A-1]=0;for(var D=a;D<t;D++){for(var M=0;M<this.m;M++)this.U[M][D]=0;this.U[D][D]=1}for(var P=a-1;P>=0;P--)if(0!==this.s[P]){for(var R=P+1;R<t;R++){for(var L=0,I=P;I<this.m;I++)L+=this.U[I][P]*this.U[I][R];L=-L/this.U[P][P];for(var O=P;O<this.m;O++)this.U[O][R]+=L*this.U[O][P]}for(var B=P;B<this.m;B++)this.U[B][P]=-this.U[B][P];this.U[P][P]=1+this.U[P][P];for(var F=0;F<P-1;F++)this.U[F][P]=0}else{for(var z=0;z<this.m;z++)this.U[z][P]=0;this.U[P][P]=1}for(var V=this.n-1;V>=0;V--){if(ed=V<o,eh=0!==n[V],ed&&eh)for(var H=V+1;H<t;H++){for(var U=0,G=V+1;G<this.n;G++)U+=this.V[G][V]*this.V[G][H];U=-U/this.V[V+1][V];for(var Y=V+1;Y<this.n;Y++)this.V[Y][H]+=U*this.V[Y][V]}for(var X=0;X<this.n;X++)this.V[X][V]=0;this.V[V][V]=1}for(var W=A-1,q=0;A>0;){var $=void 0,K=void 0;for($=A-2;$>=-1&&-1!==$;$--)if(Math.abs(n[$])<=16033346880071782e-307+2220446049250313e-31*(Math.abs(this.s[$])+Math.abs(this.s[$+1]))){n[$]=0;break}if($===A-2)K=4;else{var Z=void 0;for(Z=A-1;Z>=$&&Z!==$;Z--){var Q=(Z!==A?Math.abs(n[Z]):0)+(Z!==$+1?Math.abs(n[Z-1]):0);if(Math.abs(this.s[Z])<=16033346880071782e-307+2220446049250313e-31*Q){this.s[Z]=0;break}}Z===$?K=3:Z===A-1?K=1:(K=2,$=Z)}switch($++,K){case 1:var J=n[A-2];n[A-2]=0;for(var ee=A-2;ee>=$;ee--){var et=r.hypot(this.s[ee],J),en=this.s[ee]/et,er=J/et;this.s[ee]=et,ee!==$&&(J=-er*n[ee-1],n[ee-1]=en*n[ee-1]);for(var ei=0;ei<this.n;ei++)et=en*this.V[ei][ee]+er*this.V[ei][A-1],this.V[ei][A-1]=-er*this.V[ei][ee]+en*this.V[ei][A-1],this.V[ei][ee]=et}break;case 2:var ea=n[$-1];n[$-1]=0;for(var eo=$;eo<A;eo++){var es=r.hypot(this.s[eo],ea),el=this.s[eo]/es,ec=ea/es;this.s[eo]=es,ea=-ec*n[eo],n[eo]=el*n[eo];for(var eu=0;eu<this.m;eu++)es=el*this.U[eu][eo]+ec*this.U[eu][$-1],this.U[eu][$-1]=-ec*this.U[eu][eo]+el*this.U[eu][$-1],this.U[eu][eo]=es}break;case 3:var ed,eh,ef,ep,eg=Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[A-1]),Math.abs(this.s[A-2])),Math.abs(n[A-2])),Math.abs(this.s[$])),Math.abs(n[$])),em=this.s[A-1]/eg,ev=this.s[A-2]/eg,ex=n[A-2]/eg,ey=this.s[$]/eg,eb=n[$]/eg,ew=((ev+em)*(ev-em)+ex*ex)/2,eN=em*ex*(em*ex),ej=0;ef=0!==ew,ep=0!==eN,(ef||ep)&&(ej=Math.sqrt(ew*ew+eN),ew<0&&(ej=-ej),ej=eN/(ew+ej));for(var ek=(ey+em)*(ey-em)+ej,eC=ey*eb,eE=$;eE<A-1;eE++){var eT=r.hypot(ek,eC),eS=ek/eT,e_=eC/eT;eE!==$&&(n[eE-1]=eT),ek=eS*this.s[eE]+e_*n[eE],n[eE]=eS*n[eE]-e_*this.s[eE],eC=e_*this.s[eE+1],this.s[eE+1]=eS*this.s[eE+1];for(var eA=0;eA<this.n;eA++)eT=eS*this.V[eA][eE]+e_*this.V[eA][eE+1],this.V[eA][eE+1]=-e_*this.V[eA][eE]+eS*this.V[eA][eE+1],this.V[eA][eE]=eT;if(eT=r.hypot(ek,eC),eS=ek/eT,e_=eC/eT,this.s[eE]=eT,ek=eS*n[eE]+e_*this.s[eE+1],this.s[eE+1]=-e_*n[eE]+eS*this.s[eE+1],eC=e_*n[eE+1],n[eE+1]=eS*n[eE+1],eE<this.m-1)for(var eD=0;eD<this.m;eD++)eT=eS*this.U[eD][eE]+e_*this.U[eD][eE+1],this.U[eD][eE+1]=-e_*this.U[eD][eE]+eS*this.U[eD][eE+1],this.U[eD][eE]=eT}n[A-2]=ek;break;case 4:if(this.s[$]<=0){this.s[$]=this.s[$]<0?-this.s[$]:0;for(var eM=0;eM<=W;eM++)this.V[eM][$]=-this.V[eM][$]}for(;$<W&&!(this.s[$]>=this.s[$+1]);){var eP=this.s[$];if(this.s[$]=this.s[$+1],this.s[$+1]=eP,$<this.n-1)for(var eR=0;eR<this.n;eR++)eP=this.V[eR][$+1],this.V[eR][$+1]=this.V[eR][$],this.V[eR][$]=eP;if($<this.m-1)for(var eL=0;eL<this.m;eL++)eP=this.U[eL][$+1],this.U[eL][$+1]=this.U[eL][$],this.U[eL][$]=eP;$++}A--}}return{U:this.U,V:this.V,S:this.s}},r.hypot=function(e,t){var n=void 0;return Math.abs(e)>Math.abs(t)?(n=t/e,n=Math.abs(e)*Math.sqrt(1+n*n)):0!=t?(n=e/t,n=Math.abs(t)*Math.sqrt(1+n*n)):n=0,n},e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();e.exports=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");this.sequence1=t,this.sequence2=n,this.match_score=r,this.mismatch_penalty=i,this.gap_penalty=a,this.iMax=t.length+1,this.jMax=n.length+1,this.grid=Array(this.iMax);for(var o=0;o<this.iMax;o++){this.grid[o]=Array(this.jMax);for(var s=0;s<this.jMax;s++)this.grid[o][s]=0}this.tracebackGrid=Array(this.iMax);for(var l=0;l<this.iMax;l++){this.tracebackGrid[l]=Array(this.jMax);for(var c=0;c<this.jMax;c++)this.tracebackGrid[l][c]=[null,null,null]}this.alignments=[],this.score=-1,this.computeGrids()}return r(e,[{key:"getScore",value:function(){return this.score}},{key:"getAlignments",value:function(){return this.alignments}},{key:"computeGrids",value:function(){for(var e=1;e<this.jMax;e++)this.grid[0][e]=this.grid[0][e-1]+this.gap_penalty,this.tracebackGrid[0][e]=[!1,!1,!0];for(var t=1;t<this.iMax;t++)this.grid[t][0]=this.grid[t-1][0]+this.gap_penalty,this.tracebackGrid[t][0]=[!1,!0,!1];for(var n=1;n<this.iMax;n++)for(var r=1;r<this.jMax;r++){var i=[this.sequence1[n-1]===this.sequence2[r-1]?this.grid[n-1][r-1]+this.match_score:this.grid[n-1][r-1]+this.mismatch_penalty,this.grid[n-1][r]+this.gap_penalty,this.grid[n][r-1]+this.gap_penalty],a=this.arrayAllMaxIndexes(i);this.grid[n][r]=i[a[0]],this.tracebackGrid[n][r]=[a.includes(0),a.includes(1),a.includes(2)]}this.score=this.grid[this.iMax-1][this.jMax-1]}},{key:"alignmentTraceback",value:function(){var e=[];for(e.push({pos:[this.sequence1.length,this.sequence2.length],seq1:"",seq2:""});e[0];){var t=e[0],n=this.tracebackGrid[t.pos[0]][t.pos[1]];n[0]&&e.push({pos:[t.pos[0]-1,t.pos[1]-1],seq1:this.sequence1[t.pos[0]-1]+t.seq1,seq2:this.sequence2[t.pos[1]-1]+t.seq2}),n[1]&&e.push({pos:[t.pos[0]-1,t.pos[1]],seq1:this.sequence1[t.pos[0]-1]+t.seq1,seq2:"-"+t.seq2}),n[2]&&e.push({pos:[t.pos[0],t.pos[1]-1],seq1:"-"+t.seq1,seq2:this.sequence2[t.pos[1]-1]+t.seq2}),0===t.pos[0]&&0===t.pos[1]&&this.alignments.push({sequence1:t.seq1,sequence2:t.seq2}),e.shift()}return this.alignments}},{key:"getAllIndexes",value:function(e,t){for(var n=[],r=-1;-1!==(r=e.indexOf(t,r+1));)n.push(r);return n}},{key:"arrayAllMaxIndexes",value:function(e){return this.getAllIndexes(e,Math.max.apply(null,e))}}]),e}()},function(e,t,n){"use strict";var r=function(){};r.FDLayout=n(18),r.FDLayoutConstants=n(4),r.FDLayoutEdge=n(19),r.FDLayoutNode=n(20),r.DimensionD=n(21),r.HashMap=n(22),r.HashSet=n(23),r.IGeometry=n(8),r.IMath=n(9),r.Integer=n(10),r.Point=n(12),r.PointD=n(5),r.RandomSeed=n(16),r.RectangleD=n(13),r.Transform=n(17),r.UniqueIDGeneretor=n(14),r.Quicksort=n(25),r.LinkedList=n(11),r.LGraphObject=n(2),r.LGraph=n(6),r.LEdge=n(1),r.LGraphManager=n(7),r.LNode=n(3),r.Layout=n(15),r.LayoutConstants=n(0),r.NeedlemanWunsch=n(27),r.Matrix=n(24),r.SVD=n(26),e.exports=r},function(e,t,n){"use strict";function r(){this.listeners=[]}var i=r.prototype;i.addListener=function(e,t){this.listeners.push({event:e,callback:t})},i.removeListener=function(e,t){for(var n=this.listeners.length;n>=0;n--){var r=this.listeners[n];r.event===e&&r.callback===t&&this.listeners.splice(n,1)}},i.emit=function(e,t){for(var n=0;n<this.listeners.length;n++){var r=this.listeners[n];e===r.event&&r.callback(t)}},e.exports=r}],t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=28)}()},97659,(e,t,n)=>{var r;e.e,r=e.r(51273),t.exports=(()=>{"use strict";var e={45:(e,t,n)=>{var r={};r.layoutBase=n(551),r.CoSEConstants=n(806),r.CoSEEdge=n(767),r.CoSEGraph=n(880),r.CoSEGraphManager=n(578),r.CoSELayout=n(765),r.CoSENode=n(991),r.ConstraintHandler=n(902),e.exports=r},806:(e,t,n)=>{var r=n(551).FDLayoutConstants;function i(){}for(var a in r)i[a]=r[a];i.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,i.DEFAULT_RADIAL_SEPARATION=r.DEFAULT_EDGE_LENGTH,i.DEFAULT_COMPONENT_SEPERATION=60,i.TILE=!0,i.TILING_PADDING_VERTICAL=10,i.TILING_PADDING_HORIZONTAL=10,i.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,i.ENFORCE_CONSTRAINTS=!0,i.APPLY_LAYOUT=!0,i.RELAX_MOVEMENT_ON_CONSTRAINTS=!0,i.TREE_REDUCTION_ON_INCREMENTAL=!0,i.PURE_INCREMENTAL=i.DEFAULT_INCREMENTAL,e.exports=i},767:(e,t,n)=>{var r=n(551).FDLayoutEdge;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i},880:(e,t,n)=>{var r=n(551).LGraph;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i},578:(e,t,n)=>{var r=n(551).LGraphManager;function i(e){r.call(this,e)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i},765:(e,t,n)=>{var r=n(551).FDLayout,i=n(578),a=n(880),o=n(991),s=n(767),l=n(806),c=n(902),u=n(551).FDLayoutConstants,d=n(551).LayoutConstants,h=n(551).Point,f=n(551).PointD,p=n(551).DimensionD,g=n(551).Layout,v=n(551).Integer,x=n(551).IGeometry,y=n(551).LGraph,b=n(551).Transform,w=n(551).LinkedList;function N(){r.call(this),this.toBeTiled={},this.constraints={}}for(var j in N.prototype=Object.create(r.prototype),r)N[j]=r[j];N.prototype.newGraphManager=function(){var e=new i(this);return this.graphManager=e,e},N.prototype.newGraph=function(e){return new a(null,this.graphManager,e)},N.prototype.newNode=function(e){return new o(this.graphManager,e)},N.prototype.newEdge=function(e){return new s(null,null,e)},N.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.isSubLayout||(l.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=l.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=l.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=u.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=u.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=u.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1)},N.prototype.initSpringEmbedder=function(){r.prototype.initSpringEmbedder.call(this),this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/u.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=.04,this.coolingAdjuster=1},N.prototype.layout=function(){return d.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},N.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental){if(l.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t)}}else{var n=this.getFlatForest();if(n.length>0)this.positionNodesRadially(n);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.positionNodesRandomly()}}return Object.keys(this.constraints).length>0&&(c.handleConstraints(this),this.initConstraintVariables()),this.initSpringEmbedder(),l.APPLY_LAYOUT&&this.runSpringEmbedder(),!0},N.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(!(this.prunedNodesAll.length>0))return!0;else this.isTreeGrowing=!0;if(this.totalIterations%u.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(!(this.prunedNodesAll.length>0))return!0;else this.isTreeGrowing=!0;this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.graphManager.updateBounds(),this.updateGrid(),l.PURE_INCREMENTAL?this.coolingFactor=u.DEFAULT_COOLING_FACTOR_INCREMENTAL/2:this.coolingFactor=u.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),l.PURE_INCREMENTAL?this.coolingFactor=u.DEFAULT_COOLING_FACTOR_INCREMENTAL/2*((100-this.afterGrowthIterations)/100):this.coolingFactor=u.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var n=!this.isTreeGrowing&&!this.isGrowthFinished,r=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(n,r),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},N.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},n=0;n<e.length;n++){var r=e[n].rect,i=e[n].id;t[i]={id:i,x:r.getCenterX(),y:r.getCenterY(),w:r.width,h:r.height}}return t},N.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var e=!1;if("during"===u.ANIMATE)this.emit("layoutstarted");else{for(;!e;)e=this.tick();this.graphManager.updateBounds()}},N.prototype.moveNodes=function(){for(var e,t=this.getAllNodes(),n=0;n<t.length;n++)t[n].calculateDisplacement();Object.keys(this.constraints).length>0&&this.updateDisplacements();for(var n=0;n<t.length;n++)t[n].move()},N.prototype.initConstraintVariables=function(){var e=this;this.idToNodeMap=new Map,this.fixedNodeSet=new Set;for(var t=this.graphManager.getAllNodes(),n=0;n<t.length;n++){var r=t[n];this.idToNodeMap.set(r.id,r)}if(this.constraints.fixedNodeConstraint){this.constraints.fixedNodeConstraint.forEach(function(t){e.fixedNodeSet.add(t.nodeId)});for(var r,t=this.graphManager.getAllNodes(),n=0;n<t.length;n++)if(null!=(r=t[n]).getChild()){var i=function t(n){for(var r,i=n.getChild().getNodes(),a=0,o=0;o<i.length;o++)null==(r=i[o]).getChild()?e.fixedNodeSet.has(r.id)&&(a+=100):a+=t(r);return a}(r);i>0&&(r.fixedNodeWeight=i)}}if(this.constraints.relativePlacementConstraint){var a=new Map,o=new Map;if(this.dummyToNodeForVerticalAlignment=new Map,this.dummyToNodeForHorizontalAlignment=new Map,this.fixedNodesOnHorizontal=new Set,this.fixedNodesOnVertical=new Set,this.fixedNodeSet.forEach(function(t){e.fixedNodesOnHorizontal.add(t),e.fixedNodesOnVertical.add(t)}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var s=this.constraints.alignmentConstraint.vertical,n=0;n<s.length;n++)this.dummyToNodeForVerticalAlignment.set("dummy"+n,[]),s[n].forEach(function(t){a.set(t,"dummy"+n),e.dummyToNodeForVerticalAlignment.get("dummy"+n).push(t),e.fixedNodeSet.has(t)&&e.fixedNodesOnHorizontal.add("dummy"+n)});if(this.constraints.alignmentConstraint.horizontal)for(var c=this.constraints.alignmentConstraint.horizontal,n=0;n<c.length;n++)this.dummyToNodeForHorizontalAlignment.set("dummy"+n,[]),c[n].forEach(function(t){o.set(t,"dummy"+n),e.dummyToNodeForHorizontalAlignment.get("dummy"+n).push(t),e.fixedNodeSet.has(t)&&e.fixedNodesOnVertical.add("dummy"+n)})}if(l.RELAX_MOVEMENT_ON_CONSTRAINTS)this.shuffle=function(e){var t,n,r;for(r=e.length-1;r>=2*e.length/3;r--)t=Math.floor(Math.random()*(r+1)),n=e[r],e[r]=e[t],e[t]=n;return e},this.nodesInRelativeHorizontal=[],this.nodesInRelativeVertical=[],this.nodeToRelativeConstraintMapHorizontal=new Map,this.nodeToRelativeConstraintMapVertical=new Map,this.nodeToTempPositionMapHorizontal=new Map,this.nodeToTempPositionMapVertical=new Map,this.constraints.relativePlacementConstraint.forEach(function(t){if(t.left){var n=a.has(t.left)?a.get(t.left):t.left,r=a.has(t.right)?a.get(t.right):t.right;e.nodesInRelativeHorizontal.includes(n)||(e.nodesInRelativeHorizontal.push(n),e.nodeToRelativeConstraintMapHorizontal.set(n,[]),e.dummyToNodeForVerticalAlignment.has(n)?e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(n)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(n).getCenterX())),e.nodesInRelativeHorizontal.includes(r)||(e.nodesInRelativeHorizontal.push(r),e.nodeToRelativeConstraintMapHorizontal.set(r,[]),e.dummyToNodeForVerticalAlignment.has(r)?e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(r)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(r).getCenterX())),e.nodeToRelativeConstraintMapHorizontal.get(n).push({right:r,gap:t.gap}),e.nodeToRelativeConstraintMapHorizontal.get(r).push({left:n,gap:t.gap})}else{var i=o.has(t.top)?o.get(t.top):t.top,s=o.has(t.bottom)?o.get(t.bottom):t.bottom;e.nodesInRelativeVertical.includes(i)||(e.nodesInRelativeVertical.push(i),e.nodeToRelativeConstraintMapVertical.set(i,[]),e.dummyToNodeForHorizontalAlignment.has(i)?e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(i)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(i).getCenterY())),e.nodesInRelativeVertical.includes(s)||(e.nodesInRelativeVertical.push(s),e.nodeToRelativeConstraintMapVertical.set(s,[]),e.dummyToNodeForHorizontalAlignment.has(s)?e.nodeToTempPositionMapVertical.set(s,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(s)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(s,e.idToNodeMap.get(s).getCenterY())),e.nodeToRelativeConstraintMapVertical.get(i).push({bottom:s,gap:t.gap}),e.nodeToRelativeConstraintMapVertical.get(s).push({top:i,gap:t.gap})}});else{var u=new Map,d=new Map;this.constraints.relativePlacementConstraint.forEach(function(e){if(e.left){var t=a.has(e.left)?a.get(e.left):e.left,n=a.has(e.right)?a.get(e.right):e.right;u.has(t)?u.get(t).push(n):u.set(t,[n]),u.has(n)?u.get(n).push(t):u.set(n,[t])}else{var r=o.has(e.top)?o.get(e.top):e.top,i=o.has(e.bottom)?o.get(e.bottom):e.bottom;d.has(r)?d.get(r).push(i):d.set(r,[i]),d.has(i)?d.get(i).push(r):d.set(i,[r])}});var h=function(e,t){var n=[],r=[],i=new w,a=new Set,o=0;return e.forEach(function(s,l){if(!a.has(l)){n[o]=[],r[o]=!1;var c=l;for(i.push(c),a.add(c),n[o].push(c);0!=i.length;)c=i.shift(),t.has(c)&&(r[o]=!0),e.get(c).forEach(function(e){a.has(e)||(i.push(e),a.add(e),n[o].push(e))});o++}}),{components:n,isFixed:r}},f=h(u,e.fixedNodesOnHorizontal);this.componentsOnHorizontal=f.components,this.fixedComponentsOnHorizontal=f.isFixed;var p=h(d,e.fixedNodesOnVertical);this.componentsOnVertical=p.components,this.fixedComponentsOnVertical=p.isFixed}}},N.prototype.updateDisplacements=function(){var e=this;if(this.constraints.fixedNodeConstraint&&this.constraints.fixedNodeConstraint.forEach(function(t){var n=e.idToNodeMap.get(t.nodeId);n.displacementX=0,n.displacementY=0}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var t=this.constraints.alignmentConstraint.vertical,n=0;n<t.length;n++){for(var r=0,i=0;i<t[n].length;i++){if(this.fixedNodeSet.has(t[n][i])){r=0;break}r+=this.idToNodeMap.get(t[n][i]).displacementX}for(var a=r/t[n].length,i=0;i<t[n].length;i++)this.idToNodeMap.get(t[n][i]).displacementX=a}if(this.constraints.alignmentConstraint.horizontal)for(var o=this.constraints.alignmentConstraint.horizontal,n=0;n<o.length;n++){for(var s=0,i=0;i<o[n].length;i++){if(this.fixedNodeSet.has(o[n][i])){s=0;break}s+=this.idToNodeMap.get(o[n][i]).displacementY}for(var c=s/o[n].length,i=0;i<o[n].length;i++)this.idToNodeMap.get(o[n][i]).displacementY=c}}if(this.constraints.relativePlacementConstraint)if(l.RELAX_MOVEMENT_ON_CONSTRAINTS)this.totalIterations%10==0&&(this.shuffle(this.nodesInRelativeHorizontal),this.shuffle(this.nodesInRelativeVertical)),this.nodesInRelativeHorizontal.forEach(function(t){if(!e.fixedNodesOnHorizontal.has(t)){var n=0;n=e.dummyToNodeForVerticalAlignment.has(t)?e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(t)[0]).displacementX:e.idToNodeMap.get(t).displacementX,e.nodeToRelativeConstraintMapHorizontal.get(t).forEach(function(r){if(r.right){var i=e.nodeToTempPositionMapHorizontal.get(r.right)-e.nodeToTempPositionMapHorizontal.get(t)-n;i<r.gap&&(n-=r.gap-i)}else{var i=e.nodeToTempPositionMapHorizontal.get(t)-e.nodeToTempPositionMapHorizontal.get(r.left)+n;i<r.gap&&(n+=r.gap-i)}}),e.nodeToTempPositionMapHorizontal.set(t,e.nodeToTempPositionMapHorizontal.get(t)+n),e.dummyToNodeForVerticalAlignment.has(t)?e.dummyToNodeForVerticalAlignment.get(t).forEach(function(t){e.idToNodeMap.get(t).displacementX=n}):e.idToNodeMap.get(t).displacementX=n}}),this.nodesInRelativeVertical.forEach(function(t){if(!e.fixedNodesOnHorizontal.has(t)){var n=0;n=e.dummyToNodeForHorizontalAlignment.has(t)?e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(t)[0]).displacementY:e.idToNodeMap.get(t).displacementY,e.nodeToRelativeConstraintMapVertical.get(t).forEach(function(r){if(r.bottom){var i=e.nodeToTempPositionMapVertical.get(r.bottom)-e.nodeToTempPositionMapVertical.get(t)-n;i<r.gap&&(n-=r.gap-i)}else{var i=e.nodeToTempPositionMapVertical.get(t)-e.nodeToTempPositionMapVertical.get(r.top)+n;i<r.gap&&(n+=r.gap-i)}}),e.nodeToTempPositionMapVertical.set(t,e.nodeToTempPositionMapVertical.get(t)+n),e.dummyToNodeForHorizontalAlignment.has(t)?e.dummyToNodeForHorizontalAlignment.get(t).forEach(function(t){e.idToNodeMap.get(t).displacementY=n}):e.idToNodeMap.get(t).displacementY=n}});else{for(var n=0;n<this.componentsOnHorizontal.length;n++){var u=this.componentsOnHorizontal[n];if(this.fixedComponentsOnHorizontal[n])for(var i=0;i<u.length;i++)this.dummyToNodeForVerticalAlignment.has(u[i])?this.dummyToNodeForVerticalAlignment.get(u[i]).forEach(function(t){e.idToNodeMap.get(t).displacementX=0}):this.idToNodeMap.get(u[i]).displacementX=0;else{for(var d=0,h=0,i=0;i<u.length;i++)if(this.dummyToNodeForVerticalAlignment.has(u[i])){var f=this.dummyToNodeForVerticalAlignment.get(u[i]);d+=f.length*this.idToNodeMap.get(f[0]).displacementX,h+=f.length}else d+=this.idToNodeMap.get(u[i]).displacementX,h++;for(var p=d/h,i=0;i<u.length;i++)this.dummyToNodeForVerticalAlignment.has(u[i])?this.dummyToNodeForVerticalAlignment.get(u[i]).forEach(function(t){e.idToNodeMap.get(t).displacementX=p}):this.idToNodeMap.get(u[i]).displacementX=p}}for(var n=0;n<this.componentsOnVertical.length;n++){var u=this.componentsOnVertical[n];if(this.fixedComponentsOnVertical[n])for(var i=0;i<u.length;i++)this.dummyToNodeForHorizontalAlignment.has(u[i])?this.dummyToNodeForHorizontalAlignment.get(u[i]).forEach(function(t){e.idToNodeMap.get(t).displacementY=0}):this.idToNodeMap.get(u[i]).displacementY=0;else{for(var d=0,h=0,i=0;i<u.length;i++)if(this.dummyToNodeForHorizontalAlignment.has(u[i])){var f=this.dummyToNodeForHorizontalAlignment.get(u[i]);d+=f.length*this.idToNodeMap.get(f[0]).displacementY,h+=f.length}else d+=this.idToNodeMap.get(u[i]).displacementY,h++;for(var p=d/h,i=0;i<u.length;i++)this.dummyToNodeForHorizontalAlignment.has(u[i])?this.dummyToNodeForHorizontalAlignment.get(u[i]).forEach(function(t){e.idToNodeMap.get(t).displacementY=p}):this.idToNodeMap.get(u[i]).displacementY=p}}}},N.prototype.calculateNodesToApplyGravitationTo=function(){var e,t,n=[],r=this.graphManager.getGraphs(),i=r.length;for(t=0;t<i;t++)(e=r[t]).updateConnected(),e.isConnected||(n=n.concat(e.getNodes()));return n},N.prototype.createBendpoints=function(){var e=[];e=e.concat(this.graphManager.getAllEdges());var t=new Set;for(a=0;a<e.length;a++){var n=e[a];if(!t.has(n)){var r=n.getSource(),i=n.getTarget();if(r==i)n.getBendpoints().push(new f),n.getBendpoints().push(new f),this.createDummyNodesForBendpoints(n),t.add(n);else{var a,o,s=[];if(s=(s=s.concat(r.getEdgeListToNode(i))).concat(i.getEdgeListToNode(r)),!t.has(s[0])){if(s.length>1)for(o=0;o<s.length;o++){var l=s[o];l.getBendpoints().push(new f),this.createDummyNodesForBendpoints(l)}s.forEach(function(e){t.add(e)})}}}if(t.size==e.length)break}},N.prototype.positionNodesRadially=function(e){for(var t=new h(0,0),n=Math.ceil(Math.sqrt(e.length)),r=0,i=0,a=0,o=new f(0,0),s=0;s<e.length;s++){s%n==0&&(a=0,i=r,0!=s&&(i+=l.DEFAULT_COMPONENT_SEPERATION),r=0);var c=e[s],u=g.findCenterOfTree(c);t.x=a,t.y=i,(o=N.radialLayout(c,u,t)).y>r&&(r=Math.floor(o.y)),a=Math.floor(o.x+l.DEFAULT_COMPONENT_SEPERATION)}this.transform(new f(d.WORLD_CENTER_X-o.x/2,d.WORLD_CENTER_Y-o.y/2))},N.radialLayout=function(e,t,n){var r=Math.max(this.maxDiagonalInTree(e),l.DEFAULT_RADIAL_SEPARATION);N.branchRadialLayout(t,null,0,359,0,r);var i=y.calculateBounds(e),a=new b;a.setDeviceOrgX(i.getMinX()),a.setDeviceOrgY(i.getMinY()),a.setWorldOrgX(n.x),a.setWorldOrgY(n.y);for(var o=0;o<e.length;o++)e[o].transform(a);var s=new f(i.getMaxX(),i.getMaxY());return a.inverseTransformPoint(s)},N.branchRadialLayout=function(e,t,n,r,i,a){var o,s=(r-n+1)/2;s<0&&(s+=180);var l=(s+n)%360*x.TWO_PI/360,c=i*Math.cos(l),u=i*Math.sin(l);e.setCenter(c,u);var d=[],h=(d=d.concat(e.getEdges())).length;null!=t&&h--;for(var f=0,p=d.length,g=e.getEdgesBetween(t);g.length>1;){var v=g[0];g.splice(0,1);var y=d.indexOf(v);y>=0&&d.splice(y,1),p--,h--}o=null!=t?(d.indexOf(g[0])+1)%p:0;for(var b=Math.abs(r-n)/h,w=o;f!=h;w=++w%p){var j=d[w].getOtherEnd(e);if(j!=t){var k=(n+f*b)%360,C=(k+b)%360;N.branchRadialLayout(j,e,k,C,i+a,a),f++}}},N.maxDiagonalInTree=function(e){for(var t=v.MIN_VALUE,n=0;n<e.length;n++){var r=e[n].getDiagonal();r>t&&(t=r)}return t},N.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},N.prototype.groupZeroDegreeMembers=function(){var e=this,t={};this.memberGroups={},this.idToDummyNode={};for(var n=[],r=this.graphManager.getAllNodes(),i=0;i<r.length;i++){var a=r[i],s=a.getParent();0!==this.getNodeDegreeWithChildren(a)||void 0!=s.id&&this.getToBeTiled(s)||n.push(a)}for(var i=0;i<n.length;i++){var a=n[i],l=a.getParent().id;void 0===t[l]&&(t[l]=[]),t[l]=t[l].concat(a)}Object.keys(t).forEach(function(n){if(t[n].length>1){var r="DummyCompound_"+n;e.memberGroups[r]=t[n];var i=t[n][0].getParent(),a=new o(e.graphManager);a.id=r,a.paddingLeft=i.paddingLeft||0,a.paddingRight=i.paddingRight||0,a.paddingBottom=i.paddingBottom||0,a.paddingTop=i.paddingTop||0,e.idToDummyNode[r]=a;var s=e.getGraphManager().add(e.newGraph(),a),l=i.getChild();l.add(a);for(var c=0;c<t[n].length;c++){var u=t[n][c];l.remove(u),s.add(u)}}})},N.prototype.clearCompounds=function(){var e={},t={};this.performDFSOnCompounds();for(var n=0;n<this.compoundOrder.length;n++)t[this.compoundOrder[n].id]=this.compoundOrder[n],e[this.compoundOrder[n].id]=[].concat(this.compoundOrder[n].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[n].getChild()),this.compoundOrder[n].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(e,t)},N.prototype.clearZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach(function(n){var r=e.idToDummyNode[n];if(t[n]=e.tileNodes(e.memberGroups[n],r.paddingLeft+r.paddingRight),r.rect.width=t[n].width,r.rect.height=t[n].height,r.setCenter(t[n].centerX,t[n].centerY),r.labelMarginLeft=0,r.labelMarginTop=0,l.NODE_DIMENSIONS_INCLUDE_LABELS){var i=r.rect.width,a=r.rect.height;r.labelWidth&&("left"==r.labelPosHorizontal?(r.rect.x-=r.labelWidth,r.setWidth(i+r.labelWidth),r.labelMarginLeft=r.labelWidth):"center"==r.labelPosHorizontal&&r.labelWidth>i?(r.rect.x-=(r.labelWidth-i)/2,r.setWidth(r.labelWidth),r.labelMarginLeft=(r.labelWidth-i)/2):"right"==r.labelPosHorizontal&&r.setWidth(i+r.labelWidth)),r.labelHeight&&("top"==r.labelPosVertical?(r.rect.y-=r.labelHeight,r.setHeight(a+r.labelHeight),r.labelMarginTop=r.labelHeight):"center"==r.labelPosVertical&&r.labelHeight>a?(r.rect.y-=(r.labelHeight-a)/2,r.setHeight(r.labelHeight),r.labelMarginTop=(r.labelHeight-a)/2):"bottom"==r.labelPosVertical&&r.setHeight(a+r.labelHeight))}})},N.prototype.repopulateCompounds=function(){for(var e=this.compoundOrder.length-1;e>=0;e--){var t=this.compoundOrder[e],n=t.id,r=t.paddingLeft,i=t.paddingTop,a=t.labelMarginLeft,o=t.labelMarginTop;this.adjustLocations(this.tiledMemberPack[n],t.rect.x,t.rect.y,r,i,a,o)}},N.prototype.repopulateZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack;Object.keys(t).forEach(function(n){var r=e.idToDummyNode[n],i=r.paddingLeft,a=r.paddingTop,o=r.labelMarginLeft,s=r.labelMarginTop;e.adjustLocations(t[n],r.rect.x,r.rect.y,i,a,o,s)})},N.prototype.getToBeTiled=function(e){var t=e.id;if(null!=this.toBeTiled[t])return this.toBeTiled[t];var n=e.getChild();if(null==n)return this.toBeTiled[t]=!1,!1;for(var r=n.getNodes(),i=0;i<r.length;i++){var a=r[i];if(this.getNodeDegree(a)>0)return this.toBeTiled[t]=!1,!1;if(null==a.getChild()){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[t]=!1,!1}return this.toBeTiled[t]=!0,!0},N.prototype.getNodeDegree=function(e){e.id;for(var t=e.getEdges(),n=0,r=0;r<t.length;r++){var i=t[r];i.getSource().id!==i.getTarget().id&&(n+=1)}return n},N.prototype.getNodeDegreeWithChildren=function(e){var t=this.getNodeDegree(e);if(null==e.getChild())return t;for(var n=e.getChild().getNodes(),r=0;r<n.length;r++){var i=n[r];t+=this.getNodeDegreeWithChildren(i)}return t},N.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},N.prototype.fillCompexOrderByDFS=function(e){for(var t=0;t<e.length;t++){var n=e[t];null!=n.getChild()&&this.fillCompexOrderByDFS(n.getChild().getNodes()),this.getToBeTiled(n)&&this.compoundOrder.push(n)}},N.prototype.adjustLocations=function(e,t,n,r,i,a,o){t+=r+a,n+=i+o;for(var s=t,l=0;l<e.rows.length;l++){var c=e.rows[l];t=s;for(var u=0,d=0;d<c.length;d++){var h=c[d];h.rect.x=t,h.rect.y=n,t+=h.rect.width+e.horizontalPadding,h.rect.height>u&&(u=h.rect.height)}n+=u+e.verticalPadding}},N.prototype.tileCompoundMembers=function(e,t){var n=this;this.tiledMemberPack=[],Object.keys(e).forEach(function(r){var i=t[r];if(n.tiledMemberPack[r]=n.tileNodes(e[r],i.paddingLeft+i.paddingRight),i.rect.width=n.tiledMemberPack[r].width,i.rect.height=n.tiledMemberPack[r].height,i.setCenter(n.tiledMemberPack[r].centerX,n.tiledMemberPack[r].centerY),i.labelMarginLeft=0,i.labelMarginTop=0,l.NODE_DIMENSIONS_INCLUDE_LABELS){var a=i.rect.width,o=i.rect.height;i.labelWidth&&("left"==i.labelPosHorizontal?(i.rect.x-=i.labelWidth,i.setWidth(a+i.labelWidth),i.labelMarginLeft=i.labelWidth):"center"==i.labelPosHorizontal&&i.labelWidth>a?(i.rect.x-=(i.labelWidth-a)/2,i.setWidth(i.labelWidth),i.labelMarginLeft=(i.labelWidth-a)/2):"right"==i.labelPosHorizontal&&i.setWidth(a+i.labelWidth)),i.labelHeight&&("top"==i.labelPosVertical?(i.rect.y-=i.labelHeight,i.setHeight(o+i.labelHeight),i.labelMarginTop=i.labelHeight):"center"==i.labelPosVertical&&i.labelHeight>o?(i.rect.y-=(i.labelHeight-o)/2,i.setHeight(i.labelHeight),i.labelMarginTop=(i.labelHeight-o)/2):"bottom"==i.labelPosVertical&&i.setHeight(o+i.labelHeight))}})},N.prototype.tileNodes=function(e,t){var n=this.tileNodesByFavoringDim(e,t,!0),r=this.tileNodesByFavoringDim(e,t,!1),i=this.getOrgRatio(n);return this.getOrgRatio(r)<i?r:n},N.prototype.getOrgRatio=function(e){var t=e.width/e.height;return t<1&&(t=1/t),t},N.prototype.calcIdealRowWidth=function(e,t){var n,r=l.TILING_PADDING_VERTICAL,i=l.TILING_PADDING_HORIZONTAL,a=e.length,o=0,s=0,c=0;e.forEach(function(e){o+=e.getWidth(),s+=e.getHeight(),e.getWidth()>c&&(c=e.getWidth())});var u=o/a,d=Math.pow(r-i,2)+4*(u+i)*(s/a+r)*a,h=(i-r+Math.sqrt(d))/(2*(u+i));t?(n=Math.ceil(h))==h&&n++:n=Math.floor(h);var f=n*(u+i)-i;return c>f&&(f=c),f+=2*i},N.prototype.tileNodesByFavoringDim=function(e,t,n){var r=l.TILING_PADDING_VERTICAL,i=l.TILING_PADDING_HORIZONTAL,a=l.TILING_COMPARE_BY,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:t,verticalPadding:r,horizontalPadding:i,centerX:0,centerY:0};a&&(o.idealRowWidth=this.calcIdealRowWidth(e,n));var s=function(e){return e.rect.width*e.rect.height},c=function(e,t){return s(t)-s(e)};e.sort(function(e,t){var n=c;return o.idealRowWidth?(n=a)(e.id,t.id):n(e,t)});for(var u=0,d=0,h=0;h<e.length;h++){var f=e[h];u+=f.getCenterX(),d+=f.getCenterY()}o.centerX=u/e.length,o.centerY=d/e.length;for(var h=0;h<e.length;h++){var f=e[h];if(0==o.rows.length)this.insertNodeToRow(o,f,0,t);else if(this.canAddHorizontal(o,f.rect.width,f.rect.height)){var p=o.rows.length-1;o.idealRowWidth||(p=this.getShortestRowIndex(o)),this.insertNodeToRow(o,f,p,t)}else this.insertNodeToRow(o,f,o.rows.length,t);this.shiftToLastRow(o)}return o},N.prototype.insertNodeToRow=function(e,t,n,r){n==e.rows.length&&(e.rows.push([]),e.rowWidth.push(r),e.rowHeight.push(0));var i=e.rowWidth[n]+t.rect.width;e.rows[n].length>0&&(i+=e.horizontalPadding),e.rowWidth[n]=i,e.width<i&&(e.width=i);var a=t.rect.height;n>0&&(a+=e.verticalPadding);var o=0;a>e.rowHeight[n]&&(o=e.rowHeight[n],e.rowHeight[n]=a,o=e.rowHeight[n]-o),e.height+=o,e.rows[n].push(t)},N.prototype.getShortestRowIndex=function(e){for(var t=-1,n=Number.MAX_VALUE,r=0;r<e.rows.length;r++)e.rowWidth[r]<n&&(t=r,n=e.rowWidth[r]);return t},N.prototype.getLongestRowIndex=function(e){for(var t=-1,n=5e-324,r=0;r<e.rows.length;r++)e.rowWidth[r]>n&&(t=r,n=e.rowWidth[r]);return t},N.prototype.canAddHorizontal=function(e,t,n){if(e.idealRowWidth){var r,i,a=e.rows.length-1;return e.rowWidth[a]+t+e.horizontalPadding<=e.idealRowWidth}var o=this.getShortestRowIndex(e);if(o<0)return!0;var s=e.rowWidth[o];if(s+e.horizontalPadding+t<=e.width)return!0;var l=0;return e.rowHeight[o]<n&&o>0&&(l=n+e.verticalPadding-e.rowHeight[o]),r=e.width-s>=t+e.horizontalPadding?(e.height+l)/(s+t+e.horizontalPadding):(e.height+l)/e.width,l=n+e.verticalPadding,(i=e.width<t?(e.height+l)/t:(e.height+l)/e.width)<1&&(i=1/i),r<1&&(r=1/r),r<i},N.prototype.shiftToLastRow=function(e){var t=this.getLongestRowIndex(e),n=e.rowWidth.length-1,r=e.rows[t],i=r[r.length-1],a=i.width+e.horizontalPadding;if(e.width-e.rowWidth[n]>a&&t!=n){r.splice(-1,1),e.rows[n].push(i),e.rowWidth[t]=e.rowWidth[t]-a,e.rowWidth[n]=e.rowWidth[n]+a,e.width=e.rowWidth[instance.getLongestRowIndex(e)];for(var o=5e-324,s=0;s<r.length;s++)r[s].height>o&&(o=r[s].height);t>0&&(o+=e.verticalPadding);var l=e.rowHeight[t]+e.rowHeight[n];e.rowHeight[t]=o,e.rowHeight[n]<i.height+e.verticalPadding&&(e.rowHeight[n]=i.height+e.verticalPadding);var c=e.rowHeight[t]+e.rowHeight[n];e.height+=c-l,this.shiftToLastRow(e)}},N.prototype.tilingPreLayout=function(){l.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},N.prototype.tilingPostLayout=function(){l.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},N.prototype.reduceTrees=function(){for(var e,t=[],n=!0;n;){var r=this.graphManager.getAllNodes(),i=[];n=!1;for(var a=0;a<r.length;a++)if(1==(e=r[a]).getEdges().length&&!e.getEdges()[0].isInterGraph&&null==e.getChild()){if(l.PURE_INCREMENTAL){var o=e.getEdges()[0].getOtherEnd(e),s=new p(e.getCenterX()-o.getCenterX(),e.getCenterY()-o.getCenterY());i.push([e,e.getEdges()[0],e.getOwner(),s])}else i.push([e,e.getEdges()[0],e.getOwner()]);n=!0}if(!0==n){for(var c=[],u=0;u<i.length;u++)1==i[u][0].getEdges().length&&(c.push(i[u]),i[u][0].getOwner().remove(i[u][0]));t.push(c),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},N.prototype.growTree=function(e){for(var t,n=e.length,r=e[n-1],i=0;i<r.length;i++)t=r[i],this.findPlaceforPrunedNode(t),t[2].add(t[0]),t[2].add(t[1],t[1].source,t[1].target);e.splice(e.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},N.prototype.findPlaceforPrunedNode=function(e){var t=e[0];if(r=t==e[1].source?e[1].target:e[1].source,l.PURE_INCREMENTAL)t.setCenter(r.getCenterX()+e[3].getWidth(),r.getCenterY()+e[3].getHeight());else{var n,r,i,a,o=r.startX,s=r.finishX,c=r.startY,d=r.finishY,h=[0,0,0,0];if(c>0)for(var f=o;f<=s;f++)h[0]+=this.grid[f][c-1].length+this.grid[f][c].length-1;if(s<this.grid.length-1)for(var f=c;f<=d;f++)h[1]+=this.grid[s+1][f].length+this.grid[s][f].length-1;if(d<this.grid[0].length-1)for(var f=o;f<=s;f++)h[2]+=this.grid[f][d+1].length+this.grid[f][d].length-1;if(o>0)for(var f=c;f<=d;f++)h[3]+=this.grid[o-1][f].length+this.grid[o][f].length-1;for(var p=v.MAX_VALUE,g=0;g<h.length;g++)h[g]<p?(p=h[g],i=1,a=g):h[g]==p&&i++;if(3==i&&0==p)0==h[0]&&0==h[1]&&0==h[2]?n=1:0==h[0]&&0==h[1]&&0==h[3]?n=0:0==h[0]&&0==h[2]&&0==h[3]?n=3:0==h[1]&&0==h[2]&&0==h[3]&&(n=2);else if(2==i&&0==p){var x=Math.floor(2*Math.random());n=0==h[0]&&0==h[1]?+(0!=x):0==h[0]&&0==h[2]?2*(0!=x):0==h[0]&&0==h[3]?3*(0!=x):0==h[1]&&0==h[2]?0==x?1:2:0==h[1]&&0==h[3]?0==x?1:3:0==x?2:3}else if(4==i&&0==p){var x=Math.floor(4*Math.random());n=x}else n=a;0==n?t.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-u.DEFAULT_EDGE_LENGTH-t.getHeight()/2):1==n?t.setCenter(r.getCenterX()+r.getWidth()/2+u.DEFAULT_EDGE_LENGTH+t.getWidth()/2,r.getCenterY()):2==n?t.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+u.DEFAULT_EDGE_LENGTH+t.getHeight()/2):t.setCenter(r.getCenterX()-r.getWidth()/2-u.DEFAULT_EDGE_LENGTH-t.getWidth()/2,r.getCenterY())}},e.exports=N},991:(e,t,n)=>{var r=n(551).FDLayoutNode,i=n(551).IMath;function a(e,t,n,i){r.call(this,e,t,n,i)}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];a.prototype.calculateDisplacement=function(){var e=this.graphManager.getLayout();null!=this.getChild()&&this.fixedNodeWeight?(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.fixedNodeWeight,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.fixedNodeWeight):(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren),Math.abs(this.displacementX)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementX=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementX)),Math.abs(this.displacementY)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementY=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementY)),this.child&&this.child.getNodes().length>0&&this.propogateDisplacementToChildren(this.displacementX,this.displacementY)},a.prototype.propogateDisplacementToChildren=function(e,t){for(var n,r=this.getChild().getNodes(),i=0;i<r.length;i++)null==(n=r[i]).getChild()?(n.displacementX+=e,n.displacementY+=t):n.propogateDisplacementToChildren(e,t)},a.prototype.move=function(){var e=this.graphManager.getLayout();(null==this.child||0==this.child.getNodes().length)&&(this.moveBy(this.displacementX,this.displacementY),e.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY)),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},a.prototype.setPred1=function(e){this.pred1=e},a.prototype.getPred1=function(){return pred1},a.prototype.getPred2=function(){return pred2},a.prototype.setNext=function(e){this.next=e},a.prototype.getNext=function(){return next},a.prototype.setProcessed=function(e){this.processed=e},a.prototype.isProcessed=function(){return processed},e.exports=a},902:(e,t,n)=>{function r(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}var i=n(806),a=n(551).LinkedList,o=n(551).Matrix,s=n(551).SVD;function l(){}l.handleConstraints=function(e){var t={};t.fixedNodeConstraint=e.constraints.fixedNodeConstraint,t.alignmentConstraint=e.constraints.alignmentConstraint,t.relativePlacementConstraint=e.constraints.relativePlacementConstraint;for(var n=new Map,l=new Map,c=[],u=[],d=e.getAllNodes(),h=0,f=0;f<d.length;f++){var p=d[f];null==p.getChild()&&(l.set(p.id,h++),c.push(p.getCenterX()),u.push(p.getCenterY()),n.set(p.id,p))}t.relativePlacementConstraint&&t.relativePlacementConstraint.forEach(function(e){e.gap||0==e.gap||(e.left?e.gap=i.DEFAULT_EDGE_LENGTH+n.get(e.left).getWidth()/2+n.get(e.right).getWidth()/2:e.gap=i.DEFAULT_EDGE_LENGTH+n.get(e.top).getHeight()/2+n.get(e.bottom).getHeight()/2)});var g=function(e){var t=0,n=0;return e.forEach(function(e){t+=c[l.get(e)],n+=u[l.get(e)]}),{x:t/e.size,y:n/e.size}},v=function(e,t,n,i,o){var s=new Map;e.forEach(function(e,t){s.set(t,0)}),e.forEach(function(e,t){e.forEach(function(e){s.set(e.id,s.get(e.id)+1)})});var d=new Map,h=new Map,f=new a;for(s.forEach(function(e,r){0==e?(f.push(r),n||("horizontal"==t?d.set(r,l.has(r)?c[l.get(r)]:i.get(r)):d.set(r,l.has(r)?u[l.get(r)]:i.get(r)))):d.set(r,-1/0),n&&h.set(r,new Set([r]))}),n&&o.forEach(function(e){var r=[];if(e.forEach(function(e){n.has(e)&&r.push(e)}),r.length>0){var a=0;r.forEach(function(e){"horizontal"==t?d.set(e,l.has(e)?c[l.get(e)]:i.get(e)):d.set(e,l.has(e)?u[l.get(e)]:i.get(e)),a+=d.get(e)}),a/=r.length,e.forEach(function(e){n.has(e)||d.set(e,a)})}else{var o=0;e.forEach(function(e){"horizontal"==t?o+=l.has(e)?c[l.get(e)]:i.get(e):o+=l.has(e)?u[l.get(e)]:i.get(e)}),o/=e.length,e.forEach(function(e){d.set(e,o)})}});0!=f.length;)!function(){var r=f.shift();e.get(r).forEach(function(e){if(d.get(e.id)<d.get(r)+e.gap)if(n&&n.has(e.id)){var a=void 0;if(a="horizontal"==t?l.has(e.id)?c[l.get(e.id)]:i.get(e.id):l.has(e.id)?u[l.get(e.id)]:i.get(e.id),d.set(e.id,a),a<d.get(r)+e.gap){var o=d.get(r)+e.gap-a;h.get(r).forEach(function(e){d.set(e,d.get(e)-o)})}}else d.set(e.id,d.get(r)+e.gap);s.set(e.id,s.get(e.id)-1),0==s.get(e.id)&&f.push(e.id),n&&h.set(e.id,function(e,t){var n=new Set(e),r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var l=o.value;n.add(l)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}(h.get(r),h.get(e.id)))})}();if(n){var p=new Set;e.forEach(function(e,t){0==e.length&&p.add(t)});var g=[];h.forEach(function(e,t){if(p.has(t)){var i=!1,a=!0,o=!1,s=void 0;try{for(var l,c=e[Symbol.iterator]();!(a=(l=c.next()).done);a=!0){var u=l.value;n.has(u)&&(i=!0)}}catch(e){o=!0,s=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw s}}if(!i){var d=!1,h=void 0;g.forEach(function(t,n){t.has([].concat(r(e))[0])&&(d=!0,h=n)}),d?e.forEach(function(e){g[h].add(e)}):g.push(new Set(e))}}}),g.forEach(function(e,n){var r=1/0,a=1/0,o=-1/0,s=-1/0,h=!0,f=!1,p=void 0;try{for(var g,v=e[Symbol.iterator]();!(h=(g=v.next()).done);h=!0){var x=g.value,y=void 0;y="horizontal"==t?l.has(x)?c[l.get(x)]:i.get(x):l.has(x)?u[l.get(x)]:i.get(x);var b=d.get(x);y<r&&(r=y),y>o&&(o=y),b<a&&(a=b),b>s&&(s=b)}}catch(e){f=!0,p=e}finally{try{!h&&v.return&&v.return()}finally{if(f)throw p}}var w=(r+o)/2-(a+s)/2,N=!0,j=!1,k=void 0;try{for(var C,E=e[Symbol.iterator]();!(N=(C=E.next()).done);N=!0){var T=C.value;d.set(T,d.get(T)+w)}}catch(e){j=!0,k=e}finally{try{!N&&E.return&&E.return()}finally{if(j)throw k}}})}return d},x=function(e){var t=0,n=0,r=0,i=0;if(e.forEach(function(e){e.left?c[l.get(e.left)]-c[l.get(e.right)]>=0?t++:n++:u[l.get(e.top)]-u[l.get(e.bottom)]>=0?r++:i++}),t>n&&r>i)for(var a=0;a<l.size;a++)c[a]=-1*c[a],u[a]=-1*u[a];else if(t>n)for(var o=0;o<l.size;o++)c[o]=-1*c[o];else if(r>i)for(var s=0;s<l.size;s++)u[s]=-1*u[s]},y=function(e){var t=[],n=new a,r=new Set,i=0;return e.forEach(function(a,o){if(!r.has(o)){t[i]=[];var s=o;for(n.push(s),r.add(s),t[i].push(s);0!=n.length;)s=n.shift(),e.get(s).forEach(function(e){r.has(e.id)||(n.push(e.id),r.add(e.id),t[i].push(e.id))});i++}}),t},b=function(e){var t=new Map;return e.forEach(function(e,n){t.set(n,[])}),e.forEach(function(e,n){e.forEach(function(e){t.get(n).push(e),t.get(e.id).push({id:n,gap:e.gap,direction:e.direction})})}),t},w=function(e){var t=new Map;return e.forEach(function(e,n){t.set(n,[])}),e.forEach(function(e,n){e.forEach(function(e){t.get(e.id).push({id:n,gap:e.gap,direction:e.direction})})}),t},N=[],j=[],k=!1,C=!1,E=new Set,T=new Map,S=new Map,_=[];if(t.fixedNodeConstraint&&t.fixedNodeConstraint.forEach(function(e){E.add(e.nodeId)}),t.relativePlacementConstraint&&(t.relativePlacementConstraint.forEach(function(e){e.left?(T.has(e.left)?T.get(e.left).push({id:e.right,gap:e.gap,direction:"horizontal"}):T.set(e.left,[{id:e.right,gap:e.gap,direction:"horizontal"}]),T.has(e.right)||T.set(e.right,[])):(T.has(e.top)?T.get(e.top).push({id:e.bottom,gap:e.gap,direction:"vertical"}):T.set(e.top,[{id:e.bottom,gap:e.gap,direction:"vertical"}]),T.has(e.bottom)||T.set(e.bottom,[]))}),_=y(S=b(T))),i.TRANSFORM_ON_CONSTRAINT_HANDLING){if(t.fixedNodeConstraint&&t.fixedNodeConstraint.length>1)t.fixedNodeConstraint.forEach(function(e,t){N[t]=[e.position.x,e.position.y],j[t]=[c[l.get(e.nodeId)],u[l.get(e.nodeId)]]}),k=!0;else if(t.alignmentConstraint)!function(){var e=0;if(t.alignmentConstraint.vertical){for(var n=t.alignmentConstraint.vertical,i=0;i<n.length;i++)!function(t){var i=new Set;n[t].forEach(function(e){i.add(e)});var a=new Set([].concat(r(i)).filter(function(e){return E.has(e)})),o=void 0;o=a.size>0?c[l.get(a.values().next().value)]:g(i).x,n[t].forEach(function(t){N[e]=[o,u[l.get(t)]],j[e]=[c[l.get(t)],u[l.get(t)]],e++})}(i);k=!0}if(t.alignmentConstraint.horizontal){for(var a=t.alignmentConstraint.horizontal,o=0;o<a.length;o++)!function(t){var n=new Set;a[t].forEach(function(e){n.add(e)});var i=new Set([].concat(r(n)).filter(function(e){return E.has(e)})),o=void 0;o=i.size>0?c[l.get(i.values().next().value)]:g(n).y,a[t].forEach(function(t){N[e]=[c[l.get(t)],o],j[e]=[c[l.get(t)],u[l.get(t)]],e++})}(o);k=!0}t.relativePlacementConstraint&&(C=!0)}();else if(t.relativePlacementConstraint){for(var A=0,D=0,M=0;M<_.length;M++)_[M].length>A&&(A=_[M].length,D=M);if(A<S.size/2)x(t.relativePlacementConstraint),k=!1,C=!1;else{var P=new Map,R=new Map,L=[];_[D].forEach(function(e){T.get(e).forEach(function(t){"horizontal"==t.direction?(P.has(e)?P.get(e).push(t):P.set(e,[t]),P.has(t.id)||P.set(t.id,[]),L.push({left:e,right:t.id})):(R.has(e)?R.get(e).push(t):R.set(e,[t]),R.has(t.id)||R.set(t.id,[]),L.push({top:e,bottom:t.id}))})}),x(L),C=!1;var I=v(P,"horizontal"),O=v(R,"vertical");_[D].forEach(function(e,t){j[t]=[c[l.get(e)],u[l.get(e)]],N[t]=[],I.has(e)?N[t][0]=I.get(e):N[t][0]=c[l.get(e)],O.has(e)?N[t][1]=O.get(e):N[t][1]=u[l.get(e)]}),k=!0}}if(k){for(var B=void 0,F=o.transpose(N),z=o.transpose(j),V=0;V<F.length;V++)F[V]=o.multGamma(F[V]),z[V]=o.multGamma(z[V]);var H=o.multMat(F,o.transpose(z)),U=s.svd(H);B=o.multMat(U.V,o.transpose(U.U));for(var G=0;G<l.size;G++){var Y=[c[G],u[G]],X=[B[0][0],B[1][0]],W=[B[0][1],B[1][1]];c[G]=o.dotProduct(Y,X),u[G]=o.dotProduct(Y,W)}C&&x(t.relativePlacementConstraint)}}if(i.ENFORCE_CONSTRAINTS){if(t.fixedNodeConstraint&&t.fixedNodeConstraint.length>0){var q={x:0,y:0};t.fixedNodeConstraint.forEach(function(e,t){var n,r={x:c[l.get(e.nodeId)],y:u[l.get(e.nodeId)]},i=(n=e.position,{x:n.x-r.x,y:n.y-r.y});q.x+=i.x,q.y+=i.y}),q.x/=t.fixedNodeConstraint.length,q.y/=t.fixedNodeConstraint.length,c.forEach(function(e,t){c[t]+=q.x}),u.forEach(function(e,t){u[t]+=q.y}),t.fixedNodeConstraint.forEach(function(e){c[l.get(e.nodeId)]=e.position.x,u[l.get(e.nodeId)]=e.position.y})}if(t.alignmentConstraint){if(t.alignmentConstraint.vertical)for(var $=t.alignmentConstraint.vertical,K=0;K<$.length;K++)!function(e){var t=new Set;$[e].forEach(function(e){t.add(e)});var n=new Set([].concat(r(t)).filter(function(e){return E.has(e)})),i=void 0;i=n.size>0?c[l.get(n.values().next().value)]:g(t).x,t.forEach(function(e){E.has(e)||(c[l.get(e)]=i)})}(K);if(t.alignmentConstraint.horizontal)for(var Z=t.alignmentConstraint.horizontal,Q=0;Q<Z.length;Q++)!function(e){var t=new Set;Z[e].forEach(function(e){t.add(e)});var n=new Set([].concat(r(t)).filter(function(e){return E.has(e)})),i=void 0;i=n.size>0?u[l.get(n.values().next().value)]:g(t).y,t.forEach(function(e){E.has(e)||(u[l.get(e)]=i)})}(Q)}t.relativePlacementConstraint&&function(){var e=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,d=new Set;if(E.forEach(function(e){s.add(e),d.add(e)}),t.alignmentConstraint){if(t.alignmentConstraint.vertical)for(var h=t.alignmentConstraint.vertical,f=function(t){r.set("dummy"+t,[]),h[t].forEach(function(n){e.set(n,"dummy"+t),r.get("dummy"+t).push(n),E.has(n)&&s.add("dummy"+t)}),a.set("dummy"+t,c[l.get(h[t][0])])},p=0;p<h.length;p++)f(p);if(t.alignmentConstraint.horizontal)for(var g=t.alignmentConstraint.horizontal,x=function(e){i.set("dummy"+e,[]),g[e].forEach(function(t){n.set(t,"dummy"+e),i.get("dummy"+e).push(t),E.has(t)&&d.add("dummy"+e)}),o.set("dummy"+e,u[l.get(g[e][0])])},N=0;N<g.length;N++)x(N)}var j=new Map,k=new Map,C=function(t){T.get(t).forEach(function(r){var i=void 0,a=void 0;"horizontal"==r.direction?(i=e.get(t)?e.get(t):t,a=e.get(r.id)?{id:e.get(r.id),gap:r.gap,direction:r.direction}:r,j.has(i)?j.get(i).push(a):j.set(i,[a]),j.has(a.id)||j.set(a.id,[])):(i=n.get(t)?n.get(t):t,a=n.get(r.id)?{id:n.get(r.id),gap:r.gap,direction:r.direction}:r,k.has(i)?k.get(i).push(a):k.set(i,[a]),k.has(a.id)||k.set(a.id,[]))})},S=!0,_=!1,A=void 0;try{for(var D,M=T.keys()[Symbol.iterator]();!(S=(D=M.next()).done);S=!0){var P=D.value;C(P)}}catch(e){_=!0,A=e}finally{try{!S&&M.return&&M.return()}finally{if(_)throw A}}var R=b(j),L=b(k),I=y(R),O=y(L),B=w(j),F=w(k),z=[],V=[];I.forEach(function(e,t){z[t]=[],e.forEach(function(e){0==B.get(e).length&&z[t].push(e)})}),O.forEach(function(e,t){V[t]=[],e.forEach(function(e){0==F.get(e).length&&V[t].push(e)})});var H=v(j,"horizontal",s,a,z),U=v(k,"vertical",d,o,V),G=function(e){r.get(e)?r.get(e).forEach(function(t){c[l.get(t)]=H.get(e)}):c[l.get(e)]=H.get(e)},Y=!0,X=!1,W=void 0;try{for(var q,$=H.keys()[Symbol.iterator]();!(Y=(q=$.next()).done);Y=!0){var K=q.value;G(K)}}catch(e){X=!0,W=e}finally{try{!Y&&$.return&&$.return()}finally{if(X)throw W}}var Z=function(e){i.get(e)?i.get(e).forEach(function(t){u[l.get(t)]=U.get(e)}):u[l.get(e)]=U.get(e)},Q=!0,J=!1,ee=void 0;try{for(var et,en=U.keys()[Symbol.iterator]();!(Q=(et=en.next()).done);Q=!0){var K=et.value;Z(K)}}catch(e){J=!0,ee=e}finally{try{!Q&&en.return&&en.return()}finally{if(J)throw ee}}}()}for(var J=0;J<d.length;J++){var ee=d[J];null==ee.getChild()&&ee.setCenter(c[l.get(ee.id)],u[l.get(ee.id)])}},e.exports=l},551:e=>{e.exports=r}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}(45)})()},45108,(e,t,n)=>{var r;e.e,r=e.r(97659),t.exports=(()=>{"use strict";var e={658:e=>{e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach(function(t){Object.keys(t).forEach(function(n){return e[n]=t[n]})}),e}},548:(e,t,n)=>{var r=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}(e,t);throw TypeError("Invalid attempt to destructure non-iterable instance")},i=n(140).layoutBase.LinkedList,a={};a.getTopMostNodes=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].id()]=!0;return e.filter(function(e,n){"number"==typeof e&&(e=n);for(var r=e.parent()[0];null!=r;){if(t[r.id()])return!1;r=r.parent()[0]}return!0})},a.connectComponents=function(e,t,n,r){var a=new i,o=new Set,s=[],l=void 0,c=void 0,u=void 0,d=!1,h=1,f=[],p=[];do!function(){var r=e.collection();p.push(r);var i=n[0],g=e.collection();for(g.merge(i).merge(i.descendants().intersection(t)),s.push(i),g.forEach(function(e){a.push(e),o.add(e),r.merge(e)});0!=a.length;)!function(){i=a.shift();var c=e.collection();i.neighborhood().nodes().forEach(function(e){t.intersection(i.edgesWith(e)).length>0&&c.merge(e)});for(var u=0;u<c.length;u++){var d=c[u];null==(l=n.intersection(d.union(d.ancestors())))||o.has(l[0])||l.union(l.descendants()).forEach(function(e){a.push(e),o.add(e),r.merge(e),n.has(e)&&s.push(e)})}}();if(r.forEach(function(e){t.intersection(e.connectedEdges()).forEach(function(e){r.has(e.source())&&r.has(e.target())&&r.merge(e)})}),s.length==n.length&&(d=!0),!d||d&&h>1){u=(c=s[0]).connectedEdges().length,s.forEach(function(e){e.connectedEdges().length<u&&(u=e.connectedEdges().length,c=e)}),f.push(c.id());var v=e.collection();v.merge(s[0]),s.forEach(function(e){v.merge(e)}),s=[],n=n.difference(v),h++}}();while(!d)return r&&f.length>0&&r.set("dummy"+(r.size+1),f),p},a.relocateComponent=function(e,t,n){if(!n.fixedNodeConstraint){var i=1/0,a=-1/0,o=1/0,s=-1/0;if("draft"==n.quality){var l=!0,c=!1,u=void 0;try{for(var d,h=t.nodeIndexes[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var f=d.value,p=r(f,2),g=p[0],v=p[1],x=n.cy.getElementById(g);if(x){var y=x.boundingBox(),b=t.xCoords[v]-y.w/2,w=t.xCoords[v]+y.w/2,N=t.yCoords[v]-y.h/2,j=t.yCoords[v]+y.h/2;b<i&&(i=b),w>a&&(a=w),N<o&&(o=N),j>s&&(s=j)}}}catch(e){c=!0,u=e}finally{try{!l&&h.return&&h.return()}finally{if(c)throw u}}var k=e.x-(a+i)/2,C=e.y-(s+o)/2;t.xCoords=t.xCoords.map(function(e){return e+k}),t.yCoords=t.yCoords.map(function(e){return e+C})}else{Object.keys(t).forEach(function(e){var n=t[e],r=n.getRect().x,l=n.getRect().x+n.getRect().width,c=n.getRect().y,u=n.getRect().y+n.getRect().height;r<i&&(i=r),l>a&&(a=l),c<o&&(o=c),u>s&&(s=u)});var E=e.x-(a+i)/2,T=e.y-(s+o)/2;Object.keys(t).forEach(function(e){var n=t[e];n.setCenter(n.getCenterX()+E,n.getCenterY()+T)})}}},a.calcBoundingBox=function(e,t,n,r){for(var i=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,l=void 0,c=void 0,u=void 0,d=void 0,h=e.descendants().not(":parent"),f=h.length,p=0;p<f;p++){var g=h[p];l=t[r.get(g.id())]-g.width()/2,c=t[r.get(g.id())]+g.width()/2,u=n[r.get(g.id())]-g.height()/2,d=n[r.get(g.id())]+g.height()/2,i>l&&(i=l),a<c&&(a=c),o>u&&(o=u),s<d&&(s=d)}var v={};return v.topLeftX=i,v.topLeftY=o,v.width=a-i,v.height=s-o,v},a.calcParentsWithoutChildren=function(e,t){var n=e.collection();return t.nodes(":parent").forEach(function(e){var t=!1;e.children().forEach(function(e){"none"!=e.css("display")&&(t=!0)}),t||n.merge(e)}),n},e.exports=a},816:(e,t,n)=>{var r=n(548),i=n(140).CoSELayout,a=n(140).CoSENode,o=n(140).layoutBase.PointD,s=n(140).layoutBase.DimensionD,l=n(140).layoutBase.LayoutConstants,c=n(140).layoutBase.FDLayoutConstants,u=n(140).CoSEConstants;e.exports={coseLayout:function(e,t){var n=e.cy,d=e.eles,h=d.nodes(),f=d.edges(),p=void 0,g=void 0,v=void 0,x={};e.randomize&&(p=t.nodeIndexes,g=t.xCoords,v=t.yCoords);var y=function(e){return"function"==typeof e},b=function(e,t){return y(e)?e(t):e},w=r.calcParentsWithoutChildren(n,d);null!=e.nestingFactor&&(u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=c.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=e.nestingFactor),null!=e.gravity&&(u.DEFAULT_GRAVITY_STRENGTH=c.DEFAULT_GRAVITY_STRENGTH=e.gravity),null!=e.numIter&&(u.MAX_ITERATIONS=c.MAX_ITERATIONS=e.numIter),null!=e.gravityRange&&(u.DEFAULT_GRAVITY_RANGE_FACTOR=c.DEFAULT_GRAVITY_RANGE_FACTOR=e.gravityRange),null!=e.gravityCompound&&(u.DEFAULT_COMPOUND_GRAVITY_STRENGTH=c.DEFAULT_COMPOUND_GRAVITY_STRENGTH=e.gravityCompound),null!=e.gravityRangeCompound&&(u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=c.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=e.gravityRangeCompound),null!=e.initialEnergyOnIncremental&&(u.DEFAULT_COOLING_FACTOR_INCREMENTAL=c.DEFAULT_COOLING_FACTOR_INCREMENTAL=e.initialEnergyOnIncremental),null!=e.tilingCompareBy&&(u.TILING_COMPARE_BY=e.tilingCompareBy),"proof"==e.quality?l.QUALITY=2:l.QUALITY=0,u.NODE_DIMENSIONS_INCLUDE_LABELS=c.NODE_DIMENSIONS_INCLUDE_LABELS=l.NODE_DIMENSIONS_INCLUDE_LABELS=e.nodeDimensionsIncludeLabels,u.DEFAULT_INCREMENTAL=c.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=!e.randomize,u.ANIMATE=c.ANIMATE=l.ANIMATE=e.animate,u.TILE=e.tile,u.TILING_PADDING_VERTICAL="function"==typeof e.tilingPaddingVertical?e.tilingPaddingVertical.call():e.tilingPaddingVertical,u.TILING_PADDING_HORIZONTAL="function"==typeof e.tilingPaddingHorizontal?e.tilingPaddingHorizontal.call():e.tilingPaddingHorizontal,u.DEFAULT_INCREMENTAL=c.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=!0,u.PURE_INCREMENTAL=!e.randomize,l.DEFAULT_UNIFORM_LEAF_NODE_SIZES=e.uniformNodeDimensions,"transformed"==e.step&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,u.ENFORCE_CONSTRAINTS=!1,u.APPLY_LAYOUT=!1),"enforced"==e.step&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,u.ENFORCE_CONSTRAINTS=!0,u.APPLY_LAYOUT=!1),"cose"==e.step&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,u.ENFORCE_CONSTRAINTS=!1,u.APPLY_LAYOUT=!0),"all"==e.step&&(e.randomize?u.TRANSFORM_ON_CONSTRAINT_HANDLING=!0:u.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,u.ENFORCE_CONSTRAINTS=!0,u.APPLY_LAYOUT=!0),e.fixedNodeConstraint||e.alignmentConstraint||e.relativePlacementConstraint?u.TREE_REDUCTION_ON_INCREMENTAL=!1:u.TREE_REDUCTION_ON_INCREMENTAL=!0;var N=new i,j=N.newGraphManager();return!function e(t,n,i,l){for(var c=n.length,u=0;u<c;u++){var d=n[u],h=null;0==d.intersection(w).length&&(h=d.children());var f=void 0,y=d.layoutDimensions({nodeDimensionsIncludeLabels:l.nodeDimensionsIncludeLabels});if(null!=d.outerWidth()&&null!=d.outerHeight())if(l.randomize)if(d.isParent()){var N=r.calcBoundingBox(d,g,v,p);f=0==d.intersection(w).length?t.add(new a(i.graphManager,new o(N.topLeftX,N.topLeftY),new s(N.width,N.height))):t.add(new a(i.graphManager,new o(N.topLeftX,N.topLeftY),new s(parseFloat(y.w),parseFloat(y.h))))}else f=t.add(new a(i.graphManager,new o(g[p.get(d.id())]-y.w/2,v[p.get(d.id())]-y.h/2),new s(parseFloat(y.w),parseFloat(y.h))));else f=t.add(new a(i.graphManager,new o(d.position("x")-y.w/2,d.position("y")-y.h/2),new s(parseFloat(y.w),parseFloat(y.h))));else f=t.add(new a(this.graphManager));(f.id=d.data("id"),f.nodeRepulsion=b(l.nodeRepulsion,d),f.paddingLeft=parseInt(d.css("padding")),f.paddingTop=parseInt(d.css("padding")),f.paddingRight=parseInt(d.css("padding")),f.paddingBottom=parseInt(d.css("padding")),l.nodeDimensionsIncludeLabels&&(f.labelWidth=d.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).w,f.labelHeight=d.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).h,f.labelPosVertical=d.css("text-valign"),f.labelPosHorizontal=d.css("text-halign")),x[d.data("id")]=f,isNaN(f.rect.x)&&(f.rect.x=0),isNaN(f.rect.y)&&(f.rect.y=0),null!=h&&h.length>0)&&e(i.getGraphManager().add(i.newGraph(),f),h,i,l)}}(j.addRoot(),r.getTopMostNodes(h),N,e),!function(t,n,r){for(var i=0,a=0,o=0;o<r.length;o++){var s=r[o],l=x[s.data("source")],d=x[s.data("target")];if(l&&d&&l!==d&&0==l.getEdgesBetween(d).length){var h=n.add(t.newEdge(),l,d);h.id=s.id(),h.idealLength=b(e.idealEdgeLength,s),h.edgeElasticity=b(e.edgeElasticity,s),i+=h.idealLength,a++}}null!=e.idealEdgeLength&&(a>0?u.DEFAULT_EDGE_LENGTH=c.DEFAULT_EDGE_LENGTH=i/a:y(e.idealEdgeLength)?u.DEFAULT_EDGE_LENGTH=c.DEFAULT_EDGE_LENGTH=50:u.DEFAULT_EDGE_LENGTH=c.DEFAULT_EDGE_LENGTH=e.idealEdgeLength,u.MIN_REPULSION_DIST=c.MIN_REPULSION_DIST=c.DEFAULT_EDGE_LENGTH/10,u.DEFAULT_RADIAL_SEPARATION=c.DEFAULT_EDGE_LENGTH)}(N,j,f),e.fixedNodeConstraint&&(N.constraints.fixedNodeConstraint=e.fixedNodeConstraint),e.alignmentConstraint&&(N.constraints.alignmentConstraint=e.alignmentConstraint),e.relativePlacementConstraint&&(N.constraints.relativePlacementConstraint=e.relativePlacementConstraint),N.runLayout(),x}}},212:(e,t,n)=>{var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(658),a=n(548),o=n(657).spectralLayout,s=n(816).coseLayout,l=Object.freeze({quality:"default",randomize:!0,animate:!0,animationDuration:1e3,animationEasing:void 0,fit:!0,padding:30,nodeDimensionsIncludeLabels:!1,uniformNodeDimensions:!1,packComponents:!0,step:"all",samplingType:!0,sampleSize:25,nodeSeparation:75,piTol:1e-7,nodeRepulsion:function(e){return 4500},idealEdgeLength:function(e){return 50},edgeElasticity:function(e){return .45},nestingFactor:.1,gravity:.25,numIter:2500,tile:!0,tilingCompareBy:void 0,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:.3,fixedNodeConstraint:void 0,alignmentConstraint:void 0,relativePlacementConstraint:void 0,ready:function(){},stop:function(){}});e.exports=function(){function e(t){if(!(this instanceof e))throw TypeError("Cannot call a class as a function");this.options=i({},l,t)}return r(e,[{key:"run",value:function(){var e=this.options,t=e.cy,n=e.eles,r=[],i=[],l=void 0,c=[];e.fixedNodeConstraint&&(!Array.isArray(e.fixedNodeConstraint)||0==e.fixedNodeConstraint.length)&&(e.fixedNodeConstraint=void 0),e.alignmentConstraint&&(e.alignmentConstraint.vertical&&(!Array.isArray(e.alignmentConstraint.vertical)||0==e.alignmentConstraint.vertical.length)&&(e.alignmentConstraint.vertical=void 0),e.alignmentConstraint.horizontal&&(!Array.isArray(e.alignmentConstraint.horizontal)||0==e.alignmentConstraint.horizontal.length)&&(e.alignmentConstraint.horizontal=void 0)),e.relativePlacementConstraint&&(!Array.isArray(e.relativePlacementConstraint)||0==e.relativePlacementConstraint.length)&&(e.relativePlacementConstraint=void 0),(e.fixedNodeConstraint||e.alignmentConstraint||e.relativePlacementConstraint)&&(e.tile=!1,e.packComponents=!1);var u=void 0,d=!1;if(t.layoutUtilities&&e.packComponents&&((u=t.layoutUtilities("get"))||(u=t.layoutUtilities()),d=!0),n.nodes().length>0)if(d){var h=a.getTopMostNodes(e.eles.nodes());if((l=a.connectComponents(t,e.eles,h)).forEach(function(e){var t=e.boundingBox();c.push({x:t.x1+t.w/2,y:t.y1+t.h/2})}),e.randomize&&l.forEach(function(t){e.eles=t,r.push(o(e))}),"default"==e.quality||"proof"==e.quality){var f=t.collection();if(e.tile){var p=new Map,g=0,v={nodeIndexes:p,xCoords:[],yCoords:[]},x=[];if(l.forEach(function(e,t){0==e.edges().length&&(e.nodes().forEach(function(t,n){f.merge(e.nodes()[n]),t.isParent()||(v.nodeIndexes.set(e.nodes()[n].id(),g++),v.xCoords.push(e.nodes()[0].position().x),v.yCoords.push(e.nodes()[0].position().y))}),x.push(t))}),f.length>1){var y=f.boundingBox();c.push({x:y.x1+y.w/2,y:y.y1+y.h/2}),l.push(f),r.push(v);for(var b=x.length-1;b>=0;b--)l.splice(x[b],1),r.splice(x[b],1),c.splice(x[b],1)}}l.forEach(function(t,n){e.eles=t,i.push(s(e,r[n])),a.relocateComponent(c[n],i[n],e)})}else l.forEach(function(t,n){a.relocateComponent(c[n],r[n],e)});var w=new Set;if(l.length>1){var N=[],j=n.filter(function(e){return"none"==e.css("display")});l.forEach(function(t,n){var o=void 0;if("draft"==e.quality&&(o=r[n].nodeIndexes),t.nodes().not(j).length>0){var s={};s.edges=[],s.nodes=[];var l=void 0;t.nodes().not(j).forEach(function(t){if("draft"==e.quality)if(t.isParent()){var c=a.calcBoundingBox(t,r[n].xCoords,r[n].yCoords,o);s.nodes.push({x:c.topLeftX,y:c.topLeftY,width:c.width,height:c.height})}else l=o.get(t.id()),s.nodes.push({x:r[n].xCoords[l]-t.boundingbox().w/2,y:r[n].yCoords[l]-t.boundingbox().h/2,width:t.boundingbox().w,height:t.boundingbox().h});else i[n][t.id()]&&s.nodes.push({x:i[n][t.id()].getLeft(),y:i[n][t.id()].getTop(),width:i[n][t.id()].getWidth(),height:i[n][t.id()].getHeight()})}),t.edges().forEach(function(t){var l=t.source(),c=t.target();if("none"!=l.css("display")&&"none"!=c.css("display"))if("draft"==e.quality){var u=o.get(l.id()),d=o.get(c.id()),h=[],f=[];if(l.isParent()){var p=a.calcBoundingBox(l,r[n].xCoords,r[n].yCoords,o);h.push(p.topLeftX+p.width/2),h.push(p.topLeftY+p.height/2)}else h.push(r[n].xCoords[u]),h.push(r[n].yCoords[u]);if(c.isParent()){var g=a.calcBoundingBox(c,r[n].xCoords,r[n].yCoords,o);f.push(g.topLeftX+g.width/2),f.push(g.topLeftY+g.height/2)}else f.push(r[n].xCoords[d]),f.push(r[n].yCoords[d]);s.edges.push({startX:h[0],startY:h[1],endX:f[0],endY:f[1]})}else i[n][l.id()]&&i[n][c.id()]&&s.edges.push({startX:i[n][l.id()].getCenterX(),startY:i[n][l.id()].getCenterY(),endX:i[n][c.id()].getCenterX(),endY:i[n][c.id()].getCenterY()})}),s.nodes.length>0&&(N.push(s),w.add(n))}});var k=u.packComponents(N,e.randomize).shifts;if("draft"==e.quality)r.forEach(function(e,t){var n=e.xCoords.map(function(e){return e+k[t].dx}),r=e.yCoords.map(function(e){return e+k[t].dy});e.xCoords=n,e.yCoords=r});else{var C=0;w.forEach(function(e){Object.keys(i[e]).forEach(function(t){var n=i[e][t];n.setCenter(n.getCenterX()+k[C].dx,n.getCenterY()+k[C].dy)}),C++})}}}else{var E=e.eles.boundingBox();if(c.push({x:E.x1+E.w/2,y:E.y1+E.h/2}),e.randomize){var T=o(e);r.push(T)}"default"==e.quality||"proof"==e.quality?(i.push(s(e,r[0])),a.relocateComponent(c[0],i[0],e)):a.relocateComponent(c[0],r[0],e)}var S=function(t,n){if("default"==e.quality||"proof"==e.quality){"number"==typeof t&&(t=n);var a=void 0,o=void 0,s=t.data("id");return i.forEach(function(e){s in e&&(a={x:e[s].getRect().getCenterX(),y:e[s].getRect().getCenterY()},o=e[s])}),e.nodeDimensionsIncludeLabels&&(o.labelWidth&&("left"==o.labelPosHorizontal?a.x+=o.labelWidth/2:"right"==o.labelPosHorizontal&&(a.x-=o.labelWidth/2)),o.labelHeight&&("top"==o.labelPosVertical?a.y+=o.labelHeight/2:"bottom"==o.labelPosVertical&&(a.y-=o.labelHeight/2))),void 0==a&&(a={x:t.position("x"),y:t.position("y")}),{x:a.x,y:a.y}}var l=void 0;return r.forEach(function(e){var n=e.nodeIndexes.get(t.id());void 0!=n&&(l={x:e.xCoords[n],y:e.yCoords[n]})}),void 0==l&&(l={x:t.position("x"),y:t.position("y")}),{x:l.x,y:l.y}};if("default"==e.quality||"proof"==e.quality||e.randomize){var _=a.calcParentsWithoutChildren(t,n),A=n.filter(function(e){return"none"==e.css("display")});e.eles=n.not(A),n.nodes().not(":parent").not(A).layoutPositions(this,e,S),_.length>0&&_.forEach(function(e){e.position(S(e))})}else console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'.")}}]),e}()},657:(e,t,n)=>{var r=n(548),i=n(140).layoutBase.Matrix,a=n(140).layoutBase.SVD;e.exports={spectralLayout:function(e){var t=e.cy,n=e.eles,o=n.nodes(),s=n.nodes(":parent"),l=new Map,c=new Map,u=new Map,d=[],h=[],f=[],p=[],g=[],v=[],x=[],y=[],b=void 0,w=e.piTol,N=e.samplingType,j=e.nodeSeparation,k=void 0,C=function(){for(var e=0,t=0,n=!1;t<k;){e=Math.floor(Math.random()*b),n=!1;for(var r=0;r<t;r++)if(p[r]==e){n=!0;break}!n&&(p[t]=e,t++)}},E=function(e,t,n){for(var r=[],i=0,a=0,o=0,s=void 0,l=[],u=0,h=1,f=0;f<b;f++)l[f]=1e8;for(r[a]=e,l[e]=0;a>=i;){for(var p=d[o=r[i++]],x=0;x<p.length;x++)1e8==l[s=c.get(p[x])]&&(l[s]=l[o]+1,r[++a]=s);v[o][t]=l[o]*j}if(n){for(var y=0;y<b;y++)v[y][t]<g[y]&&(g[y]=v[y][t]);for(var w=0;w<b;w++)g[w]>u&&(u=g[w],h=w)}return h};r.connectComponents(t,n,r.getTopMostNodes(o),l),s.forEach(function(e){r.connectComponents(t,n,r.getTopMostNodes(e.descendants().intersection(n)),l)});for(var T=0,S=0;S<o.length;S++)o[S].isParent()||c.set(o[S].id(),T++);var _=!0,A=!1,D=void 0;try{for(var M,P=l.keys()[Symbol.iterator]();!(_=(M=P.next()).done);_=!0){var R=M.value;c.set(R,T++)}}catch(e){A=!0,D=e}finally{try{!_&&P.return&&P.return()}finally{if(A)throw D}}for(var L=0;L<c.size;L++)d[L]=[];s.forEach(function(e){for(var t=e.children().intersection(n);0==t.nodes(":childless").length;)t=t.nodes()[0].children().intersection(n);var r=0,i=t.nodes(":childless")[0].connectedEdges().length;t.nodes(":childless").forEach(function(e,t){e.connectedEdges().length<i&&(i=e.connectedEdges().length,r=t)}),u.set(e.id(),t.nodes(":childless")[r].id())}),o.forEach(function(e){var t=void 0;t=e.isParent()?c.get(u.get(e.id())):c.get(e.id()),e.neighborhood().nodes().forEach(function(r){n.intersection(e.edgesWith(r)).length>0&&(r.isParent()?d[t].push(u.get(r.id())):d[t].push(r.id()))})});var I=function(e){var n=c.get(e),r=void 0;l.get(e).forEach(function(i){r=t.getElementById(i).isParent()?u.get(i):i,d[n].push(r),d[c.get(r)].push(e)})},O=!0,B=!1,F=void 0;try{for(var z,V=l.keys()[Symbol.iterator]();!(O=(z=V.next()).done);O=!0){var H=z.value;I(H)}}catch(e){B=!0,F=e}finally{try{!O&&V.return&&V.return()}finally{if(B)throw F}}b=c.size;if(b>2){k=b<e.sampleSize?b:e.sampleSize;for(var U=0;U<b;U++)v[U]=[];for(var G=0;G<k;G++)y[G]=[];return"draft"==e.quality||"all"==e.step?(!function(e){var t=void 0;if(e){t=Math.floor(Math.random()*b);for(var n=0;n<b;n++)g[n]=1e8;for(var r=0;r<k;r++)p[r]=t,t=E(t,r,e)}else{C();for(var i=0;i<k;i++)E(p[i],i,e,!1)}for(var a=0;a<b;a++)for(var o=0;o<k;o++)v[a][o]*=v[a][o];for(var s=0;s<k;s++)x[s]=[];for(var l=0;l<k;l++)for(var c=0;c<k;c++)x[l][c]=v[p[c]][l]}(N),!function(){for(var e=a.svd(x),t=e.S,n=e.U,r=e.V,o=t[0]*t[0]*t[0],s=[],l=0;l<k;l++){s[l]=[];for(var c=0;c<k;c++)s[l][c]=0,l==c&&(s[l][c]=t[l]/(t[l]*t[l]+o/(t[l]*t[l])))}y=i.multMat(i.multMat(r,s),i.transpose(n))}(),!function(){for(var e=void 0,t=void 0,n=[],r=[],a=[],o=[],s=0;s<b;s++)n[s]=Math.random(),r[s]=Math.random();n=i.normalize(n),r=i.normalize(r);for(var l=0,c=1e-9,u=1e-9,d=void 0;;){l++;for(var p=0;p<b;p++)a[p]=n[p];if(n=i.multGamma(i.multL(i.multGamma(a),v,y)),e=i.dotProduct(a,n),n=i.normalize(n),(d=Math.abs((c=i.dotProduct(a,n))/u))<=1+w&&d>=1)break;u=c}for(var g=0;g<b;g++)a[g]=n[g];for(l=0,u=1e-9;;){l++;for(var x=0;x<b;x++)o[x]=r[x];if(o=i.minusOp(o,i.multCons(a,i.dotProduct(a,o))),r=i.multGamma(i.multL(i.multGamma(o),v,y)),t=i.dotProduct(o,r),r=i.normalize(r),(d=Math.abs((c=i.dotProduct(o,r))/u))<=1+w&&d>=1)break;u=c}for(var N=0;N<b;N++)o[N]=r[N];h=i.multCons(a,Math.sqrt(Math.abs(e))),f=i.multCons(o,Math.sqrt(Math.abs(t)))}()):c.forEach(function(e,n){h.push(t.getElementById(n).position("x")),f.push(t.getElementById(n).position("y"))}),{nodeIndexes:c,xCoords:h,yCoords:f}}var Y=c.keys(),X=t.getElementById(Y.next().value),W=X.position(),q=X.outerWidth();if(h.push(W.x),f.push(W.y),2==b){var $=t.getElementById(Y.next().value).outerWidth();h.push(W.x+q/2+$/2+e.idealEdgeLength),f.push(W.y)}return{nodeIndexes:c,xCoords:h,yCoords:f}}}},579:(e,t,n)=>{var r=n(212),i=function(e){e&&e("layout","fcose",r)};"u">typeof cytoscape&&i(cytoscape),e.exports=i},140:e=>{e.exports=r}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}(579)})()},26568,(e,t,n)=>{"use strict";var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g;function d(e){return e?e.replace(u,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,u=1;function h(e){var t=e.match(i);t&&(n+=t.length);var r=e.lastIndexOf("\n");u=~r?e.length-r:u+e.length}function f(){var e={line:n,column:u};return function(t){return t.position=new p(e),v(a),t}}function p(e){this.start=e,this.end={line:n,column:u},this.source=t.source}function g(r){var i=Error(t.source+":"+n+":"+u+": "+r);if(i.reason=r,i.filename=t.source,i.line=n,i.column=u,i.source=e,t.silent);else throw i}function v(t){var n=t.exec(e);if(n){var r=n[0];return h(r),e=e.slice(r.length),n}}function x(e){var t;for(e=e||[];t=y();)!1!==t&&e.push(t);return e}function y(){var t=f();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return g("End of comment missing");var r=e.slice(2,n-2);return u+=2,h(r),e=e.slice(n),u+=2,t({type:"comment",comment:r})}}p.prototype.content=e,v(a);var b,w=[];for(x(w);b=function(){var e=f(),t=v(o);if(t){if(y(),!v(s))return g("property missing ':'");var n=v(l),i=e({type:"declaration",property:d(t[0].replace(r,"")),value:n?d(n[0].replace(r,"")):""});return v(c),i}}();)!1!==b&&(w.push(b),x(w));return w}},70454,(e,t,n)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){let n=null;if(!e||"string"!=typeof e)return n;let r=(0,i.default)(e),a="function"==typeof t;return r.forEach(e=>{if("declaration"!==e.type)return;let{property:r,value:i}=e;a?t(r,i,e):i&&((n=n||{})[r]=i)}),n};let i=r(e.r(26568))},65185,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var r=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,a=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,l=function(e,t){return t.toUpperCase()},c=function(e,t){return"".concat(t,"-")};n.camelCase=function(e,t){var n;return(void 0===t&&(t={}),!(n=e)||a.test(n)||r.test(n))?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(s,c):e.replace(o,c)).replace(i,l))}},15511,(e,t,n)=>{"use strict";var r=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),i=e.r(65185);function a(e,t){var n={};return e&&"string"==typeof e&&(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a},4100,(e,t,n)=>{"use strict";var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===i.call(e)},l=function(e){if(!e||"[object Object]"!==i.call(e))return!1;var t,n=r.call(e,"constructor"),a=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!a)return!1;for(t in e);return void 0===t||r.call(e,t)},c=function(e,t){a&&"__proto__"===t.name?a(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},u=function(e,t){if("__proto__"===t){if(!r.call(e,t))return;else if(o)return o(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,o,d=arguments[0],h=1,f=arguments.length,p=!1;for("boolean"==typeof d&&(p=d,d=arguments[1]||{},h=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});h<f;++h)if(t=arguments[h],null!=t)for(n in t)r=u(d,n),d!==(i=u(t,n))&&(p&&i&&(l(i)||(a=s(i)))?(a?(a=!1,o=r&&s(r)?r:[]):o=r&&l(r)?r:{},c(d,{name:n,newValue:e(p,o,i)})):void 0!==i&&c(d,{name:n,newValue:i}));return d}},37578,e=>{"use strict";let t,n,r,i,a,o,s;var l,c,u,d,h,f,p,g,v,x,y,b,w,N,j,k,C,E,T,S,_,A,D=e.i(9087),M=e.i(41357),P=e.i(45965),R=e.i(46696),L=e.i(99729),I=e.i(59321),O=e.i(78152),B=e.i(55436),F=e.i(75254);let z=(0,F.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),V=(0,F.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var H=e.i(78583);let U=(0,F.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),G=(0,F.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Y=(0,F.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),X=(0,F.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var W=e.i(68373),q=e.i(28830);function $({currentTab:e,onTabChange:t}){let{currentBank:n}=(0,I.useBank)(),{features:r}=(0,O.useFeatures)(),[i,a]=(0,M.useState)(!0);if(!n)return null;let o=[{id:"data",label:"Memories",icon:V},{id:"recall",label:"Recall",icon:B.Search},{id:"reflect",label:"Reflect",icon:z},{id:"documents",label:"Documents",icon:H.FileText},{id:"entities",label:"Entities",icon:U},{id:"profile",label:"Bank Configuration",icon:X}];return(0,D.jsxs)("aside",{className:(0,W.cn)("bg-card border-r border-border flex flex-col transition-all duration-300",i?"w-16":"w-64"),children:[(0,D.jsx)("nav",{className:"flex-1 p-3 pt-4",children:(0,D.jsx)("ul",{className:"space-y-1",children:o.map(r=>{let a=r.icon,o=e===r.id,s=`/banks/${n}?view=${r.id}`;return(0,D.jsx)("li",{children:(0,D.jsxs)(q.default,{href:s,onClick:e=>{0!==e.button||e.ctrlKey||e.metaKey||(e.preventDefault(),t(r.id))},className:(0,W.cn)("w-full flex items-center gap-3 px-4 py-3 rounded-lg text-sm font-medium transition-all",o?"bg-primary-gradient text-white shadow-sm":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",i&&"justify-center px-0"),title:i?r.label:void 0,children:[(0,D.jsx)(a,{className:"w-5 h-5 flex-shrink-0"}),!i&&(0,D.jsx)("span",{children:r.label})]})},r.id)})})}),(0,D.jsx)("div",{className:"p-3 border-t border-border",children:(0,D.jsx)("button",{onClick:()=>a(!i),className:(0,W.cn)("w-full flex items-center gap-3 px-4 py-2 rounded-lg text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",i&&"justify-center px-0"),title:i?"Expand sidebar":"Collapse sidebar",children:i?(0,D.jsx)(Y,{className:"w-5 h-5"}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(G,{className:"w-5 h-5"}),(0,D.jsx)("span",{children:"Collapse"})]})})})]})}var K=e.i(7122),Z=e.i(88029),Q=e.i(80208);let J=(0,F.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),ee=(0,F.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),et=(0,F.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),en=(0,F.default)("chevrons-left",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]),er=(0,F.default)("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]),ei=(0,F.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),ea=(0,F.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),eo=(0,F.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),es=(0,F.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),el=(0,F.default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ec=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{className:"relative w-full overflow-auto",children:(0,D.jsx)("table",{ref:n,className:(0,W.cn)("w-full caption-bottom text-sm",e),...t})}));ec.displayName="Table";let eu=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("thead",{ref:n,className:(0,W.cn)("[&_tr]:border-b",e),...t}));eu.displayName="TableHeader";let ed=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("tbody",{ref:n,className:(0,W.cn)("[&_tr:last-child]:border-0",e),...t}));ed.displayName="TableBody",M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("tfoot",{ref:n,className:(0,W.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t})).displayName="TableFooter";let eh=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("tr",{ref:n,className:(0,W.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));eh.displayName="TableRow";let ef=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("th",{ref:n,className:(0,W.cn)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));ef.displayName="TableHead";let ep=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("td",{ref:n,className:(0,W.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ep.displayName="TableCell",M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("caption",{ref:n,className:(0,W.cn)("mt-4 text-sm text-muted-foreground",e),...t})).displayName="TableCaption";var eg=e.i(62971),em=e.i(91918),ev=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,em.createSlot)(`Primitive.${t}`),r=M.forwardRef((e,r)=>{let{asChild:i,...a}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,D.jsx)(i?n:t,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),ex=M.forwardRef((e,t)=>(0,D.jsx)(ev.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ex.displayName="Label";var ey=e.i(25913);let eb=(0,ey.cva)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ew=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(ex,{ref:n,className:(0,W.cn)(eb(),e),...t}));function eN(e,[t,n]){return Math.min(n,Math.max(t,e))}ew.displayName=ex.displayName;var ej=e.i(81140),ek=e.i(20783),eC=e.i(30030),eE=e.i(69340),eT=e.i(86318),eS=e.i(99682),e_=e.i(35804),eA=e.i(48425),eD=e.i(75830),eM=["PageUp","PageDown"],eP=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],eR={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},eL="Slider",[eI,eO,eB]=(0,eD.createCollection)(eL),[eF,ez]=(0,eC.createContextScope)(eL,[eB]),[eV,eH]=eF(eL),eU=M.forwardRef((e,t)=>{let{name:n,min:r=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:s=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:u,onValueChange:d=()=>{},onValueCommit:h=()=>{},inverted:f=!1,form:p,...g}=e,v=M.useRef(new Set),x=M.useRef(0),y="horizontal"===o,[b=[],w]=(0,eE.useControllableState)({prop:u,defaultProp:c,onChange:e=>{let t=[...v.current];t[x.current]?.focus(),d(e)}}),N=M.useRef(b);function j(e,t,{commit:n}={commit:!1}){let o,s=(String(a).split(".")[1]||"").length,c=eN(Math.round((Math.round((e-r)/a)*a+r)*(o=Math.pow(10,s)))/o,[r,i]);w((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,l*a))return e;{x.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&h(r),t?r:e}})}return(0,D.jsx)(eV,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:i,valueIndexToChangeRef:x,thumbs:v.current,values:b,orientation:o,form:p,children:(0,D.jsx)(eI.Provider,{scope:e.__scopeSlider,children:(0,D.jsx)(eI.Slot,{scope:e.__scopeSlider,children:(0,D.jsx)(y?eX:eW,{"aria-disabled":s,"data-disabled":s?"":void 0,...g,ref:t,onPointerDown:(0,ej.composeEventHandlers)(g.onPointerDown,()=>{s||(N.current=b)}),min:r,max:i,inverted:f,onSlideStart:s?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(b,e);j(e,t)},onSlideMove:s?void 0:function(e){j(e,x.current)},onSlideEnd:s?void 0:function(){let e=N.current[x.current];b[x.current]!==e&&h(b)},onHomeKeyDown:()=>!s&&j(r,0,{commit:!0}),onEndKeyDown:()=>!s&&j(i,b.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!s){let n=eM.includes(e.key)||e.shiftKey&&eP.includes(e.key),r=x.current;j(b[r]+a*(n?10:1)*t,r,{commit:!0})}}})})})})});eU.displayName=eL;var[eG,eY]=eF(eL,{startEdge:"left",endEdge:"right",size:"width",direction:1}),eX=M.forwardRef((e,t)=>{let{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:s,onSlideEnd:l,onStepKeyDown:c,...u}=e,[d,h]=M.useState(null),f=(0,ek.useComposedRefs)(t,e=>h(e)),p=M.useRef(void 0),g=(0,eT.useDirection)(i),v="ltr"===g,x=v&&!a||!v&&a;function y(e){let t=p.current||d.getBoundingClientRect(),i=e3([0,t.width],x?[n,r]:[r,n]);return p.current=t,i(e-t.left)}return(0,D.jsx)(eG,{scope:e.__scopeSlider,startEdge:x?"left":"right",endEdge:x?"right":"left",direction:x?1:-1,size:"width",children:(0,D.jsx)(eq,{dir:g,"data-orientation":"horizontal",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=y(e.clientX);o?.(t)},onSlideMove:e=>{let t=y(e.clientX);s?.(t)},onSlideEnd:()=>{p.current=void 0,l?.()},onStepKeyDown:e=>{let t=eR[x?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),eW=M.forwardRef((e,t)=>{let{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:s,onStepKeyDown:l,...c}=e,u=M.useRef(null),d=(0,ek.useComposedRefs)(t,u),h=M.useRef(void 0),f=!i;function p(e){let t=h.current||u.current.getBoundingClientRect(),i=e3([0,t.height],f?[r,n]:[n,r]);return h.current=t,i(e-t.top)}return(0,D.jsx)(eG,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1,children:(0,D.jsx)(eq,{"data-orientation":"vertical",...c,ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=p(e.clientY);a?.(t)},onSlideMove:e=>{let t=p(e.clientY);o?.(t)},onSlideEnd:()=>{h.current=void 0,s?.()},onStepKeyDown:e=>{let t=eR[f?"from-bottom":"from-top"].includes(e.key);l?.({event:e,direction:t?-1:1})}})})}),eq=M.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:l,...c}=e,u=eH(eL,n);return(0,D.jsx)(eA.Primitive.span,{...c,ref:t,onKeyDown:(0,ej.composeEventHandlers)(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(s(e),e.preventDefault()):eM.concat(eP).includes(e.key)&&(l(e),e.preventDefault())}),onPointerDown:(0,ej.composeEventHandlers)(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(t)?t.focus():r(e)}),onPointerMove:(0,ej.composeEventHandlers)(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:(0,ej.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))})})}),e$="SliderTrack",eK=M.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,i=eH(e$,n);return(0,D.jsx)(eA.Primitive.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});eK.displayName=e$;var eZ="SliderRange",eQ=M.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,i=eH(eZ,n),a=eY(eZ,n),o=M.useRef(null),s=(0,ek.useComposedRefs)(t,o),l=i.values.length,c=i.values.map(e=>e5(e,i.min,i.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return(0,D.jsx)(eA.Primitive.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:s,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:d+"%"}})});eQ.displayName=eZ;var eJ="SliderThumb",e0=M.forwardRef((e,t)=>{let n=eO(e.__scopeSlider),[r,i]=M.useState(null),a=(0,ek.useComposedRefs)(t,e=>i(e)),o=M.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,D.jsx)(e1,{...e,ref:a,index:o})}),e1=M.forwardRef((e,t)=>{var n,r,i,a,o;let s,l,{__scopeSlider:c,index:u,name:d,...h}=e,f=eH(eJ,c),p=eY(eJ,c),[g,v]=M.useState(null),x=(0,ek.useComposedRefs)(t,e=>v(e)),y=!g||f.form||!!g.closest("form"),b=(0,e_.useSize)(g),w=f.values[u],N=void 0===w?0:e5(w,f.min,f.max),j=(n=u,(r=f.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=b?.[p.size],C=k?(i=k,a=N,o=p.direction,l=e3([0,50],[0,s=i/2]),(s-l(a)*o)*o):0;return M.useEffect(()=>{if(g)return f.thumbs.add(g),()=>{f.thumbs.delete(g)}},[g,f.thumbs]),(0,D.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[p.startEdge]:`calc(${N}% + ${C}px)`},children:[(0,D.jsx)(eI.ItemSlot,{scope:e.__scopeSlider,children:(0,D.jsx)(eA.Primitive.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":f.min,"aria-valuenow":w,"aria-valuemax":f.max,"aria-orientation":f.orientation,"data-orientation":f.orientation,"data-disabled":f.disabled?"":void 0,tabIndex:f.disabled?void 0:0,...h,ref:x,style:void 0===w?{display:"none"}:e.style,onFocus:(0,ej.composeEventHandlers)(e.onFocus,()=>{f.valueIndexToChangeRef.current=u})})}),y&&(0,D.jsx)(e2,{name:d??(f.name?f.name+(f.values.length>1?"[]":""):void 0),form:f.form,value:w},u)]})});e0.displayName=eJ;var e2=M.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let i=M.useRef(null),a=(0,ek.useComposedRefs)(i,r),o=(0,eS.usePrevious)(t);return M.useEffect(()=>{let e=i.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,D.jsx)(eA.Primitive.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});function e5(e,t,n){return eN(100/(n-t)*(e-t),[0,100])}function e3(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}e2.displayName="RadioBubbleInput";let e4=M.forwardRef(({className:e,...t},n)=>(0,D.jsxs)(eU,{ref:n,className:(0,W.cn)("relative flex w-full touch-none select-none items-center",e),...t,children:[(0,D.jsx)(eK,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary/50 border border-border",children:(0,D.jsx)(eQ,{className:"absolute h-full bg-primary"})}),(0,D.jsx)(e0,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));e4.displayName=eU.displayName;var e6="Switch",[e9,e7]=(0,eC.createContextScope)(e6),[e8,te]=e9(e6),tt=M.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,f]=M.useState(null),p=(0,ek.useComposedRefs)(t,e=>f(e)),g=M.useRef(!1),v=!h||u||!!h.closest("form"),[x,y]=(0,eE.useControllableState)({prop:i,defaultProp:a??!1,onChange:c,caller:e6});return(0,D.jsxs)(e8,{scope:n,checked:x,disabled:s,children:[(0,D.jsx)(eA.Primitive.button,{type:"button",role:"switch","aria-checked":x,"aria-required":o,"data-state":ta(x),"data-disabled":s?"":void 0,disabled:s,value:l,...d,ref:p,onClick:(0,ej.composeEventHandlers)(e.onClick,e=>{y(e=>!e),v&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),v&&(0,D.jsx)(ti,{control:h,bubbles:!g.current,name:r,value:l,checked:x,required:o,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});tt.displayName=e6;var tn="SwitchThumb",tr=M.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=te(tn,n);return(0,D.jsx)(eA.Primitive.span,{"data-state":ta(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});tr.displayName=tn;var ti=M.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=M.useRef(null),s=(0,ek.useComposedRefs)(o,a),l=(0,eS.usePrevious)(n),c=(0,e_.useSize)(t);return M.useEffect(()=>{let e=o.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(l!==n&&t){let i=new Event("click",{bubbles:r});t.call(e,n),e.dispatchEvent(i)}},[l,n,r]),(0,D.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function ta(e){return e?"checked":"unchecked"}ti.displayName="SwitchBubbleInput";let to=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(tt,{className:(0,W.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:(0,D.jsx)(tr,{className:(0,W.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));to.displayName=tt.displayName;let ts=(0,F.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var tl=e.i(43531),tc=e.i(37727),tu=e.i(17521),tu=tu,td=e.i(76223);function th({type:e,id:t,onClose:n}){let{currentBank:r}=(0,I.useBank)(),[i,a]=(0,M.useState)(null),[o,s]=(0,M.useState)(!1),[l,c]=(0,M.useState)(null);(0,M.useEffect)(()=>{t&&(async()=>{s(!0),c(null);try{if("document"===e){if(!r)return void c("No bank selected");let e=await K.client.getDocument(t,r);a(e)}else{let e=await K.client.getChunk(t);a(e)}}catch(t){console.error(`Error loading ${e}:`,t),c(t.message)}finally{s(!1)}})()},[t,e,r]);let u=null!==t;return(0,D.jsx)(td.Dialog,{open:u,onOpenChange:e=>!e&&n(),children:(0,D.jsxs)(td.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"document"===e?"Document Details":"Chunk Details"}),(0,D.jsx)(td.DialogDescription,{children:"document"===e?"View the original document text and metadata":"View the chunk text and metadata"})]}),(0,D.jsx)("div",{className:"flex-1 overflow-y-auto",children:o?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,D.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Loading ",e,"..."]})]})}):l?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center text-destructive",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"❌"}),(0,D.jsxs)("div",{className:"text-sm",children:["Error: ",l]})]})}):i?(0,D.jsx)("div",{className:"space-y-4",children:"document"===e?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"space-y-3",children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Document ID"}),(0,D.jsx)("div",{className:"text-sm font-mono break-all text-foreground",children:i.id})]}),i.created_at&&(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:new Date(i.created_at).toLocaleString()})]}),(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Memory Units"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:i.memory_unit_count})]})]}),i.original_text&&(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm text-foreground",children:[i.original_text.length.toLocaleString()," characters"]})]})]}),i.original_text&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-bold text-foreground mb-2",children:"Original Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted rounded-lg border border-border max-h-[300px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono text-foreground",children:i.original_text})})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"space-y-3",children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Chunk ID"}),(0,D.jsx)("div",{className:"text-sm font-mono break-all text-foreground",children:i.chunk_id})]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Document ID"}),(0,D.jsx)("div",{className:"text-sm font-mono break-all text-foreground",children:i.document_id})]}),(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Chunk Index"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:i.chunk_index})]})]}),i.created_at&&(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:new Date(i.created_at).toLocaleString()})]}),i.chunk_text&&(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm text-foreground",children:[i.chunk_text.length.toLocaleString()," characters"]})]})]}),i.chunk_text&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-bold text-foreground mb-2",children:"Chunk Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted rounded-lg border border-border max-h-[300px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono text-foreground",children:i.chunk_text})})]})]})}):null})]})})}var tf=e.i(63738),tu=tu,tp=e.i(51975);let tg=(0,F.default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);function tm({memoryId:e,onClose:t}){let{currentBank:n}=(0,I.useBank)(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(!1),[s,l]=(0,M.useState)(null),[c,u]=(0,M.useState)("memory"),[d,h]=(0,M.useState)(null),[f,p]=(0,M.useState)(null),[g,v]=(0,M.useState)(!1),[x,y]=(0,M.useState)(!1),[b,w]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&n&&(async()=>{o(!0),l(null),i(null),h(null),p(null),u("memory");try{let t=await K.client.getMemory(e,n);i(t)}catch(e){console.error("Error loading memory:",e),l(e.message)}finally{o(!1)}})()},[e,n]),(0,M.useEffect)(()=>{"document"===c&&r?.document_id&&n&&!d&&(async()=>{v(!0);try{let e=await K.client.getDocument(r.document_id,n);h(e)}catch(e){console.error("Error loading document:",e)}finally{v(!1)}})()},[c,r?.document_id,n,d]),(0,M.useEffect)(()=>{"chunk"!==c||!r?.chunk_id||f||(async()=>{y(!0);try{let e=await K.client.getChunk(r.chunk_id);p(e)}catch(e){console.error("Error loading chunk:",e)}finally{y(!1)}})()},[c,r?.chunk_id,f]);let N=null!==e,j=r?.type==="observation";return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(td.Dialog,{open:N,onOpenChange:e=>!e&&t(),children:(0,D.jsxs)(td.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[(0,D.jsx)(td.DialogHeader,{children:(0,D.jsx)(td.DialogTitle,{children:r?r?.type==="observation"?"Observation":r?.type==="world"?"World Fact":r?.type==="experience"?"Experience":"Memory Details":"Memory Details"})}),a?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)(tu.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):s?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)("div",{className:"text-center text-destructive",children:(0,D.jsxs)("div",{className:"text-sm",children:["Error: ",s]})})}):r?j?(0,D.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text"}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:r.text})]}),r.occurred_start&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Occurred"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsxs)("span",{children:[new Date(r.occurred_start).toLocaleString(),r.occurred_end&&r.occurred_end!==r.occurred_start&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"text-muted-foreground mx-1",children:"→"}),new Date(r.occurred_end).toLocaleString()]})]})]})]}),r.mentioned_at&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentioned"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsx)("span",{children:new Date(r.mentioned_at).toLocaleString()})]})]}),r.entities&&r.entities.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 flex items-center gap-1",children:[(0,D.jsx)(U,{className:"w-3 h-3"}),"Entities"]}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.entities.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-primary/10 text-primary rounded text-xs",children:e},t))})]}),r.tags&&r.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 flex items-center gap-1",children:[(0,D.jsx)(tp.Tag,{className:"w-3 h-3"}),"Tags"]}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded text-xs",children:e},t))})]}),r.source_memories&&r.source_memories.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Source Memories (",r.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-3",children:r.source_memories.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:`px-2 py-0.5 rounded text-xs flex-shrink-0 ${"experience"===e.type?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:e.type}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>w(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground mb-2",children:e.text}),e.context&&(0,D.jsxs)("p",{className:"text-xs text-muted-foreground mb-2 italic",children:["Context: ",e.context]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.occurred_start&&(0,D.jsxs)("div",{className:"p-2 bg-background/50 rounded",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-0.5",children:"Occurred"}),(0,D.jsx)("div",{className:"font-medium",children:new Date(e.occurred_start).toLocaleString()})]}),e.mentioned_at&&(0,D.jsxs)("div",{className:"p-2 bg-background/50 rounded",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-0.5",children:"Mentioned"}),(0,D.jsx)("div",{className:"font-medium",children:new Date(e.mentioned_at).toLocaleString()})]})]})]},e.id||t))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Memory ID"}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:r.id})]})]}):(0,D.jsxs)(tf.Tabs,{value:c,onValueChange:u,className:"flex-1 flex flex-col overflow-hidden",children:[(0,D.jsxs)(tf.TabsList,{className:"grid w-full grid-cols-3",children:[(0,D.jsxs)(tf.TabsTrigger,{value:"memory",className:"flex items-center gap-1.5",children:[(0,D.jsx)(H.FileText,{className:"w-3.5 h-3.5"}),"world"===r.type?"World Fact":"Experience"]}),(0,D.jsxs)(tf.TabsTrigger,{value:"chunk",disabled:!r.chunk_id,className:"flex items-center gap-1.5",children:[(0,D.jsx)(tg,{className:"w-3.5 h-3.5"}),"Chunk"]}),(0,D.jsxs)(tf.TabsTrigger,{value:"document",disabled:!r.document_id,className:"flex items-center gap-1.5",children:[(0,D.jsx)(H.FileText,{className:"w-3.5 h-3.5"}),"Document"]})]}),(0,D.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,D.jsxs)(tf.TabsContent,{value:"memory",className:"mt-0 space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text"}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:r.text})]}),r.context&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Context"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:r.context})]}),r.occurred_start&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Occurred"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsxs)("span",{children:[new Date(r.occurred_start).toLocaleString(),r.occurred_end&&r.occurred_end!==r.occurred_start&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"text-muted-foreground mx-1",children:"→"}),new Date(r.occurred_end).toLocaleString()]})]})]})]}),r.mentioned_at&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentioned"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsx)("span",{children:new Date(r.mentioned_at).toLocaleString()})]})]}),r.entities&&r.entities.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 flex items-center gap-1",children:[(0,D.jsx)(U,{className:"w-3 h-3"}),"Entities"]}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.entities.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-primary/10 text-primary rounded text-xs",children:e},t))})]}),r.tags&&r.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 flex items-center gap-1",children:[(0,D.jsx)(tp.Tag,{className:"w-3 h-3"}),"Tags"]}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded text-xs",children:e},t))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Memory ID"}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:r.id})]})]}),(0,D.jsx)(tf.TabsContent,{value:"chunk",className:"mt-0 space-y-4",children:x?(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)(tu.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):f?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Chunk Index"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:f.chunk_index})]}),f.chunk_text&&(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm text-foreground",children:[f.chunk_text.length.toLocaleString()," chars"]})]})]}),f.chunk_text&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Chunk Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted rounded-lg border border-border max-h-[300px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono text-foreground",children:f.chunk_text})})]}),(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Chunk ID"}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:f.chunk_id})]})]}):(0,D.jsx)("div",{className:"text-center py-12 text-muted-foreground",children:"No chunk data available"})}),(0,D.jsx)(tf.TabsContent,{value:"document",className:"mt-0 space-y-4",children:g?(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)(tu.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):d?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[d.created_at&&(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:new Date(d.created_at).toLocaleString()})]}),(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Memory Units"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:d.memory_unit_count})]})]}),d.original_text&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm text-foreground",children:[d.original_text.length.toLocaleString()," chars"]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Original Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted rounded-lg border border-border max-h-[300px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono text-foreground",children:d.original_text})})]})]}),(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-1",children:"Document ID"}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:d.id})]})]}):(0,D.jsx)("div",{className:"text-center py-12 text-muted-foreground",children:"No document data available"})})]})]}):null]})}),b&&(0,D.jsx)(tm,{memoryId:b,onClose:()=>w(null)})]})}function tv({memory:e,onClose:t,compact:n=!1,inPanel:r=!1,bankId:i}){let a,[o,s]=(0,M.useState)(null),[l,c]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),[h,f]=(0,M.useState)(null),[p,g]=(0,M.useState)(!1),[v,x]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=e?.id||e?.node_id;t&&i?(g(!0),K.client.getMemory(t,i).then(e=>{f(e)}).catch(e=>{console.error("Failed to fetch memory details:",e),f(null)}).finally(()=>{g(!1)})):f(null)},[e?.id,e?.node_id,e?.fact_type,e?.type,i]);let y=h||e,b=y?.fact_type==="observation"||y?.type==="observation",w="observation"===(a=y?.fact_type||y?.type)?"Observation":"world"===a?"World Fact":"experience"===a?"Experience":"Memory Details",N=async e=>{try{await navigator.clipboard.writeText(e),s(e),setTimeout(()=>s(null),2e3)}catch(e){console.error("Failed to copy:",e)}},j=e=>{c("document"),d(e)},k=e=>{c("chunk"),d(e)},C=()=>{c(null),d(null)};if(!e)return null;let E=y.id||y.node_id,T=n?"text-[10px]":"text-xs",S=n?"text-xs":"text-sm";return r?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"p-5",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:w}),(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(tc.X,{className:"h-5 w-5"})})]}),p?(0,D.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,D.jsx)(tu.default,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,D.jsx)("span",{className:"ml-2 text-muted-foreground",children:"Loading memory details..."})]}):(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text"}),(0,D.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-relaxed text-foreground",children:y.text})]}),y.context&&!b&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Context"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:y.context})]}),y.occurred_start&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Occurred"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsxs)("span",{children:[new Date(y.occurred_start).toLocaleString(),y.occurred_end&&y.occurred_end!==y.occurred_start&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"text-muted-foreground mx-1",children:"→"}),new Date(y.occurred_end).toLocaleString()]})]})]})]}),y.mentioned_at&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentioned"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,D.jsx)(J,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,D.jsx)("span",{children:new Date(y.mentioned_at).toLocaleString()})]})]}),y.entities&&(Array.isArray(y.entities)?y.entities.length>0:y.entities)&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Entities"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:(Array.isArray(y.entities)?y.entities:String(y.entities).split(", ")).map((e,t)=>{let n="string"==typeof e?e:e?.name||JSON.stringify(e);return(0,D.jsx)("span",{className:"text-sm px-3 py-1.5 rounded-full bg-primary/10 text-primary font-medium",children:n},t)})})]}),y.tags&&y.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:y.tags.map((e,t)=>(0,D.jsx)("span",{className:"text-sm px-3 py-1.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:e},t))})]}),y.source_memories&&y.source_memories.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Source Memories (",y.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-3",children:y.source_memories.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:`px-2 py-0.5 rounded text-xs flex-shrink-0 ${"experience"===e.type?"bg-green-500/10 text-green-600":"bg-blue-500/10 text-blue-600"}`,children:e.type}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>x(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground mb-3",children:e.text}),e.context&&(0,D.jsxs)("p",{className:"text-xs text-muted-foreground mb-3 italic",children:["Context: ",e.context]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[(0,D.jsxs)("div",{className:"p-2 bg-background/50 rounded",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-0.5",children:"Occurred"}),(0,D.jsx)("div",{className:"font-medium",children:e.occurred_start?new Date(e.occurred_start).toLocaleString():"N/A"})]}),(0,D.jsxs)("div",{className:"p-2 bg-background/50 rounded",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-0.5",children:"Mentioned"}),(0,D.jsx)("div",{className:"font-medium",children:e.mentioned_at?new Date(e.mentioned_at).toLocaleString():"N/A"})]})]})]},e.id||t))})]}),(y.document_id||y.chunk_id)&&(0,D.jsxs)("div",{className:"flex gap-3 pt-2",children:[y.document_id&&(0,D.jsx)(Z.Button,{onClick:()=>j(y.document_id),variant:"secondary",className:"flex-1",children:"View Document"}),y.chunk_id&&(0,D.jsx)(Z.Button,{onClick:()=>k(y.chunk_id),variant:"secondary",className:"flex-1",children:"View Chunk"})]}),E&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Memory ID"}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:E}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>N(E),children:o===E?(0,D.jsx)(tl.Check,{className:"h-3 w-3 text-green-600"}):(0,D.jsx)(ts,{className:"h-3 w-3 text-muted-foreground"})})]})]})]})]}),l&&u&&(0,D.jsx)(th,{type:l,id:u,onClose:C}),(0,D.jsx)(tm,{memoryId:v,onClose:()=>x(null)})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:`bg-card border-2 border-primary rounded-lg ${n?"p-3":"p-4"} sticky top-4 max-h-[calc(100vh-120px)] overflow-y-auto`,children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-4",children:[(0,D.jsx)("h3",{className:`${n?"text-sm":"text-lg"} font-bold text-card-foreground`,children:w}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:t,className:n?"h-6 w-6 p-0":"h-8 w-8 p-0",children:(0,D.jsx)(tc.X,{className:n?"h-3 w-3":"h-4 w-4"})})]}),p?(0,D.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,D.jsx)(tu.default,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,D.jsx)("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading..."})]}):(0,D.jsxs)("div",{className:n?"space-y-2":"space-y-4",children:[(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-1`,children:"Text"}),(0,D.jsx)("div",{className:`${S} whitespace-pre-wrap`,children:y.text})]}),y.context&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-1`,children:"Context"}),(0,D.jsx)("div",{className:S,children:y.context})]}),y.occurred_start&&(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-1`,children:"Occurred"}),(0,D.jsxs)("div",{className:`flex items-center gap-2 ${S}`,children:[(0,D.jsx)(J,{className:`${n?"h-3 w-3":"h-4 w-4"} text-muted-foreground flex-shrink-0`}),(0,D.jsxs)("span",{children:[new Date(y.occurred_start).toLocaleString(),y.occurred_end&&y.occurred_end!==y.occurred_start&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"text-muted-foreground mx-1",children:"→"}),new Date(y.occurred_end).toLocaleString()]})]})]})]}),y.mentioned_at&&(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-1`,children:"Mentioned"}),(0,D.jsxs)("div",{className:`flex items-center gap-2 ${S}`,children:[(0,D.jsx)(J,{className:`${n?"h-3 w-3":"h-4 w-4"} text-muted-foreground flex-shrink-0`}),(0,D.jsx)("span",{children:new Date(y.mentioned_at).toLocaleString()})]})]}),y.entities&&(Array.isArray(y.entities)?y.entities.length>0:y.entities)&&(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-2`,children:"Entities"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:(Array.isArray(y.entities)?y.entities:String(y.entities).split(", ")).map((e,t)=>{let r="string"==typeof e?e:e?.name||JSON.stringify(e);return(0,D.jsx)("span",{className:`${n?"text-[10px] px-1.5 py-0.5":"text-xs px-2 py-1"} rounded bg-secondary text-secondary-foreground`,children:r},t)})})]}),y.tags&&y.tags.length>0&&(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-2`,children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:y.tags.map((e,t)=>(0,D.jsx)("span",{className:`${n?"text-[10px] px-1.5 py-0.5":"text-xs px-2 py-1"} rounded bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:e},t))})]}),(y.document_id||y.chunk_id)&&(0,D.jsxs)("div",{className:`flex gap-2 ${n?"pt-1":""}`,children:[y.document_id&&(0,D.jsx)(Z.Button,{onClick:()=>j(y.document_id),size:"sm",variant:"secondary",className:`flex-1 ${n?"h-7 text-xs":""}`,children:"View Document"}),y.chunk_id&&(0,D.jsx)(Z.Button,{onClick:()=>k(y.chunk_id),size:"sm",variant:"secondary",className:`flex-1 ${n?"h-7 text-xs":""}`,children:"View Chunk"})]}),y.source_memories&&y.source_memories.length>0&&(0,D.jsxs)("div",{className:`${n?"p-2":"p-3"} bg-muted rounded-lg`,children:[(0,D.jsxs)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-2`,children:["Source Memories (",y.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-2",children:y.source_memories.map((e,t)=>(0,D.jsxs)("div",{className:"p-2 bg-background/50 rounded border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-1",children:[(0,D.jsx)("span",{className:`px-1.5 py-0.5 rounded text-[10px] flex-shrink-0 ${"experience"===e.type?"bg-green-500/10 text-green-600":"bg-blue-500/10 text-blue-600"}`,children:e.type}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",className:"h-5 text-[10px] px-2",onClick:()=>x(e.id),children:"View"})]}),(0,D.jsx)("p",{className:`${S} mb-1`,children:e.text}),e.context&&(0,D.jsxs)("p",{className:"text-[10px] text-muted-foreground italic",children:["Context: ",e.context]})]},e.id||t))})]}),E&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:`${T} font-bold text-muted-foreground uppercase mb-1`,children:"Memory ID"}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("code",{className:`${n?"text-[9px]":"text-xs"} font-mono text-muted-foreground`,children:E}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",className:`${n?"h-4 w-4":"h-5 w-5"} p-0`,onClick:()=>N(E),children:o===E?(0,D.jsx)(tl.Check,{className:`${n?"h-2.5 w-2.5":"h-3 w-3"} text-green-600`}):(0,D.jsx)(ts,{className:`${n?"h-2.5 w-2.5":"h-3 w-3"} text-muted-foreground`})})]})]})]})]}),l&&u&&(0,D.jsx)(th,{type:l,id:u,onClose:C}),(0,D.jsx)(tm,{memoryId:v,onClose:()=>x(null)})]})}function tx(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ty(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function tb(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,tC(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function tw(e,t){var n="u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=tT(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function tN(e,t,n){return(t=tC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tj(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||tT(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tk(e){return function(e){if(Array.isArray(e))return tx(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tT(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tC(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function tE(e){return(tE="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function tT(e,t){if(e){if("string"==typeof e)return tx(e,t);var n=({}).toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tx(e,t):void 0}}var tS="u"<typeof window?null:window,t_=tS?tS.navigator:null;tS&&tS.document;var tA=tE(""),tD=tE({}),tM=tE(function(){}),tP="u"<typeof HTMLElement?"undefined":tE(HTMLElement),tR=function(e){return e&&e.instanceString&&tI(e.instanceString)?e.instanceString():null},tL=function(e){return null!=e&&tE(e)==tA},tI=function(e){return null!=e&&tE(e)===tM},tO=function(e){return!tV(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},tB=function(e){return null!=e&&tE(e)===tD&&!tO(e)&&e.constructor===Object},tF=function(e){return null!=e&&tE(e)===tE(1)&&!isNaN(e)},tz=function(e){if("undefined"!==tP)return null!=e&&e instanceof HTMLElement},tV=function(e){return tH(e)||tU(e)},tH=function(e){return"collection"===tR(e)&&e._private.single},tU=function(e){return"collection"===tR(e)&&!e._private.single},tG=function(e){return"core"===tR(e)},tY=function(e){return"stylesheet"===tR(e)},tX=function(e){return null==e||!!(""===e||e.match(/^\s+$/))},tW=function(e){return null!=e&&tE(e)===tD&&tI(e.then)},tq=function(e,t){t||(t=function(){if(1==arguments.length)return arguments[0];if(0==arguments.length)return"undefined";for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join("$")});var n=function(){var r,i=arguments,a=t.apply(this,i),o=n.cache;return(r=o[a])||(r=o[a]=e.apply(this,i)),r};return n.cache={},n},t$=tq(function(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),tK=tq(function(e){return e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),tZ=tq(function(e,t){return e+t[0].toUpperCase()+t.substring(1)},function(e,t){return e+"$"+t}),tQ=function(e){return tX(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},tJ=function(e,t){return e.slice(-1*t.length)===t},t0="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",t1="rgb[a]?\\(("+t0+"[%]?)\\s*,\\s*("+t0+"[%]?)\\s*,\\s*("+t0+"[%]?)(?:\\s*,\\s*("+t0+"))?\\)",t2="rgb[a]?\\((?:"+t0+"[%]?)\\s*,\\s*(?:"+t0+"[%]?)\\s*,\\s*(?:"+t0+"[%]?)(?:\\s*,\\s*(?:"+t0+"))?\\)",t5="hsl[a]?\\(("+t0+")\\s*,\\s*("+t0+"[%])\\s*,\\s*("+t0+"[%])(?:\\s*,\\s*("+t0+"))?\\)",t3="hsl[a]?\\((?:"+t0+")\\s*,\\s*(?:"+t0+"[%])\\s*,\\s*(?:"+t0+"[%])(?:\\s*,\\s*(?:"+t0+"))?\\)",t4=function(e,t){return e<t?-1:+(e>t)},t6=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(null!=r)for(var i=Object.keys(r),a=0;a<i.length;a++){var o=i[a];e[o]=r[o]}}return e},t9=function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r;return 4===e.length?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):(t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16)),[t,n,r]}},t7=function(e){function t(e,t,n){return(n<0&&(n+=1),n>1&&(n-=1),n<1/6)?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var n,r,i,a,o,s,l,c,u=RegExp("^"+t5+"$").exec(e);if(u){if((r=parseInt(u[1]))<0?r=(360- -1*r%360)%360:r>360&&(r%=360),r/=360,(i=parseFloat(u[2]))<0||i>100||(i/=100,(a=parseFloat(u[3]))<0||a>100)||(a/=100,void 0!==(o=u[4])&&((o=parseFloat(o))<0||o>1)))return;if(0===i)s=l=c=Math.round(255*a);else{var d=a<.5?a*(1+i):a+i-a*i,h=2*a-d;s=Math.round(255*t(h,d,r+1/3)),l=Math.round(255*t(h,d,r)),c=Math.round(255*t(h,d,r-1/3))}n=[s,l,c,o]}return n},t8=function(e){var t,n=RegExp("^"+t1+"$").exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var a=n[i];if("%"===a[a.length-1]&&(r[i]=!0),a=parseFloat(a),r[i]&&(a=a/100*255),a<0||a>255)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t},ne=function(e){return(tO(e)?e:null)||nt[e.toLowerCase()]||t9(e)||t8(e)||t7(e)},nt={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},nn=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(tB(a))throw Error("Tried to set map with object key");i<n.length-1?(null==t[a]&&(t[a]={}),t=t[a]):t[a]=e.value}},nr=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(tB(a))throw Error("Tried to get map with object key");if(null==(t=t[a]))break}return t},ni="u">typeof globalThis?globalThis:"u">typeof window?window:e.g;function na(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function no(){return s9?s6:(s9=1,s6=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)})}function ns(){if(lt)return le;lt=1;var e=s8?s7:(s8=1,s7="object"==typeof ni&&ni&&ni.Object===Object&&ni),t="object"==typeof self&&self&&self.Object===Object&&self;return le=e||t||Function("return this")()}function nl(){return lc?ll:(lc=1,ll=ns().Symbol)}function nc(){if(lg)return lp;lg=1;var e=nl(),t=function(){if(ld)return lu;ld=1;var e=nl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;return lu=function(e){var t=n.call(e,i),a=e[i];try{e[i]=void 0;var o=!0}catch(e){}var s=r.call(e);return o&&(t?e[i]=a:delete e[i]),s}}(),n=function(){if(lf)return lh;lf=1;var e=Object.prototype.toString;return lh=function(t){return e.call(t)}}(),r=e?e.toStringTag:void 0;return lp=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":r&&r in Object(e)?t(e):n(e)}}function nu(){if(ly)return lx;ly=1;var e=nc(),t=lv?lm:(lv=1,lm=function(e){return null!=e&&"object"==typeof e});return lx=function(n){return"symbol"==typeof n||t(n)&&"[object Symbol]"==e(n)}}var nd=na(function(){if(lj)return lN;lj=1;var e=no(),t=function(){if(lr)return ln;lr=1;var e=ns();return ln=function(){return e.Date.now()}}(),n=function(){if(lw)return lb;lw=1;var e=function(){if(ls)return lo;ls=1;var e=function(){if(la)return li;la=1;var e=/\s/;return li=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}}(),t=/^\s+/;return lo=function(n){return n?n.slice(0,e(n)+1).replace(t,""):n}}(),t=no(),n=nu(),r=0/0,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;return lb=function(l){if("number"==typeof l)return l;if(n(l))return r;if(t(l)){var c="function"==typeof l.valueOf?l.valueOf():l;l=t(c)?c+"":c}if("string"!=typeof l)return 0===l?l:+l;l=e(l);var u=a.test(l);return u||o.test(l)?s(l.slice(2),u?2:8):i.test(l)?r:+l}}(),r=Math.max,i=Math.min;return lN=function(a,o,s){var l,c,u,d,h,f,p=0,g=!1,v=!1,x=!0;if("function"!=typeof a)throw TypeError("Expected a function");function y(e){var t=l,n=c;return l=c=void 0,p=e,d=a.apply(n,t)}function b(e){var t=e-f,n=e-p;return void 0===f||t>=o||t<0||v&&n>=u}function w(){var e,n,r,a=t();if(b(a))return N(a);h=setTimeout(w,(e=a-f,n=a-p,r=o-e,v?i(r,u-n):r))}function N(e){return(h=void 0,x&&l)?y(e):(l=c=void 0,d)}function j(){var e,n=t(),r=b(n);if(l=arguments,c=this,f=n,r){if(void 0===h)return p=e=f,h=setTimeout(w,o),g?y(e):d;if(v)return clearTimeout(h),h=setTimeout(w,o),y(f)}return void 0===h&&(h=setTimeout(w,o)),d}return o=n(o)||0,e(s)&&(g=!!s.leading,u=(v="maxWait"in s)?r(n(s.maxWait)||0,o):u,x="trailing"in s?!!s.trailing:x),j.cancel=function(){void 0!==h&&clearTimeout(h),p=0,l=f=c=h=void 0},j.flush=function(){return void 0===h?d:N(t())},j}}()),nh=tS?tS.performance:null,nf=nh&&nh.now?function(){return nh.now()}:function(){return Date.now()},np=function(){if(tS){if(tS.requestAnimationFrame)return function(e){tS.requestAnimationFrame(e)};else if(tS.mozRequestAnimationFrame)return function(e){tS.mozRequestAnimationFrame(e)};else if(tS.webkitRequestAnimationFrame)return function(e){tS.webkitRequestAnimationFrame(e)};else if(tS.msRequestAnimationFrame)return function(e){tS.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(nf())},1e3/60)}}(),ng=function(e){return np(e)},nm=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9261,r=n;!(t=e.next()).done;)r=65599*r+t.value|0;return r},nv=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9261;return 65599*t+e|0},nx=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;return(t<<5)+t+e|0},ny=function(e){return 2097152*e[0]+e[1]},nb=function(e,t){return[nv(e[0],t[0]),nx(e[1],t[1])]},nw=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return nm({next:function(){return r<i?n.value=e[r++]:n.done=!0,n}},t)},nN=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return nm({next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},nj=function(){return nk(arguments)},nk=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?nN(r):nN(r,t)}return t},nC=!0,nE=null!=console.warn,nT=null!=console.trace,nS=Number.MAX_SAFE_INTEGER||0x1fffffffffffff,n_=function(){return!0},nA=function(){return!1},nD=function(){return 0},nM=function(){},nP=function(e){throw Error(e)},nR=function(e){if(void 0===e)return nC;nC=!!e},nL=function(e){nR()&&(nE?console.warn(e):(console.log(e),nT&&console.trace()))},nI=function(e){return null==e?e:tO(e)?e.slice():tB(e)?t6({},e):e},nO=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t},nB={},nF=function(){return nB},nz=function(e){var t=Object.keys(e);return function(n){for(var r={},i=0;i<t.length;i++){var a=t[i],o=null==n?void 0:n[a];r[a]=void 0===o?e[a]:o}return r}},nV=function(e,t,n){for(var r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)},nH=function(e){e.splice(0,e.length)},nU=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.push(r)}},nG=function(e,t,n){return n&&(t=tZ(n,t)),e[t]},nY=function(e,t,n,r){n&&(t=tZ(n,t)),e[t]=r},nX=tb(function e(){ty(this,e),this._obj={}},[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}]),nW="u">typeof Map?Map:nX,nq=tb(function e(t){if(ty(this,e),this._obj=Object.create(null),this.size=0,null!=t){var n;n=null!=t.instanceString&&t.instanceString()===this.instanceString()?t.toArray():t;for(var r=0;r<n.length;r++)this.add(n[r])}},[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(e){var t=this._obj;1!==t[e]&&(t[e]=1,this.size++)}},{key:"delete",value:function(e){var t=this._obj;1===t[e]&&(t[e]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(e){return 1===this._obj[e]}},{key:"toArray",value:function(){var e=this;return Object.keys(this._obj).filter(function(t){return e.has(t)})}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}]),n$=("u"<typeof Set?"undefined":tE(Set))!=="undefined"?Set:nq,nK=function(e,t){var n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(void 0===e||void 0===t||!tG(e))return void nP("An element must have a core reference and parameters set");var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"!==r&&"edges"!==r)return void nP("An element must be of type `nodes` or `edges`; you specified `"+r+"`");this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,active:!1,classes:new n$,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==i.position.x&&(i.position.x=0),null==i.position.y&&(i.position.y=0),t.renderedPosition){var a=t.renderedPosition,o=e.pan(),s=e.zoom();i.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}var l=[];tO(t.classes)?l=t.classes:tL(t.classes)&&(l=t.classes.split(/\s+/));for(var c=0,u=l.length;c<u;c++){var d=l[c];d&&""!==d&&i.classes.add(d)}this.createEmitter(),(void 0===n||n)&&this.restore();var h=t.style||t.css;h&&(nL("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(h))},nZ=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){tB(t)&&!tV(t)&&(t=(i=t).roots||i.root,n=i.visit,r=i.directed),r=2!=arguments.length||tI(n)?r:n,n=tI(n)?n:function(){};for(var i,a,o,s=this._private.cy,l=t=tL(t)?this.filter(t):t,c=[],u=[],d={},h={},f={},p=0,g=this.byGroup(),v=g.nodes,x=g.edges,y=0;y<l.length;y++){var b=l[y],w=b.id();b.isNode()&&(c.unshift(b),e.bfs&&(f[w]=!0,u.push(b)),h[w]=0)}for(;0!==c.length&&(0===(o=function(){var t,i=e.bfs?c.shift():c.pop(),o=i.id();if(e.dfs){if(f[o])return 0;f[o]=!0,u.push(i)}var s=h[o],l=d[o],g=null!=l?l.source():null,y=null!=l?l.target():null,b=null==l?void 0:i.same(g)?y[0]:g[0];if(!0===(t=n(i,l,b,p++,s)))return a=i,1;if(!1===t)return 1;for(var w=i.connectedEdges().filter(function(e){return(!r||e.source().same(i))&&x.has(e)}),N=0;N<w.length;N++){var j=w[N],k=j.connectedNodes().filter(function(e){return!e.same(i)&&v.has(e)}),C=k.id();0===k.length||f[C]||(k=k[0],c.push(k),e.bfs&&(f[C]=!0,u.push(k)),d[C]=j,h[C]=h[o]+1)}}())||1!==o););for(var N=s.collection(),j=0;j<u.length;j++){var k=u[j],C=d[k.id()];null!=C&&N.push(C),N.push(k)}return{path:s.collection(N),found:s.collection(a)}}},nQ={breadthFirstSearch:nZ({bfs:!0}),depthFirstSearch:nZ({dfs:!0})};nQ.bfs=nQ.breadthFirstSearch,nQ.dfs=nQ.depthFirstSearch;var nJ={exports:{}},n0=nJ.exports,n1=na(lE?lC:(lE=1,lC=function(){return lk?nJ.exports:(lk=1,(function(){var e,t,n,r,i,a,o,s,l,c,u,d,h,f,p;n=Math.floor,c=Math.min,t=function(e,t){return e<t?-1:+(e>t)},l=function(e,r,i,a,o){var s;if(null==i&&(i=0),null==o&&(o=t),i<0)throw Error("lo must be non-negative");for(null==a&&(a=e.length);i<a;)0>o(r,e[s=n((i+a)/2)])?a=s:i=s+1;return[].splice.apply(e,[i,i-i].concat(r)),r},a=function(e,n,r){return null==r&&(r=t),e.push(n),f(e,0,e.length-1,r)},i=function(e,n){var r,i;return null==n&&(n=t),r=e.pop(),e.length?(i=e[0],e[0]=r,p(e,0,n)):i=r,i},s=function(e,n,r){var i;return null==r&&(r=t),i=e[0],e[0]=n,p(e,0,r),i},o=function(e,n,r){var i;return null==r&&(r=t),e.length&&0>r(e[0],n)&&(n=(i=[e[0],n])[0],e[0]=i[1],p(e,0,r)),n},r=function(e,r){var i,a,o,s,l,c;for(null==r&&(r=t),s=(function(){c=[];for(var t=0,r=n(e.length/2);0<=r?t<r:t>r;0<=r?t++:t--)c.push(t);return c}).apply(this).reverse(),l=[],a=0,o=s.length;a<o;a++)i=s[a],l.push(p(e,i,r));return l},h=function(e,n,r){var i;if(null==r&&(r=t),-1!==(i=e.indexOf(n)))return f(e,0,i,r),p(e,i,r)},u=function(e,n,i){var a,s,l,c;if(null==i&&(i=t),!(a=e.slice(0,n)).length)return a;for(r(a,i),s=0,l=(c=e.slice(n)).length;s<l;s++)o(a,c[s],i);return a.sort(i).reverse()},d=function(e,n,a){var o,s,u,d,h,f,p,g,v;if(null==a&&(a=t),10*n<=e.length){if(!(u=e.slice(0,n).sort(a)).length)return u;for(d=0,s=u[u.length-1],f=(p=e.slice(n)).length;d<f;d++)0>a(o=p[d],s)&&(l(u,o,0,null,a),u.pop(),s=u[u.length-1]);return u}for(r(e,a),v=[],h=0,g=c(n,e.length);0<=g?h<g:h>g;0<=g?++h:--h)v.push(i(e,a));return v},f=function(e,n,r,i){var a,o,s;for(null==i&&(i=t),a=e[r];r>n;){if(0>i(a,o=e[s=r-1>>1])){e[r]=o,r=s;continue}break}return e[r]=a},p=function(e,n,r){var i,a,o,s,l;for(null==r&&(r=t),a=e.length,l=n,o=e[n],i=2*n+1;i<a;)(s=i+1)<a&&!(0>r(e[i],e[s]))&&(i=s),e[n]=e[i],i=2*(n=i)+1;return e[n]=o,f(e,l,n,r)},e=function(){function e(e){this.cmp=null!=e?e:t,this.nodes=[]}return e.push=a,e.pop=i,e.replace=s,e.pushpop=o,e.heapify=r,e.updateItem=h,e.nlargest=u,e.nsmallest=d,e.prototype.push=function(e){return a(this.nodes,e,this.cmp)},e.prototype.pop=function(){return i(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return -1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return s(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return o(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return r(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return h(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return(t=new e).nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),nJ.exports=e}).call(n0),nJ.exports)}())),n2=nz({root:null,weight:function(e){return 1},directed:!1}),n5=nz({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),n3=nz({weight:function(e){return 1},directed:!1}),n4=nz({weight:function(e){return 1},directed:!1,root:null}),n6=Math.sqrt(2),n9=function(e,t,n){0===n.length&&nP("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],i=r[1],a=r[2],o=t[i],s=t[a],l=n.length-1;l>=0;l--){var c=n[l],u=c[1],d=c[2];(t[u]===o&&t[d]===s||t[u]===s&&t[d]===o)&&n.splice(l,1)}for(var h=0;h<n.length;h++){var f=n[h];f[1]===s?(n[h]=f.slice(),n[h][1]=o):f[2]===s&&(n[h]=f.slice(),n[h][2]=o)}for(var p=0;p<t.length;p++)t[p]===s&&(t[p]=o);return n},n7=function(e,t,n,r){for(;n>r;)t=n9(Math.floor(Math.random()*t.length),e,t),n--;return t},n8=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},re=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},rt=function(e){return{x:e[0],y:e[1]}},rn=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.min(a,r))}return r},rr=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.max(a,r))}return r},ri=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0,a=t;a<n;a++){var o=e[a];isFinite(o)&&(r+=o,i++)}return r/i},ra=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>3)||void 0===arguments[3]||arguments[3],i=!(arguments.length>4)||void 0===arguments[4]||arguments[4],a=!(arguments.length>5)||void 0===arguments[5]||arguments[5];r?e=e.slice(t,n):(n<e.length&&e.splice(n,e.length-n),t>0&&e.splice(0,t));for(var o=0,s=e.length-1;s>=0;s--){var l=e[s];a?!isFinite(l)&&(e[s]=-1/0,o++):e.splice(s,1)}i&&e.sort(function(e,t){return e-t});var c=e.length,u=Math.floor(c/2);return c%2!=0?e[u+1+o]:(e[u-1+o]+e[u+o])/2},ro=function(e,t){return Math.atan2(t,e)-Math.PI/2},rs=Math.log2||function(e){return Math.log(e)/Math.log(2)},rl=function(e){return e>0?1:e<0?-1:0},rc=function(e,t){return Math.sqrt(ru(e,t))},ru=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},rd=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},rh=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},rf=function(e,t,n,r){return{x:rh(e.x,t.x,n.x,r),y:rh(e.y,t.y,n.y,r)}},rp=function(e,t,n,r){var i={x:t.x-e.x,y:t.y-e.y},a=rc(e,t),o={x:i.x/a,y:i.y/a};return n=null==n?0:n,r=null!=r?r:n*a,{x:e.x+o.x*r,y:e.y+o.y*r}},rg=function(e,t,n){return Math.max(e,Math.min(n,t))},rm=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};else if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},rv=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},rx=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},ry=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},rb=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},rw=function(e){var t,n,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===a.length)t=n=r=i=a[0];else if(2===a.length)t=r=a[0],i=n=a[1];else if(4===a.length){var o=tj(a,4);t=o[0],n=o[1],r=o[2],i=o[3]}return e.x1-=i,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},rN=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},rj=function(e,t){return!(e.x1>t.x2)&&!(t.x1>e.x2)&&!(e.x2<t.x1)&&!(t.x2<e.x1)&&!(e.y2<t.y1)&&!(t.y2<e.y1)&&!(e.y1>t.y2)&&!(t.y1>e.y2)&&!0},rk=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},rC=function(e,t){return rk(e,t.x,t.y)},rE=function(e,t){return rk(e,t.x1,t.y1)&&rk(e,t.x2,t.y2)},rT=null!=(lT=Math.hypot)?lT:function(e,t){return Math.sqrt(e*e+t*t)},rS=function(e,t,n,r,i,a,o){var s,l,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",u="auto"===c?rQ(i,a):c,d=i/2,h=a/2,f=(u=Math.min(u,d,h))!==d,p=u!==h;if(f){var g=n-d+u-o,v=r-h-o,x=n+d-u+o;if((s=rG(e,t,n,r,g,v,x,v,!1)).length>0)return s}if(p){var y=n+d+o,b=r-h+u-o,w=r+h-u+o;if((s=rG(e,t,n,r,y,b,y,w,!1)).length>0)return s}if(f){var N=n-d+u-o,j=r+h+o,k=n+d-u+o;if((s=rG(e,t,n,r,N,j,k,j,!1)).length>0)return s}if(p){var C=n-d-o,E=r-h+u-o,T=r+h-u+o;if((s=rG(e,t,n,r,C,E,C,T,!1)).length>0)return s}var S=n-d+u,_=r-h+u;if((l=rH(e,t,n,r,S,_,u+o)).length>0&&l[0]<=S&&l[1]<=_)return[l[0],l[1]];var A=n+d-u,D=r-h+u;if((l=rH(e,t,n,r,A,D,u+o)).length>0&&l[0]>=A&&l[1]<=D)return[l[0],l[1]];var M=n+d-u,P=r+h-u;if((l=rH(e,t,n,r,M,P,u+o)).length>0&&l[0]>=M&&l[1]>=P)return[l[0],l[1]];var R=n-d+u,L=r+h-u;return(l=rH(e,t,n,r,R,L,u+o)).length>0&&l[0]<=R&&l[1]>=L?[l[0],l[1]]:[]},r_=function(e,t,n,r,i,a,o){var s=Math.min(n,i),l=Math.max(n,i),c=Math.min(r,a),u=Math.max(r,a);return s-o<=e&&e<=l+o&&c-o<=t&&t<=u+o},rA=function(e,t,n,r,i,a,o,s,l){var c={x1:Math.min(n,o,i)-l,x2:Math.max(n,o,i)+l,y1:Math.min(r,s,a)-l,y2:Math.max(r,s,a)+l};return!(e<c.x1)&&!(e>c.x2)&&!(t<c.y1)&&!(t>c.y2)},rD=function(e,t,n,r){var i=t*t-4*e*(n-=r);if(i<0)return[];var a=Math.sqrt(i),o=2*e;return[(-t+a)/o,(-t-a)/o]},rM=function(e,t,n,r,i){var a,o,s,l,c,u,d,h;if(0===e&&(e=1e-5),t/=e,n/=e,r/=e,a=(o=(3*n-t*t)/9)*o*o+(s=(-(27*r)+t*(9*n-t*t*2))/54)*s,i[1]=0,d=t/3,a>0){c=(c=s+Math.sqrt(a))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),u=(u=s-Math.sqrt(a))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),i[0]=-d+c+u,d+=(c+u)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-u+c)/2,i[3]=d,i[5]=-d;return}if(i[5]=i[3]=0,0===a){h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=-d+2*h,i[4]=i[2]=-(h+d);return}l=Math.acos(s/Math.sqrt(l=(o=-o)*o*o)),h=2*Math.sqrt(o),i[0]=-d+h*Math.cos(l/3),i[2]=-d+h*Math.cos((l+2*Math.PI)/3),i[4]=-d+h*Math.cos((l+4*Math.PI)/3)},rP=function(e,t,n,r,i,a,o,s){var l,c=[];rM(n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s,9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,c);for(var u=[],d=0;d<6;d+=2)1e-7>Math.abs(c[d+1])&&c[d]>=0&&c[d]<=1&&u.push(c[d]);u.push(1),u.push(0);for(var h=-1,f=0;f<u.length;f++)l=Math.pow(Math.pow(1-u[f],2)*n+2*(1-u[f])*u[f]*i+u[f]*u[f]*o-e,2)+Math.pow(Math.pow(1-u[f],2)*r+2*(1-u[f])*u[f]*a+u[f]*u[f]*s-t,2),h>=0?l<h&&(h=l):h=l;return h},rR=function(e,t,n,r,i,a){var o=[e-n,t-r],s=[i-n,a-r],l=s[0]*s[0]+s[1]*s[1],c=o[0]*o[0]+o[1]*o[1],u=o[0]*s[0]+o[1]*s[1],d=u*u/l;return u<0?c:d>l?(e-i)*(e-i)+(t-a)*(t-a):c-d},rL=function(e,t,n){for(var r,i,a,o,s=0,l=0;l<n.length/2;l++)if(r=n[2*l],i=n[2*l+1],l+1<n.length/2?(a=n[(l+1)*2],o=n[(l+1)*2+1]):(a=n[(l+1-n.length/2)*2],o=n[(l+1-n.length/2)*2+1]),r==e&&a==e);else{if((!(r>=e)||!(e>=a))&&(!(r<=e)||!(e<=a)))continue;(e-r)/(a-r)*(o-i)+i>t&&s++}return s%2!=0},rI=function(e,t,n,r,i,a,o,s,l){var c,u=Array(n.length);null!=s[0]?(c=Math.atan(s[1]/s[0]),s[0]<0?c+=Math.PI/2:c=-c-Math.PI/2):c=s;for(var d=Math.cos(-c),h=Math.sin(-c),f=0;f<u.length/2;f++)u[2*f]=a/2*(n[2*f]*d-n[2*f+1]*h),u[2*f+1]=o/2*(n[2*f+1]*d+n[2*f]*h),u[2*f]+=r,u[2*f+1]+=i;return rL(e,t,l>0?rB(rF(u,-l)):u)},rO=function(e,t,n,r,i,a,o,s){for(var l=Array(2*n.length),c=0;c<s.length;c++){var u=s[c];if(l[4*c+0]=u.startX,l[4*c+1]=u.startY,l[4*c+2]=u.stopX,l[4*c+3]=u.stopY,Math.pow(u.cx-e,2)+Math.pow(u.cy-t,2)<=Math.pow(u.radius,2))return!0}return rL(e,t,l)},rB=function(e){for(var t,n,r,i,a,o,s,l,c=Array(e.length/2),u=0;u<e.length/4;u++){t=e[4*u],n=e[4*u+1],r=e[4*u+2],i=e[4*u+3],u<e.length/4-1?(a=e[(u+1)*4],o=e[(u+1)*4+1],s=e[(u+1)*4+2],l=e[(u+1)*4+3]):(a=e[0],o=e[1],s=e[2],l=e[3]);var d=rG(t,n,r,i,a,o,s,l,!0);c[2*u]=d[0],c[2*u+1]=d[1]}return c},rF=function(e,t){for(var n,r,i,a,o=Array(2*e.length),s=0;s<e.length/2;s++){n=e[2*s],r=e[2*s+1],s<e.length/2-1?(i=e[(s+1)*2],a=e[(s+1)*2+1]):(i=e[0],a=e[1]);var l=a-r,c=-(i-n),u=Math.sqrt(l*l+c*c),d=l/u,h=c/u;o[4*s]=n+d*t,o[4*s+1]=r+h*t,o[4*s+2]=i+d*t,o[4*s+3]=a+h*t}return o},rz=function(e,t,n,r,i,a){var o=n-e,s=r-t,l=Math.sqrt((o/=i)*o+(s/=a)*s),c=l-1;if(c<0)return[];var u=c/l;return[(n-e)*u+e,(r-t)*u+t]},rV=function(e,t,n,r,i,a,o){return e-=i,t-=a,(e/=n/2+o)*e+(t/=r/2+o)*t<=1},rH=function(e,t,n,r,i,a,o){var s=[n-e,r-t],l=[e-i,t-a],c=s[0]*s[0]+s[1]*s[1],u=2*(l[0]*s[0]+l[1]*s[1]),d=u*u-4*c*(l[0]*l[0]+l[1]*l[1]-o*o);if(d<0)return[];var h=(-u+Math.sqrt(d))/(2*c),f=(-u-Math.sqrt(d))/(2*c),p=Math.min(h,f),g=Math.max(h,f),v=[];if(p>=0&&p<=1&&v.push(p),g>=0&&g<=1&&v.push(g),0===v.length)return[];var x=v[0]*s[0]+e,y=v[0]*s[1]+t;return v.length>1?v[0]==v[1]?[x,y]:[x,y,v[1]*s[0]+e,v[1]*s[1]+t]:[x,y]},rU=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},rG=function(e,t,n,r,i,a,o,s,l){var c=e-i,u=n-e,d=o-i,h=t-a,f=r-t,p=s-a,g=d*h-p*c,v=u*h-f*c,x=p*u-d*f;if(0!==x){var y=g/x,b=v/x;return -.001<=y&&y<=1.001&&-.001<=b&&b<=1.001||l?[e+y*u,t+y*f]:[]}return 0!==g&&0!==v?[]:rU(e,n,o)===o?[o,s]:rU(e,n,i)===i?[i,a]:rU(i,o,n)===n?[n,r]:[]},rY=function(e,t,n,r,i){var a=[],o=r/2,s=i/2;a.push({x:t+o*e[0],y:n+s*e[1]});for(var l=1;l<e.length/2;l++)a.push({x:t+o*e[2*l],y:n+s*e[2*l+1]});return a},rX=function(e,t,n,r,i,a,o,s){var l,c,u,d,h,f,p=[],g=Array(n.length),v=!0;if(null==a&&(v=!1),v){for(var x=0;x<g.length/2;x++)g[2*x]=n[2*x]*a+r,g[2*x+1]=n[2*x+1]*o+i;c=s>0?rB(rF(g,-s)):g}else c=n;for(var y=0;y<c.length/2;y++)u=c[2*y],d=c[2*y+1],y<c.length/2-1?(h=c[(y+1)*2],f=c[(y+1)*2+1]):(h=c[0],f=c[1]),0!==(l=rG(e,t,r,i,u,d,h,f)).length&&p.push(l[0],l[1]);return p},rW=function(e,t,n,r,i,a,o,s,l){var c,u=[],d=Array(2*n.length);l.forEach(function(n,a){0===a?(d[d.length-2]=n.startX,d[d.length-1]=n.startY):(d[4*a-2]=n.startX,d[4*a-1]=n.startY),d[4*a]=n.stopX,d[4*a+1]=n.stopY,0!==(c=rH(e,t,r,i,n.cx,n.cy,n.radius)).length&&u.push(c[0],c[1])});for(var h=0;h<d.length/4;h++)0!==(c=rG(e,t,r,i,d[4*h],d[4*h+1],d[4*h+2],d[4*h+3],!1)).length&&u.push(c[0],c[1]);if(u.length>2){for(var f=[u[0],u[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),g=1;g<u.length/2;g++){var v=Math.pow(u[2*g]-e,2)+Math.pow(u[2*g+1]-t,2);v<=p&&(f[0]=u[2*g],f[1]=u[2*g+1],p=v)}return f}return u},rq=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(r[0]*r[0]+r[1]*r[1]),a=(i-n)/i;return a<0&&(a=1e-5),[t[0]+a*r[0],t[1]+a*r[1]]},r$=function(e,t){var n=rZ(e,t);return rK(n)},rK=function(e){for(var t,n,r=e.length/2,i=1/0,a=1/0,o=-1/0,s=-1/0,l=0;l<r;l++)t=e[2*l],n=e[2*l+1],i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);for(var c=2/(o-i),u=2/(s-a),d=0;d<r;d++)t=e[2*d]=e[2*d]*c,n=e[2*d+1]=e[2*d+1]*u,i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);if(a<-1)for(var h=0;h<r;h++)n=e[2*h+1]=e[2*h+1]+(-1-a);return e},rZ=function(e,t){var n,r=1/e*2*Math.PI,i=e%2==0?Math.PI/2+r/2:Math.PI/2;i+=t;for(var a=Array(2*e),o=0;o<e;o++)n=o*r+i,a[2*o]=Math.cos(n),a[2*o+1]=Math.sin(-n);return a},rQ=function(e,t){return Math.min(e/4,t/4,8)},rJ=function(e,t){return Math.min(e/10,t/10,8)},r0=function(){return 8},r1=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}};function r2(e,t){function n(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length],a={x:i.x-r.x,y:i.y-r.y},o={x:-a.y,y:a.x},s=Math.sqrt(o.x*o.x+o.y*o.y);t.push({x:o.x/s,y:o.y/s})}return t}function r(e,t){var n,r=1/0,i=-1/0,a=tw(e);try{for(a.s();!(n=a.n()).done;){var o=n.value,s=o.x*t.x+o.y*t.y;r=Math.min(r,s),i=Math.max(i,s)}}catch(e){a.e(e)}finally{a.f()}return{min:r,max:i}}var i,a=tw([].concat(tk(n(e)),tk(n(t))));try{for(a.s();!(i=a.n()).done;){var o=i.value,s=r(e,o),l=r(t,o);if(s.max<l.min||l.max<s.min)return!1}}catch(e){a.e(e)}finally{a.f()}return!0}var r5=nz({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),r3=nz({root:null,weight:function(e){return 1},directed:!1,alpha:0}),r4={degreeCentralityNormalized:function(e){e=r3(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var i={},a={},o=0,s=0,l=0;l<r;l++){var c=n[l],u=c.id();e.root=c;var d=this.degreeCentrality(e);o<d.indegree&&(o=d.indegree),s<d.outdegree&&(s=d.outdegree),i[u]=d.indegree,a[u]=d.outdegree}return{indegree:function(e){return 0==o?0:(tL(e)&&(e=t.filter(e)),i[e.id()]/o)},outdegree:function(e){return 0===s?0:(tL(e)&&(e=t.filter(e)),a[e.id()]/s)}}}for(var h={},f=0,p=0;p<r;p++){var g=n[p];e.root=g;var v=this.degreeCentrality(e);f<v.degree&&(f=v.degree),h[g.id()]=v.degree}return{degree:function(e){return 0===f?0:(tL(e)&&(e=t.filter(e)),h[e.id()]/f)}}},degreeCentrality:function(e){e=r3(e);var t=this.cy(),n=this,r=e,i=r.root,a=r.weight,o=r.directed,s=r.alpha;if(i=t.collection(i)[0],o){for(var l=i.connectedEdges(),c=l.filter(function(e){return e.target().same(i)&&n.has(e)}),u=l.filter(function(e){return e.source().same(i)&&n.has(e)}),d=c.length,h=u.length,f=0,p=0,g=0;g<c.length;g++)f+=a(c[g]);for(var v=0;v<u.length;v++)p+=a(u[v]);return{indegree:Math.pow(d,1-s)*Math.pow(f,s),outdegree:Math.pow(h,1-s)*Math.pow(p,s)}}for(var x=i.connectedEdges().intersection(n),y=x.length,b=0,w=0;w<x.length;w++)b+=a(x[w]);return{degree:Math.pow(y,1-s)*Math.pow(b,s)}}};r4.dc=r4.degreeCentrality,r4.dcn=r4.degreeCentralityNormalised=r4.degreeCentralityNormalized;var r6=nz({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),r9={closenessCentralityNormalized:function(e){for(var t=r6(e),n=t.harmonic,r=t.weight,i=t.directed,a=this.cy(),o={},s=0,l=this.nodes(),c=this.floydWarshall({weight:r,directed:i}),u=0;u<l.length;u++){for(var d=0,h=l[u],f=0;f<l.length;f++)if(u!==f){var p=c.distance(h,l[f]);n?d+=1/p:d+=p}n||(d=1/d),s<d&&(s=d),o[h.id()]=d}return{closeness:function(e){return 0==s?0:o[e=tL(e)?a.filter(e)[0].id():e.id()]/s}}},closenessCentrality:function(e){var t=r6(e),n=t.root,r=t.weight,i=t.directed,a=t.harmonic;n=this.filter(n)[0];for(var o=this.dijkstra({root:n,weight:r,directed:i}),s=0,l=this.nodes(),c=0;c<l.length;c++){var u=l[c];if(!u.same(n)){var d=o.distanceTo(u);a?s+=1/d:s+=d}}return a?s:1/s}};r9.cc=r9.closenessCentrality,r9.ccn=r9.closenessCentralityNormalised=r9.closenessCentralityNormalized;var r7=nz({weight:null,directed:!1}),r8={betweennessCentrality:function(e){for(var t=r7(e),n=t.directed,r=t.weight,i=null!=r,a=this.cy(),o=this.nodes(),s={},l={},c=0,u=function(e,t){l[e]=t,t>c&&(c=t)},d=function(e){return l[e]},h=0;h<o.length;h++){var f=o[h],p=f.id();n?s[p]=f.outgoers().nodes():s[p]=f.openNeighborhood().nodes(),u(p,0)}for(var g=0;g<o.length;g++)!function(){for(var e=o[g].id(),t=[],n={},l={},c={},h=new n1(function(e,t){return c[e]-c[t]}),f=0;f<o.length;f++){var p=o[f].id();n[p]=[],l[p]=0,c[p]=1/0}for(l[e]=1,c[e]=0,h.push(e);!h.empty();){var v=h.pop();if(t.push(v),i)for(var x=0;x<s[v].length;x++){var y=s[v][x],b=a.getElementById(v),w=r(b.edgesTo(y).length>0?b.edgesTo(y)[0]:y.edgesTo(b)[0]);c[y=y.id()]>c[v]+w&&(c[y]=c[v]+w,0>h.nodes.indexOf(y)?h.push(y):h.updateItem(y),l[y]=0,n[y]=[]),c[y]==c[v]+w&&(l[y]=l[y]+l[v],n[y].push(v))}else for(var N=0;N<s[v].length;N++){var j=s[v][N].id();c[j]==1/0&&(h.push(j),c[j]=c[v]+1),c[j]==c[v]+1&&(l[j]=l[j]+l[v],n[j].push(v))}}for(var k={},C=0;C<o.length;C++)k[o[C].id()]=0;for(;t.length>0;){for(var E=t.pop(),T=0;T<n[E].length;T++){var S=n[E][T];k[S]=k[S]+l[S]/l[E]*(1+k[E])}E!=o[g].id()&&u(E,d(E)+k[E])}}();var v={betweenness:function(e){return d(a.collection(e).id())},betweennessNormalized:function(e){return 0==c?0:d(a.collection(e).id())/c}};return v.betweennessNormalised=v.betweennessNormalized,v}};r8.bc=r8.betweennessCentrality;var ie=nz({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),it=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},ir=function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n},ii=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var i=0;i<t;i++)n+=e[i*t+r];for(var a=0;a<t;a++)e[a*t+r]=e[a*t+r]/n}},ia=function(e,t,n){for(var r=Array(n*n),i=0;i<n;i++){for(var a=0;a<n;a++)r[i*n+a]=0;for(var o=0;o<n;o++)for(var s=0;s<n;s++)r[i*n+s]+=e[i*n+o]*t[o*n+s]}return r},io=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=ia(e,r,t);return e},is=function(e,t,n){for(var r=Array(t*t),i=0;i<t*t;i++)r[i]=Math.pow(e[i],n);return ii(r,t),r},il=function(e,t,n,r){for(var i=0;i<n;i++)if(Math.round(e[i]*Math.pow(10,r))/Math.pow(10,r)!=Math.round(t[i]*Math.pow(10,r))/Math.pow(10,r))return!1;return!0},ic=function(e,t,n,r){for(var i=[],a=0;a<t;a++){for(var o=[],s=0;s<t;s++)Math.round(1e3*e[a*t+s])/1e3>0&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i},iu=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},id=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&iu(e[t],e[n])&&e.splice(n,1);return e},ih=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=ie(e),a={},o=0;o<t.length;o++)a[t[o].id()]=o;for(var s,l=t.length,c=l*l,u=Array(c),d=0;d<c;d++)u[d]=0;for(var h=0;h<n.length;h++){var f=n[h],p=a[f.source().id()],g=a[f.target().id()],v=it(f,i.attributes);u[p*l+g]+=v,u[g*l+p]+=v}ir(u,l,i.multFactor),ii(u,l);for(var x=!0,y=0;x&&y<i.maxIterations;)x=!1,il(u=is(s=io(u,l,i.expandFactor),l,i.inflateFactor),s,c,4)||(x=!0),y++;var b=ic(u,l,t,r);return id(b)},ip=function(e){return e},ig=function(e,t){return Math.abs(t-e)},im=function(e,t,n){return e+ig(t,n)},iv=function(e,t,n){return e+Math.pow(n-t,2)},ix=function(e){return Math.sqrt(e)},iy=function(e,t,n){return Math.max(e,ig(t,n))},ib=function(e,t,n,r,i){for(var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:ip,o=r,s=0;s<e;s++)o=i(o,t(s),n(s));return a(o)},iw={euclidean:function(e,t,n){return e>=2?ib(e,t,n,0,iv,ix):ib(e,t,n,0,im)},squaredEuclidean:function(e,t,n){return ib(e,t,n,0,iv)},manhattan:function(e,t,n){return ib(e,t,n,0,im)},max:function(e,t,n){return ib(e,t,n,-1/0,iy)}};function iN(e,t,n,r,i,a){var o;return(o=tI(e)?e:iw[e]||iw.euclidean,0===t&&tI(e))?o(i,a):o(t,n,r,i,a)}iw["squared-euclidean"]=iw.squaredEuclidean,iw.squaredeuclidean=iw.squaredEuclidean;var ij=nz({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),ik=function(e){return ij(e)},iC=function(e,t,n,r,i){var a="kMedoids"!==i?function(e){return n[e]}:function(e){return r[e](n)};return iN(e,r.length,a,function(e){return r[e](t)},n,t)},iE=function(e,t,n){for(var r=n.length,i=Array(r),a=Array(r),o=Array(t),s=null,l=0;l<r;l++)i[l]=e.min(n[l]).value,a[l]=e.max(n[l]).value;for(var c=0;c<t;c++){s=[];for(var u=0;u<r;u++)s[u]=Math.random()*(a[u]-i[u])+i[u];o[c]=s}return o},iT=function(e,t,n,r,i){for(var a=1/0,o=0,s=0;s<t.length;s++){var l=iC(n,e,t[s],r,i);l<a&&(a=l,o=s)}return o},iS=function(e,t,n){for(var r=[],i=null,a=0;a<t.length;a++)n[(i=t[a]).id()]===e&&r.push(i);return r},i_=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++)if(Math.abs(e[r][i]-t[r][i])>n)return!1;return!0},iA=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},iD=function(e,t){var n=Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var i=e[Math.floor(Math.random()*e.length)];iA(i,n,r);)i=e[Math.floor(Math.random()*e.length)];n[r]=i}else for(var a=0;a<t;a++)n[a]=e[Math.floor(Math.random()*e.length)];return n},iM=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=iC("manhattan",t[i],e,n,"kMedoids");return r},iP=function(e,t,n,r,i){for(var a,o,s=0;s<t.length;s++)for(var l=0;l<e.length;l++)r[s][l]=Math.pow(n[s][l],i.m);for(var c=0;c<e.length;c++)for(var u=0;u<i.attributes.length;u++){a=0,o=0;for(var d=0;d<t.length;d++)a+=r[d][c]*i.attributes[u](t[d]),o+=r[d][c];e[c][u]=a/o}},iR=function(e,t,n,r,i){for(var a,o=0;o<e.length;o++)t[o]=e[o].slice();for(var s=2/(i.m-1),l=0;l<n.length;l++)for(var c=0;c<r.length;c++){a=0;for(var u=0;u<n.length;u++)a+=Math.pow(iC(i.distance,r[c],n[l],i.attributes,"cmeans")/iC(i.distance,r[c],n[u],i.attributes,"cmeans"),s);e[c][l]=1/a}},iL=function(e,t,n,r){for(var i,a,o=Array(n.k),s=0;s<o.length;s++)o[s]=[];for(var l=0;l<t.length;l++){i=-1/0,a=-1;for(var c=0;c<t[0].length;c++)t[l][c]>i&&(i=t[l][c],a=c);o[a].push(e[l])}for(var u=0;u<o.length;u++)o[u]=r.collection(o[u]);return o},iI=function(e){var t,n,r,i,a=this.cy(),o=this.nodes(),s=ik(e);r=Array(o.length);for(var l=0;l<o.length;l++)r[l]=Array(s.k);n=Array(o.length);for(var c=0;c<o.length;c++)n[c]=Array(s.k);for(var u=0;u<o.length;u++){for(var d=0,h=0;h<s.k;h++)n[u][h]=Math.random(),d+=n[u][h];for(var f=0;f<s.k;f++)n[u][f]=n[u][f]/d}t=Array(s.k);for(var p=0;p<s.k;p++)t[p]=Array(s.attributes.length);i=Array(o.length);for(var g=0;g<o.length;g++)i[g]=Array(s.k);for(var v=!0,x=0;v&&x<s.maxIterations;)v=!1,iP(t,o,n,i,s),iR(n,r,t,o,s),i_(n,r,s.sensitivityThreshold)||(v=!0),x++;return{clusters:iL(o,n,s,a),degreeOfMembership:n}},iO=nz({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),iB={single:"min",complete:"max"},iF=function(e){var t=iO(e),n=iB[t.linkage];return null!=n&&(t.linkage=n),t},iz=function(e,t,n,r,i){for(var a,o,s=0,l=1/0,c=i.attributes,u=function(e,t){return iN(i.distance,c.length,function(t){return c[t](e)},function(e){return c[e](t)},e,t)},d=0;d<e.length;d++){var h=e[d].key,f=n[h][r[h]];f<l&&(s=h,l=f)}if("threshold"===i.mode&&l>=i.threshold||"dendrogram"===i.mode&&1===e.length)return!1;var p=t[s],g=t[r[s]];o="dendrogram"===i.mode?{left:p,right:g,key:p.key}:{value:p.value.concat(g.value),key:p.key},e[p.index]=o,e.splice(g.index,1),t[p.key]=o;for(var v=0;v<e.length;v++){var x=e[v];p.key===x.key?a=1/0:"min"===i.linkage?(a=n[p.key][x.key],n[p.key][x.key]>n[g.key][x.key]&&(a=n[g.key][x.key])):"max"===i.linkage?(a=n[p.key][x.key],n[p.key][x.key]<n[g.key][x.key]&&(a=n[g.key][x.key])):a="mean"===i.linkage?(n[p.key][x.key]*p.size+n[g.key][x.key]*g.size)/(p.size+g.size):"dendrogram"===i.mode?u(x.value,p.value):u(x.value[0],p.value[0]),n[p.key][x.key]=n[x.key][p.key]=a}for(var y=0;y<e.length;y++){var b=e[y].key;if(r[b]===p.key||r[b]===g.key){for(var w=b,N=0;N<e.length;N++){var j=e[N].key;n[b][j]<n[b][w]&&(w=j)}r[b]=w}e[y].index=y}return p.key=g.key=p.index=g.index=null,!0},iV=function(e,t,n){e&&(e.value?t.push(e.value):(e.left&&iV(e.left,t),e.right&&iV(e.right,t)))},iH=function(e,t){if(!e)return"";if(e.left&&e.right){var n=iH(e.left,t),r=iH(e.right,t),i=t.add({group:"nodes",data:{id:n+","+r}});return t.add({group:"edges",data:{source:n,target:i.id()}}),t.add({group:"edges",data:{source:r,target:i.id()}}),i.id()}if(e.value)return e.value.id()},iU=function(e,t,n){if(!e)return[];var r=[],i=[],a=[];if(0===t)return e.left&&iV(e.left,r),e.right&&iV(e.right,i),a=r.concat(i),[n.collection(a)];if(1===t)if(e.value)return[n.collection(e.value)];else return e.left&&iV(e.left,r),e.right&&iV(e.right,i),[n.collection(r),n.collection(i)];return e.value?[n.collection(e.value)]:(e.left&&(r=iU(e.left,t-1,n)),e.right&&(i=iU(e.right,t-1,n)),r.concat(i))},iG=function(e){for(var t,n=this.cy(),r=this.nodes(),i=iF(e),a=i.attributes,o=function(e,t){return iN(i.distance,a.length,function(t){return a[t](e)},function(e){return a[e](t)},e,t)},s=[],l=[],c=[],u=[],d=0;d<r.length;d++){var h={value:"dendrogram"===i.mode?r[d]:[r[d]],key:d,index:d};s[d]=h,u[d]=h,l[d]=[],c[d]=0}for(var f=0;f<s.length;f++)for(var p=0;p<=f;p++){var g=void 0;g="dendrogram"===i.mode?f===p?1/0:o(s[f].value,s[p].value):f===p?1/0:o(s[f].value[0],s[p].value[0]),l[f][p]=g,l[p][f]=g,g<l[f][c[f]]&&(c[f]=p)}for(var v=iz(s,u,l,c,i);v;)v=iz(s,u,l,c,i);return"dendrogram"===i.mode?(t=iU(s[0],i.dendrogramDepth,n),i.addDendrogram&&iH(s[0],n)):(t=Array(s.length),s.forEach(function(e,r){e.key=e.index=null,t[r]=n.collection(e.value)})),t},iY=nz({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),iX=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||nP("Damping must range on [0.5, 1). Got: ".concat(t));var r=["median","mean","min","max"];return r.some(function(e){return e===n})||tF(n)||nP("Preference must be one of [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"] or a number. Got: ").concat(n)),iY(e)},iW=function(e,t,n,r){var i=function(e,t){return r[t](e)};return-iN(e,r.length,function(e){return i(t,e)},function(e){return i(n,e)},t,n)},iq=function(e,t){return"median"===t?ra(e):"mean"===t?ri(e):"min"===t?rn(e):"max"===t?rr(e):t},i$=function(e,t,n){for(var r=[],i=0;i<e;i++)t[i*e+i]+n[i*e+i]>0&&r.push(i);return r},iK=function(e,t,n){for(var r=[],i=0;i<e;i++){for(var a=-1,o=-1/0,s=0;s<n.length;s++){var l=n[s];t[i*e+l]>o&&(a=l,o=t[i*e+l])}a>0&&r.push(a)}for(var c=0;c<n.length;c++)r[n[c]]=n[c];return r},iZ=function(e,t,n){for(var r=iK(e,t,n),i=0;i<n.length;i++){for(var a=[],o=0;o<r.length;o++)r[o]===n[i]&&a.push(o);for(var s=-1,l=-1/0,c=0;c<a.length;c++){for(var u=0,d=0;d<a.length;d++)u+=t[a[d]*e+a[c]];u>l&&(s=c,l=u)}n[i]=a[s]}return iK(e,t,n)},iQ=function(e){for(var t,n,r,i,a,o,s,l=this.cy(),c=this.nodes(),u=iX(e),d={},h=0;h<c.length;h++)d[c[h].id()]=h;r=Array(n=(t=c.length)*t);for(var f=0;f<n;f++)r[f]=-1/0;for(var p=0;p<t;p++)for(var g=0;g<t;g++)p!==g&&(r[p*t+g]=iW(u.distance,c[p],c[g],u.attributes));i=iq(r,u.preference);for(var v=0;v<t;v++)r[v*t+v]=i;a=Array(n);for(var x=0;x<n;x++)a[x]=0;o=Array(n);for(var y=0;y<n;y++)o[y]=0;for(var b=Array(t),w=Array(t),N=Array(t),j=0;j<t;j++)b[j]=0,w[j]=0,N[j]=0;for(var k=Array(t*u.minIterations),C=0;C<k.length;C++)k[C]=0;for(s=0;s<u.maxIterations;s++){for(var E=0;E<t;E++){for(var T=-1/0,S=-1/0,_=-1,A=0,D=0;D<t;D++)b[D]=a[E*t+D],(A=o[E*t+D]+r[E*t+D])>=T?(S=T,T=A,_=D):A>S&&(S=A);for(var M=0;M<t;M++)a[E*t+M]=(1-u.damping)*(r[E*t+M]-T)+u.damping*b[M];a[E*t+_]=(1-u.damping)*(r[E*t+_]-S)+u.damping*b[_]}for(var P=0;P<t;P++){for(var R=0,L=0;L<t;L++)b[L]=o[L*t+P],w[L]=Math.max(0,a[L*t+P]),R+=w[L];R-=w[P],w[P]=a[P*t+P],R+=w[P];for(var I=0;I<t;I++)o[I*t+P]=(1-u.damping)*Math.min(0,R-w[I])+u.damping*b[I];o[P*t+P]=(1-u.damping)*(R-w[P])+u.damping*b[P]}for(var O=0,B=0;B<t;B++){var F=+(o[B*t+B]+a[B*t+B]>0);k[s%u.minIterations*t+B]=F,O+=F}if(O>0&&(s>=u.minIterations-1||s==u.maxIterations-1)){for(var z=0,V=0;V<t;V++){N[V]=0;for(var H=0;H<u.minIterations;H++)N[V]+=k[H*t+V];(0===N[V]||N[V]===u.minIterations)&&z++}if(z===t)break}}for(var U=i$(t,a,o),G=iZ(t,r,U),Y={},X=0;X<U.length;X++)Y[U[X]]=[];for(var W=0;W<c.length;W++){var q=G[d[c[W].id()]];null!=q&&Y[q].push(c[W])}for(var $=Array(U.length),K=0;K<U.length;K++)$[K]=l.collection(Y[U[K]]);return $},iJ=nz({root:void 0,directed:!1}),i0=function(){var e=this,t={},n=0,r=0,i=[],a=[],o={},s=function(n,r){for(var o=a.length-1,s=[],l=e.spawn();a[o].x!=n||a[o].y!=r;)s.push(a.pop().edge),o--;s.push(a.pop().edge),s.forEach(function(n){var r=n.connectedNodes().intersection(e);l.merge(n),r.forEach(function(n){var r=n.id(),i=n.connectedEdges().intersection(e);l.merge(n),t[r].cutVertex?l.merge(i.filter(function(e){return e.isLoop()})):l.merge(i)})}),i.push(l)},l=function(c,u,d){c===d&&(r+=1),t[u]={id:n,low:n++,cutVertex:!1};var h,f,p,g,v=e.getElementById(u).connectedEdges().intersection(e);0===v.size()?i.push(e.spawn(e.getElementById(u))):v.forEach(function(e){h=e.source().id(),f=e.target().id(),(p=h===u?f:h)!==d&&(o[g=e.id()]||(o[g]=!0,a.push({x:u,y:p,edge:e})),p in t?t[u].low=Math.min(t[u].low,t[p].id):(l(c,p,u),t[u].low=Math.min(t[u].low,t[p].low),t[u].id<=t[p].low&&(t[u].cutVertex=!0,s(u,p))))})};e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||(r=0,l(n,n),t[n].cutVertex=r>1)}});var c=Object.keys(t).filter(function(e){return t[e].cutVertex}).map(function(t){return e.getElementById(t)});return{cut:e.spawn(c),components:i}},i1=function(){var e=this,t={},n=0,r=[],i=[],a=e.spawn(e),o=function(s){if(i.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach(function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))}),t[s].index===t[s].low){for(var l=e.spawn();;){var c=i.pop();if(l.merge(e.getElementById(c)),t[c].low=t[s].index,t[c].explored=!0,c===s)break}var u=l.edgesWith(l),d=l.merge(u);r.push(d),a=a.difference(d)}};return e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||o(n)}}),{cut:a,components:r}},i2={};[nQ,{dijkstra:function(e){if(!tB(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=n2(e),r=n.root,i=n.weight,a=n.directed,o=this,s=tL(r)?this.filter(r)[0]:r[0],l={},c={},u={},d=this.byGroup(),h=d.nodes,f=d.edges;f.unmergeBy(function(e){return e.isLoop()});for(var p=function(e){return l[e.id()]},g=new n1(function(e,t){return p(e)-p(t)}),v=0;v<h.length;v++){var x=h[v];l[x.id()]=x.same(s)?0:1/0,g.push(x)}for(;g.size()>0;){var y=g.pop(),b=p(y);if(u[y.id()]=b,b!==1/0)for(var w=y.neighborhood().intersect(h),N=0;N<w.length;N++){var j=w[N],k=j.id(),C=function(e,t){for(var n,r=(a?e.edgesTo(t):e.edgesWith(t)).intersect(f),o=1/0,s=0;s<r.length;s++){var l=r[s],c=i(l);(c<o||!n)&&(o=c,n=l)}return{edge:n,dist:o}}(y,j),E=b+C.dist;E<p(j)&&(l[j.id()]=E,g.updateItem(j),c[k]={node:y,edge:C.edge})}}return{distanceTo:function(e){return u[(tL(e)?h.filter(e)[0]:e[0]).id()]},pathTo:function(e){var t=tL(e)?h.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(t.length>0)for(n.unshift(t);c[i];){var a=c[i];n.unshift(a.edge),n.unshift(a.node),i=(r=a.node).id()}return o.spawn(n)}}}},{kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,a=Array(i),o=function(e){for(var t=0;t<a.length;t++)if(a[t].has(e))return t},s=0;s<i;s++)a[s]=this.spawn(n[s]);for(var l=r.sort(function(t,n){return e(t)-e(n)}),c=0;c<l.length;c++){var u=l[c],d=u.source()[0],h=u.target()[0],f=o(d),p=o(h),g=a[f],v=a[p];f!==p&&(n.merge(u),g.merge(v),a.splice(p,1))}return n}},{aStar:function(e){var t,n,r=this.cy(),i=n5(e),a=i.root,o=i.goal,s=i.heuristic,l=i.directed,c=i.weight;a=r.collection(a)[0],o=r.collection(o)[0];var u=a.id(),d=o.id(),h={},f={},p={},g=new n1(function(e,t){return f[e.id()]-f[t.id()]}),v=new n$,x={},y={},b=function(e,t){g.push(e),v.add(t)};b(a,u),h[u]=0,f[u]=s(a);for(var w=0;g.size()>0;){if(n=(t=g.pop()).id(),v.delete(n),w++,n===d){for(var N=[],j=o,k=d,C=y[k];N.unshift(j),null!=C&&N.unshift(C),null!=(j=x[k]);)C=y[k=j.id()];return{found:!0,distance:h[n],path:this.spawn(N),steps:w}}p[n]=!0;for(var E=t._private.edges,T=0;T<E.length;T++){var S=E[T];if(this.hasElementWithId(S.id())&&(!l||S.data("source")===n)){var _=S.source(),A=S.target(),D=_.id()!==n?_:A,M=D.id();if(this.hasElementWithId(M)&&!p[M]){var P=h[n]+c(S);if(!v.has(M)){h[M]=P,f[M]=P+s(D),b(D,M),x[M]=t,y[M]=S;continue}P<h[M]&&(h[M]=P,f[M]=P+s(D),x[M]=t,y[M]=S)}}}}return{found:!1,distance:void 0,path:void 0,steps:w}}},{floydWarshall:function(e){for(var t=this.cy(),n=n3(e),r=n.weight,i=n.directed,a=this.byGroup(),o=a.nodes,s=a.edges,l=o.length,c=l*l,u=function(e){return o.indexOf(e)},d=function(e){return o[e]},h=Array(c),f=0;f<c;f++){var p=f%l;(f-p)/l===p?h[f]=0:h[f]=1/0}for(var g=Array(c),v=Array(c),x=0;x<s.length;x++){var y=s[x],b=y.source()[0],w=y.target()[0];if(b!==w){var N=u(b),j=u(w),k=N*l+j,C=r(y);if(h[k]>C&&(h[k]=C,g[k]=j,v[k]=y),!i){var E=j*l+N;!i&&h[E]>C&&(h[E]=C,g[E]=N,v[E]=y)}}}for(var T=0;T<l;T++)for(var S=0;S<l;S++)for(var _=S*l+T,A=0;A<l;A++){var D=S*l+A,M=T*l+A;h[_]+h[M]<h[D]&&(h[D]=h[_]+h[M],g[D]=g[_])}var P=function(e){return u((tL(e)?t.filter(e):e)[0])};return{distance:function(e,t){return h[P(e)*l+P(t)]},path:function(e,n){var r,i=P(e),a=P(n),o=d(i);if(i===a)return o.collection();if(null==g[i*l+a])return t.collection();var s=t.collection(),c=i;for(s.merge(o);i!==a;)c=i,i=g[i*l+a],r=v[c*l+i],s.merge(r),s.merge(d(i));return s}}}},{bellmanFord:function(e){var t=this,n=n4(e),r=n.weight,i=n.directed,a=n.root,o=this,s=this.cy(),l=this.byGroup(),c=l.edges,u=l.nodes,d=u.length,h=new nW,f=!1,p=[];a=s.collection(a)[0],c.unmergeBy(function(e){return e.isLoop()});for(var g=c.length,v=function(e){var t=h.get(e.id());return t||(t={},h.set(e.id(),t)),t},x=function(e){return(tL(e)?s.$(e):e)[0]},y=0;y<d;y++){var b=u[y],w=v(b);b.same(a)?w.dist=0:w.dist=1/0,w.pred=null,w.edge=null}for(var N=!1,j=function(e,t,n,r,i,a){var o=r.dist+a;o<i.dist&&!n.same(r.edge)&&(i.dist=o,i.pred=e,i.edge=n,N=!0)},k=1;k<d;k++){N=!1;for(var C=0;C<g;C++){var E=c[C],T=E.source(),S=E.target(),_=r(E),A=v(T),D=v(S);j(T,S,E,A,D,_),i||j(S,T,E,D,A,_)}if(!N)break}if(N)for(var M=[],P=0;P<g;P++){var R=c[P],L=R.source(),I=R.target(),O=r(R),B=v(L).dist,F=v(I).dist;if(B+O<F||!i&&F+O<B)if(f||(nL("Graph contains a negative weight cycle for Bellman-Ford"),f=!0),!1!==e.findNegativeWeightCycles){var z=[];B+O<F&&z.push(L),!i&&F+O<B&&z.push(I);for(var V=z.length,H=0;H<V;H++){var U=z[H],G=[U];G.push(v(U).edge);for(var Y=v(U).pred;-1===G.indexOf(Y);)G.push(Y),G.push(v(Y).edge),Y=v(Y).pred;for(var X=(G=G.slice(G.indexOf(Y)))[0].id(),W=0,q=2;q<G.length;q+=2)G[q].id()<X&&(X=G[q].id(),W=q);(G=G.slice(W).concat(G.slice(0,W))).push(G[0]);var $=G.map(function(e){return e.id()}).join(",");-1===M.indexOf($)&&(p.push(o.spawn(G)),M.push($))}}else break}return{distanceTo:function(e){return v(x(e)).dist},pathTo:function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,r=x(e),i=[],s=r;;){if(null==s)return t.spawn();var l=v(s),c=l.edge,u=l.pred;if(i.unshift(s[0]),s.same(n)&&i.length>0)break;null!=c&&i.unshift(c),s=u}return o.spawn(i)},hasNegativeWeightCycle:f,negativeWeightCycles:p}}},{kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy(function(e){return e.isLoop()});var i=n.length,a=r.length,o=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),s=Math.floor(i/n6);if(i<2)return void nP("At least 2 nodes are required for Karger-Stein algorithm");for(var l=[],c=0;c<a;c++){var u=r[c];l.push([c,n.indexOf(u.source()),n.indexOf(u.target())])}for(var d=1/0,h=[],f=Array(i),p=Array(i),g=Array(i),v=function(e,t){for(var n=0;n<i;n++)t[n]=e[n]},x=0;x<=o;x++){for(var y=0;y<i;y++)p[y]=y;var b=n7(p,l.slice(),i,s),w=b.slice();v(p,g);var N=n7(p,b,s,2),j=n7(g,w,s,2);N.length<=j.length&&N.length<d?(d=N.length,h=N,v(p,f)):j.length<=N.length&&j.length<d&&(d=j.length,h=j,v(g,f))}for(var k=this.spawn(h.map(function(e){return r[e[0]]})),C=this.spawn(),E=this.spawn(),T=f[0],S=0;S<f.length;S++){var _=f[S],A=n[S];_===T?C.merge(A):E.merge(A)}var D=function(t){var n=e.spawn();return t.forEach(function(t){n.merge(t),t.connectedEdges().forEach(function(t){e.contains(t)&&!k.contains(t)&&n.merge(t)})}),n};return{cut:k,components:[D(C),D(E)],partition1:C,partition2:E}}},{pageRank:function(e){for(var t,n=r5(e),r=n.dampingFactor,i=n.precision,a=n.iterations,o=n.weight,s=this._private.cy,l=this.byGroup(),c=l.nodes,u=l.edges,d=c.length,h=d*d,f=u.length,p=Array(h),g=Array(d),v=(1-r)/d,x=0;x<d;x++){for(var y=0;y<d;y++)p[x*d+y]=0;g[x]=0}for(var b=0;b<f;b++){var w=u[b],N=w.data("source"),j=w.data("target");if(N!==j){var k=c.indexOfId(N),C=c.indexOfId(j),E=o(w),T=C*d+k;p[T]+=E,g[k]+=E}}for(var S=1/d+v,_=0;_<d;_++)if(0===g[_])for(var A=0;A<d;A++)p[A*d+_]=S;else for(var D=0;D<d;D++){var M=D*d+_;p[M]=p[M]/g[_]+v}for(var P=Array(d),R=Array(d),L=0;L<d;L++)P[L]=1;for(var I=0;I<a;I++){for(var O=0;O<d;O++)R[O]=0;for(var B=0;B<d;B++)for(var F=0;F<d;F++){var z=B*d+F;R[B]+=p[z]*P[F]}rd(R),t=P,P=R,R=t;for(var V=0,H=0;H<d;H++){var U=t[H]-P[H];V+=U*U}if(V<i)break}return{rank:function(e){return e=s.collection(e)[0],P[c.indexOf(e)]}}}},r4,r9,r8,{markovClustering:ih,mcl:ih},{kMeans:function(e){var t,n=this.cy(),r=this.nodes(),i=null,a=ik(e),o=Array(a.k),s={};a.testMode?"number"==typeof a.testCentroids?(a.testCentroids,t=iE(r,a.k,a.attributes)):t="object"===tE(a.testCentroids)?a.testCentroids:iE(r,a.k,a.attributes):t=iE(r,a.k,a.attributes);for(var l=!0,c=0;l&&c<a.maxIterations;){for(var u=0;u<r.length;u++)s[(i=r[u]).id()]=iT(i,t,a.distance,a.attributes,"kMeans");l=!1;for(var d=0;d<a.k;d++){var h=iS(d,r,s);if(0!==h.length){for(var f=a.attributes.length,p=t[d],g=Array(f),v=Array(f),x=0;x<f;x++){v[x]=0;for(var y,b=0;b<h.length;b++)i=h[b],v[x]+=a.attributes[x](i);g[x]=v[x]/h.length,y=g[x],Math.abs(p[x]-y)<=a.sensitivityThreshold||(l=!0)}t[d]=g,o[d]=n.collection(h)}}c++}return o},kMedoids:function(e){var t,n,r=this.cy(),i=this.nodes(),a=null,o=ik(e),s=Array(o.k),l={},c=Array(o.k);o.testMode?"number"==typeof o.testCentroids||(t="object"===tE(o.testCentroids)?o.testCentroids:iD(i,o.k)):t=iD(i,o.k);for(var u=!0,d=0;u&&d<o.maxIterations;){for(var h=0;h<i.length;h++)l[(a=i[h]).id()]=iT(a,t,o.distance,o.attributes,"kMedoids");u=!1;for(var f=0;f<t.length;f++){var p=iS(f,i,l);if(0!==p.length){c[f]=iM(t[f],p,o.attributes);for(var g=0;g<p.length;g++)(n=iM(p[g],p,o.attributes))<c[f]&&(c[f]=n,t[f]=p[g],u=!0);s[f]=r.collection(p)}}d++}return s},fuzzyCMeans:iI,fcm:iI},{hierarchicalClustering:iG,hca:iG},{affinityPropagation:iQ,ap:iQ},{hierholzer:function(e){if(!tB(e)){var t,n,r,i=arguments;e={root:i[0],directed:i[1]}}var a=iJ(e),o=a.root,s=a.directed,l=!1;o&&(r=tL(o)?this.filter(o)[0].id():o[0].id());var c={},u={};s?this.forEach(function(e){var r=e.id();if(e.isNode()){var i=e.indegree(!0),a=e.outdegree(!0),o=i-a,s=a-i;1==o?t?l=!0:t=r:1==s?n?l=!0:n=r:(s>1||o>1)&&(l=!0),c[r]=[],e.outgoers().forEach(function(e){e.isEdge()&&c[r].push(e.id())})}else u[r]=[void 0,e.target().id()]}):this.forEach(function(e){var r=e.id();e.isNode()?(e.degree(!0)%2&&(t?n?l=!0:n=r:t=r),c[r]=[],e.connectedEdges().forEach(function(e){return c[r].push(e.id())})):u[r]=[e.source().id(),e.target().id()]});var d={found:!1,trail:void 0};if(l)return d;if(n&&t)if(s){if(r&&n!=r)return d;r=n}else{if(r&&n!=r&&t!=r)return d;r||(r=n)}else r||(r=this[0].id());var h=function(e){for(var t,n,r,i=e,a=[e];c[i].length;)n=u[t=c[i].shift()][0],i!=(r=u[t][1])?(c[r]=c[r].filter(function(e){return e!=t}),i=r):s||i==n||(c[n]=c[n].filter(function(e){return e!=t}),i=n),a.unshift(t),a.unshift(i);return a},f=[],p=[];for(p=h(r);1!=p.length;)0==c[p[0]].length?(f.unshift(this.getElementById(p.shift())),f.unshift(this.getElementById(p.shift()))):p=h(p.shift()).concat(p);for(var g in f.unshift(this.getElementById(p.shift())),c)if(c[g].length)return d;return d.found=!0,d.trail=this.spawn(f,!0),d}},{hopcroftTarjanBiconnected:i0,htbc:i0,htb:i0,hopcroftTarjanBiconnectedComponents:i0},{tarjanStronglyConnected:i1,tsc:i1,tscc:i1,tarjanStronglyConnectedComponents:i1}].forEach(function(e){t6(i2,e)});var i5=function(e){if(!(this instanceof i5))return new i5(e);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};i5.prototype={fulfill:function(e){return i3(this,1,"fulfillValue",e)},reject:function(e){return i3(this,2,"rejectReason",e)},then:function(e,t){var n=new i5;return this.onFulfilled.push(i9(e,n,"fulfill")),this.onRejected.push(i9(t,n,"reject")),i4(this),n.proxy}};var i3=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,i4(e)),e},i4=function(e){1===e.state?i6(e,"onFulfilled",e.fulfillValue):2===e.state&&i6(e,"onRejected",e.rejectReason)},i6=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var i=function(){for(var e=0;e<r.length;e++)r[e](n)};"function"==typeof setImmediate?setImmediate(i):setTimeout(i,0)}},i9=function(e,t,n){return function(r){if("function"!=typeof e)t[n].call(t,r);else{var i;try{i=e(r)}catch(e){t.reject(e);return}i7(t,i)}}},i7=function(e,t){if(e===t||e.proxy===t)return void e.reject(TypeError("cannot resolve promise with itself"));if("object"===tE(t)&&null!==t||"function"==typeof t)try{n=t.then}catch(t){e.reject(t);return}if("function"==typeof n){var n,r=!1;try{n.call(t,function(n){r||(r=!0,n===t?e.reject(TypeError("circular thenable chain")):i7(e,n))},function(t){r||(r=!0,e.reject(t))})}catch(t){r||e.reject(t)}return}e.fulfill(t)};i5.all=function(e){return new i5(function(t,n){for(var r=Array(e.length),i=0,a=function(n,a){r[n]=a,++i===e.length&&t(r)},o=0;o<e.length;o++)!function(t){var r=e[t];null!=r&&null!=r.then?r.then(function(e){a(t,e)},function(e){n(e)}):a(t,r)}(o)})},i5.resolve=function(e){return new i5(function(t,n){t(e)})},i5.reject=function(e){return new i5(function(t,n){n(e)})};var i8="u">typeof Promise?Promise:i5,ae=function(e,t,n){var r=tG(e),i=this._private=t6({duration:1e3},t,n);if(i.target=e,i.style=i.style||i.css,i.started=!1,i.playing=!1,i.hooked=!1,i.applying=!1,i.progress=0,i.completes=[],i.frames=[],i.complete&&tI(i.complete)&&i.completes.push(i.complete),!r){var a=e.position();i.startPosition=i.startPosition||{x:a.x,y:a.y},i.startStyle=i.startStyle||e.cy().style().getAnimationStartStyle(e,i.style)}if(r){var o=e.pan();i.startPan={x:o.x,y:o.y},i.startZoom=e.zoom()}this.length=1,this[0]=this},at=ae.prototype;function an(){return l_?lS:(l_=1,lS=Array.isArray)}function ar(){if(lY)return lG;lY=1;var e=function(){if(lV)return lz;lV=1;var e=function(){if(lP)return lM;lP=1;var e=nc(),t=no();return lM=function(n){if(!t(n))return!1;var r=e(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}(),t=function(){if(lO)return lI;lO=1;var e,t=lL?lR:(lL=1,lR=ns()["__core-js_shared__"]),n=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return lI=function(e){return!!n&&n in e}}(),n=no(),r=function(){if(lF)return lB;lF=1;var e=Function.prototype.toString;return lB=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,a=Object.prototype,o=Function.prototype.toString,s=a.hasOwnProperty,l=RegExp("^"+o.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return lz=function(a){return!(!n(a)||t(a))&&(e(a)?l:i).test(r(a))}}(),t=lU?lH:(lU=1,lH=function(e,t){return null==e?void 0:e[t]});return lG=function(n,r){var i=t(n,r);return e(i)?i:void 0}}function ai(){return lW?lX:(lW=1,lX=ar()(Object,"create"))}function aa(){return l8?l7:(l8=1,l7=function(e,t){return e===t||e!=e&&t!=t})}function ao(){if(ct)return ce;ct=1;var e=aa();return ce=function(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return -1}}function as(){if(cy)return cx;cy=1;var e=cv?cm:(cv=1,cm=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return cx=function(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map}}function al(){if(cL)return cR;cL=1;var e=function(){if(cP)return cM;cP=1;var e=function(){if(cD)return cA;cD=1;var e=function(){if(c_)return cS;c_=1;var e=function(){if(cg)return cp;cg=1;var e=function(){if(l4)return l3;l4=1;var e=function(){if(l$)return lq;l$=1;var e=ai();return lq=function(){this.__data__=e?e(null):{},this.size=0}}(),t=lZ?lK:(lZ=1,lK=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t}),n=function(){if(lJ)return lQ;lJ=1;var e=ai(),t=Object.prototype.hasOwnProperty;return lQ=function(n){var r=this.__data__;if(e){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(r,n)?r[n]:void 0}}(),r=function(){if(l1)return l0;l1=1;var e=ai(),t=Object.prototype.hasOwnProperty;return l0=function(n){var r=this.__data__;return e?void 0!==r[n]:t.call(r,n)}}(),i=function(){if(l5)return l2;l5=1;var e=ai();return l2=function(t,n){var r=this.__data__;return this.size+=+!this.has(t),r[t]=e&&void 0===n?"__lodash_hash_undefined__":n,this}}();function a(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,l3=a}(),t=function(){if(cd)return cu;cd=1;var e=l9?l6:(l9=1,l6=function(){this.__data__=[],this.size=0}),t=function(){if(cr)return cn;cr=1;var e=ao(),t=Array.prototype.splice;return cn=function(n){var r=this.__data__,i=e(r,n);return!(i<0)&&(i==r.length-1?r.pop():t.call(r,i,1),--this.size,!0)}}(),n=function(){if(ca)return ci;ca=1;var e=ao();return ci=function(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}}(),r=function(){if(cs)return co;cs=1;var e=ao();return co=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(cc)return cl;cc=1;var e=ao();return cl=function(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this}}();function a(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,cu=a}(),n=cf?ch:(cf=1,ch=ar()(ns(),"Map"));return cp=function(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}}(),t=function(){if(cw)return cb;cw=1;var e=as();return cb=function(t){var n=e(this,t).delete(t);return this.size-=!!n,n}}(),n=function(){if(cj)return cN;cj=1;var e=as();return cN=function(t){return e(this,t).get(t)}}(),r=function(){if(cC)return ck;cC=1;var e=as();return ck=function(t){return e(this,t).has(t)}}(),i=function(){if(cT)return cE;cT=1;var e=as();return cE=function(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=+(r.size!=i),this}}();function a(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,cS=a}();function t(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw TypeError("Expected a function");var i=function(){var e=arguments,t=r?r.apply(this,e):e[0],a=i.cache;if(a.has(t))return a.get(t);var o=n.apply(this,e);return i.cache=a.set(t,o)||a,o};return i.cache=new(t.Cache||e),i}return t.Cache=e,cA=t}();return cM=function(t){var n=e(t,function(e){return 500===r.size&&r.clear(),e}),r=n.cache;return n}}(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g;return cR=e(function(e){var r=[];return 46===e.charCodeAt(0)&&r.push(""),e.replace(t,function(e,t,i,a){r.push(i?a.replace(n,"$1"):t||e)}),r})}function ac(){return cO?cI:(cO=1,cI=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i})}function au(){if(cV)return cz;cV=1;var e=function(){if(cF)return cB;cF=1;var e=nl(),t=ac(),n=an(),r=nu(),i=e?e.prototype:void 0,a=i?i.toString:void 0;return cB=function e(i){if("string"==typeof i)return i;if(n(i))return t(i,e)+"";if(r(i))return a?a.call(i):"";var o=i+"";return"0"==o&&1/i==-1/0?"-0":o}}();return cz=function(t){return null==t?"":e(t)}}function ad(){if(cU)return cH;cU=1;var e=an(),t=function(){if(lD)return lA;lD=1;var e=an(),t=nu(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return lA=function(i,a){if(e(i))return!1;var o=typeof i;return!!("number"==o||"symbol"==o||"boolean"==o||null==i||t(i))||r.test(i)||!n.test(i)||null!=a&&i in Object(a)}}(),n=al(),r=au();return cH=function(i,a){return e(i)?i:t(i,a)?[i]:n(r(i))}}function ah(){if(cY)return cG;cY=1;var e=nu();return cG=function(t){if("string"==typeof t||e(t))return t;var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}}t6(at,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t=e.target._private.animation;(e.queue?t.queue:t.current).push(this),tV(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return 1===e.progress&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return void 0===e?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,n=t.playing;return void 0===e?t.progress:(n&&this.pause(),t.progress=e,t.started=!1,n&&this.play(),this)},completed:function(){return 1===this._private.progress},reverse:function(){var e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(t,n){var r=e[t];null!=r&&(e[t]=e[n],e[n]=r)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var r=0;r<e.style.length;r++){var i=e.style[r],a=i.name,o=e.startStyle[a];e.startStyle[a]=i,e.style[r]=o}return t&&this.play(),this},promise:function(e){var t,n=this._private;return t="frame"===e?n.frames:n.completes,new i8(function(e,n){t.push(function(){e()})})}}),at.complete=at.completed,at.run=at.play,at.running=at.playing;var af=na(function(){if(c$)return cq;c$=1;var e=function(){if(cW)return cX;cW=1;var e=ad(),t=ah();return cX=function(n,r){r=e(r,n);for(var i=0,a=r.length;null!=n&&i<a;)n=n[t(r[i++])];return i&&i==a?n:void 0}}();return cq=function(t,n,r){var i=null==t?void 0:e(t,n);return void 0===i?r:i}}()),ap=na(function(){if(c9)return c6;c9=1;var e=function(){if(c4)return c3;c4=1;var e=function(){if(c1)return c0;c1=1;var e=function(){if(cJ)return cQ;cJ=1;var e=function(){if(cZ)return cK;cZ=1;var e=ar();return cK=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}()}();return cQ=function(t,n,r){"__proto__"==n&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}}(),t=aa(),n=Object.prototype.hasOwnProperty;return c0=function(r,i,a){var o=r[i];n.call(r,i)&&t(o,a)&&(void 0!==a||i in r)||e(r,i,a)}}(),t=ad(),n=function(){if(c5)return c2;c5=1;var e=/^(?:0|[1-9]\d*)$/;return c2=function(t,n){var r=typeof t;return!!(n=null==n?0x1fffffffffffff:n)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n}}(),r=no(),i=ah();return c3=function(a,o,s,l){if(!r(a))return a;o=t(o,a);for(var c=-1,u=o.length,d=u-1,h=a;null!=h&&++c<u;){var f=i(o[c]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)break;if(c!=d){var g=h[f];void 0===(p=l?l(g,f,h):void 0)&&(p=r(g)?g:n(o[c+1])?[]:{})}e(h,f,p),h=h[f]}return a}}();return c6=function(t,n,r){return null==t?t:e(t,n,r)}}()),ag=na(function(){if(ut)return ue;ut=1;var e=ac(),t=c8?c7:(c8=1,c7=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}),n=an(),r=nu(),i=al(),a=ah(),o=au();return ue=function(s){return n(s)?e(s,a):r(s)?[s]:t(i(o(s)))}}()),am={};[{animated:function(){return function(){var e=void 0!==this.length;if(!(this._private.cy||this).styleEnabled())return!1;var t=(e?this:[this])[0];if(t)return t._private.animation.current.length>0}},clearQueue:function(){return function(){var e=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;for(var t=0;t<e.length;t++)e[t]._private.animation.queue=[];return this}},delay:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=void 0!==this.length,r=n?this:[this],i=this._private.cy||this,a=!n,o=!a;if(!i.styleEnabled())return this;var s=i.style();if(0===Object.keys(e=t6({},e,t)).length)return new ae(r[0],e);switch(void 0===e.duration&&(e.duration=400),e.duration){case"slow":e.duration=600;break;case"fast":e.duration=200}if(o&&(e.style=s.getPropsList(e.style||e.css),e.css=void 0),o&&null!=e.renderedPosition){var l=e.renderedPosition,c=i.pan(),u=i.zoom();e.position=re(l,u,c)}if(a&&null!=e.panBy){var d=e.panBy,h=i.pan();e.pan={x:h.x+d.x,y:h.y+d.y}}var f=e.center||e.centre;if(a&&null!=f){var p=i.getCenterPan(f.eles,e.zoom);null!=p&&(e.pan=p)}if(a&&null!=e.fit){var g=e.fit,v=i.getFitViewport(g.eles||g.boundingBox,g.padding);null!=v&&(e.pan=v.pan,e.zoom=v.zoom)}if(a&&tB(e.zoom)){var x=i.getZoomedViewport(e.zoom);null!=x?(x.zoomed&&(e.zoom=x.zoom),x.panned&&(e.pan=x.pan)):e.zoom=null}return new ae(r[0],e)}},animate:function(){return function(e,t){var n=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;t&&(e=t6({},e,t));for(var r=0;r<n.length;r++){var i=n[r],a=i.animated()&&(void 0===e.queue||e.queue);i.animation(e,a?{queue:!0}:void 0).play()}return this}},stop:function(){return function(e,t){var n=void 0!==this.length?this:[this],r=this._private.cy||this;if(!r.styleEnabled())return this;for(var i=0;i<n.length;i++){for(var a=n[i]._private,o=a.animation.current,s=0;s<o.length;s++){var l=o[s]._private;t&&(l.duration=0)}e&&(a.animation.queue=[]),t||(a.animation.current=[])}return r.notify("draw"),this}}},{data:function(e){return e=t6({},{field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},e),function(t,n){var r,i=e,a=void 0!==this.length,o=a?this:[this],s=a?this[0]:this;if(tL(t)){var l,c=-1!==t.indexOf(".")&&ag(t);if(i.allowGetting&&void 0===n)return s&&(i.beforeGet(s),l=c&&void 0===s._private[i.field][t]?af(s._private[i.field],c):s._private[i.field][t]),l;if(i.allowSetting&&void 0!==n&&!i.immutableKeys[t]){var u=tN({},t,n);i.beforeSet(this,u);for(var d=0,h=o.length;d<h;d++){var f=o[d];i.canSet(f)&&(c&&void 0===s._private[i.field][t]?ap(f._private[i.field],c,n):f._private[i.field][t]=n)}i.updateStyle&&this.updateStyle(),i.onSet(this),i.settingTriggersEvent&&this[i.triggerFnName](i.settingEvent)}}else if(i.allowSetting&&tB(t)){var p,g,v=Object.keys(t);i.beforeSet(this,t);for(var x=0;x<v.length;x++)if(g=t[p=v[x]],!i.immutableKeys[p])for(var y=0;y<o.length;y++){var b=o[y];i.canSet(b)&&(b._private[i.field][p]=g)}i.updateStyle&&this.updateStyle(),i.onSet(this),i.settingTriggersEvent&&this[i.triggerFnName](i.settingEvent)}else if(i.allowBinding&&tI(t))this.on(i.bindingEvent,t);else if(i.allowGetting&&void 0===t)return s&&(i.beforeGet(s),r=s._private[i.field]),r;return this}},removeData:function(e){return e=t6({},{field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}},e),function(t){var n=e,r=void 0!==this.length?this:[this];if(tL(t)){for(var i=t.split(/\s+/),a=i.length,o=0;o<a;o++){var s=i[o];if(!tX(s)&&!n.immutableKeys[s])for(var l=0,c=r.length;l<c;l++)r[l]._private[n.field][s]=void 0}n.triggerEvent&&this[n.triggerFnName](n.event)}else if(void 0===t){for(var u=0,d=r.length;u<d;u++)for(var h=r[u]._private[n.field],f=Object.keys(h),p=0;p<f.length;p++){var g=f[p];n.immutableKeys[g]||(h[g]=void 0)}n.triggerEvent&&this[n.triggerFnName](n.event)}return this}}},{eventAliasesOn:function(e){e.addListener=e.listen=e.bind=e.on,e.unlisten=e.unbind=e.off=e.removeListener,e.trigger=e.emit,e.pon=e.promiseOn=function(e,t){var n=this,r=Array.prototype.slice.call(arguments,0);return new i8(function(e,t){var i=r.concat([function(t){n.off.apply(n,a),e(t)}]),a=i.concat([]);n.on.apply(n,i)})}}}].forEach(function(e){t6(am,e)});var av={animate:am.animate(),animation:am.animation(),animated:am.animated(),clearQueue:am.clearQueue(),delay:am.delay(),delayAnimation:am.delayAnimation(),stop:am.stop()},ax={classes:function(e){if(void 0===e){var t=[];return this[0]._private.classes.forEach(function(e){return t.push(e)}),t}tO(e)||(e=(e||"").match(/\S+/g)||[]);for(var n=[],r=new n$(e),i=0;i<this.length;i++){for(var a=this[i],o=a._private,s=o.classes,l=!1,c=0;c<e.length;c++){var u=e[c];if(!s.has(u)){l=!0;break}}l||(l=s.size!==e.length),l&&(o.classes=r,n.push(a))}return n.length>0&&this.spawn(n).updateStyle().emit("class"),this},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){tO(e)||(e=e.match(/\S+/g)||[]);for(var n=void 0===t,r=[],i=0,a=this.length;i<a;i++)for(var o=this[i],s=o._private.classes,l=!1,c=0;c<e.length;c++){var u=e[c],d=s.has(u),h=!1;t||n&&!d?(s.add(u),h=!0):(!t||n&&d)&&(s.delete(u),h=!0),!l&&h&&(r.push(o),l=!0)}return r.length>0&&this.spawn(r).updateStyle().emit("class"),this},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n}};ax.className=ax.classNames=ax.classes;var ay={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:t0,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};for(s4=0,ay.variable="(?:[\\w-.]|(?:\\\\"+ay.metaChar+"))+",ay.className="(?:[\\w-]|(?:\\\\"+ay.metaChar+"))+",ay.value=ay.string+"|"+ay.number,ay.id=ay.variable,s5=ay.comparatorOp.split("|");s4<s5.length;s4++)s3=s5[s4],ay.comparatorOp+="|@"+s3;for(s4=0,s5=ay.comparatorOp.split("|");s4<s5.length;s4++)(s3=s5[s4]).indexOf("!")>=0||"="!==s3&&(ay.comparatorOp+="|\\!"+s3);var ab=function(){return{checks:[]}},aw=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort(function(e,t){return -1*t4(e.selector,t.selector)}),aN=function(){for(var e,t={},n=0;n<aw.length;n++)t[(e=aw[n]).selector]=e.matches;return t}(),aj="("+aw.map(function(e){return e.selector}).join("|")+")",ak=function(e){return e.replace(RegExp("\\\\("+ay.metaChar+")","g"),function(e,t){return t})},aC=function(e,t,n){e[e.length-1]=n},aE=[{name:"group",query:!0,regex:"("+ay.group+")",populate:function(e,t,n){var r=tj(n,1)[0];t.checks.push({type:0,value:"*"===r?r:r+"s"})}},{name:"state",query:!0,regex:aj,populate:function(e,t,n){var r=tj(n,1)[0];t.checks.push({type:7,value:r})}},{name:"id",query:!0,regex:"\\#("+ay.id+")",populate:function(e,t,n){var r=tj(n,1)[0];t.checks.push({type:8,value:ak(r)})}},{name:"className",query:!0,regex:"\\.("+ay.className+")",populate:function(e,t,n){var r=tj(n,1)[0];t.checks.push({type:9,value:ak(r)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+ay.variable+")\\s*\\]",populate:function(e,t,n){var r=tj(n,1)[0];t.checks.push({type:4,field:ak(r)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+ay.variable+")\\s*("+ay.comparatorOp+")\\s*("+ay.value+")\\s*\\]",populate:function(e,t,n){var r=tj(n,3),i=r[0],a=r[1],o=r[2];o=null!=RegExp("^"+ay.string+"$").exec(o)?o.substring(1,o.length-1):parseFloat(o),t.checks.push({type:3,field:ak(i),operator:a,value:o})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+ay.boolOp+")\\s*("+ay.variable+")\\s*\\]",populate:function(e,t,n){var r=tj(n,2),i=r[0],a=r[1];t.checks.push({type:5,field:ak(a),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+ay.meta+")\\s*("+ay.comparatorOp+")\\s*("+ay.number+")\\s*\\]\\]",populate:function(e,t,n){var r=tj(n,3),i=r[0],a=r[1],o=r[2];t.checks.push({type:6,field:ak(i),operator:a,value:parseFloat(o)})}},{name:"nextQuery",separator:!0,regex:ay.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,i=e.compoundCount,a=e[e.length-1];return null!=n&&(a.subject=n,e.currentSubject=null),a.edgeCount=r,a.compoundCount=i,e.edgeCount=0,e.compoundCount=0,e[e.length++]=ab()}},{name:"directedEdge",separator:!0,regex:ay.directedEdge,populate:function(e,t){if(null==e.currentSubject){var n=ab(),r=ab();return n.checks.push({type:11,source:t,target:r}),aC(e,t,n),e.edgeCount++,r}var i=ab(),a=ab();return i.checks.push({type:12,source:t,target:a}),aC(e,t,i),e.edgeCount++,a}},{name:"undirectedEdge",separator:!0,regex:ay.undirectedEdge,populate:function(e,t){if(null==e.currentSubject){var n=ab(),r=ab();return n.checks.push({type:10,nodes:[t,r]}),aC(e,t,n),e.edgeCount++,r}var i=ab(),a=ab();return i.checks.push({type:14,node:t,neighbor:a}),aC(e,t,i),a}},{name:"child",separator:!0,regex:ay.child,populate:function(e,t){if(null==e.currentSubject){var n=ab(),r=ab(),i=e[e.length-1];return n.checks.push({type:15,parent:i,child:r}),aC(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=ab(),o=e[e.length-1],s=ab(),l=ab(),c=ab(),u=ab();return a.checks.push({type:19,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:20}],u.checks.push({type:20}),s.checks.push({type:17,parent:u,child:c}),aC(e,o,a),e.currentSubject=l,e.compoundCount++,c}var d=ab(),h=ab(),f=[{type:17,parent:d,child:h}];return d.checks=t.checks,t.checks=f,e.compoundCount++,h}},{name:"descendant",separator:!0,regex:ay.descendant,populate:function(e,t){if(null==e.currentSubject){var n=ab(),r=ab(),i=e[e.length-1];return n.checks.push({type:16,ancestor:i,descendant:r}),aC(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=ab(),o=e[e.length-1],s=ab(),l=ab(),c=ab(),u=ab();return a.checks.push({type:19,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:20}],u.checks.push({type:20}),s.checks.push({type:18,ancestor:u,descendant:c}),aC(e,o,a),e.currentSubject=l,e.compoundCount++,c}var d=ab(),h=ab(),f=[{type:18,ancestor:d,descendant:h}];return d.checks=t.checks,t.checks=f,e.compoundCount++,h}},{name:"subject",modifier:!0,regex:ay.subject,populate:function(e,t){if(null!=e.currentSubject&&e.currentSubject!==t)return nL("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1].checks[0],r=null==n?null:n.type;11===r?n.type=13:10===r&&(n.type=14,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];aE.forEach(function(e){return e.regexObj=RegExp("^"+e.regex)});var aT=function(e){for(var t,n,r,i=0;i<aE.length;i++){var a=aE[i],o=a.name,s=e.match(a.regexObj);if(null!=s){n=s,t=a,r=o;var l=s[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:r,remaining:e}},aS=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e},a_=function(e,t,n){var r,i,a,o=tL(e),s=tF(e),l=tL(n),c=!1,u=!1,d=!1;switch(t.indexOf("!")>=0&&(t=t.replace("!",""),u=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),c=!0),(o||l||c)&&(i=o||s?""+e:"",a=""+n),c&&(e=i=i.toLowerCase(),n=a=a.toLowerCase()),t){case"*=":r=i.indexOf(a)>=0;break;case"$=":r=i.indexOf(a,i.length-a.length)>=0;break;case"^=":r=0===i.indexOf(a);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e<n;break;case"<=":d=!0,r=e<=n;break;default:r=!1}return u&&(null!=e||!d)&&(r=!r),r},aA=function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return void 0===e}},aD=function(e,t){return e.data(t)},aM=[],aP=function(e,t){return e.checks.every(function(e){return aM[e.type](e,t)})};aM[0]=function(e,t){var n=e.value;return"*"===n||n===t.group()},aM[7]=function(e,t){var n;return n=e.value,aN[n](t)},aM[8]=function(e,t){var n=e.value;return t.id()===n},aM[9]=function(e,t){var n=e.value;return t.hasClass(n)},aM[6]=function(e,t){var n=e.field,r=e.operator,i=e.value;return a_(t[n](),r,i)},aM[3]=function(e,t){var n=e.field,r=e.operator,i=e.value;return a_(aD(t,n),r,i)},aM[5]=function(e,t){var n=e.field,r=e.operator;return aA(aD(t,n),r)},aM[4]=function(e,t){var n=e.field;return e.operator,void 0!==aD(t,n)},aM[10]=function(e,t){var n=e.nodes[0],r=e.nodes[1],i=t.source(),a=t.target();return aP(n,i)&&aP(r,a)||aP(r,i)&&aP(n,a)},aM[14]=function(e,t){return aP(e.node,t)&&t.neighborhood().some(function(t){return t.isNode()&&aP(e.neighbor,t)})},aM[11]=function(e,t){return aP(e.source,t.source())&&aP(e.target,t.target())},aM[12]=function(e,t){return aP(e.source,t)&&t.outgoers().some(function(t){return t.isNode()&&aP(e.target,t)})},aM[13]=function(e,t){return aP(e.target,t)&&t.incomers().some(function(t){return t.isNode()&&aP(e.source,t)})},aM[15]=function(e,t){return aP(e.child,t)&&aP(e.parent,t.parent())},aM[17]=function(e,t){return aP(e.parent,t)&&t.children().some(function(t){return aP(e.child,t)})},aM[16]=function(e,t){return aP(e.descendant,t)&&t.ancestors().some(function(t){return aP(e.ancestor,t)})},aM[18]=function(e,t){return aP(e.ancestor,t)&&t.descendants().some(function(t){return aP(e.descendant,t)})},aM[19]=function(e,t){return aP(e.subject,t)&&aP(e.left,t)&&aP(e.right,t)},aM[20]=function(){return!0},aM[1]=function(e,t){return e.value.has(t)},aM[2]=function(e,t){return(0,e.value)(t)};var aR=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,null==e||tL(e)&&e.match(/^\s*$/)||(tV(e)?this.addQuery({checks:[{type:1,value:e.collection()}]}):tI(e)?this.addQuery({checks:[{type:2,value:e}]}):tL(e)?this.parse(e)||(this.invalid=!0):nP("A selector must be created from a string; found "))},aL=aR.prototype;[{parse:function(e){var t=this.inputText=e,n=this[0]=ab();for(this.length=1,t=aS(t);;){var r=aT(t);if(null==r.expr)return nL("The selector `"+e+"`is invalid"),!1;var i=r.match.slice(1),a=r.expr.populate(this,n,i);if(!1===a)return!1;if(null!=a&&(n=a),(t=r.remaining).match(/^\s*$/))break}var o=this[this.length-1];null!=this.currentSubject&&(o.subject=this.currentSubject),o.edgeCount=this.edgeCount,o.compoundCount=this.compoundCount;for(var s=0;s<this.length;s++){var l=this[s];if(l.compoundCount>0&&l.edgeCount>0)return nL("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return nL("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===l.edgeCount&&nL("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return tL(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,a){var o=r.type,s=r.value;switch(o){case 0:var l=e(s);return l.substring(0,l.length-1);case 3:return"["+r.field+n(e(r.operator))+t(s)+"]";case 5:var c=r.operator,u=r.field;return"["+e(c)+u+"]";case 4:return"["+r.field+"]";case 6:var d=r.operator;return"[["+r.field+n(e(d))+t(s)+"]]";case 7:return s;case 8:return"#"+s;case 9:return"."+s;case 17:case 15:return i(r.parent,a)+n(">")+i(r.child,a);case 18:case 16:return i(r.ancestor,a)+" "+i(r.descendant,a);case 19:var h=i(r.left,a),f=i(r.subject,a),p=i(r.right,a);return h+(h.length>0?" ":"")+f+p;case 20:return""}},i=function(e,t){return e.checks.reduce(function(n,i,a){return n+(t===e&&0===a?"$":"")+r(i,t)},"")},a="",o=0;o<this.length;o++){var s=this[o];a+=i(s,s.subject),this.length>1&&o<this.length-1&&(a+=", ")}return this.toStringCache=a,a}},{matches:function(e){for(var t=0;t<this.length;t++)if(aP(this[t],e))return!0;return!1},filter:function(e){var t=this;if(1===t.length&&1===t[0].checks.length&&8===t[0].checks[0].type)return e.getElementById(t[0].checks[0].value).collection();var n=function(e){for(var n=0;n<t.length;n++)if(aP(t[n],e))return!0;return!1};return null==t.text()&&(n=function(){return!0}),e.filter(n)}}].forEach(function(e){return t6(aL,e)}),aL.text=function(){return this.inputText},aL.size=function(){return this.length},aL.eq=function(e){return this[e]},aL.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},aL.addQuery=function(e){this[this.length++]=e},aL.selector=aL.toString;var aI={allAre:function(e){var t=new aR(e);return this.every(function(e){return t.matches(e)})},is:function(e){var t=new aR(e);return this.some(function(e){return t.matches(e)})},some:function(e,t){for(var n=0;n<this.length;n++)if(t?e.apply(t,[this[n],n,this]):e(this[n],n,this))return!0;return!1},every:function(e,t){for(var n=0;n<this.length;n++)if(!(t?e.apply(t,[this[n],n,this]):e(this[n],n,this)))return!1;return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length;return t===e.length&&(1===t?this[0]===e[0]:this.every(function(t){return e.hasElementWithId(t.id())}))},anySame:function(e){return e=this.cy().collection(e),this.some(function(t){return e.hasElementWithId(t.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every(function(e){return t.hasElementWithId(e.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(e){return t.hasElementWithId(e.id())})}};aI.allAreNeighbours=aI.allAreNeighbors,aI.has=aI.contains,aI.equal=aI.equals=aI.same;var aO=function(e,t){return function(n,r,i,a){if(null==n?o="":tV(n)&&1===n.length&&(o=n.id()),1!==this.length||!o)return e.call(this,n,r,i,a);var o,s=this[0]._private,l=s.traversalCache=s.traversalCache||{},c=l[t]=l[t]||[],u=nN(o),d=c[u];return d||(c[u]=e.call(this,n,r,i,a))}},aB={parent:function(e){var t=[];if(1===this.length){var n=this[0]._private.parent;if(n)return n}for(var r=0;r<this.length;r++){var i=this[r]._private.parent;i&&t.push(i)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var r=0;r<n.length;r++){var i=n[r];t.push(i)}n=n.parent()}return this.spawn(t,!0).filter(e)},commonAncestors:function(e){for(var t,n=0;n<this.length;n++){var r=this[n].parents();t=(t=t||r).intersect(r)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(e){return e.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(e){return e.isChild()}).filter(e)},children:aO(function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n]._private.children,i=0;i<r.length;i++)t.push(r[i]);return this.spawn(t,!0).filter(e)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&0!==e._private.children.length},isChildless:function(){var e=this[0];if(e)return e.isNode()&&0===e._private.children.length},isChild:function(){var e=this[0];if(e)return e.isNode()&&null!=e._private.parent},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&null==e._private.parent},descendants:function(e){var t=[];return!function e(n){for(var r=0;r<n.length;r++){var i=n[r];t.push(i),i.children().nonempty()&&e(i.children())}}(this.children()),this.spawn(t,!0).filter(e)}};function aF(e,t,n,r){for(var i=[],a=new n$,o=e.cy().hasCompoundNodes(),s=0;s<e.length;s++){var l=e[s];n?i.push(l):o&&r(i,a,l)}for(;i.length>0;){var c=i.shift();t(c),a.add(c.id()),o&&r(i,a,c)}return e}function az(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i<r.length;i++){var a=r[i];t.has(a.id())||e.push(a)}}function aV(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}function aH(e,t,n){aV(e,t,n),az(e,t,n)}aB.forEachDown=function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return aF(this,e,t,az)},aB.forEachUp=function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return aF(this,e,t,aV)},aB.forEachUpAndDown=function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return aF(this,e,t,aH)},aB.ancestors=aB.parents,(un=ur={data:am.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:am.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:am.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:am.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:am.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:am.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=un.data,un.removeAttr=un.removeData;var aU={};function aG(e){return function(t){if(void 0===t&&(t=!0),0!==this.length)if(!this.isNode()||this.removed())return;else{for(var n=0,r=this[0],i=r._private.edges,a=0;a<i.length;a++){var o=i[a];!t&&o.isLoop()||(n+=e(r,o))}return n}}}function aY(e,t){return function(n){for(var r,i=this.nodes(),a=0;a<i.length;a++){var o=i[a][e](n);void 0!==o&&(void 0===r||t(o,r))&&(r=o)}return r}}t6(aU,{degree:aG(function(e,t){return t.source().same(t.target())?2:1}),indegree:aG(function(e,t){return+!!t.target().same(e)}),outdegree:aG(function(e,t){return+!!t.source().same(e)})}),t6(aU,{minDegree:aY("degree",function(e,t){return e<t}),maxDegree:aY("degree",function(e,t){return e>t}),minIndegree:aY("indegree",function(e,t){return e<t}),maxIndegree:aY("indegree",function(e,t){return e>t}),minOutdegree:aY("outdegree",function(e,t){return e<t}),maxOutdegree:aY("outdegree",function(e,t){return e>t})}),t6(aU,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var aX=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(!i.locked()){var a=i._private.position,o={x:null!=t.x?t.x-a.x:0,y:null!=t.y?t.y-a.y:0};i.isParent()&&(0!==o.x||0!==o.y)&&i.children().shift(o,n),i.dirtyBoundingBoxCache()}}},aW={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){aX(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};(ui=ua={position:am.data(aW),silentPosition:am.data(t6({},aW,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){aX(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(tB(e))t?this.silentPosition(e):this.position(e);else if(tI(e)){var n=this.cy();n.startBatch();for(var r=0;r<this.length;r++){var i=this[r],a=void 0;(a=e(i,r))&&(t?i.silentPosition(a):i.position(a))}n.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(tB(e)?(r={x:tF(e.x)?e.x:0,y:tF(e.y)?e.y:0},n=t):tL(e)&&tF(t)&&((r={x:0,y:0})[e]=t),null!=r){var i=this.cy();i.startBatch();for(var a=0;a<this.length;a++){var o=this[a];if(!(i.hasCompoundNodes()&&o.isChild()&&o.ancestors().anySame(this))){var s=o.position(),l={x:s.x+r.x,y:s.y+r.y};n?o.silentPosition(l):o.position(l)}}i.endBatch()}return this},silentShift:function(e,t){return tB(e)?this.shift(e,!0):tL(e)&&tF(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],r=this.cy(),i=r.zoom(),a=r.pan(),o=tB(e)?e:void 0,s=void 0!==o||void 0!==t&&tL(e);if(n&&n.isNode())if(!s)return(o=n8(n.position(),i,a),void 0===e)?o:o[e];else for(var l=0;l<this.length;l++){var c=this[l];void 0!==t?c.position(e,(t-a[e])/i):void 0!==o&&c.position(re(o,i,a))}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),i=tB(e)?e:void 0,a=void 0!==i||void 0!==t&&tL(e),o=r.hasCompoundNodes();if(n&&n.isNode())if(a)for(var s=0;s<this.length;s++){var l=this[s],c=o?l.parent():null,u=c&&c.length>0;u&&(c=c[0]);var d=u?c.position():{x:0,y:0};void 0!==t?l.position(e,t+d[e]):void 0!==i&&l.position({x:i.x+d.x,y:i.y+d.y})}else{var h=n.position(),f=o?n.parent():null,p=f&&f.length>0;p&&(f=f[0]);var g=p?f.position():{x:0,y:0};return(i={x:h.x-g.x,y:h.y-g.y},void 0===e)?i:i[e]}else if(!a)return;return this}}).modelPosition=ui.point=ui.position,ui.modelPositions=ui.points=ui.positions,ui.renderedPoint=ui.renderedPosition,ui.relativePoint=ui.relativePosition,uo=us={},us.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),a=t.x1*r+i.x,o=t.x2*r+i.x,s=t.y1*r+i.y,l=t.y2*r+i.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},us.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()&&this.forEachUp(function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify("bounds")}}),this},us.updateCompoundBounds=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes()||!e&&t.batching())return this;for(var n=0;n<this.length;n++){var r=this[n],i=r._private;(!i.compoundBoundsClean||e)&&(!function(e){if(e.isParent()){var t=e._private,n=e.children(),r="include"===e.pstyle("compound-sizing-wrt-labels").value,i={width:{val:e.pstyle("min-width").pfValue,left:e.pstyle("min-width-bias-left"),right:e.pstyle("min-width-bias-right")},height:{val:e.pstyle("min-height").pfValue,top:e.pstyle("min-height-bias-top"),bottom:e.pstyle("min-height-bias-bottom")}},a=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;(0===a.w||0===a.h)&&((a={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);var s=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(s=100*s/i.width.val);var l=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(l=100*l/i.width.val);var c=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(c=100*c/i.height.val);var u=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(u=100*u/i.height.val);var d=x(i.width.val-a.w,s,l),h=d.biasDiff,f=d.biasComplementDiff,p=x(i.height.val-a.h,c,u),g=p.biasDiff,v=p.biasComplementDiff;t.autoPadding=function(e,t,n,r){if("%"===n.units)switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}return"px"===n.units?n.pfValue:0}(a.w,a.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-h+a.x1+a.x2+f)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-g+a.y1+a.y2+v)/2}function x(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}}(r),t.batching()||(i.compoundBoundsClean=!0))}return this};var aq=function(e){return e===1/0||e===-1/0?0:e},a$=function(e,t,n,r,i){r-t==0||i-n==0||null!=t&&null!=n&&null!=r&&null!=i&&(e.x1=t<e.x1?t:e.x1,e.x2=r>e.x2?r:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=i>e.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},aK=function(e,t){return null==t?e:a$(e,t.x1,t.y1,t.x2,t.y2)},aZ=function(e,t,n){return nG(e,t,n)},aQ=function(e,t,n){if(!t.cy().headless()){var r,i,a=t._private,o=a.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,i=o.srcY):"target"===n?(r=o.tgtX,i=o.tgtY):(r=o.midX,i=o.midY);var l=a.arrowBounds=a.arrowBounds||{},c=l[n]=l[n]||{};c.x1=r-s,c.y1=i-s,c.x2=r+s,c.y2=i+s,c.w=c.x2-c.x1,c.h=c.y2-c.y1,rb(c,1),a$(e,c.x1,c.y1,c.x2,c.y2)}}},aJ=function(e,t,n){if(!t.cy().headless()){a=n?n+"-":"";var r=t._private,i=r.rstyle;if(t.pstyle(a+"label").strValue){var a,o,s,l,c,u=t.pstyle("text-halign"),d=t.pstyle("text-valign"),h=aZ(i,"labelWidth",n),f=aZ(i,"labelHeight",n),p=aZ(i,"labelX",n),g=aZ(i,"labelY",n),v=t.pstyle(a+"text-margin-x").pfValue,x=t.pstyle(a+"text-margin-y").pfValue,y=t.isEdge(),b=t.pstyle(a+"text-rotation"),w=t.pstyle("text-outline-width").pfValue,N=t.pstyle("text-border-width").pfValue/2,j=t.pstyle("text-background-padding").pfValue,k=h/2,C=f/2;if(y)o=p-k,s=p+k,l=g-C,c=g+C;else{switch(u.value){case"left":o=p-h,s=p;break;case"center":o=p-k,s=p+k;break;case"right":o=p,s=p+h}switch(d.value){case"top":l=g-f,c=g;break;case"center":l=g-C,c=g+C;break;case"bottom":l=g,c=g+f}}var E=v-Math.max(w,N)-j-2,T=v+Math.max(w,N)+j+2,S=x-Math.max(w,N)-j-2,_=x+Math.max(w,N)+j+2;o+=E,s+=T,l+=S,c+=_;var A=n||"main",D=r.labelBounds,M=D[A]=D[A]||{};M.x1=o,M.y1=l,M.x2=s,M.y2=c,M.w=s-o,M.h=c-l,M.leftPad=E,M.rightPad=T,M.topPad=S,M.botPad=_;var P=y&&"autorotate"===b.strValue,R=null!=b.pfValue&&0!==b.pfValue;if(P||R){var L=P?aZ(r.rstyle,"labelAngle",n):b.pfValue,I=Math.cos(L),O=Math.sin(L),B=(o+s)/2,F=(l+c)/2;if(!y){switch(u.value){case"left":B=s;break;case"right":B=o}switch(d.value){case"top":F=c;break;case"bottom":F=l}}var z=function(e,t){return{x:(e-=B)*I-(t-=F)*O+B,y:e*O+t*I+F}},V=z(o,l),H=z(o,c),U=z(s,l),G=z(s,c);o=Math.min(V.x,H.x,U.x,G.x),s=Math.max(V.x,H.x,U.x,G.x),l=Math.min(V.y,H.y,U.y,G.y),c=Math.max(V.y,H.y,U.y,G.y)}var Y=A+"Rot",X=D[Y]=D[Y]||{};X.x1=o,X.y1=l,X.x2=s,X.y2=c,X.w=s-o,X.h=c-l,a$(e,o,l,s,c),a$(r.labelBounds.all,o,l,s,c)}return e}},a0=function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,r=t.pstyle("outline-width").value+t.pstyle("outline-offset").value;a1(e,t,n,r,"outside",r/2)}},a1=function(e,t,n,r,i,a){if(0!==n&&!(r<=0)&&"inside"!==i){var o=t.cy(),s=t.pstyle("shape").value,l=o.renderer().nodeShapes[s],c=t.position(),u=c.x,d=c.y,h=t.width(),f=t.height();l.hasMiterBounds?("center"===i&&(r/=2),aK(e,l.miterBounds(u,d,h,f,r))):null!=a&&a>0&&rw(e,[a,a,a,a])}},a2=function(e,t){if(!t.cy().headless()){var n=t.pstyle("border-opacity").value,r=t.pstyle("border-width").pfValue,i=t.pstyle("border-position").value;a1(e,t,n,r,i)}},a5=function(e,t){var n=e._private.cy,r=n.styleEnabled(),i=n.headless(),a=rm(),o=e._private,s=e.isNode(),l=e.isEdge(),c=o.rstyle,u=s&&r?e.pstyle("bounds-expansion").pfValue:[0],d=function(e){return"none"!==e.pstyle("display").value},h=!r||d(e)&&(!l||d(e.source())&&d(e.target()));if(h){var f=0;r&&t.includeOverlays&&0!==e.pstyle("overlay-opacity").value&&(f=e.pstyle("overlay-padding").value);var p=0;r&&t.includeUnderlays&&0!==e.pstyle("underlay-opacity").value&&(p=e.pstyle("underlay-padding").value);var g=Math.max(f,p),v=0;if(r&&(v=e.pstyle("width").pfValue/2),s&&t.includeNodes){var x=e.position();C=x.x,E=x.y;var y=e.outerWidth()/2,b=e.outerHeight()/2;w=C-y,N=C+y,a$(a,w,j=E-b,N,k=E+b),r&&a0(a,e),r&&t.includeOutlines&&!i&&a0(a,e),r&&a2(a,e)}else if(l&&t.includeEdges)if(r&&!i){var w,N,j,k,C,E,T,S=e.pstyle("curve-style").strValue;if(w=Math.min(c.srcX,c.midX,c.tgtX),N=Math.max(c.srcX,c.midX,c.tgtX),j=Math.min(c.srcY,c.midY,c.tgtY),k=Math.max(c.srcY,c.midY,c.tgtY),w-=v,N+=v,a$(a,w,j-=v,N,k+=v),"haystack"===S){var _=c.haystackPts;if(_&&2===_.length){if(w=_[0].x,j=_[0].y,N=_[1].x,k=_[1].y,w>N){var A=w;w=N,N=A}if(j>k){var D=j;j=k,k=D}a$(a,w-v,j-v,N+v,k+v)}}else if("bezier"===S||"unbundled-bezier"===S||tJ(S,"segments")||tJ(S,"taxi")){switch(S){case"bezier":case"unbundled-bezier":T=c.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":T=c.linePts}if(null!=T)for(var M=0;M<T.length;M++){var P=T[M];w=P.x-v,N=P.x+v,a$(a,w,j=P.y-v,N,k=P.y+v)}}}else{var R=e.source().position(),L=e.target().position();if(w=R.x,N=L.x,j=R.y,k=L.y,w>N){var I=w;w=N,N=I}if(j>k){var O=j;j=k,k=O}w-=v,N+=v,a$(a,w,j-=v,N,k+=v)}if(r&&t.includeEdges&&l&&(aQ(a,e,"mid-source"),aQ(a,e,"mid-target"),aQ(a,e,"source"),aQ(a,e,"target")),r&&"yes"===e.pstyle("ghost").value){var B=e.pstyle("ghost-offset-x").pfValue,F=e.pstyle("ghost-offset-y").pfValue;a$(a,a.x1+B,a.y1+F,a.x2+B,a.y2+F)}var z=o.bodyBounds=o.bodyBounds||{};rN(z,a),rw(z,u),rb(z,1),r&&(w=a.x1,N=a.x2,j=a.y1,k=a.y2,a$(a,w-g,j-g,N+g,k+g));var V=o.overlayBounds=o.overlayBounds||{};rN(V,a),rw(V,u),rb(V,1);var H=o.labelBounds=o.labelBounds||{};null!=H.all?rv(H.all):H.all=rm(),r&&t.includeLabels&&(t.includeMainLabels&&aJ(a,e,null),l&&(t.includeSourceLabels&&aJ(a,e,"source"),t.includeTargetLabels&&aJ(a,e,"target")))}return a.x1=aq(a.x1),a.y1=aq(a.y1),a.x2=aq(a.x2),a.y2=aq(a.y2),a.w=aq(a.x2-a.x1),a.h=aq(a.y2-a.y1),a.w>0&&a.h>0&&h&&(rw(a,u),rb(a,1)),a},a3=function(e){var t=0,n=function(e){return!!e<<t++};return 0+n(e.incudeNodes)+n(e.includeEdges)+n(e.includeLabels)+n(e.includeMainLabels)+n(e.includeSourceLabels)+n(e.includeTargetLabels)+n(e.includeOverlays)+n(e.includeOutlines)},a4=function(e){var t=function(e){return Math.round(e)};if(e.isEdge()){var n=e.source().position(),r=e.target().position();return nw([t(n.x),t(n.y),t(r.x),t(r.y)])}var i=e.position();return nw([t(i.x),t(i.y)])},a6=function(e,t){var n,r=e._private,i=e.isEdge(),a=null==t?a7:a3(t);if(null==r.bbCache?(r.bbCache=n=a5(e,a9),r.bbCachePosKey=a4(e)):n=r.bbCache,a!==a7){var o=e.isNode();n=rm(),(t.includeNodes&&o||t.includeEdges&&!o)&&(t.includeOverlays?aK(n,r.overlayBounds):aK(n,r.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!i||t.includeSourceLabels&&t.includeTargetLabels)?aK(n,r.labelBounds.all):(t.includeMainLabels&&aK(n,r.labelBounds.mainRot),t.includeSourceLabels&&aK(n,r.labelBounds.sourceRot),t.includeTargetLabels&&aK(n,r.labelBounds.targetRot))),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},a9={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},a7=a3(a9),a8=nz(a9);us.boundingBox=function(e){var t,n=void 0===e||void 0===e.useCache||!0===e.useCache,r=tq(function(e){var t=e._private;return null==t.bbCache||t.styleDirty||t.bbCachePosKey!==a4(e)},function(e){return e.id()});if(n&&1===this.length&&!r(this[0]))e=void 0===e?a9:a8(e),t=a6(this[0],e);else{t=rm();var i=a8(e=e||a9),a=this.cy().styleEnabled();this.edges().forEach(r),this.nodes().forEach(r),a&&this.recalculateRenderedStyle(n),this.updateCompoundBounds(!n);for(var o=0;o<this.length;o++){var s=this[o];r(s)&&s.dirtyBoundingBoxCache(),aK(t,a6(s,i))}}return t.x1=aq(t.x1),t.y1=aq(t.y1),t.x2=aq(t.x2),t.y2=aq(t.y2),t.w=aq(t.x2-t.x1),t.h=aq(t.y2-t.y1),t},us.dirtyBoundingBoxCache=function(){for(var e=0;e<this.length;e++){var t=this[e]._private;t.bbCache=null,t.bbCachePosKey=null,t.bodyBounds=null,t.overlayBounds=null,t.labelBounds.all=null,t.labelBounds.source=null,t.labelBounds.target=null,t.labelBounds.main=null,t.labelBounds.sourceRot=null,t.labelBounds.targetRot=null,t.labelBounds.mainRot=null,t.arrowBounds.source=null,t.arrowBounds.target=null,t.arrowBounds["mid-source"]=null,t.arrowBounds["mid-target"]=null}return this.emitAndNotify("bounds"),this},us.boundingBoxAt=function(e){var t,n=this.nodes(),r=this.cy(),i=r.hasCompoundNodes(),a=r.collection();if(i&&(a=n.filter(function(e){return e.isParent()}),n=n.not(a)),tB(e)){var o=e;e=function(){return o}}r.startBatch(),n.forEach(function(t,n){return t._private.bbAtOldPos=e(t,n)}).silentPositions(e),i&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0));var s={x1:(t=this.boundingBox({useCache:!1})).x1,x2:t.x2,w:t.w,y1:t.y1,y2:t.y2,h:t.h};return n.silentPositions(function(e){return e._private.bbAtOldPos}),i&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0)),r.endBatch(),s},uo.boundingbox=uo.bb=uo.boundingBox,uo.renderedBoundingbox=uo.renderedBoundingBox,ul=uc={};var oe=function(e){e.uppercaseName=tQ(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=tQ(e.outerName),ul[e.name]=function(){var t=this[0],n=t._private,r=n.cy._private.styleEnabled;if(t)if(!r)return 1;else{if(t.isParent())return t.updateCompoundBounds(),n[e.autoName]||0;var i=t.pstyle(e.name);return"label"===i.strValue?(t.recalculateRenderedStyle(),n.rstyle[e.labelName]||0):i.pfValue}},ul["outer"+e.uppercaseName]=function(){var t=this[0],n=t._private.cy._private.styleEnabled;if(t)if(!n)return 1;else{var r=t[e.name](),i=t.pstyle("border-position").value;return r+("center"===i?t.pstyle("border-width").pfValue:"outside"===i?2*t.pstyle("border-width").pfValue:0)+2*t.padding()}},ul["rendered"+e.uppercaseName]=function(){var t=this[0];if(t)return t[e.name]()*this.cy().zoom()},ul["rendered"+e.uppercaseOuterName]=function(){var t=this[0];if(t)return t[e.outerName]()*this.cy().zoom()}};oe({name:"width"}),oe({name:"height"}),uc.padding=function(){var e=this[0],t=e._private;return e.isParent()&&(e.updateCompoundBounds(),void 0!==t.autoPadding)?t.autoPadding:e.pstyle("padding").pfValue},uc.paddedHeight=function(){var e=this[0];return e.height()+2*e.padding()},uc.paddedWidth=function(){var e=this[0];return e.width()+2*e.padding()};var ot=function(e,t){if(e.isEdge()&&e.takesUpSpace())return t(e)},on=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return n8(t(e),n.zoom(),n.pan())}},or=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),r=n.pan(),i=n.zoom();return t(e).map(function(e){return n8(e,i,r)})}},oi={controlPoints:{get:function(e){return e.renderer().getControlPoints(e)},mult:!0},segmentPoints:{get:function(e){return e.renderer().getSegmentPoints(e)},mult:!0},sourceEndpoint:{get:function(e){return e.renderer().getSourceEndpoint(e)}},targetEndpoint:{get:function(e){return e.renderer().getTargetEndpoint(e)}},midpoint:{get:function(e){return e.renderer().getEdgeMidpoint(e)}}},oa=t6({},ua,us,uc,Object.keys(oi).reduce(function(e,t){var n=oi[t],r="rendered"+t[0].toUpperCase()+t.substr(1);return e[t]=function(){return ot(this,n.get)},n.mult?e[r]=function(){return or(this,n.get)}:e[r]=function(){return on(this,n.get)},e},{})),oo=function(e,t){this.recycle(e,t)};function os(){return!1}function ol(){return!0}oo.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=os,null!=e&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?ol:os):null!=e&&e.type?t=e:this.type=e,null!=t&&(this.originalEvent=t.originalEvent,this.type=null!=t.type?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),null!=this.cy&&null!=this.position&&null==this.renderedPosition){var n=this.position,r=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:n.x*r+i.x,y:n.y*r+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=ol;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=ol;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ol,this.stopPropagation()},isDefaultPrevented:os,isPropagationStopped:os,isImmediatePropagationStopped:os};var oc=/^([^.]+)(\.(?:[^.]+))?$/,ou={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},od=Object.keys(ou),oh={};function of(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:oh,t=arguments.length>1?arguments[1]:void 0,n=0;n<od.length;n++){var r=od[n];this[r]=e[r]||ou[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var op=of.prototype,og=function(e,t,n,r,i,a,o){tI(r)&&(i=r,r=null),o&&(a=null==a?o:t6({},a,o));for(var s=tO(n)?n:n.split(/\s+/),l=0;l<s.length;l++){var c=s[l];if(!tX(c)){var u=c.match(oc);if(u&&!1===t(e,c,u[1],u[2]?u[2]:null,r,i,a))break}}},om=function(e,t){return e.addEventFields(e.context,t),new oo(t.type,t)},ov=function(e,t,n){if("event"===tR(n))return void t(e,n);if(tB(n))return void t(e,om(e,n));for(var r=tO(n)?n:n.split(/\s+/),i=0;i<r.length;i++){var a=r[i];if(!tX(a)){var o=a.match(oc);if(o){var s=om(e,{type:o[1],namespace:o[2]?o[2]:null,target:e.context});t(e,s)}}}};op.on=op.addListener=function(e,t,n,r,i){return og(this,function(e,t,n,r,i,a,o){tI(a)&&e.listeners.push({event:t,callback:a,type:n,namespace:r,qualifier:i,conf:o})},e,t,n,r,i),this},op.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},op.removeListener=op.off=function(e,t,n,r){var i=this;0!==this.emitting&&(this.listeners=this.listeners.slice());for(var a=this.listeners,o=function(o){var s=a[o];og(i,function(t,n,r,i,l,c){if((s.type===r||"*"===e)&&(!i&&".*"!==s.namespace||s.namespace===i)&&(!l||t.qualifierCompare(s.qualifier,l))&&(!c||s.callback===c))return a.splice(o,1),!1},e,t,n,r)},s=a.length-1;s>=0;s--)o(s);return this},op.removeAllListeners=function(){return this.removeListener("*")},op.emit=op.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,tO(t)||(t=[t]),ov(this,function(e,a){null!=n&&(i=(r=[{event:a.event,type:a.type,namespace:a.namespace,callback:n}]).length);for(var o=0;o<i;o++)!function(){var n=r[o];if(n.type===a.type&&(!n.namespace||n.namespace===a.namespace||".*"===n.namespace)&&e.eventMatches(e.context,n,a)){var i=[a];null!=t&&nU(i,t),e.beforeEmit(e.context,n,a),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter(function(e){return e!==n}));var s=e.callbackContext(e.context,n,a),l=n.callback.apply(s,i);e.afterEmit(e.context,n,a),!1===l&&(a.stopPropagation(),a.preventDefault())}}();e.bubble(e.context)&&!a.isPropagationStopped()&&e.parent(e.context).emit(a,t)},e),this.emitting--,this};var ox={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&tH(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},oy=function(e){return tL(e)?new aR(e):e},ob={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new of(ox,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=oy(t),i=0;i<this.length;i++)this[i].emitter().on(e,r,n);return this},removeListener:function(e,t,n){for(var r=oy(t),i=0;i<this.length;i++)this[i].emitter().removeListener(e,r,n);return this},removeAllListeners:function(){for(var e=0;e<this.length;e++)this[e].emitter().removeAllListeners();return this},one:function(e,t,n){for(var r=oy(t),i=0;i<this.length;i++)this[i].emitter().one(e,r,n);return this},once:function(e,t,n){for(var r=oy(t),i=0;i<this.length;i++)this[i].emitter().on(e,r,n,{once:!0,onceCollection:this})},emit:function(e,t){for(var n=0;n<this.length;n++)this[n].emitter().emit(e,t);return this},emitAndNotify:function(e,t){if(0!==this.length)return this.cy().notify(e,this),this.emit(e,t),this}};am.eventAliasesOn(ob);var ow={nodes:function(e){return this.filter(function(e){return e.isNode()}).filter(e)},edges:function(e){return this.filter(function(e){return e.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var r=this[n];r.isNode()?e.push(r):t.push(r)}return{nodes:e,edges:t}},filter:function(e,t){if(void 0===e)return this;if(tL(e)||tV(e))return new aR(e).filter(this);if(tI(e)){for(var n=this.spawn(),r=0;r<this.length;r++){var i=this[r];(t?e.apply(t,[i,r,this]):e(i,r,this))&&n.push(i)}return n}return this.spawn()},not:function(e){if(!e)return this;tL(e)&&(e=this.filter(e));for(var t=this.spawn(),n=0;n<this.length;n++){var r=this[n];e.has(r)||t.push(r)}return t},absoluteComplement:function(){return this.cy().mutableElements().not(this)},intersect:function(e){if(tL(e))return this.filter(e);for(var t=this.spawn(),n=this.length<e.length,r=n?this:e,i=n?e:this,a=0;a<r.length;a++){var o=r[a];i.has(o)&&t.push(o)}return t},xor:function(e){var t=this._private.cy;tL(e)&&(e=t.$(e));var n=this.spawn(),r=e,i=function(e,t){for(var r=0;r<e.length;r++){var i=e[r],a=i._private.data.id;t.hasElementWithId(a)||n.push(i)}};return i(this,r),i(r,this),n},diff:function(e){var t=this._private.cy;tL(e)&&(e=t.$(e));var n=this.spawn(),r=this.spawn(),i=this.spawn(),a=e,o=function(e,t,n){for(var r=0;r<e.length;r++){var a=e[r],o=a._private.data.id;t.hasElementWithId(o)?i.merge(a):n.push(a)}};return o(this,a,n),o(a,this,r),{left:n,right:r,both:i}},add:function(e){var t=this._private.cy;if(!e)return this;if(tL(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=this.spawnSelf(),i=0;i<e.length;i++){var a=e[i];this.has(a)||r.push(a)}return r},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&tL(e)){var r=e;e=n.mutableElements().filter(r)}for(var i=t.map,a=0;a<e.length;a++){var o=e[a],s=o._private.data.id;if(!i.has(s)){var l=this.length++;this[l]=o,i.set(s,{ele:o,index:l})}}return this},unmergeAt:function(e){var t=this[e].id(),n=this._private.map;this[e]=void 0,n.delete(t);var r=e===this.length-1;if(this.length>1&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&tL(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r<e.length;r++)this.unmergeOne(e[r]);return this},unmergeBy:function(e){for(var t=this.length-1;t>=0;t--)e(this[t])&&this.unmergeAt(t);return this},map:function(e,t){for(var n=[],r=0;r<this.length;r++){var i=this[r],a=t?e.apply(t,[i,r,this]):e(i,r,this);n.push(a)}return n},reduce:function(e,t){for(var n=t,r=0;r<this.length;r++)n=e(n,this[r],r,this);return n},max:function(e,t){for(var n,r=-1/0,i=0;i<this.length;i++){var a=this[i],o=t?e.apply(t,[a,i,this]):e(a,i,this);o>r&&(r=o,n=a)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=0;i<this.length;i++){var a=this[i],o=t?e.apply(t,[a,i,this]):e(a,i,this);o<r&&(r=o,n=a)}return{value:r,ele:n}}};ow.u=ow["|"]=ow["+"]=ow.union=ow.or=ow.add,ow["\\"]=ow["!"]=ow["-"]=ow.difference=ow.relativeComplement=ow.subtract=ow.not,ow.n=ow["&"]=ow["."]=ow.and=ow.intersection=ow.intersect,ow["^"]=ow["(+)"]=ow["(-)"]=ow.symmetricDifference=ow.symdiff=ow.xor,ow.fnFilter=ow.filterFn=ow.stdFilter=ow.filter,ow.complement=ow.abscomp=ow.absoluteComplement;var oN=function(e,t){var n=e.cy().hasCompoundNodes();function r(e){var t=e.pstyle("z-compound-depth");return"auto"===t.value?n?e.zDepth():0:"bottom"===t.value?-1:"top"===t.value?nS:0}var i=r(e)-r(t);if(0!==i)return i;function a(e){return"auto"===e.pstyle("z-index-compare").value?+!!e.isNode():0}var o=a(e)-a(t);if(0!==o)return o;var s=e.pstyle("z-index").value-t.pstyle("z-index").value;return 0!==s?s:e.poolIndex()-t.poolIndex()},oj={forEach:function(e,t){if(tI(e))for(var n=this.length,r=0;r<n;r++){var i=this[r];if(!1===(t?e.apply(t,[i,r,this]):e(i,r,this)))break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var n=[],r=this.length;null==t&&(t=r),null==e&&(e=0),e<0&&(e=r+e),t<0&&(t=r+t);for(var i=e;i>=0&&i<t&&i<r;i++)n.push(this[i]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(e){if(!tI(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(oN)},zDepth:function(){var e=this[0];if(e){var t=e._private;if("nodes"===t.group){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:nS-1}var r=t.source,i=t.target;return Math.max(r.zDepth(),i.zDepth(),0)}}};oj.each=oj.forEach,("u"<typeof Symbol?"undefined":tE(Symbol))!="undefined"&&"undefined"!=tE(Symbol.iterator)&&(oj[Symbol.iterator]=function(){var e=this,t={value:void 0,done:!1},n=0,r=this.length;return tN({next:function(){return n<r?t.value=e[n++]:(t.value=void 0,t.done=!0),t}},Symbol.iterator,function(){return this})});var ok=nz({nodeDimensionsIncludeLabels:!1}),oC={layoutDimensions:function(e){if(e=ok(e),this.takesUpSpace())if(e.nodeDimensionsIncludeLabels){var t,n=this.boundingBox();t={w:n.w,h:n.h}}else t={w:this.outerWidth(),h:this.outerHeight()};else t={w:0,h:0};return(0===t.w||0===t.h)&&(t.w=t.h=1),t},layoutPositions:function(e,t,n){var r=this.nodes().filter(function(e){return!e.isParent()}),i=this.cy(),a=t.eles,o=function(e){return e.id()},s=tq(n,o);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=function(e,t,n){var r={x:t.x1+t.w/2,y:t.y1+t.h/2},i={x:(n.x-r.x)*e,y:(n.y-r.y)*e};return{x:r.x+i.x,y:r.y+i.y}},c=t.spacingFactor&&1!==t.spacingFactor,u=function(){if(!c)return null;for(var e=rm(),t=0;t<r.length;t++){var n=s(r[t],t);ry(e,n.x,n.y)}return e}(),d=tq(function(e,n){var r=s(e,n);return c&&(r=l(Math.abs(t.spacingFactor),u,r)),null!=t.transform&&(r=t.transform(e,r)),r},o);if(t.animate){for(var h=0;h<r.length;h++){var f=r[h],p=d(f,h);if(null==t.animateFilter||t.animateFilter(f,h)){var g=f.animation({position:p,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(g)}else f.position(p)}if(t.fit){var v=i.animation({fit:{boundingBox:a.boundingBoxAt(d),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(v)}else if(void 0!==t.zoom&&void 0!==t.pan){var x=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(x)}e.animations.forEach(function(e){return e.play()}),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),i8.all(e.animations.map(function(e){return e.promise()})).then(function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})})}else r.positions(d),t.fit&&i.fit(t.eles,t.padding),null!=t.zoom&&i.zoom(t.zoom),t.pan&&i.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){return this.cy().makeLayout(t6({},e,{eles:this}))}};function oE(e,t,n){var r,i=n._private,a=i.styleCache=i.styleCache||[];return null!=(r=a[e])?r:r=a[e]=t(n)}function oT(e,t){return e=nN(e),function(n){return oE(e,t,n)}}function oS(e,t){e=nN(e);var n=function(e){return t.call(e)};return function(){var t=this[0];if(t)return oE(e,n,t)}}oC.createLayout=oC.makeLayout=oC.layout;var o_={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),r=t.styleEnabled();return n&&r&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e,t=this.cy(),n=function(e){return e._private.styleCache=null};return t.hasCompoundNodes()?((e=this.spawnSelf().merge(this.descendants()).merge(this.parents())).merge(e.connectedEdges()),e.forEach(n)):this.forEach(function(e){n(e),e.connectedEdges().forEach(n)}),this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching())return t._private.batchStyleEles.merge(this),this;var n=t.hasCompoundNodes(),r=this;e=!!e||void 0===e,n&&(r=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var i=r;return e?i.emitAndNotify("style"):i.emit("style"),r.forEach(function(e){return e._private.styleDirty=!0}),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var t=0;t<this.length;t++){var n=this[t];n._private.styleDirty&&(n._private.styleDirty=!1,e.style().apply(n))}},parsedStyle:function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n));var i=n._private.style[e];return null!=i?i:t?r.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled()&&t)return t.pstyle(e).units},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];if(n)return t.style().getRenderedStyle(n,e)},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=n.style();if(tB(e))r.applyBypass(this,e,!1),this.emitAndNotify("style");else if(tL(e))if(void 0===t){var i=this[0];return i?r.getStylePropertyValue(i,e):void 0}else r.applyBypass(this,e,t,!1),this.emitAndNotify("style");else if(void 0===e){var a=this[0];return a?r.getRawStyle(a):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=t.style();if(void 0===e)for(var r=0;r<this.length;r++){var i=this[r];n.removeAllBypasses(i,!1)}else{e=e.split(/\s+/);for(var a=0;a<this.length;a++){var o=this[a];n.removeBypasses(o,e,!1)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),n=this[0];if(n){var r=n._private,i=n.pstyle("opacity").value;if(!t)return i;var a=r.data.parent?n.parents():null;if(a)for(var o=0;o<a.length;o++)i*=a[o].pstyle("opacity").value;return i}},transparent:function(){if(!this.cy().styleEnabled())return!1;var e=this[0],t=e.cy().hasCompoundNodes();if(e)if(!t)return 0===e.pstyle("opacity").value;else return 0===e.effectiveOpacity()},backgrounding:function(){return!!this.cy().styleEnabled()&&!!this[0]._private.backgrounding}};function oA(e,t){var n=e._private.data.parent?e.parents():null;if(n){for(var r=0;r<n.length;r++)if(!t(n[r]))return!1}return!0}function oD(e){var t=e.ok,n=e.edgeOkViaNode||e.ok,r=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var i=this[0],a=e.hasCompoundNodes();if(i){var o=i._private;if(!t(i))return!1;if(i.isNode())return!a||oA(i,r);var s=o.source,l=o.target;return n(s)&&(!a||oA(s,n))&&(s===l||n(l)&&(!a||oA(l,n)))}}}var oM=oT("eleTakesUpSpace",function(e){return"element"===e.pstyle("display").value&&0!==e.width()&&(!e.isNode()||0!==e.height())});o_.takesUpSpace=oS("takesUpSpace",oD({ok:oM})),o_.interactive=oS("interactive",oD({ok:oT("eleInteractive",function(e){return"yes"===e.pstyle("events").value&&"visible"===e.pstyle("visibility").value&&oM(e)}),parentOk:oT("parentInteractive",function(e){return"visible"===e.pstyle("visibility").value&&oM(e)}),edgeOkViaNode:oM})),o_.noninteractive=function(){var e=this[0];if(e)return!e.interactive()},o_.visible=oS("visible",oD({ok:oT("eleVisible",function(e){return"visible"===e.pstyle("visibility").value&&0!==e.pstyle("opacity").pfValue&&oM(e)}),edgeOkViaNode:oM})),o_.hidden=function(){var e=this[0];if(e)return!e.visible()},o_.isBundledBezier=oS("isBundledBezier",function(){return!!this.cy().styleEnabled()&&!this.removed()&&"bezier"===this.pstyle("curve-style").value&&this.takesUpSpace()}),o_.bypass=o_.css=o_.style,o_.renderedCss=o_.renderedStyle,o_.removeBypass=o_.removeCss=o_.removeStyle,o_.pstyle=o_.parsedStyle;var oP={};function oR(e){return function(){var t=arguments,n=[];if(2===t.length){var r=t[0],i=t[1];this.on(e.event,r,i)}else if(1===t.length&&tI(t[0])){var a=t[0];this.on(e.event,a)}else if(0===t.length||1===t.length&&tO(t[0])){for(var o=1===t.length?t[0]:null,s=0;s<this.length;s++){var l=this[s],c=!e.ableField||l._private[e.ableField],u=l._private[e.field]!=e.value;if(e.overrideAble){var d=e.overrideAble(l);if(void 0!==d&&(c=d,!d))return this}c&&(l._private[e.field]=e.value,u&&n.push(l))}var h=this.spawn(n);h.updateStyle(),h.emit(e.event),o&&h.emit(o)}return this}}function oL(e){oP[e.field]=function(){var t=this[0];if(t){if(e.overrideField){var n=e.overrideField(t);if(void 0!==n)return n}return t._private[e.field]}},oP[e.on]=oR({event:e.on,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!0}),oP[e.off]=oR({event:e.off,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!1})}oL({field:"locked",overrideField:function(e){return!!e.cy().autolock()||void 0},on:"lock",off:"unlock"}),oL({field:"grabbable",overrideField:function(e){return!(e.cy().autoungrabify()||e.pannable())&&void 0},on:"grabify",off:"ungrabify"}),oL({field:"selected",ableField:"selectable",overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:"select",off:"unselect"}),oL({field:"selectable",overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:"selectify",off:"unselectify"}),oP.deselect=oP.unselect,oP.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},oL({field:"active",on:"activate",off:"unactivate"}),oL({field:"pannable",on:"panify",off:"unpanify"}),oP.inactive=function(){var e=this[0];if(e)return!e._private.active};var oI={},oO=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r];if(i.isNode()){for(var a=!1,o=i.connectedEdges(),s=0;s<o.length;s++){var l=o[s],c=l.source(),u=l.target();if(e.noIncomingEdges&&u===i&&c!==i||e.noOutgoingEdges&&c===i&&u!==i){a=!0;break}}a||n.push(i)}}return this.spawn(n,!0).filter(t)}},oB=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r];if(i.isNode())for(var a=i.connectedEdges(),o=0;o<a.length;o++){var s=a[o],l=s.source(),c=s.target();e.outgoing&&l===i?(n.push(s),n.push(c)):e.incoming&&c===i&&(n.push(s),n.push(l))}}return this.spawn(n,!0).filter(t)}},oF=function(e){return function(t){for(var n=this,r=[],i={};;){var a=e.outgoing?n.outgoers():n.incomers();if(0===a.length)break;for(var o=!1,s=0;s<a.length;s++){var l=a[s],c=l.id();i[c]||(i[c]=!0,r.push(l),o=!0)}if(!o)break;n=a}return this.spawn(r,!0).filter(t)}};function oz(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r]._private[e.attr];i&&n.push(i)}return this.spawn(n,!0).filter(t)}}function oV(e){return function(t){var n=[],r=this._private.cy,i=e||{};tL(t)&&(t=r.$(t));for(var a=0;a<t.length;a++)for(var o=t[a]._private.edges,s=0;s<o.length;s++){var l=o[s],c=l._private.data,u=this.hasElementWithId(c.source)&&t.hasElementWithId(c.target),d=t.hasElementWithId(c.source)&&this.hasElementWithId(c.target);if(u||d){if((i.thisIsSrc||i.thisIsTgt)&&(i.thisIsSrc&&!u||i.thisIsTgt&&!d))continue;n.push(l)}}return this.spawn(n,!0)}}function oH(e){return e=t6({},{codirected:!1},e),function(t){for(var n=[],r=this.edges(),i=e,a=0;a<r.length;a++)for(var o=r[a]._private,s=o.source,l=s._private.data.id,c=o.data.target,u=s._private.edges,d=0;d<u.length;d++){var h=u[d],f=h._private.data,p=f.target,g=f.source,v=p===c&&g===l,x=l===p&&c===g;(i.codirected&&v||!i.codirected&&(v||x))&&n.push(h)}return this.spawn(n,!0).filter(t)}}oI.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},t6(oI,{roots:oO({noIncomingEdges:!0}),leaves:oO({noOutgoingEdges:!0}),outgoers:aO(oB({outgoing:!0}),"outgoers"),successors:oF({outgoing:!0}),incomers:aO(oB({incoming:!0}),"incomers"),predecessors:oF({})}),t6(oI,{neighborhood:aO(function(e){for(var t=[],n=this.nodes(),r=0;r<n.length;r++)for(var i=n[r],a=i.connectedEdges(),o=0;o<a.length;o++){var s=a[o],l=s.source(),c=s.target(),u=i===l?c:l;u.length>0&&t.push(u[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),oI.neighbourhood=oI.neighborhood,oI.closedNeighbourhood=oI.closedNeighborhood,oI.openNeighbourhood=oI.openNeighborhood,t6(oI,{source:aO(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"source"),target:aO(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"target"),sources:oz({attr:"source"}),targets:oz({attr:"target"})}),t6(oI,{edgesWith:aO(oV(),"edgesWith"),edgesTo:aO(oV({thisIsSrc:!0}),"edgesTo")}),t6(oI,{connectedEdges:aO(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode())for(var i=r._private.edges,a=0;a<i.length;a++){var o=i[a];t.push(o)}}return this.spawn(t,!0).filter(e)},"connectedEdges"),connectedNodes:aO(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];r.isEdge()&&(t.push(r.source()[0]),t.push(r.target()[0]))}return this.spawn(t,!0).filter(e)},"connectedNodes"),parallelEdges:aO(oH(),"parallelEdges"),codirectedEdges:aO(oH({codirected:!0}),"codirectedEdges")}),t6(oI,{components:function(e){var t=this,n=t.cy(),r=n.collection(),i=null==e?t.nodes():e.nodes(),a=[];null!=e&&i.empty()&&(i=e.sources());var o=function(e,t){r.merge(e),i.unmerge(e),t.merge(e)};if(i.empty())return t.spawn();do!function(){var e=n.collection();a.push(e);var r=i[0];o(r,e),t.bfs({directed:!1,roots:r,visit:function(t){return o(t,e)}}),e.forEach(function(n){n.connectedEdges().forEach(function(n){t.has(n)&&e.has(n.source())&&e.has(n.target())&&e.merge(n)})})}();while(i.length>0)return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),oI.componentsOf=oI.components;var oU=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0===e)return void nP("A collection must have a reference to the core");var i=new nW,a=!1;if(t){if(t.length>0&&tB(t[0])&&!tH(t[0])){a=!0;for(var o=[],s=new n$,l=0,c=t.length;l<c;l++){var u=t[l];null==u.data&&(u.data={});var d=u.data;if(null==d.id)d.id=nO();else if(e.hasElementWithId(d.id)||s.has(d.id))continue;var h=new nK(e,u,!1);o.push(h),s.add(d.id)}t=o}}else t=[];this.length=0;for(var f=0,p=t.length;f<p;f++){var g=t[f][0];if(null!=g){var v=g._private.data.id;(!n||!i.has(v))&&(n&&i.set(v,{index:this.length,ele:g}),this[this.length]=g,this.length++)}}this._private={eles:this,cy:e,get map(){return null==this.lazyMap&&this.rebuildMap(),this.lazyMap},set map(m){this.lazyMap=m},rebuildMap:function(){for(var e=this.lazyMap=new nW,t=this.eles,n=0;n<t.length;n++){var r=t[n];e.set(r.id(),{index:n,ele:r})}}},n&&(this._private.map=i),a&&!r&&this.restore()},oG=nK.prototype=oU.prototype=Object.create(Array.prototype);oG.instanceString=function(){return"collection"},oG.spawn=function(e,t){return new oU(this.cy(),e,t)},oG.spawnSelf=function(){return this.spawn(this)},oG.cy=function(){return this._private.cy},oG.renderer=function(){return this._private.cy.renderer()},oG.element=function(){return this[0]},oG.collection=function(){return tU(this)?this:new oU(this._private.cy,[this])},oG.unique=function(){return new oU(this._private.cy,this,!0)},oG.hasElementWithId=function(e){return e=""+e,this._private.map.has(e)},oG.getElementById=function(e){e=""+e;var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new oU(t)},oG.$id=oG.getElementById,oG.poolIndex=function(){var e=this._private.cy._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},oG.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},oG.indexOfId=function(e){return e=""+e,this._private.map.get(e).index},oG.json=function(e){var t=this.element(),n=this.cy();if(null==t&&e)return this;if(null!=t){var r=t._private;if(tB(e)){if(n.startBatch(),e.data){t.data(e.data);var i=r.data;if(t.isEdge()){var a=!1,o={},s=e.data.source,l=e.data.target;null!=s&&s!=i.source&&(o.source=""+s,a=!0),null!=l&&l!=i.target&&(o.target=""+l,a=!0),a&&(t=t.move(o))}else{var c="parent"in e.data,u=e.data.parent;c&&(null!=u||null!=i.parent)&&u!=i.parent&&(void 0===u&&(u=null),null!=u&&(u=""+u),t=t.move({parent:u}))}}e.position&&t.position(e.position);var d=function(n,i,a){var o=e[n];null!=o&&o!==r[n]&&(o?t[i]():t[a]())};return d("removed","remove","restore"),d("selected","select","unselect"),d("selectable","selectify","unselectify"),d("locked","lock","unlock"),d("grabbable","grabify","ungrabify"),d("pannable","panify","unpanify"),null!=e.classes&&t.classes(e.classes),n.endBatch(),this}if(void 0===e){var h={data:nI(r.data),position:nI(r.position),group:r.group,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbable:r.grabbable,pannable:r.pannable,classes:null};h.classes="";var f=0;return r.classes.forEach(function(e){return h.classes+=0==f++?e:" "+e}),h}}},oG.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t].json();e.push(n)}return e},oG.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=new nK(e,this[n].json(),!1);t.push(r)}return new oU(e,t)},oG.copy=oG.clone,oG.restore=function(){for(var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this.cy(),r=n._private,i=[],a=[],o=0,s=this.length;o<s;o++){var l=this[o];(!t||l.removed())&&(l.isNode()?i.push(l):a.push(l))}D=i.concat(a);var c=function(){D.splice(M,1),M--};for(M=0;M<D.length;M++){var u=D[M],d=u._private,h=d.data;if(u.clearTraversalCache(),t||d.removed){if(void 0===h.id)h.id=nO();else if(tF(h.id))h.id=""+h.id;else if(tX(h.id)||!tL(h.id)){nP("Can not create element with invalid string ID `"+h.id+"`"),c();continue}else if(n.hasElementWithId(h.id)){nP("Can not create second element with ID `"+h.id+"`"),c();continue}}var f=h.id;if(u.isNode()){var p=d.position;null==p.x&&(p.x=0),null==p.y&&(p.y=0)}if(u.isEdge()){for(var g=["source","target"],v=g.length,x=!1,y=0;y<v;y++){var b=g[y],w=h[b];tF(w)&&(w=h[b]=""+h[b]),null==w||""===w?(nP("Can not create edge `"+f+"` with unspecified "+b),x=!0):n.hasElementWithId(w)||(nP("Can not create edge `"+f+"` with nonexistant "+b+" `"+w+"`"),x=!0)}if(x){c();continue}var N=n.getElementById(h.source),j=n.getElementById(h.target);N.same(j)?N._private.edges.push(u):(N._private.edges.push(u),j._private.edges.push(u)),u._private.source=N,u._private.target=j}d.map=new nW,d.map.set(f,{ele:u,index:0}),d.removed=!1,t&&n.addToPool(u)}for(var k=0;k<i.length;k++){var C=i[k],E=C._private.data;tF(E.parent)&&(E.parent=""+E.parent);var T=E.parent;if(null!=T||C._private.parent){var S=C._private.parent?n.collection().merge(C._private.parent):n.getElementById(T);if(S.empty())E.parent=void 0;else if(S[0].removed())nL("Node added with missing parent, reference to parent removed"),E.parent=void 0,C._private.parent=null;else{for(var _=!1,A=S;!A.empty();){if(C.same(A)){_=!0,E.parent=void 0;break}A=A.parent()}_||(S[0]._private.children.push(C),C._private.parent=S[0],r.hasCompoundNodes=!0)}}}if(D.length>0){for(var D,M,P,R=D.length===this.length?this:new oU(n,D),L=0;L<R.length;L++){var I=R[L];I.isNode()||(I.parallelEdges().clearTraversalCache(),I.source().clearTraversalCache(),I.target().clearTraversalCache())}(r.hasCompoundNodes?n.collection().merge(R).merge(R.connectedNodes()).merge(R.parent()):R).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(e),e?R.emitAndNotify("add"):t&&R.emit("add")}return this},oG.removed=function(){var e=this[0];return e&&e._private.removed},oG.inside=function(){var e=this[0];return e&&!e._private.removed},oG.remove=function(){for(var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=[],r={},i=this._private.cy,a=0,o=this.length;a<o;a++)!function e(i){var a=r[i.id()];if(!(t&&i.removed())&&!a)if(r[i.id()]=!0,i.isNode()){n.push(i);for(var o=i._private.edges,s=0;s<o.length;s++)e(o[s]);for(var l=i._private.children,c=0;c<l.length;c++)e(l[c])}else n.unshift(i)}(this[a]);function s(e,t){nV(e._private.edges,t),e.clearTraversalCache()}var l=[];l.ids={},this.dirtyCompoundBoundsCache(),t&&i.removeFromPool(n);for(var c=0;c<n.length;c++){var u=n[c];if(u.isEdge()){var d=u.source()[0],h=u.target()[0];s(d,u),s(h,u);for(var f=u.parallelEdges(),p=0;p<f.length;p++){var g=f[p];g.clearTraversalCache(),g.isBundledBezier()&&g.dirtyBoundingBoxCache()}}else{var v=u.parent();0!==v.length&&function(e,t){t=t[0];var n=(e=e[0])._private.children,r=e.id();nV(n,t),t._private.parent=null,l.ids[r]||(l.ids[r]=!0,l.push(e))}(v,u)}t&&(u._private.removed=!0)}var x=i._private.elements;i._private.hasCompoundNodes=!1;for(var y=0;y<x.length;y++)if(x[y].isParent()){i._private.hasCompoundNodes=!0;break}var b=new oU(this.cy(),n);b.size()>0&&(e?b.emitAndNotify("remove"):t&&b.emit("remove"));for(var w=0;w<l.length;w++){var N=l[w];t&&N.removed()||N.updateStyle()}return b},oG.move=function(e){var t=this._private.cy,n=this,r=function(e){return null==e?e:""+e};if(void 0!==e.source||void 0!==e.target){var i=r(e.source),a=r(e.target),o=null!=i&&t.hasElementWithId(i),s=null!=a&&t.hasElementWithId(a);(o||s)&&(t.batch(function(){n.remove(!1,!1),n.emitAndNotify("moveout");for(var e=0;e<n.length;e++){var t=n[e],r=t._private.data;t.isEdge()&&(o&&(r.source=i),s&&(r.target=a))}n.restore(!1,!1)}),n.emitAndNotify("move"))}else if(void 0!==e.parent){var l=r(e.parent);if(null===l||t.hasElementWithId(l)){var c=null===l?void 0:l;t.batch(function(){var e=n.remove(!1,!1);e.emitAndNotify("moveout");for(var t=0;t<n.length;t++){var r=n[t],i=r._private.data;r.isNode()&&(i.parent=c)}e.restore(!1,!1)}),n.emitAndNotify("move")}}return this},[i2,av,ax,aI,aB,ur,aU,oa,ob,ow,{isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},oj,oC,o_,oP,oI].forEach(function(e){t6(oG,e)});var oY=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var i={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:i.v,dv:e(i)}}return function n(r,i,a){var o,s,l,c,u,d,h,f,p,g,v,x={x:-1,v:0,tension:null,friction:null},y=[0],b=0;for(r=parseFloat(r)||500,i=parseFloat(i)||20,a=a||null,x.tension=r,x.friction=i,g=(p=null!==a)?(b=n(r,i))/a*.016:.016;o=v||x,s=g,l={dx:o.v,dv:e(o)},c=t(o,.5*s,l),u=t(o,.5*s,c),d=t(o,s,u),h=1/6*(l.dx+2*(c.dx+u.dx)+d.dx),f=1/6*(l.dv+2*(c.dv+u.dv)+d.dv),o.x=o.x+h*s,o.v=o.v+f*s,v=o,y.push(1+v.x),b+=16,Math.abs(v.x)>1e-4&&Math.abs(v.v)>1e-4;);return p?function(e){return y[e*(y.length-1)|0]}:b}}(),oX=function(e,t,n,r){var i=function(e,t,n,r){var i="u">typeof Float32Array;if(4!=arguments.length)return!1;for(var a=0;a<4;++a)if("number"!=typeof arguments[a]||isNaN(arguments[a])||!isFinite(arguments[a]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var o=i?new Float32Array(11):Array(11);function s(e,t,n){return(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e}function l(e,t,n){return 3*(1-3*n+3*t)*e*e+2*(3*n-6*t)*e+3*t}var c=!1,u=function(i){return(c||(c=!0,(e!==t||n!==r)&&function(){for(var t=0;t<11;++t)o[t]=s(.1*t,e,n)}()),e===t&&n===r)?i:0===i?0:1===i?1:s(function(t){for(var r=0,i=1;10!==i&&o[i]<=t;++i)r+=.1;var a=r+(t-o[--i])/(o[i+1]-o[i])*.1,c=l(a,e,n);if(c>=.001){for(var u=a,d=0;d<4;++d){var h=l(u,e,n);if(0===h)break;var f=s(u,e,n)-t;u-=f/h}return u}return 0===c?a:function(t,r,i){var a,o,l=0;do(a=s(o=r+(i-r)/2,e,n)-t)>0?i=o:r=o;while(Math.abs(a)>1e-7&&++l<10)return o}(t,r,r+.1)}(i),t,r)};u.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var d="generateBezier("+[e,t,n,r]+")";return u.toString=function(){return d},u}(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},oW={linear:function(e,t,n){return e+(t-e)*n},ease:oX(.25,.1,.25,1),"ease-in":oX(.42,0,1,1),"ease-out":oX(0,0,.58,1),"ease-in-out":oX(.42,0,.58,1),"ease-in-sine":oX(.47,0,.745,.715),"ease-out-sine":oX(.39,.575,.565,1),"ease-in-out-sine":oX(.445,.05,.55,.95),"ease-in-quad":oX(.55,.085,.68,.53),"ease-out-quad":oX(.25,.46,.45,.94),"ease-in-out-quad":oX(.455,.03,.515,.955),"ease-in-cubic":oX(.55,.055,.675,.19),"ease-out-cubic":oX(.215,.61,.355,1),"ease-in-out-cubic":oX(.645,.045,.355,1),"ease-in-quart":oX(.895,.03,.685,.22),"ease-out-quart":oX(.165,.84,.44,1),"ease-in-out-quart":oX(.77,0,.175,1),"ease-in-quint":oX(.755,.05,.855,.06),"ease-out-quint":oX(.23,1,.32,1),"ease-in-out-quint":oX(.86,0,.07,1),"ease-in-expo":oX(.95,.05,.795,.035),"ease-out-expo":oX(.19,1,.22,1),"ease-in-out-expo":oX(1,0,0,1),"ease-in-circ":oX(.6,.04,.98,.335),"ease-out-circ":oX(.075,.82,.165,1),"ease-in-out-circ":oX(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return oW.linear;var r=oY(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":oX};function oq(e,t,n,r,i){if(1===r||t===n)return n;var a=i(t,n,r);return null==e||((e.roundValue||e.color)&&(a=Math.round(a)),void 0!==e.min&&(a=Math.max(a,e.min)),void 0!==e.max&&(a=Math.min(a,e.max))),a}function o$(e,t){return null==e.pfValue&&null==e.value?e:null!=e.pfValue&&(null==t||"%"!==t.type.units)?e.pfValue:e.value}function oK(e,t,n,r,i){var a=null!=i?i.type:null;n<0?n=0:n>1&&(n=1);var o=o$(e,i),s=o$(t,i);if(tF(o)&&tF(s))return oq(a,o,s,n,r);if(tO(o)&&tO(s)){for(var l=[],c=0;c<s.length;c++){var u=o[c],d=s[c];if(null!=u&&null!=d){var h=oq(a,u,d,n,r);l.push(h)}else l.push(d)}return l}}function oZ(e,t){return null!=e&&null!=t&&(!!(tF(e)&&tF(t))||!!e&&!!t)}function oQ(e,t){var n=t._private.aniEles,r=[];function i(t,n){var i=t._private,a=i.animation.current,o=i.animation.queue,s=!1;if(0===a.length){var l=o.shift();l&&a.push(l)}for(var c=function(e){for(var t=e.length-1;t>=0;t--)(0,e[t])();e.splice(0,e.length)},u=a.length-1;u>=0;u--){var d=a[u],h=d._private;if(h.stopped){a.splice(u,1),h.hooked=!1,h.playing=!1,h.started=!1,c(h.frames);continue}(h.playing||h.applying)&&(h.playing&&h.applying&&(h.applying=!1),h.started||function(e,t,n,r){var i=t._private;i.started=!0,i.startTime=n-i.progress*i.duration}(0,d,e),function(e,t,n,r){var i,a,o,s,l=!r,c=e._private,u=t._private,d=u.easing,h=u.startTime,f=(r?e:e.cy()).style();u.easingImpl||(null==d?u.easingImpl=oW.linear:(i=tL(d)?f.parse("transition-timing-function",d).value:d,tL(i)?(a=i,o=[]):(a=i[1],o=i.slice(2).map(function(e){return+e})),o.length>0?("spring"===a&&o.push(u.duration),u.easingImpl=oW[a].apply(null,o)):u.easingImpl=oW[a]));var p=u.easingImpl;if(s=0===u.duration?1:(n-h)/u.duration,u.applying&&(s=u.progress),s<0?s=0:s>1&&(s=1),null==u.delay){var g=u.startPosition,v=u.position;if(v&&l&&!e.locked()){var x={};oZ(g.x,v.x)&&(x.x=oK(g.x,v.x,s,p)),oZ(g.y,v.y)&&(x.y=oK(g.y,v.y,s,p)),e.position(x)}var y=u.startPan,b=u.pan,w=c.pan,N=null!=b&&r;N&&(oZ(y.x,b.x)&&(w.x=oK(y.x,b.x,s,p)),oZ(y.y,b.y)&&(w.y=oK(y.y,b.y,s,p)),e.emit("pan"));var j=u.startZoom,k=u.zoom,C=null!=k&&r;C&&(oZ(j,k)&&(c.zoom=rg(c.minZoom,oK(j,k,s,p),c.maxZoom)),e.emit("zoom")),(N||C)&&e.emit("viewport");var E=u.style;if(E&&E.length>0&&l){for(var T=0;T<E.length;T++){var S=E[T],_=S.name,A=u.startStyle[_],D=f.properties[A.name],M=oK(A,S,s,p,D);f.overrideBypass(e,_,M)}e.emit("style")}}u.progress=s}(t,d,e,n),h.applying&&(h.applying=!1),c(h.frames),null!=h.step&&h.step(e),d.completed()&&(a.splice(u,1),h.hooked=!1,h.playing=!1,h.started=!1,c(h.completes)),s=!0)}return n||0!==a.length||0!==o.length||r.push(t),s}for(var a=!1,o=0;o<n.length;o++){var s=i(n[o]);a=a||s}var l=i(t,!0);(a||l)&&(n.length>0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var oJ={animate:am.animate(),animation:am.animation(),animated:am.animated(),clearQueue:am.clearQueue(),delay:am.delay(),delayAnimation:am.delayAnimation(),stop:am.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender(function(t,n){oQ(n,e)},t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&ng(function(n){oQ(n,e),t()})}()}}},o0={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&tH(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e}},o1=function(e){return tL(e)?new aR(e):e},o2={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new of(o0,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,o1(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,o1(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,o1(t),n),this},once:function(e,t,n){return this.emitter().one(e,o1(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};am.eventAliasesOn(o2);var o5={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};o5.jpeg=o5.jpg;var o3={layout:function(e){if(null==e)return void nP("Layout options must be specified to make a layout");if(null==e.name)return void nP("A `name` must be specified to make a layout");var t,n=e.name,r=this.extension("layout",n);return null==r?void nP("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?"):(t=tL(e.eles)?this.$(e.eles):null!=e.eles?e.eles:this.$(),new r(t6({},e,{cy:this,eles:t})))}};o3.createLayout=o3.makeLayout=o3.layout;var o4=nz({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:36,webglTexRowsNodes:18,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),o6={renderTo:function(e,t,n,r){return this._private.renderer.renderTo(e,t,n,r),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this.extension("renderer",e.name);if(null==t)return void nP("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"));void 0!==e.wheelSensitivity&&nL("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var n=o4(e);n.cy=this,this._private.renderer=new t(n),this.notify("init")},destroyRenderer:function(){this.notify("destroy");var e=this.container();if(e)for(e._cyreg=null;e.childNodes.length>0;)e.removeChild(e.childNodes[0]);this._private.renderer=null,this.mutableElements().forEach(function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};o6.invalidateDimensions=o6.resize;var o9={collection:function(e,t){return tL(e)?this.$(e):tV(e)?e.collection():tO(e)?(t||(t={}),new oU(this,e,t.unique,t.removed)):new oU(this)},nodes:function(e){var t=this.$(function(e){return e.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(e){return e.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};o9.elements=o9.filter=o9.$;var o7={};o7.apply=function(e){for(var t=this._private.cy.collection(),n=0;n<e.length;n++){var r=e[n],i=this.getContextMeta(r);if(!i.empty){var a=this.getContextStyle(i),o=this.applyContextStyle(i,a,r);r._private.appliedInitStyle?this.updateTransitions(r,o.diffProps):r._private.appliedInitStyle=!0,this.updateStyleHints(r)&&t.push(r)}}return t},o7.getPropertiesDiff=function(e,t){var n=this._private.propDiffs=this._private.propDiffs||{},r=e+"-"+t,i=n[r];if(i)return i;for(var a=[],o={},s=0;s<this.length;s++){var l=this[s],c="t"===e[s],u="t"===t[s],d=c!==u,h=l.mappedProperties.length>0;if(d||u&&h){var f=void 0;d&&h||d?f=l.properties:h&&(f=l.mappedProperties);for(var p=0;p<f.length;p++){for(var g=f[p],v=g.name,x=!1,y=s+1;y<this.length;y++){var b=this[y];if("t"===t[y]&&(x=null!=b.properties[g.name]))break}o[v]||x||(o[v]=!0,a.push(v))}}}return n[r]=a,a},o7.getContextMeta=function(e){for(var t,n="",r=e._private.styleCxtKey||"",i=0;i<this.length;i++){var a=this[i];a.selector&&a.selector.matches(e)?n+="t":n+="f"}return t=this.getPropertiesDiff(r,n),e._private.styleCxtKey=n,{key:n,diffPropNames:t,empty:0===t.length}},o7.getContextStyle=function(e){var t=e.key,n=this._private.contextStyles=this._private.contextStyles||{};if(n[t])return n[t];for(var r={_private:{key:t}},i=0;i<this.length;i++){var a=this[i];if("t"===t[i])for(var o=0;o<a.properties.length;o++){var s=a.properties[o];r[s.name]=s}}return n[t]=r,r},o7.applyContextStyle=function(e,t,n){for(var r=e.diffPropNames,i={},a=this.types,o=0;o<r.length;o++){var s=r[o],l=t[s],c=n.pstyle(s);if(!l)if(!c)continue;else l=c.bypass?{name:s,deleteBypassed:!0}:{name:s,delete:!0};if(c!==l){if(l.mapped===a.fn&&null!=c&&null!=c.mapping&&c.mapping.value===l.value){var u=c.mapping;if((u.fnValue=l.value(n))===u.prevFnValue)continue}var d=i[s]={prev:c};this.applyParsedProperty(n,l),d.next=n.pstyle(s),d.next&&d.next.bypass&&(d.next=d.next.bypassed)}}return{diffProps:i}},o7.updateStyleHints=function(e){var t=e._private,n=this,r=n.propertyGroupNames,i=n.propertyGroupKeys,a=function(e,t,r){return n.getPropertiesHash(e,t,r)},o=t.styleKey;if(e.removed())return!1;var s="nodes"===t.group,l=e._private.style;r=Object.keys(l);for(var c=0;c<i.length;c++){var u=i[c];t.styleKeys[u]=[9261,5381]}for(var d=function(e,n){return t.styleKeys[n][0]=nv(e,t.styleKeys[n][0])},h=function(e,n){return t.styleKeys[n][1]=nx(e,t.styleKeys[n][1])},f=function(e,t){for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);d(r,t),h(r,t)}},p=0;p<r.length;p++){var g=r[p],v=l[g];if(null!=v){var x,y,b=this.properties[g],w=b.type,N=b.groupKey,j=void 0;null!=b.hashOverride?j=b.hashOverride(e,v):null!=v.pfValue&&(j=v.pfValue);var k=null==b.enums?v.value:null,C=null!=j,E=null!=k,T=C||E,S=v.units;w.number&&T&&!w.multiple?(d(y=-128<(x=C?j:k)&&x<128&&Math.floor(x)!==x?2e9-(1024*x|0):x,N),h(y,N),C||null==S||f(S,N)):f(v.strValue,N)}}for(var _=[9261,5381],A=0;A<i.length;A++){var D=i[A],M=t.styleKeys[D];_[0]=nv(M[0],_[0]),_[1]=nx(M[1],_[1])}t.styleKey=2097152*_[0]+_[1];var P=t.styleKeys;t.labelDimsKey=ny(P.labelDimensions);var R=a(e,["label"],P.labelDimensions);if(t.labelKey=ny(R),t.labelStyleKey=ny(nb(P.commonLabel,R)),!s){var L=a(e,["source-label"],P.labelDimensions);t.sourceLabelKey=ny(L),t.sourceLabelStyleKey=ny(nb(P.commonLabel,L));var I=a(e,["target-label"],P.labelDimensions);t.targetLabelKey=ny(I),t.targetLabelStyleKey=ny(nb(P.commonLabel,I))}if(s){var O=t.styleKeys,B=O.nodeBody,F=O.nodeBorder,z=O.nodeOutline,V=O.backgroundImage,H=O.compound,U=O.pie,G=O.stripe;t.nodeKey=ny([B,F,z,V,H,U,G].filter(function(e){return null!=e}).reduce(nb,[9261,5381])),t.hasPie=null!=U&&9261!==U[0]&&5381!==U[1],t.hasStripe=null!=G&&9261!==G[0]&&5381!==G[1]}return o!==t.styleKey},o7.clearStyleHints=function(e){var t=e._private;t.styleCxtKey="",t.styleKeys={},t.styleKey=null,t.labelKey=null,t.labelStyleKey=null,t.sourceLabelKey=null,t.sourceLabelStyleKey=null,t.targetLabelKey=null,t.targetLabelStyleKey=null,t.nodeKey=null,t.hasPie=null,t.hasStripe=null},o7.applyParsedProperty=function(e,t){var n=this,r=t,i=e._private.style,a=n.types,o=n.properties[r.name].type,s=r.bypass,l=i[r.name],c=l&&l.bypass,u=e._private,d="mapping",h=function(e){return null==e?null:null!=e.pfValue?e.pfValue:e.value},f=function(){var t=h(l),i=h(r);n.checkTriggers(e,r.name,t,i)};if("curve-style"===t.name&&e.isEdge()&&("bezier"!==t.value&&e.isLoop()||"haystack"===t.value&&(e.source().isParent()||e.target().isParent()))&&(r=t=this.parse(t.name,"bezier",s)),r.delete)return i[r.name]=void 0,f(),!0;if(r.deleteBypassed)if(!l)return f(),!0;else if(l.bypass)return l.bypassed=void 0,f(),!0;else return!1;if(r.deleteBypass)if(!l)return f(),!0;else if(l.bypass)return i[r.name]=l.bypassed,f(),!0;else return!1;var p=function(){nL("Do not assign mappings to elements without corresponding data (i.e. ele `"+e.id()+"` has no mapping for property `"+r.name+"` with data field `"+r.field+"`); try a `["+r.field+"]` selector to limit scope to elements with `"+r.field+"` defined")};switch(r.mapped){case a.mapData:for(var g,v,x=r.field.split("."),y=u.data,b=0;b<x.length&&y;b++)y=y[x[b]];if(null==y)return p(),!1;if(!tF(y))return nL("Do not use continuous mappers without specifying numeric data (i.e. `"+r.field+": "+y+"` for `"+e.id()+"` is non-numeric)"),!1;var w=r.fieldMax-r.fieldMin;if((v=0===w?0:(y-r.fieldMin)/w)<0?v=0:v>1&&(v=1),o.color){var N=r.valueMin[0],j=r.valueMax[0],k=r.valueMin[1],C=r.valueMax[1],E=r.valueMin[2],T=r.valueMax[2],S=null==r.valueMin[3]?1:r.valueMin[3],_=[Math.round(N+(j-N)*v),Math.round(k+(C-k)*v),Math.round(E+(T-E)*v),Math.round(S+((null==r.valueMax[3]?1:r.valueMax[3])-S)*v)];g={bypass:r.bypass,name:r.name,value:_,strValue:"rgb("+_[0]+", "+_[1]+", "+_[2]+")"}}else{if(!o.number)return!1;var A=r.valueMin+(r.valueMax-r.valueMin)*v;g=this.parse(r.name,A,r.bypass,d)}if(!g)return p(),!1;g.mapping=r,r=g;break;case a.data:for(var D=r.field.split("."),M=u.data,P=0;P<D.length&&M;P++)M=M[D[P]];if(null!=M&&(g=this.parse(r.name,M,r.bypass,d)),!g)return p(),!1;g.mapping=r,r=g;break;case a.fn:var R=r.value,L=null!=r.fnValue?r.fnValue:R(e);if(r.prevFnValue=L,null==L)return nL("Custom function mappers may not return null (i.e. `"+r.name+"` for ele `"+e.id()+"` is null)"),!1;if(!(g=this.parse(r.name,L,r.bypass,d)))return nL("Custom function mappers may not return invalid values for the property type (i.e. `"+r.name+"` for ele `"+e.id()+"` is invalid)"),!1;g.mapping=nI(r),r=g;break;case void 0:break;default:return!1}return s?(c?r.bypassed=l.bypassed:r.bypassed=l,i[r.name]=r):c?l.bypassed=r:i[r.name]=r,f(),!0},o7.cleanElements=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(this.clearStyleHints(r),r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),t)for(var i=r._private.style,a=Object.keys(i),o=0;o<a.length;o++){var s=a[o],l=i[s];null!=l&&(l.bypass?l.bypassed=null:i[s]=null)}else r._private.style={}}},o7.update=function(){this._private.cy.mutableElements().updateStyle()},o7.updateTransitions=function(e,t){var n=this,r=e._private,i=e.pstyle("transition-property").value,a=e.pstyle("transition-duration").pfValue,o=e.pstyle("transition-delay").pfValue;if(i.length>0&&a>0){for(var s={},l=!1,c=0;c<i.length;c++){var u=i[c],d=e.pstyle(u),h=t[u];if(h){var f=h.prev,p=null!=h.next?h.next:d,g=!1,v=void 0;f&&(tF(f.pfValue)&&tF(p.pfValue)?(g=p.pfValue-f.pfValue,v=f.pfValue+1e-6*g):tF(f.value)&&tF(p.value)?(g=p.value-f.value,v=f.value+1e-6*g):tO(f.value)&&tO(p.value)&&(g=f.value[0]!==p.value[0]||f.value[1]!==p.value[1]||f.value[2]!==p.value[2],v=f.strValue),g&&(s[u]=p.strValue,this.applyBypass(e,u,v),l=!0))}}if(!l)return;r.transitioning=!0,new i8(function(t){o>0?e.delayAnimation(o).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:a,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1})}else r.transitioning&&(this.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1)},o7.checkTrigger=function(e,t,n,r,i,a){var o=this.properties[t],s=i(o);!e.removed()&&null!=s&&s(n,r,e)&&a(o)},o7.checkZOrderTrigger=function(e,t,n,r){var i=this;this.checkTrigger(e,t,n,r,function(e){return e.triggersZOrder},function(){i._private.cy.notify("zorder",e)})},o7.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},o7.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfConnectedEdges},function(t){e.connectedEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},o7.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfParallelEdges},function(t){e.parallelEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},o7.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var o8={};o8.applyBypass=function(e,t,n,r){var i=[];if("*"===t||"**"===t){if(void 0!==n)for(var a=0;a<this.properties.length;a++){var o=this.properties[a].name,s=this.parse(o,n,!0);s&&i.push(s)}}else if(tL(t)){var l=this.parse(t,n,!0);l&&i.push(l)}else{if(!tB(t))return!1;r=n;for(var c=Object.keys(t),u=0;u<c.length;u++){var d=c[u],h=t[d];if(void 0===h&&(h=t[tK(d)]),void 0!==h){var f=this.parse(d,h,!0);f&&i.push(f)}}}if(0===i.length)return!1;for(var p=!1,g=0;g<e.length;g++){for(var v=e[g],x={},y=void 0,b=0;b<i.length;b++){var w=i[b];if(r){var N=v.pstyle(w.name);y=x[w.name]={prev:N}}p=this.applyParsedProperty(v,nI(w))||p,r&&(y.next=v.pstyle(w.name))}p&&this.updateStyleHints(v),r&&this.updateTransitions(v,x,!0)}return p},o8.overrideBypass=function(e,t,n){t=t$(t);for(var r=0;r<e.length;r++){var i=e[r],a=i._private.style[t],o=this.properties[t].type,s=o.color,l=o.mutiple,c=a?null!=a.pfValue?a.pfValue:a.value:null;a&&a.bypass?(a.value=n,null!=a.pfValue&&(a.pfValue=n),s?a.strValue="rgb("+n.join(",")+")":l?a.strValue=n.join(" "):a.strValue=""+n,this.updateStyleHints(i)):this.applyBypass(i,t,n),this.checkTriggers(i,t,c,n)}},o8.removeAllBypasses=function(e,t){return this.removeBypasses(e,this.propertyNames,t)},o8.removeBypasses=function(e,t,n){for(var r=0;r<e.length;r++){for(var i=e[r],a={},o=0;o<t.length;o++){var s=t[o],l=this.properties[s],c=i.pstyle(l.name);if(c&&c.bypass){var u=this.parse(s,"",!0),d=a[l.name]={prev:c};this.applyParsedProperty(i,u),d.next=i.pstyle(l.name)}}this.updateStyleHints(i),n&&this.updateTransitions(i,a,!0)}};var se={};se.getEmSizeInPixels=function(){var e=this.containerCss("font-size");return null!=e?parseFloat(e):1},se.containerCss=function(e){var t=this._private.cy,n=t.container(),r=t.window();if(r&&n&&r.getComputedStyle)return r.getComputedStyle(n).getPropertyValue(e)};var st={};st.getRenderedStyle=function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},st.getRawStyle=function(e,t){if(e=e[0]){for(var n={},r=0;r<this.properties.length;r++){var i=this.properties[r],a=this.getStylePropertyValue(e,i.name,t);null!=a&&(n[i.name]=a,n[tK(i.name)]=a)}return n}},st.getIndexedStyle=function(e,t,n,r){var i=e.pstyle(t)[n][r];return null!=i?i:e.cy().style().getDefaultProperty(t)[n][0]},st.getStylePropertyValue=function(e,t,n){if(e=e[0]){var r=this.properties[t];r.alias&&(r=r.pointsTo);var i=r.type,a=e.pstyle(r.name);if(a){var o=a.value,s=a.units,l=a.strValue;if(n&&i.number&&null!=o&&tF(o)){var c=e.cy().zoom(),u=function(e){return e*c},d=function(e,t){return u(e)+t},h=tO(o);if(h?s.every(function(e){return null!=e}):null!=s)if(h)return o.map(function(e,t){return d(e,s[t])}).join(" ");else return d(o,s);return h?o.map(function(e){return tL(e)?e:""+u(e)}).join(" "):""+u(o)}if(null!=l)return l}return null}},st.getAnimationStartStyle=function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r].name,a=e.pstyle(i);void 0!==a&&(a=tB(a)?this.parse(i,a.strValue):this.parse(i,a)),a&&(n[i]=a)}return n},st.getPropsList=function(e){var t=[],n=this.properties;if(e)for(var r=Object.keys(e),i=0;i<r.length;i++){var a=r[i],o=e[a],s=n[a]||n[t$(a)],l=this.parse(s.name,o);l&&t.push(l)}return t},st.getNonDefaultPropertiesHash=function(e,t,n){var r,i,a,o,s,l,c=n.slice();for(s=0;s<t.length;s++)if(r=t[s],null!=(i=e.pstyle(r,!1)))if(null!=i.pfValue)c[0]=nv(o,c[0]),c[1]=nx(o,c[1]);else for(l=0,a=i.strValue;l<a.length;l++)o=a.charCodeAt(l),c[0]=nv(o,c[0]),c[1]=nx(o,c[1]);return c},st.getPropertiesHash=st.getNonDefaultPropertiesHash;var sn={};sn.appendFromJson=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n.selector,i=n.style||n.css,a=Object.keys(i);this.selector(r);for(var o=0;o<a.length;o++){var s=a[o],l=i[s];this.css(s,l)}}return this},sn.fromJson=function(e){return this.resetToDefault(),this.appendFromJson(e),this},sn.json=function(){for(var e=[],t=this.defaultLength;t<this.length;t++){for(var n=this[t],r=n.selector,i=n.properties,a={},o=0;o<i.length;o++){var s=i[o];a[s.name]=s.strValue}e.push({selector:r?r.toString():"core",style:a})}return e};var sr={};sr.appendFromString=function(e){var t,n,r,i=""+e;function a(){i=i.length>t.length?i.substr(t.length):""}function o(){n=n.length>r.length?n.substr(r.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");!i.match(/^\s*$/);){var s=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!s){nL("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}t=s[0];var l=s[1];if("core"!==l&&new aR(l).invalid){nL("Skipping parsing of block: Invalid selector found in string stylesheet: "+l),a();continue}var c=s[2],u=!1;n=c;for(var d=[];!n.match(/^\s*$/);){var h=n.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!h){nL("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+c),u=!0;break}r=h[0];var f=h[1],p=h[2];if(!this.properties[f]){nL("Skipping property: Invalid property name in: "+r),o();continue}if(!this.parse(f,p)){nL("Skipping property: Invalid property definition in: "+r),o();continue}d.push({name:f,val:p}),o()}if(u){a();break}this.selector(l);for(var g=0;g<d.length;g++){var v=d[g];this.css(v.name,v.val)}a()}return this},sr.fromString=function(e){return this.resetToDefault(),this.appendFromString(e),this};var si={};!function(){var e=function(e){return"^"+e+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},t=function(e){var t=t0+"|\\w+|"+t2+"|"+t3+"|\\#[0-9a-fA-F]{3}|\\#[0-9a-fA-F]{6}";return"^"+e+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+t0+")\\s*\\,\\s*("+t0+")\\s*,\\s*("+t+")\\s*\\,\\s*("+t+")\\)$"},n=["^url\\s*\\(\\s*['\"]?(.+?)['\"]?\\s*\\)$","^(none)$","^(.+)$"];si.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},axisDirectionExplicit:{enums:["leftward","rightward","upward","downward"]},axisDirectionPrimary:{enums:["horizontal","vertical"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},boxSelection:{enums:["contain","overlap","none"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle","circle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:e("data")},layoutData:{mapping:!0,regex:e("layoutData")},scratch:{mapping:!0,regex:e("scratch")},mapData:{mapping:!0,regex:t("mapData")},mapLayoutData:{mapping:!0,regex:t("mapLayoutData")},mapScratch:{mapping:!0,regex:t("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:n,singleRegexMatchValue:!0},urls:{regexes:n,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(e,t){switch(e.length){case 2:return"deg"!==t[0]&&"rad"!==t[0]&&"deg"!==t[1]&&"rad"!==t[1];case 1:return tL(e[0])||"deg"===t[0]||"rad"===t[0];default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+t0+")\\s*,\\s*("+t0+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+t0+")\\s*,\\s*("+t0+")\\s*,\\s*("+t0+")\\s*,\\s*("+t0+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(e){var t=e.length;return 1===t||2===t||4===t}}};var r=function(e,t){return(null==e||null==t)&&e!==t||0==e&&0!=t||0!=e&&0==t},i=function(e,t){return e!=t},a=si.types,o=[{name:"label",type:a.text,triggersBounds:i,triggersZOrder:function(e,t){var n=tX(e),r=tX(t);return n&&!r||!n&&r}},{name:"text-rotation",type:a.textRotation,triggersBounds:i},{name:"text-margin-x",type:a.bidirectionalSize,triggersBounds:i},{name:"text-margin-y",type:a.bidirectionalSize,triggersBounds:i}],s=[{name:"source-label",type:a.text,triggersBounds:i},{name:"source-text-rotation",type:a.textRotation,triggersBounds:i},{name:"source-text-margin-x",type:a.bidirectionalSize,triggersBounds:i},{name:"source-text-margin-y",type:a.bidirectionalSize,triggersBounds:i},{name:"source-text-offset",type:a.size,triggersBounds:i}],l=[{name:"target-label",type:a.text,triggersBounds:i},{name:"target-text-rotation",type:a.textRotation,triggersBounds:i},{name:"target-text-margin-x",type:a.bidirectionalSize,triggersBounds:i},{name:"target-text-margin-y",type:a.bidirectionalSize,triggersBounds:i},{name:"target-text-offset",type:a.size,triggersBounds:i}],c=[{name:"font-family",type:a.fontFamily,triggersBounds:i},{name:"font-style",type:a.fontStyle,triggersBounds:i},{name:"font-weight",type:a.fontWeight,triggersBounds:i},{name:"font-size",type:a.size,triggersBounds:i},{name:"text-transform",type:a.textTransform,triggersBounds:i},{name:"text-wrap",type:a.textWrap,triggersBounds:i},{name:"text-overflow-wrap",type:a.textOverflowWrap,triggersBounds:i},{name:"text-max-width",type:a.size,triggersBounds:i},{name:"text-outline-width",type:a.size,triggersBounds:i},{name:"line-height",type:a.positiveNumber,triggersBounds:i}],u=[{name:"text-valign",type:a.valign,triggersBounds:i},{name:"text-halign",type:a.halign,triggersBounds:i},{name:"color",type:a.color},{name:"text-outline-color",type:a.color},{name:"text-outline-opacity",type:a.zeroOneNumber},{name:"text-background-color",type:a.color},{name:"text-background-opacity",type:a.zeroOneNumber},{name:"text-background-padding",type:a.size,triggersBounds:i},{name:"text-border-opacity",type:a.zeroOneNumber},{name:"text-border-color",type:a.color},{name:"text-border-width",type:a.size,triggersBounds:i},{name:"text-border-style",type:a.borderStyle,triggersBounds:i},{name:"text-background-shape",type:a.textBackgroundShape,triggersBounds:i},{name:"text-justification",type:a.justification},{name:"box-select-labels",type:a.bool,triggersBounds:i}],d=[{name:"events",type:a.bool,triggersZOrder:i},{name:"text-events",type:a.bool,triggersZOrder:i},{name:"box-selection",type:a.boxSelection,triggersZOrder:i}],h=[{name:"display",type:a.display,triggersZOrder:i,triggersBounds:i,triggersBoundsOfConnectedEdges:i,triggersBoundsOfParallelEdges:function(e,t,n){return e!==t&&"bezier"===n.pstyle("curve-style").value}},{name:"visibility",type:a.visibility,triggersZOrder:i},{name:"opacity",type:a.zeroOneNumber,triggersZOrder:r},{name:"text-opacity",type:a.zeroOneNumber},{name:"min-zoomed-font-size",type:a.size},{name:"z-compound-depth",type:a.zCompoundDepth,triggersZOrder:i},{name:"z-index-compare",type:a.zIndexCompare,triggersZOrder:i},{name:"z-index",type:a.number,triggersZOrder:i}],f=[{name:"overlay-padding",type:a.size,triggersBounds:i},{name:"overlay-color",type:a.color},{name:"overlay-opacity",type:a.zeroOneNumber,triggersBounds:r},{name:"overlay-shape",type:a.overlayShape,triggersBounds:i},{name:"overlay-corner-radius",type:a.cornerRadius}],p=[{name:"underlay-padding",type:a.size,triggersBounds:i},{name:"underlay-color",type:a.color},{name:"underlay-opacity",type:a.zeroOneNumber,triggersBounds:r},{name:"underlay-shape",type:a.overlayShape,triggersBounds:i},{name:"underlay-corner-radius",type:a.cornerRadius}],g=[{name:"transition-property",type:a.propList},{name:"transition-duration",type:a.time},{name:"transition-delay",type:a.time},{name:"transition-timing-function",type:a.easing}],v=function(e,t){return"label"===t.value?-e.poolIndex():t.pfValue},x=[{name:"height",type:a.nodeSize,triggersBounds:i,hashOverride:v},{name:"width",type:a.nodeSize,triggersBounds:i,hashOverride:v},{name:"shape",type:a.nodeShape,triggersBounds:i},{name:"shape-polygon-points",type:a.polygonPointList,triggersBounds:i},{name:"corner-radius",type:a.cornerRadius},{name:"background-color",type:a.color},{name:"background-fill",type:a.fill},{name:"background-opacity",type:a.zeroOneNumber},{name:"background-blacken",type:a.nOneOneNumber},{name:"background-gradient-stop-colors",type:a.colors},{name:"background-gradient-stop-positions",type:a.percentages},{name:"background-gradient-direction",type:a.gradientDirection},{name:"padding",type:a.sizeMaybePercent,triggersBounds:i},{name:"padding-relative-to",type:a.paddingRelativeTo,triggersBounds:i},{name:"bounds-expansion",type:a.boundsExpansion,triggersBounds:i}],y=[{name:"border-color",type:a.color},{name:"border-opacity",type:a.zeroOneNumber},{name:"border-width",type:a.size,triggersBounds:i},{name:"border-style",type:a.borderStyle},{name:"border-cap",type:a.lineCap},{name:"border-join",type:a.lineJoin},{name:"border-dash-pattern",type:a.numbers},{name:"border-dash-offset",type:a.number},{name:"border-position",type:a.linePosition}],b=[{name:"outline-color",type:a.color},{name:"outline-opacity",type:a.zeroOneNumber},{name:"outline-width",type:a.size,triggersBounds:i},{name:"outline-style",type:a.borderStyle},{name:"outline-offset",type:a.size,triggersBounds:i}],w=[{name:"background-image",type:a.urls},{name:"background-image-crossorigin",type:a.bgCrossOrigin},{name:"background-image-opacity",type:a.zeroOneNumbers},{name:"background-image-containment",type:a.bgContainment},{name:"background-image-smoothing",type:a.bools},{name:"background-position-x",type:a.bgPos},{name:"background-position-y",type:a.bgPos},{name:"background-width-relative-to",type:a.bgRelativeTo},{name:"background-height-relative-to",type:a.bgRelativeTo},{name:"background-repeat",type:a.bgRepeat},{name:"background-fit",type:a.bgFit},{name:"background-clip",type:a.bgClip},{name:"background-width",type:a.bgWH},{name:"background-height",type:a.bgWH},{name:"background-offset-x",type:a.bgPos},{name:"background-offset-y",type:a.bgPos}],N=[{name:"position",type:a.position,triggersBounds:i},{name:"compound-sizing-wrt-labels",type:a.compoundIncludeLabels,triggersBounds:i},{name:"min-width",type:a.size,triggersBounds:i},{name:"min-width-bias-left",type:a.sizeMaybePercent,triggersBounds:i},{name:"min-width-bias-right",type:a.sizeMaybePercent,triggersBounds:i},{name:"min-height",type:a.size,triggersBounds:i},{name:"min-height-bias-top",type:a.sizeMaybePercent,triggersBounds:i},{name:"min-height-bias-bottom",type:a.sizeMaybePercent,triggersBounds:i}],j=[{name:"line-style",type:a.lineStyle},{name:"line-color",type:a.color},{name:"line-fill",type:a.fill},{name:"line-cap",type:a.lineCap},{name:"line-opacity",type:a.zeroOneNumber},{name:"line-dash-pattern",type:a.numbers},{name:"line-dash-offset",type:a.number},{name:"line-outline-width",type:a.size},{name:"line-outline-color",type:a.color},{name:"line-gradient-stop-colors",type:a.colors},{name:"line-gradient-stop-positions",type:a.percentages},{name:"curve-style",type:a.curveStyle,triggersBounds:i,triggersBoundsOfParallelEdges:function(e,t){return e!==t&&("bezier"===e||"bezier"===t)}},{name:"haystack-radius",type:a.zeroOneNumber,triggersBounds:i},{name:"source-endpoint",type:a.edgeEndpoint,triggersBounds:i},{name:"target-endpoint",type:a.edgeEndpoint,triggersBounds:i},{name:"control-point-step-size",type:a.size,triggersBounds:i},{name:"control-point-distances",type:a.bidirectionalSizes,triggersBounds:i},{name:"control-point-weights",type:a.numbers,triggersBounds:i},{name:"segment-distances",type:a.bidirectionalSizes,triggersBounds:i},{name:"segment-weights",type:a.numbers,triggersBounds:i},{name:"segment-radii",type:a.numbers,triggersBounds:i},{name:"radius-type",type:a.radiusType,triggersBounds:i},{name:"taxi-turn",type:a.bidirectionalSizeMaybePercent,triggersBounds:i},{name:"taxi-turn-min-distance",type:a.size,triggersBounds:i},{name:"taxi-direction",type:a.axisDirection,triggersBounds:i},{name:"taxi-radius",type:a.number,triggersBounds:i},{name:"edge-distances",type:a.edgeDistances,triggersBounds:i},{name:"arrow-scale",type:a.positiveNumber,triggersBounds:i},{name:"loop-direction",type:a.angle,triggersBounds:i},{name:"loop-sweep",type:a.angle,triggersBounds:i},{name:"source-distance-from-node",type:a.size,triggersBounds:i},{name:"target-distance-from-node",type:a.size,triggersBounds:i}],k=[{name:"ghost",type:a.bool,triggersBounds:i},{name:"ghost-offset-x",type:a.bidirectionalSize,triggersBounds:i},{name:"ghost-offset-y",type:a.bidirectionalSize,triggersBounds:i},{name:"ghost-opacity",type:a.zeroOneNumber}],C=[{name:"selection-box-color",type:a.color},{name:"selection-box-opacity",type:a.zeroOneNumber},{name:"selection-box-border-color",type:a.color},{name:"selection-box-border-width",type:a.size},{name:"active-bg-color",type:a.color},{name:"active-bg-opacity",type:a.zeroOneNumber},{name:"active-bg-size",type:a.size},{name:"outside-texture-bg-color",type:a.color},{name:"outside-texture-bg-opacity",type:a.zeroOneNumber}],E=[];si.pieBackgroundN=16,E.push({name:"pie-size",type:a.sizeMaybePercent}),E.push({name:"pie-hole",type:a.sizeMaybePercent}),E.push({name:"pie-start-angle",type:a.angle});for(var T=1;T<=si.pieBackgroundN;T++)E.push({name:"pie-"+T+"-background-color",type:a.color}),E.push({name:"pie-"+T+"-background-size",type:a.percent}),E.push({name:"pie-"+T+"-background-opacity",type:a.zeroOneNumber});var S=[];si.stripeBackgroundN=16,S.push({name:"stripe-size",type:a.sizeMaybePercent}),S.push({name:"stripe-direction",type:a.axisDirectionPrimary});for(var _=1;_<=si.stripeBackgroundN;_++)S.push({name:"stripe-"+_+"-background-color",type:a.color}),S.push({name:"stripe-"+_+"-background-size",type:a.percent}),S.push({name:"stripe-"+_+"-background-opacity",type:a.zeroOneNumber});var A=[],D=si.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:a.arrowShape,triggersBounds:i},{name:"arrow-color",type:a.color},{name:"arrow-fill",type:a.arrowFill},{name:"arrow-width",type:a.arrowWidth}].forEach(function(e){D.forEach(function(t){var n=t+"-"+e.name,r=e.type,i=e.triggersBounds;A.push({name:n,type:r,triggersBounds:i})})},{});var M=si.properties=[].concat(d,g,h,f,p,k,u,c,o,s,l,x,y,b,w,E,S,N,j,A,C),P=si.propertyGroups={behavior:d,transition:g,visibility:h,overlay:f,underlay:p,ghost:k,commonLabel:u,labelDimensions:c,mainLabel:o,sourceLabel:s,targetLabel:l,nodeBody:x,nodeBorder:y,nodeOutline:b,backgroundImage:w,pie:E,stripe:S,compound:N,edgeLine:j,edgeArrow:A,core:C},R=si.propertyGroupNames={};(si.propertyGroupKeys=Object.keys(P)).forEach(function(e){R[e]=P[e].map(function(e){return e.name}),P[e].forEach(function(t){return t.groupKey=e})});var L=si.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];si.propertyNames=M.map(function(e){return e.name});for(var I=0;I<M.length;I++){var O=M[I];M[O.name]=O}for(var B=0;B<L.length;B++){var F=L[B],z=M[F.pointsTo],V={name:F.name,alias:!0,pointsTo:z};M.push(V),M[F.name]=V}}(),si.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},si.getDefaultProperties=function(){var e=this._private;if(null!=e.defaultProperties)return e.defaultProperties;for(var t=t6({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","box-selection":"contain","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","box-select-labels":"no","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1, 1, -1, 1, 1, -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%","pie-hole":0,"pie-start-angle":"0deg"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(e,t){for(var n=1;n<=si.pieBackgroundN;n++){var r=t.name.replace("{{i}}",n),i=t.value;e[r]=i}return e},{}),{"stripe-size":"100%","stripe-direction":"horizontal"},[{name:"stripe-{{i}}-background-color",value:"black"},{name:"stripe-{{i}}-background-size",value:"0%"},{name:"stripe-{{i}}-background-opacity",value:1}].reduce(function(e,t){for(var n=1;n<=si.stripeBackgroundN;n++){var r=t.name.replace("{{i}}",n),i=t.value;e[r]=i}return e},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1}].reduce(function(e,t){return si.arrowPrefixes.forEach(function(n){var r=n+"-"+t.name,i=t.value;e[r]=i}),e},{})),n={},r=0;r<this.properties.length;r++){var i=this.properties[r];if(!i.pointsTo){var a=i.name,o=t[a],s=this.parse(a,o);n[a]=s}}return e.defaultProperties=n,e.defaultProperties},si.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var sa={};sa.parse=function(e,t,n,r){if(tI(t))return this.parseImplWarn(e,t,n,r);var i,a=nj(e,""+t,n?"t":"f","mapping"===r||!0===r||!1===r||null==r?"dontcare":r),o=this.propCache=this.propCache||[];return(i=o[a])||(i=o[a]=this.parseImplWarn(e,t,n,r)),(n||"mapping"===r)&&(i=nI(i))&&(i.value=nI(i.value)),i},sa.parseImplWarn=function(e,t,n,r){var i=this.parseImpl(e,t,n,r);return i||null==t||nL("The style property `".concat(e,": ").concat(t,"` is invalid")),i&&("width"===i.name||"height"===i.name)&&"label"===t&&nL("The style value of `label` is deprecated for `"+i.name+"`"),i},sa.parseImpl=function(e,t,n,r){e=t$(e);var i=this.properties[e],a=t,o=this.types;if(!i||void 0===t)return null;i.alias&&(e=(i=i.pointsTo).name);var s=tL(t);s&&(t=t.trim());var l=i.type;if(!l)return null;if(n&&(""===t||null===t))return{name:e,value:t,bypass:!0,deleteBypass:!0};if(tI(t))return{name:e,value:t,strValue:"fn",mapped:o.fn,bypass:n};if(!s||r||t.length<7||"a"!==t[1]);else if(t.length>=7&&"d"===t[0]&&(g=new RegExp(o.data.regex).exec(t))){if(n)return!1;var c=o.data;return{name:e,value:g,strValue:""+t,mapped:c,field:g[1],bypass:n}}else if(t.length>=10&&"m"===t[0]&&(v=new RegExp(o.mapData.regex).exec(t))){if(n||l.multiple)return!1;var u=o.mapData;if(!(l.color||l.number))return!1;var d=this.parse(e,v[4]);if(!d||d.mapped)return!1;var h=this.parse(e,v[5]);if(!h||h.mapped)return!1;if(d.pfValue===h.pfValue||d.strValue===h.strValue)return nL("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+d.strValue+"`"),this.parse(e,d.strValue);if(l.color){var f=d.value,p=h.value;if(f[0]===p[0]&&f[1]===p[1]&&f[2]===p[2]&&(f[3]===p[3]||(null==f[3]||1===f[3])&&(null==p[3]||1===p[3])))return!1}return{name:e,value:v,strValue:""+t,mapped:u,field:v[1],fieldMin:parseFloat(v[2]),fieldMax:parseFloat(v[3]),valueMin:d.value,valueMax:h.value,bypass:n}}if(l.multiple&&"multiple"!==r){if(x=s?t.split(/\s+/):tO(t)?t:[t],l.evenMultiple&&x.length%2!=0)return null;for(var g,v,x,y=[],b=[],w=[],N="",j=!1,k=0;k<x.length;k++){var C=this.parse(e,x[k],n,"multiple");j=j||tL(C.value),y.push(C.value),w.push(null!=C.pfValue?C.pfValue:C.value),b.push(C.units),N+=(k>0?" ":"")+C.strValue}if(l.validate&&!l.validate(y,b))return null;if(l.singleEnum&&j)if(1===y.length&&tL(y[0]))return{name:e,value:y[0],strValue:y[0],bypass:n};else return null;return{name:e,value:y,pfValue:w,strValue:N,bypass:n,units:b}}var E=function(){for(var r=0;r<l.enums.length;r++)if(l.enums[r]===t)return{name:e,value:t,strValue:""+t,bypass:n};return null};if(l.number){var T,S,_="px";if(l.units&&(S=l.units),l.implicitUnits&&(_=l.implicitUnits),!l.unitless)if(s){var A="px|em"+(l.allowPercent?"|\\%":"");S&&(A=S);var D=t.match("^("+t0+")("+A+")?$");D&&(t=D[1],S=D[2]||_)}else(!S||l.implicitUnits)&&(S=_);if(isNaN(t=parseFloat(t))&&void 0===l.enums)return null;if(isNaN(t)&&void 0!==l.enums)return t=a,E();if(l.integer&&!(tF(T=t)&&Math.floor(T)===T)||void 0!==l.min&&(t<l.min||l.strictMin&&t===l.min)||void 0!==l.max&&(t>l.max||l.strictMax&&t===l.max))return null;var M={name:e,value:t,strValue:""+t+(S||""),units:S,bypass:n};return l.unitless||"px"!==S&&"em"!==S?M.pfValue=t:M.pfValue="px"!==S&&S?this.getEmSizeInPixels()*t:t,("ms"===S||"s"===S)&&(M.pfValue="ms"===S?t:1e3*t),("deg"===S||"rad"===S)&&(M.pfValue="rad"===S?t:Math.PI*t/180),"%"===S&&(M.pfValue=t/100),M}if(l.propList){var P=[],R=""+t;if("none"===R);else{for(var L=R.split(/\s*,\s*|\s+/),I=0;I<L.length;I++){var O=L[I].trim();this.properties[O]?P.push(O):nL("`"+O+"` is not a valid property name")}if(0===P.length)return null}return{name:e,value:P,strValue:0===P.length?"none":P.join(" "),bypass:n}}if(l.color){var B=ne(t);return B?{name:e,value:B,pfValue:B,strValue:"rgb("+B[0]+","+B[1]+","+B[2]+")",bypass:n}:null}if(l.regex||l.regexes){if(l.enums){var F=E();if(F)return F}for(var z=l.regexes?l.regexes:[l.regex],V=0;V<z.length;V++){var H=new RegExp(z[V]).exec(t);if(H)return{name:e,value:l.singleRegexMatchValue?H[1]:H,strValue:""+t,bypass:n}}return null}if(l.string)return{name:e,value:""+t,strValue:""+t,bypass:n};else if(l.enums)return E();else return null};var so=function(e){return this instanceof so?tG(e)?void(this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()):void nP("A style must have a core reference"):new so(e)},ss=so.prototype;ss.instanceString=function(){return"style"},ss.clear=function(){for(var e=this._private,t=e.cy.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,e.contextStyles={},e.propDiffs={},this.cleanElements(t,!0),t.forEach(function(e){var t=e[0]._private;t.styleDirty=!0,t.appliedInitStyle=!1}),this},ss.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},ss.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},ss.selector=function(e){var t="core"===e?null:new aR(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},ss.css=function(){var e=arguments;if(1===e.length)for(var t=e[0],n=0;n<this.properties.length;n++){var r=this.properties[n],i=t[r.name];void 0===i&&(i=t[tK(r.name)]),void 0!==i&&this.cssRule(r.name,i)}else 2===e.length&&this.cssRule(e[0],e[1]);return this},ss.style=ss.css,ss.cssRule=function(e,t){var n=this.parse(e,t);if(n){var r=this.length-1;this[r].properties.push(n),this[r].properties[n.name]=n,n.name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.name.match(/stripe-(\d+)-background-size/)&&n.value&&(this._private.hasStripe=!0),n.mapped&&this[r].mappedProperties.push(n),this[r].selector||(this._private.coreStyle[n.name]=n)}return this},ss.append=function(e){return tY(e)?e.appendToStyle(this):tO(e)?this.appendFromJson(e):tL(e)&&this.appendFromString(e),this},so.fromJson=function(e,t){var n=new so(e);return n.fromJson(t),n},so.fromString=function(e,t){return new so(e).fromString(t)},[o7,o8,se,st,sn,sr,si,sa].forEach(function(e){t6(ss,e)}),so.types=ss.types,so.properties=ss.properties,so.propertyGroups=ss.propertyGroups,so.propertyGroupNames=ss.propertyGroupNames,so.propertyGroupKeys=ss.propertyGroupKeys;var sl={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},selectionType:function(e){var t=this._private;return(null==t.selectionType&&(t.selectionType="single"),void 0===e)?t.selectionType:(("additive"===e||"single"===e)&&(t.selectionType=e),this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,n,r,i,a=arguments,o=this._private.pan;switch(a.length){case 0:return o;case 1:if(tL(a[0]))return o[e=a[0]];if(tB(a[0])){if(!this._private.panningEnabled)return this;r=(n=a[0]).x,i=n.y,tF(r)&&(o.x=r),tF(i)&&(o.y=i),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;e=a[0],t=a[1],("x"===e||"y"===e)&&tF(t)&&(o[e]=t),this.emit("pan viewport")}return this.notify("viewport"),this},panBy:function(e,t){var n,r,i,a=arguments,o=this._private.pan;if(!this._private.panningEnabled)return this;switch(a.length){case 1:tB(e)&&(r=(n=a[0]).x,i=n.y,tF(r)&&(o.x+=r),tF(i)&&(o.y+=i),this.emit("pan viewport"));break;case 2:("x"===e||"y"===e)&&tF(t)&&(o[e]+=t),this.emit("pan viewport")}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(tF(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){if(tL(e)){var n,r,i,a=e;e=this.$(a)}else if(tB(n=e)&&tF(n.x1)&&tF(n.x2)&&tF(n.y1)&&tF(n.y2)){var o=e;(r={x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2}).w=r.x2-r.x1,r.h=r.y2-r.y1}else tV(e)||(e=this.mutableElements());if(!(tV(e)&&e.empty())){r=r||e.boundingBox();var s=this.width(),l=this.height();if(t=tF(t)?t:0,!isNaN(s)&&!isNaN(l)&&s>0&&l>0&&!isNaN(r.w)&&!isNaN(r.h)&&r.w>0&&r.h>0){i=(i=(i=Math.min((s-2*t)/r.w,(l-2*t)/r.h))>this._private.maxZoom?this._private.maxZoom:i)<this._private.minZoom?this._private.minZoom:i;var c={x:(s-i*(r.x1+r.x2))/2,y:(l-i*(r.y1+r.y2))/2};return{zoom:i,pan:c}}}}},zoomRange:function(e,t){var n=this._private;if(null==t){var r=e;e=r.min,t=r.max}return tF(e)&&tF(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):tF(e)&&void 0===t&&e<=n.maxZoom?n.minZoom=e:tF(t)&&void 0===e&&t>=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t,n,r=this._private,i=r.pan,a=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),tF(e)?n=e:tB(e)&&(n=e.level,null!=e.position?t=n8(e.position,a,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)<r.minZoom?r.minZoom:n,o||!tF(n)||n===a||null!=t&&(!tF(t.x)||!tF(t.y)))return null;if(null==t)return{zoomed:!0,panned:!1,zoom:n,pan:i};var s=n,l={x:-s/a*(t.x-i.x)+t.x,y:-s/a*(t.y-i.y)+t.y};return{zoomed:!0,panned:!0,zoom:s,pan:l}},zoom:function(e){if(void 0===e)return this._private.zoom;var t=this.getZoomedViewport(e),n=this._private;return null!=t&&t.zoomed&&(n.zoom=t.zoom,t.panned&&(n.pan.x=t.pan.x,n.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport")),this},viewport:function(e){var t=this._private,n=!0,r=!0,i=[],a=!1;if(!e||(tF(e.zoom)||(n=!1),tB(e.pan)||(r=!1),!n&&!r))return this;if(n){var o=e.zoom;o<t.minZoom||o>t.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=o,i.push("zoom"))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var s=e.pan;tF(s.x)&&(t.pan.x=s.x),tF(s.y)&&(t.pan.y=s.y),i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(tL(e)){var n=e;e=this.mutableElements().filter(n)}else tV(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),i=this.width(),a=this.height();return{x:(i-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled&&this.viewport({pan:{x:0,y:0},zoom:1}),this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e,t,n=this._private,r=n.container;return n.sizeCache=n.sizeCache||(r?(e=this.window().getComputedStyle(r),t=function(t){return parseFloat(e.getPropertyValue(t))},{width:r.clientWidth-t("padding-left")-t("padding-right"),height:r.clientHeight-t("padding-top")-t("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime}};sl.centre=sl.center,sl.autolockNodes=sl.autolock,sl.autoungrabifyNodes=sl.autoungrabify;var sc={data:am.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:am.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:am.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:am.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};sc.attr=sc.data,sc.removeAttr=sc.removeData;var su=function(e){var t=this,n=(e=t6({},e)).container;n&&!tz(n)&&tz(n[0])&&(n=n[0]);var r=n?n._cyreg:null;(r=r||{}).cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var a=void 0!==tS&&void 0!==n&&!e.headless,o=e;o.layout=t6({name:a?"grid":"null"},o.layout),o.renderer=t6({name:a?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:n,ready:!1,options:o,elements:new oU(this),listeners:[],aniEles:new oU(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?a:o.styleEnabled,zoom:tF(o.zoom)?o.zoom:1,pan:{x:tB(o.pan)&&tF(o.pan.x)?o.pan.x:0,y:tB(o.pan)&&tF(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom}),l.styleEnabled&&t.setStyle([]);var c=t6({},o,o.renderer);t.initRenderer(c);var u=function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),null!=e&&(tB(e)||tO(e))&&t.add(e),t.one("layoutready",function(e){t.notifications(!0),t.emit(e),t.one("load",n),t.emitAndNotify("load")}).one("layoutstop",function(){t.one("done",r),t.emit("done")});var a=t6({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()};!function(e,t){if(e.some(tW))return i8.all(e).then(t);t(e)}([o.style,o.elements],function(e){var n=e[0],a=e[1];l.styleEnabled&&t.style().append(n),u(a,function(){t.startAnimationLoop(),l.ready=!0,tI(o.ready)&&t.on("ready",o.ready);for(var e=0;e<i.length;e++){var n=i[e];t.on("ready",n)}r&&(r.readies=[]),t.emit("ready")},o.done)})},sd=su.prototype;t6(sd,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){if(!this.destroyed())return this.stopAnimationLoop(),this.destroyRenderer(),this.emit("destroy"),this._private.destroyed=!0,this},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){if(null==this._private.container)return tS;var e=this._private.container.ownerDocument;return void 0===e||null==e?tS:e.defaultView||tS},mount:function(e){if(null!=e){var t=this._private,n=t.options;return!tz(e)&&tz(e[0])&&(e=e[0]),this.stopAnimationLoop(),this.destroyRenderer(),t.container=e,t.styleEnabled=!0,this.invalidateSize(),this.initRenderer(t6({},n,n.renderer,{name:"null"===n.renderer.name?"canvas":n.renderer.name})),this.startAnimationLoop(),this.style(n.style),this.emit("mount"),this}},unmount:function(){return this.stopAnimationLoop(),this.destroyRenderer(),this.initRenderer({name:"null"}),this.emit("unmount"),this},options:function(){return nI(this._private.options)},json:function(e){var t=this,n=t._private,r=t.mutableElements();if(tB(e)){if(t.startBatch(),e.elements){var i={},a=function(e,n){for(var r=[],a=[],o=0;o<e.length;o++){var s=e[o];if(!s.data.id){nL("cy.json() cannot handle elements without an ID attribute");continue}var l=""+s.data.id,c=t.getElementById(l);i[l]=!0,0!==c.length?a.push({ele:c,json:s}):(n&&(s.group=n),r.push(s))}t.add(r);for(var u=0;u<a.length;u++){var d=a[u],h=d.ele,f=d.json;h.json(f)}};if(tO(e.elements))a(e.elements);else for(var o=["nodes","edges"],s=0;s<o.length;s++){var l=o[s],c=e.elements[l];tO(c)&&a(c,l)}var u=t.collection();r.filter(function(e){return!i[e.id()]}).forEach(function(e){e.isParent()?u.merge(e):e.remove()}),u.forEach(function(e){return e.children().move({parent:null})}),u.forEach(function(e){return t.getElementById(e.id()).remove()})}e.style&&t.style(e.style),null!=e.zoom&&e.zoom!==n.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x!==n.pan.x||e.pan.y!==n.pan.y)&&t.pan(e.pan),e.data&&t.data(e.data);for(var d=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],h=0;h<d.length;h++){var f=d[h];null!=e[f]&&t[f](e[f])}return t.endBatch(),this}var p={};e?p.elements=this.elements().map(function(e){return e.json()}):(p.elements={},r.forEach(function(e){var t=e.group();p.elements[t]||(p.elements[t]=[]),p.elements[t].push(e.json())})),this._private.styleEnabled&&(p.style=t.style().json()),p.data=nI(t.data());var g=n.options;return p.zoomingEnabled=n.zoomingEnabled,p.userZoomingEnabled=n.userZoomingEnabled,p.zoom=n.zoom,p.minZoom=n.minZoom,p.maxZoom=n.maxZoom,p.panningEnabled=n.panningEnabled,p.userPanningEnabled=n.userPanningEnabled,p.pan=nI(n.pan),p.boxSelectionEnabled=n.boxSelectionEnabled,p.renderer=nI(g.renderer),p.hideEdgesOnViewport=g.hideEdgesOnViewport,p.textureOnViewport=g.textureOnViewport,p.wheelSensitivity=g.wheelSensitivity,p.motionBlur=g.motionBlur,p.multiClickDebounceTime=g.multiClickDebounceTime,p}}),sd.$id=sd.getElementById,[{add:function(e){var t;if(tV(e))if(e._private.cy===this)t=e.restore();else{for(var n=[],r=0;r<e.length;r++){var i=e[r];n.push(i.json())}t=new oU(this,n)}else if(tO(e))t=new oU(this,e);else if(tB(e)&&(tO(e.nodes)||tO(e.edges))){for(var a=[],o=["nodes","edges"],s=0,l=o.length;s<l;s++){var c=o[s],u=e[c];if(tO(u))for(var d=0,h=u.length;d<h;d++){var f=t6({group:c},u[d]);a.push(f)}}t=new oU(this,a)}else t=new nK(this,e).collection();return t},remove:function(e){if(tV(e));else if(tL(e)){var t=e;e=this.$(t)}return e.remove()}},oJ,o2,o5,o3,{notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t);return}if(n.notificationsEnabled){var i=this.renderer();!this.destroyed()&&i&&i.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch(function(){for(var n=Object.keys(e),r=0;r<n.length;r++){var i=n[r],a=e[i];t.getElementById(i).data(a)}})}},o6,o9,{style:function(e){return e&&this.setStyle(e).update(),this._private.style},setStyle:function(e){var t=this._private;return tY(e)?t.style=e.generateStyle(this):tO(e)?t.style=so.fromJson(this,e):tL(e)?t.style=so.fromString(this,e):t.style=so(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},sl,sc].forEach(function(e){t6(sd,e)});var sh={fit:!0,directed:!1,direction:"downward",padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}},sf={maximal:!1,acyclic:!1},sp=function(e){return e.scratch("breadthfirst")},sg=function(e,t){return e.scratch("breadthfirst",t)};function sm(e){this.options=t6({},sh,sf,e)}sm.prototype.run=function(){var e,t=this.options,n=t.cy,r=t.eles,i=r.nodes().filter(function(e){return e.isChildless()}),a=t.directed,o=t.acyclic||t.maximal||t.maximalAdjustments>0,s=!!t.boundingBox,l=rm(s?t.boundingBox:structuredClone(n.extent()));if(tV(t.roots))e=t.roots;else if(tO(t.roots)){for(var c=[],u=0;u<t.roots.length;u++){var d=t.roots[u],h=n.getElementById(d);c.push(h)}e=n.collection(c)}else if(tL(t.roots))e=n.$(t.roots);else if(a)e=i.roots();else{var f=r.components();e=n.collection();for(var p=0;p<f.length;p++)!function(){var t=f[p],n=t.maxDegree(!1),r=t.filter(function(e){return e.degree(!1)===n});e=e.add(r)}()}var g=[],v={},x=function(e,t){null==g[t]&&(g[t]=[]);var n=g[t].length;g[t].push(e),sg(e,{index:n,depth:t})},y=function(e,t){var n=sp(e),r=n.depth,i=n.index;g[r][i]=null,e.isChildless()&&x(e,t)};r.bfs({roots:e,directed:t.directed,visit:function(e,t,n,r,i){var a=e[0],o=a.id();a.isChildless()&&x(a,i),v[o]=!0}});for(var b=[],w=0;w<i.length;w++){var N=i[w];v[N.id()]||b.push(N)}var j=function(e){for(var t=g[e],n=0;n<t.length;n++){var r=t[n];if(null==r){t.splice(n,1),n--;continue}sg(r,{depth:e,index:n})}};if(a&&o){var k=[],C={},E=function(e){return k.push(e)};for(i.forEach(function(e){return k.push(e)});k.length>0;){var T=k.shift(),S=function(e,n){for(var i=sp(e),a=e.incomers().filter(function(e){return e.isNode()&&r.has(e)}),o=-1,s=e.id(),l=0;l<a.length;l++)o=Math.max(o,sp(a[l]).depth);if(i.depth<=o){if(!t.acyclic&&n[s])return null;var c=o+1;return y(e,c),n[s]=c,!0}return!1}(T,C);if(S)T.outgoers().filter(function(e){return e.isNode()&&r.has(e)}).forEach(E);else if(null===S){nL("Detected double maximal shift for node `"+T.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var _=0;if(t.avoidOverlap)for(var A=0;A<i.length;A++){var D=i[A].layoutDimensions(t),M=D.w,P=D.h;_=Math.max(_,M,P)}var R={},L=function(e){if(R[e.id()])return R[e.id()];for(var t=sp(e).depth,n=e.neighborhood(),r=0,a=0,o=0;o<n.length;o++){var s=n[o];if(!(s.isEdge()||s.isParent())&&i.has(s)){var l=sp(s);if(null!=l){var c=l.index,u=l.depth;if(null!=c&&null!=u){var d=g[u].length;u<t&&(r+=c/d,a++)}}}}return r/=a=Math.max(1,a),0===a&&(r=0),R[e.id()]=r,r},I=function(e,t){var n=L(e)-L(t);return 0===n?t4(e.id(),t.id()):n};void 0!==t.depthSort&&(I=t.depthSort);for(var O=g.length,B=0;B<O;B++)g[B].sort(I),j(B);for(var F=[],z=0;z<b.length;z++)F.push(b[z]);if(F.length){g.unshift(F),O=g.length;for(var V=0;V<O;V++)j(V)}for(var H=0,U=0;U<O;U++)H=Math.max(g[U].length,H);var G={x:l.x1+l.w/2,y:l.y1+l.h/2},Y=i.reduce(function(e,n){var r;return r=n.boundingBox({includeLabels:t.nodeDimensionsIncludeLabels}),{w:-1===e.w?r.w:(e.w+r.w)/2,h:-1===e.h?r.h:(e.h+r.h)/2}},{w:-1,h:-1}),X=Math.max(1===O?0:s?(l.h-2*t.padding-Y.h)/(O-1):(l.h-2*t.padding-Y.h)/(O+1),_),W=g.reduce(function(e,t){return Math.max(e,t.length)},0),q=function(e){var n=sp(e),r=n.depth,i=n.index;if(t.circle){var a=Math.min(l.w/2/O,l.h/2/O),o=(a=Math.max(a,_))*r+a-(O>0&&g[0].length<=3?a/2:0),c=2*Math.PI/g[r].length*i;return 0===r&&1===g[0].length&&(o=1),{x:G.x+o*Math.cos(c),y:G.y+o*Math.sin(c)}}var u=g[r].length,d=Math.max(1===u?0:s?(l.w-2*t.padding-Y.w)/((t.grid?W:u)-1):(l.w-2*t.padding-Y.w)/((t.grid?W:u)+1),_);return{x:G.x+(i+1-(u+1)/2)*d,y:G.y+(r+1-(O+1)/2)*X}},$={downward:0,leftward:90,upward:180,rightward:-90};return -1===Object.keys($).indexOf(t.direction)&&nP("Invalid direction '".concat(t.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys($).join(", "))),r.nodes().layoutPositions(this,t,function(e){return function(e,t,n){if(0===n)return e;var r,i,a,o,s=(t.x1+t.x2)/2,l=(t.y1+t.y2)/2,c=t.w/t.h,u=(r=e.x,i=e.y,{x:Math.cos(a=n*Math.PI/180)*(r-s)-Math.sin(a)*(i-l)+s,y:Math.sin(a)*(r-s)+Math.cos(a)*(i-l)+l}),d=(o=u.x,{x:(o-s)*c+s,y:(u.y-l)*(1/c)+l});return{x:d.x,y:d.y}}(q(e),l,$[t.direction])}),this};var sv={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function sx(e){this.options=t6({},sv,e)}sx.prototype.run=function(){var e,t=this.options,n=t.cy,r=t.eles,i=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,a=r.nodes().not(":parent");t.sort&&(a=a.sort(t.sort));for(var o=rm(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},l=(void 0===t.sweep?2*Math.PI-2*Math.PI/a.length:t.sweep)/Math.max(1,a.length-1),c=0,u=0;u<a.length;u++){var d=a[u].layoutDimensions(t);c=Math.max(c,d.w,d.h)}if(e=tF(t.radius)?t.radius:a.length<=1?0:Math.min(o.h,o.w)/2-c,a.length>1&&t.avoidOverlap){var h=Math.cos(l)-1,f=Math.sin(l)-0;e=Math.max(Math.sqrt((c*=1.75)*c/(h*h+f*f)),e)}return r.nodes().layoutPositions(this,t,function(n,r){var a=t.startAngle+r*l*(i?1:-1),o=e*Math.cos(a),c=e*Math.sin(a);return{x:s.x+o,y:s.y+c}}),this};var sy={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function sb(e){this.options=t6({},sy,e)}sb.prototype.run=function(){for(var e=this.options,t=void 0!==e.counterclockwise?!e.counterclockwise:e.clockwise,n=e.cy,r=e.eles,i=r.nodes().not(":parent"),a=rm(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),o={x:a.x1+a.w/2,y:a.y1+a.h/2},s=[],l=0,c=0;c<i.length;c++){var u=i[c],d=void 0;d=e.concentric(u),s.push({value:d,node:u}),u._private.scratch.concentric=d}i.updateStyle();for(var h=0;h<i.length;h++){var f=i[h].layoutDimensions(e);l=Math.max(l,f.w,f.h)}s.sort(function(e,t){return t.value-e.value});for(var p=e.levelWidth(i),g=[[]],v=g[0],x=0;x<s.length;x++){var y=s[x];v.length>0&&Math.abs(v[0].value-y.value)>=p&&(v=[],g.push(v)),v.push(y)}var b=l+e.minNodeSpacing;if(!e.avoidOverlap){var w=g.length>0&&g[0].length>1,N=(Math.min(a.w,a.h)/2-b)/(g.length+w?1:0);b=Math.min(b,N)}for(var j=0,k=0;k<g.length;k++){var C=g[k],E=void 0===e.sweep?2*Math.PI-2*Math.PI/C.length:e.sweep,T=C.dTheta=E/Math.max(1,C.length-1);if(C.length>1&&e.avoidOverlap){var S=Math.cos(T)-1,_=Math.sin(T)-0;j=Math.max(Math.sqrt(b*b/(S*S+_*_)),j)}C.r=j,j+=b}if(e.equidistant){for(var A=0,D=0,M=0;M<g.length;M++)A=Math.max(A,g[M].r-D);D=0;for(var P=0;P<g.length;P++){var R=g[P];0===P&&(D=R.r),R.r=D,D+=A}}for(var L={},I=0;I<g.length;I++)for(var O=g[I],B=O.dTheta,F=O.r,z=0;z<O.length;z++){var V=O[z],H=e.startAngle+(t?1:-1)*B*z,U={x:o.x+F*Math.cos(H),y:o.y+F*Math.sin(H)};L[V.node.id()]=U}return r.nodes().layoutPositions(this,e,function(e){return L[e.id()]}),this};var sw={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function sN(e){this.options=t6({},sw,e),this.options.layout=this;var t=this.options.eles.nodes(),n=this.options.eles.edges().filter(function(e){var n=e.source().data("id"),r=e.target().data("id"),i=t.some(function(e){return e.data("id")===n}),a=t.some(function(e){return e.data("id")===r});return!i||!a});this.options.eles=this.options.eles.not(n)}sN.prototype.run=function(){var e=this.options,t=e.cy,n=this;n.stopped=!1,(!0===e.animate||!1===e.animate)&&n.emit({type:"layoutstart",layout:n}),uu=!0===e.debug;var r=sj(t,n,e);uu&&ud(r),e.randomize&&sE(r);var i=nf(),a=function(){sS(r,t,e),!0===e.fit&&t.fit(e.padding)},o=function(t){return!n.stopped&&!(t>=e.numIter)&&(s_(r,e),r.temperature=r.temperature*e.coolingFactor,!(r.temperature<e.minTemp))},s=function(){if(!0===e.animate||!1===e.animate)a(),n.one("layoutstop",e.stop),n.emit({type:"layoutstop",layout:n});else{var t=e.eles.nodes(),i=sT(r,e,t);t.layoutPositions(n,e,i)}},l=0,c=!0;if(!0===e.animate){var u=function(){for(var t=0;c&&t<e.refresh;)c=o(l),l++,t++;c?(nf()-i>=e.animationThreshold&&a(),ng(u)):(sV(r,e),s())};u()}else{for(;c;)c=o(l),l++;sV(r,e),s()}return this},sN.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},sN.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var sj=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),a=rm(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:a.w,clientHeight:a.h,boundingBox:a},s=n.eles.components(),l={},c=0;c<s.length;c++)for(var u=s[c],d=0;d<u.length;d++){var h=u[d];l[h.id()]=c}for(var c=0;c<o.nodeSize;c++){var f=i[c],p=f.layoutDimensions(n),g={};g.isLocked=f.locked(),g.id=f.data("id"),g.parentId=f.data("parent"),g.cmptId=l[f.id()],g.children=[],g.positionX=f.position("x"),g.positionY=f.position("y"),g.offsetX=0,g.offsetY=0,g.height=p.w,g.width=p.h,g.maxX=g.positionX+g.width/2,g.minX=g.positionX-g.width/2,g.maxY=g.positionY+g.height/2,g.minY=g.positionY-g.height/2,g.padLeft=parseFloat(f.style("padding")),g.padRight=parseFloat(f.style("padding")),g.padTop=parseFloat(f.style("padding")),g.padBottom=parseFloat(f.style("padding")),g.nodeRepulsion=tI(n.nodeRepulsion)?n.nodeRepulsion(f):n.nodeRepulsion,o.layoutNodes.push(g),o.idToIndex[g.id]=c}for(var v=[],x=0,y=-1,b=[],c=0;c<o.nodeSize;c++){var f=o.layoutNodes[c],w=f.parentId;null!=w?o.layoutNodes[o.idToIndex[w]].children.push(f.id):(v[++y]=f.id,b.push(f.id))}for(o.graphSet.push(b);x<=y;){var N=v[x++],j=o.idToIndex[N],h=o.layoutNodes[j],k=h.children;if(k.length>0){o.graphSet.push(k);for(var c=0;c<k.length;c++)v[++y]=k[c]}}for(var c=0;c<o.graphSet.length;c++)for(var C=o.graphSet[c],d=0;d<C.length;d++){var E=o.idToIndex[C[d]];o.indexToGraph[E]=c}for(var c=0;c<o.edgeSize;c++){var T=r[c],S={};S.id=T.data("id"),S.sourceId=T.data("source"),S.targetId=T.data("target");var _=tI(n.idealEdgeLength)?n.idealEdgeLength(T):n.idealEdgeLength,A=tI(n.edgeElasticity)?n.edgeElasticity(T):n.edgeElasticity,D=o.idToIndex[S.sourceId],M=o.idToIndex[S.targetId];if(o.indexToGraph[D]!=o.indexToGraph[M]){for(var P=sk(S.sourceId,S.targetId,o),R=o.graphSet[P],L=0,g=o.layoutNodes[D];-1===R.indexOf(g.id);)g=o.layoutNodes[o.idToIndex[g.parentId]],L++;for(g=o.layoutNodes[M];-1===R.indexOf(g.id);)g=o.layoutNodes[o.idToIndex[g.parentId]],L++;_*=L*n.nestingFactor}S.idealLength=_,S.elasticity=A,o.layoutEdges.push(S)}return o},sk=function(e,t,n){var r=sC(e,t,0,n);return 2>r.count?0:r.graph},sC=function(e,t,n,r){var i=r.graphSet[n];if(-1<i.indexOf(e)&&-1<i.indexOf(t))return{count:2,graph:n};for(var a=0,o=0;o<i.length;o++){var s=i[o],l=r.idToIndex[s],c=r.layoutNodes[l].children;if(0!==c.length){var u=sC(e,t,r.indexToGraph[r.idToIndex[c[0]]],r);if(0===u.count)continue;if(1!==u.count)return u;if(2==++a)break}}return{count:a,graph:n}},sE=function(e,t){for(var n=e.clientWidth,r=e.clientHeight,i=0;i<e.nodeSize;i++){var a=e.layoutNodes[i];0!==a.children.length||a.isLocked||(a.positionX=Math.random()*n,a.positionY=Math.random()*r)}},sT=function(e,t,n){var r=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach(function(t){var n=e.layoutNodes[e.idToIndex[t.data("id")]];i.x1=Math.min(i.x1,n.positionX),i.x2=Math.max(i.x2,n.positionX),i.y1=Math.min(i.y1,n.positionY),i.y2=Math.max(i.y2,n.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(n,a){var o=e.layoutNodes[e.idToIndex[n.data("id")]];if(!t.boundingBox)return{x:o.positionX,y:o.positionY};var s=0===i.w?.5:(o.positionX-i.x1)/i.w,l=0===i.h?.5:(o.positionY-i.y1)/i.h;return{x:r.x1+s*r.w,y:r.y1+l*r.h}}},sS=function(e,t,n){var r=n.layout,i=n.eles.nodes(),a=sT(e,n,i);i.positions(a),!0!==e.ready&&(e.ready=!0,r.one("layoutready",n.ready),r.emit({type:"layoutready",layout:this}))},s_=function(e,t,n){sA(e,t),sL(e),sI(e,t),sO(e),sB(e)},sA=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var r=e.graphSet[n],i=r.length,a=0;a<i;a++)for(var o=e.layoutNodes[e.idToIndex[r[a]]],s=a+1;s<i;s++)sM(o,e.layoutNodes[e.idToIndex[r[s]]],e,t)},sD=function(e){return -1+2*e*Math.random()},sM=function(e,t,n,r){if(e.cmptId===t.cmptId||n.isCompound){var i=t.positionX-e.positionX,a=t.positionY-e.positionY;0===i&&0===a&&(i=sD(1),a=sD(1));var o=sP(e,t,i,a);if(o>0)var s=r.nodeOverlap*o,l=Math.sqrt(i*i+a*a),c=s*i/l,u=s*a/l;else var d=sR(e,i,a),h=sR(t,-1*i,-1*a),f=h.x-d.x,p=h.y-d.y,g=f*f+p*p,l=Math.sqrt(g),s=(e.nodeRepulsion+t.nodeRepulsion)/g,c=s*f/l,u=s*p/l;e.isLocked||(e.offsetX-=c,e.offsetY-=u),t.isLocked||(t.offsetX+=c,t.offsetY+=u)}},sP=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(r>0)var a=e.maxY-t.minY;else var a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},sR=function(e,t,n){var r=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=n/t,l=a/o,c={};return 0===t&&0<n||0===t&&0>n?(c.x=r,c.y=i+a/2):0<t&&-1*l<=s&&s<=l?(c.x=r+o/2,c.y=i+o*n/2/t):0>t&&-1*l<=s&&s<=l?(c.x=r-o/2,c.y=i-o*n/2/t):0<n&&(s<=-1*l||s>=l)?(c.x=r+a*t/2/n,c.y=i+a/2):0>n&&(s<=-1*l||s>=l)&&(c.x=r-a*t/2/n,c.y=i-a/2),c},sL=function(e,t){for(var n=0;n<e.edgeSize;n++){var r=e.layoutEdges[n],i=e.idToIndex[r.sourceId],a=e.layoutNodes[i],o=e.idToIndex[r.targetId],s=e.layoutNodes[o],l=s.positionX-a.positionX,c=s.positionY-a.positionY;if(0!==l||0!==c){var u=sR(a,l,c),d=sR(s,-1*l,-1*c),h=d.x-u.x,f=d.y-u.y,p=Math.sqrt(h*h+f*f),g=Math.pow(r.idealLength-p,2)/r.elasticity;if(0!==p)var v=g*h/p,x=g*f/p;else var v=0,x=0;a.isLocked||(a.offsetX+=v,a.offsetY+=x),s.isLocked||(s.offsetX-=v,s.offsetY-=x)}}},sI=function(e,t){if(0!==t.gravity)for(var n=0;n<e.graphSet.length;n++){var r=e.graphSet[n],i=r.length;if(0===n)var a=e.clientHeight/2,o=e.clientWidth/2;else var s=e.layoutNodes[e.idToIndex[r[0]]],l=e.layoutNodes[e.idToIndex[s.parentId]],a=l.positionX,o=l.positionY;for(var c=0;c<i;c++){var u=e.layoutNodes[e.idToIndex[r[c]]];if(!u.isLocked){var d=a-u.positionX,h=o-u.positionY,f=Math.sqrt(d*d+h*h);if(f>1){var p=t.gravity*d/f,g=t.gravity*h/f;u.offsetX+=p,u.offsetY+=g}}}}},sO=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],l=s.children;if(0<l.length&&!s.isLocked){for(var c=s.offsetX,u=s.offsetY,d=0;d<l.length;d++){var h=e.layoutNodes[e.idToIndex[l[d]]];h.offsetX+=c,h.offsetY+=u,n[++i]=l[d]}s.offsetX=0,s.offsetY=0}}},sB=function(e,t){for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];0<r.children.length&&(r.maxX=void 0,r.minX=void 0,r.maxY=void 0,r.minY=void 0)}for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];if(!(0<r.children.length)&&!r.isLocked){var i=sF(r.offsetX,r.offsetY,e.temperature);r.positionX+=i.x,r.positionY+=i.y,r.offsetX=0,r.offsetY=0,r.minX=r.positionX-r.width,r.maxX=r.positionX+r.width,r.minY=r.positionY-r.height,r.maxY=r.positionY+r.height,sz(r,e)}}for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];0<r.children.length&&!r.isLocked&&(r.positionX=(r.maxX+r.minX)/2,r.positionY=(r.maxY+r.minY)/2,r.width=r.maxX-r.minX,r.height=r.maxY-r.minY)}},sF=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(r>n)var i={x:n*e/r,y:n*t/r};else var i={x:e,y:t};return i},sz=function(e,t){var n=e.parentId;if(null!=n){var r=t.layoutNodes[t.idToIndex[n]],i=!1;if((null==r.maxX||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,i=!0),(null==r.minX||e.minX-r.padLeft<r.minX)&&(r.minX=e.minX-r.padLeft,i=!0),(null==r.maxY||e.maxY+r.padBottom>r.maxY)&&(r.maxY=e.maxY+r.padBottom,i=!0),(null==r.minY||e.minY-r.padTop<r.minY)&&(r.minY=e.minY-r.padTop,i=!0),i)return sz(r,t)}},sV=function(e,t){for(var n=e.layoutNodes,r=[],i=0;i<n.length;i++){var a=n[i],o=a.cmptId;(r[o]=r[o]||[]).push(a)}for(var s=0,i=0;i<r.length;i++){var l=r[i];if(l){l.x1=1/0,l.x2=-1/0,l.y1=1/0,l.y2=-1/0;for(var c=0;c<l.length;c++){var u=l[c];l.x1=Math.min(l.x1,u.positionX-u.width/2),l.x2=Math.max(l.x2,u.positionX+u.width/2),l.y1=Math.min(l.y1,u.positionY-u.height/2),l.y2=Math.max(l.y2,u.positionY+u.height/2)}l.w=l.x2-l.x1,l.h=l.y2-l.y1,s+=l.w*l.h}}r.sort(function(e,t){return t.w*t.h-e.w*e.h});for(var d=0,h=0,f=0,p=0,g=Math.sqrt(s)*e.clientWidth/e.clientHeight,i=0;i<r.length;i++){var l=r[i];if(l){for(var c=0;c<l.length;c++){var u=l[c];u.isLocked||(u.positionX+=d-l.x1,u.positionY+=h-l.y1)}d+=l.w+t.componentSpacing,f+=l.w+t.componentSpacing,p=Math.max(p,l.h),f>g&&(h+=p+t.componentSpacing,d=0,f=0,p=0)}}},sH={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function sU(e){this.options=t6({},sH,e)}sU.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=n.nodes().not(":parent");e.sort&&(r=r.sort(e.sort));var i=rm(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});if(0===i.h||0===i.w)n.nodes().layoutPositions(this,e,function(e){return{x:i.x1,y:i.y1}});else{var a=r.size(),o=Math.sqrt(a*i.h/i.w),s=Math.round(o),l=Math.round(i.w/i.h*o),c=function(e){if(null==e)return Math.min(s,l);Math.min(s,l)==s?s=e:l=e},u=function(e){if(null==e)return Math.max(s,l);Math.max(s,l)==s?s=e:l=e},d=e.rows,h=null!=e.cols?e.cols:e.columns;if(null!=d&&null!=h)s=d,l=h;else if(null!=d&&null==h)l=Math.ceil(a/(s=d));else if(null==d&&null!=h)s=Math.ceil(a/(l=h));else if(l*s>a){var f=c(),p=u();(f-1)*p>=a?c(f-1):(p-1)*f>=a&&u(p-1)}else for(;l*s<a;){var g=c(),v=u();(v+1)*g>=a?u(v+1):c(g+1)}var x=i.w/l,y=i.h/s;if(e.condense&&(x=0,y=0),e.avoidOverlap)for(var b=0;b<r.length;b++){var w=r[b],N=w._private.position;(null==N.x||null==N.y)&&(N.x=0,N.y=0);var j=w.layoutDimensions(e),k=e.avoidOverlapPadding,C=j.w+k,E=j.h+k;x=Math.max(x,C),y=Math.max(y,E)}for(var T={},S=function(e,t){return!!T["c-"+e+"-"+t]},_=function(e,t){T["c-"+e+"-"+t]=!0},A=0,D=0,M=function(){++D>=l&&(D=0,A++)},P={},R=0;R<r.length;R++){var L=r[R],I=e.position(L);if(I&&(void 0!==I.row||void 0!==I.col)){var O={row:I.row,col:I.col};if(void 0===O.col)for(O.col=0;S(O.row,O.col);)O.col++;else if(void 0===O.row)for(O.row=0;S(O.row,O.col);)O.row++;P[L.id()]=O,_(O.row,O.col)}}r.layoutPositions(this,e,function(e,t){if(e.locked()||e.isParent())return!1;var n,r,a=P[e.id()];if(a)n=a.col*x+x/2+i.x1,r=a.row*y+y/2+i.y1;else{for(;S(A,D);)M();n=D*x+x/2+i.x1,r=A*y+y/2+i.y1,_(A,D),M()}return{x:n,y:r}})}return this};var sG={ready:function(){},stop:function(){}};function sY(e){this.options=t6({},sG,e)}sY.prototype.run=function(){var e=this.options,t=e.eles;return e.cy,this.emit("layoutstart"),t.nodes().positions(function(){return{x:0,y:0}}),this.one("layoutready",e.ready),this.emit("layoutready"),this.one("layoutstop",e.stop),this.emit("layoutstop"),this},sY.prototype.stop=function(){return this};var sX={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function sW(e){this.options=t6({},sX,e)}sW.prototype.run=function(){var e=this.options,t=e.eles.nodes(),n=tI(e.positions);return t.layoutPositions(this,e,function(t,r){var i=function(t){if(null==e.positions){var r;return{x:(r=t.position()).x,y:r.y}}if(n)return e.positions(t);var i=e.positions[t._private.data.id];return null==i?null:i}(t);return!t.locked()&&null!=i&&i}),this};var sq={fit:!0,padding:30,boundingBox:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function s$(e){this.options=t6({},sq,e)}s$.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=rm(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});return n.nodes().layoutPositions(this,e,function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}}),this};var sK=[{name:"breadthfirst",impl:sm},{name:"circle",impl:sx},{name:"concentric",impl:sb},{name:"cose",impl:sN},{name:"grid",impl:sU},{name:"null",impl:sY},{name:"preset",impl:sW},{name:"random",impl:s$}];function sZ(e){this.options=e,this.notifications=0}var sQ=function(){},sJ=function(){throw Error("A headless instance can not render images")};sZ.prototype={recalculateRenderedStyle:sQ,notify:function(){this.notifications++},init:sQ,isHeadless:function(){return!0},png:sJ,jpg:sJ};var s0={};s0.arrowShapeWidth=.3,s0.registerArrowShapes=function(){var e=this.arrowShapes={},t=this,n=function(e,t,n,r,i,a,o){var s=i.x-n/2-o,l=i.x+n/2+o,c=i.y-n/2-o,u=i.y+n/2+o;return s<=e&&e<=l&&c<=t&&t<=u},r=function(e,t,n,r,i){var a=e*Math.cos(r)-t*Math.sin(r),o=e*Math.sin(r)+t*Math.cos(r);return{x:a*n+i.x,y:o*n+i.y}},i=function(e,t,n,i){for(var a=[],o=0;o<e.length;o+=2){var s=e[o],l=e[o+1];a.push(r(s,l,t,n,i))}return a},a=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},o=function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").pfValue*2},s=function(r,s){tL(s)&&(s=e[s]),e[r]=t6({name:r,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,o,s){return rL(e,t,a(i(this.points,n+2*s,r,o)))},roughCollide:n,draw:function(e,n,r,a){var o=i(this.points,n,r,a);t.arrowShapeImpl("polygon")(e,o)},spacing:function(e){return 0},gap:o},s)};s("none",{collide:nA,roughCollide:nA,draw:nM,spacing:nD,gap:nD}),s("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),s("arrow","triangle"),s("triangle-backcurve",{points:e.triangle.points,controlPoint:[0,-.15],roughCollide:n,draw:function(e,n,a,o,s){var l=i(this.points,n,a,o),c=this.controlPoint,u=r(c[0],c[1],n,a,o);t.arrowShapeImpl(this.name)(e,l,u)},gap:function(e){return .8*o(e)}}),s("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(e,t,n,r,o,s,l){var c=a(i(this.points,n+2*l,r,o)),u=a(i(this.pointsTee,n+2*l,r,o));return rL(e,t,c)||rL(e,t,u)},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),l=i(this.pointsTee,n,r,a);t.arrowShapeImpl(this.name)(e,s,l)}}),s("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(e,t,n,r,o,s,l){var c=Math.pow(o.x-e,2)+Math.pow(o.y-t,2)<=Math.pow((n+2*l)*this.radius,2);return rL(e,t,a(i(this.points,n+2*l,r,o)))||c},draw:function(e,n,r,a,o){var s=i(this.pointsTr,n,r,a);t.arrowShapeImpl(this.name)(e,s,a.x,a.y,this.radius*n)},spacing:function(e){return t.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),s("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(e,t){var n=this.baseCrossLinePts.slice(),r=t/e;return n[3]=n[3]-r,n[5]=n[5]-r,n},collide:function(e,t,n,r,o,s,l){var c=a(i(this.points,n+2*l,r,o)),u=a(i(this.crossLinePts(n,s),n+2*l,r,o));return rL(e,t,c)||rL(e,t,u)},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),l=i(this.crossLinePts(n,o),n,r,a);t.arrowShapeImpl(this.name)(e,s,l)}}),s("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e){return .525*o(e)}}),s("circle",{radius:.15,collide:function(e,t,n,r,i,a,o){return Math.pow(i.x-e,2)+Math.pow(i.y-t,2)<=Math.pow((n+2*o)*this.radius,2)},draw:function(e,n,r,i,a){t.arrowShapeImpl(this.name)(e,i.x,i.y,this.radius*n)},spacing:function(e){return t.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),s("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e){return 1},gap:function(e){return 1}}),s("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),s("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}}),s("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(e){return .95*e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}})};var s1={};s1.projectIntoViewport=function(e,t){var n=this.cy,r=this.findContainerClientCoords(),i=r[0],a=r[1],o=r[4],s=n.pan(),l=n.zoom();return[((e-i)/o-s.x)/l,((t-a)/o-s.y)/l]},s1.findContainerClientCoords=function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=this.cy.window().getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},i={left:r("padding-left"),right:r("padding-right"),top:r("padding-top"),bottom:r("padding-bottom")},a={left:r("border-left-width"),right:r("border-right-width"),top:r("border-top-width"),bottom:r("border-bottom-width")},o=e.clientWidth,s=e.clientHeight,l=i.left+i.right,c=i.top+i.bottom,u=a.left+a.right,d=t.width/(o+u),h=t.left+i.left+a.left,f=t.top+i.top+a.top;return this.containerBB=[h,f,o-l,s-c,d]},s1.invalidateContainerClientCoordsCache=function(){this.containerBB=null},s1.findNearestElement=function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},s1.findNearestElements=function(e,t,n,r){var i,a,o=this,s=this,l=s.getCachedZSortedEles(),c=[],u=s.cy.zoom(),d=s.cy.hasCompoundNodes(),h=(r?24:8)/u,f=(r?8:2)/u,p=(r?8:2)/u,g=1/0;function v(e,t){if(e.isNode())if(a)return;else a=e,c.push(e);if(e.isEdge()&&(null==t||t<g))if(i){if(i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value&&i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value){for(var n=0;n<c.length;n++)if(c[n].isEdge()){c[n]=e,i=e,g=null!=t?t:g;break}}}else c.push(e),i=e,g=null!=t?t:g}function x(n){var r=n.outerWidth()+2*f,i=n.outerHeight()+2*f,a=r/2,l=i/2,c=n.position(),u="auto"===n.pstyle("corner-radius").value?"auto":n.pstyle("corner-radius").pfValue,d=n._private.rscratch;if(c.x-a<=e&&e<=c.x+a&&c.y-l<=t&&t<=c.y+l&&s.nodeShapes[o.getNodeShape(n)].checkPoint(e,t,0,r,i,c.x,c.y,u,d))return v(n,0),!0}n&&(l=l.interactive);function y(n,r){var i,a=n._private;i=r?r+"-":"",n.boundingBox();var o=a.labelBounds[r||"main"],s=n.pstyle(i+"label").value;if("yes"===n.pstyle("text-events").strValue&&s){var l=nG(a.rscratch,"labelX",r),c=nG(a.rscratch,"labelY",r),u=nG(a.rscratch,"labelAngle",r),d=n.pstyle(i+"text-margin-x").pfValue,h=n.pstyle(i+"text-margin-y").pfValue,f=o.x1-p-d,g=o.x2+p-d,x=o.y1-p-h,y=o.y2+p-h;if(u){var b=Math.cos(u),w=Math.sin(u),N=function(e,t){return{x:(e-=l)*b-(t-=c)*w+l,y:e*w+t*b+c}},j=N(f,x),k=N(f,y),C=N(g,x),E=N(g,y);if(rL(e,t,[j.x+d,j.y+h,C.x+d,C.y+h,E.x+d,E.y+h,k.x+d,k.y+h]))return v(n),!0}else if(rk(o,e,t))return v(n),!0}}for(var b=l.length-1;b>=0;b--){var w=l[b];w.isNode()?x(w)||y(w):function(n){var r,i=n._private,a=i.rscratch,l=n.pstyle("width").pfValue,u=n.pstyle("arrow-scale").value,f=l/2+h,p=f*f,g=2*f,y=i.source,b=i.target;if("segments"===a.edgeType||"straight"===a.edgeType||"haystack"===a.edgeType){for(var w=a.allpts,N=0;N+3<w.length;N+=2)if(r_(e,t,w[N],w[N+1],w[N+2],w[N+3],g)&&p>(r=rR(e,t,w[N],w[N+1],w[N+2],w[N+3])))return v(n,r),!0}else if("bezier"===a.edgeType||"multibezier"===a.edgeType||"self"===a.edgeType||"compound"===a.edgeType){for(var w=a.allpts,N=0;N+5<a.allpts.length;N+=4)if(rA(e,t,w[N],w[N+1],w[N+2],w[N+3],w[N+4],w[N+5],g)&&p>(r=rP(e,t,w[N],w[N+1],w[N+2],w[N+3],w[N+4],w[N+5])))return v(n,r),!0}for(var y=y||i.source,b=b||i.target,j=o.getArrowWidth(l,u),k=[{name:"source",x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:"target",x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:"mid-source",x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:"mid-target",x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}],N=0;N<k.length;N++){var C=k[N],E=s.arrowShapes[n.pstyle(C.name+"-arrow-shape").value],T=n.pstyle("width").pfValue;if(E.roughCollide(e,t,j,C.angle,{x:C.x,y:C.y},T,h)&&E.collide(e,t,j,C.angle,{x:C.x,y:C.y},T,h))return v(n),!0}d&&c.length>0&&(x(y),x(b))}(w)||y(w)||y(w,"source")||y(w,"target")}return c},s1.getAllInBox=function(e,t,n,r){var i=this.getCachedZSortedEles().interactive,a=2/this.cy.zoom(),o=[],s=Math.min(e,n),l=Math.max(e,n),c=Math.min(t,r),u=Math.max(t,r);e=s,n=l;var d=rm({x1:e,y1:t=c,x2:n,y2:r=u}),h=[{x:d.x1,y:d.y1},{x:d.x2,y:d.y1},{x:d.x2,y:d.y2},{x:d.x1,y:d.y2}],f=[[h[0],h[1]],[h[1],h[2]],[h[2],h[3]],[h[3],h[0]]];function p(e,t){var n=e._private;e.boundingBox();var r=n.labelBounds.main;if(!r)return null;var i=nG(n.rscratch,"labelX",t),o=nG(n.rscratch,"labelY",t),s=nG(n.rscratch,"labelAngle",t),l=e.pstyle("text-margin-x").pfValue,c=e.pstyle("text-margin-y").pfValue,u=r.x1-a-l,d=r.x2+a-l,h=r.y1-a-c,f=r.y2+a-c;if(!s)return[{x:u,y:h},{x:d,y:h},{x:d,y:f},{x:u,y:f}];var p=Math.cos(s),g=Math.sin(s),v=function(e,t){return{x:(e-=i)*p-(t-=o)*g+i,y:e*g+t*p+o}};return[v(u,h),v(d,h),v(d,f),v(u,f)]}for(var g=0;g<i.length;g++){var v=i[g];if(v.isNode()){var x="yes"===v.pstyle("text-events").strValue,y=v.pstyle("box-selection").strValue,b="yes"===v.pstyle("box-select-labels").strValue;if("none"===y)continue;var w=("overlap"===y||b)&&x,N=v.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:w});if("contain"===y){var j=!1;if(b&&x){var k=p(v);k&&r2(k,h)&&(o.push(v),j=!0)}!j&&rE(d,N)&&o.push(v)}else if("overlap"===y&&rj(d,N)){var C=v.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1});if(r2([{x:C.x1,y:C.y1},{x:C.x2,y:C.y1},{x:C.x2,y:C.y2},{x:C.x1,y:C.y2}],h))o.push(v);else{var E=p(v);E&&r2(E,h)&&o.push(v)}}}else{var T=v._private,S=T.rscratch,_=v.pstyle("box-selection").strValue;if("none"===_)continue;if("contain"===_){if(null!=S.startX&&null!=S.startY&&!rk(d,S.startX,S.startY)||null!=S.endX&&null!=S.endY&&!rk(d,S.endX,S.endY))continue;if("bezier"===S.edgeType||"multibezier"===S.edgeType||"self"===S.edgeType||"compound"===S.edgeType||"segments"===S.edgeType||"haystack"===S.edgeType){for(var A=T.rstyle.bezierPts||T.rstyle.linePts||T.rstyle.haystackPts,D=!0,M=0;M<A.length;M++)if(!rC(d,A[M])){D=!1;break}D&&o.push(v)}else"straight"===S.edgeType&&o.push(v)}else if("overlap"===_){var P=!1;if(null!=S.startX&&null!=S.startY&&null!=S.endX&&null!=S.endY&&(rk(d,S.startX,S.startY)||rk(d,S.endX,S.endY)))o.push(v),P=!0;else if(!P&&"haystack"===S.edgeType){for(var R=T.rstyle.haystackPts,L=0;L<R.length;L++)if(rC(d,R[L])){o.push(v),P=!0;break}}if(!P){var I=T.rstyle.bezierPts||T.rstyle.linePts||T.rstyle.haystackPts;if((!I||I.length<2)&&"straight"===S.edgeType&&null!=S.startX&&null!=S.startY&&null!=S.endX&&null!=S.endY&&(I=[{x:S.startX,y:S.startY},{x:S.endX,y:S.endY}]),!I||I.length<2)continue;for(var O=0;O<I.length-1;O++){for(var B=I[O],F=I[O+1],z=0;z<f.length;z++){var V=tj(f[z],2);if(function(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}(B,F,V[0],V[1])){o.push(v),P=!0;break}}if(P)break}}}}}return o};var s2={};s2.calculateArrowAngles=function(e){var t=e._private.rscratch,n="haystack"===t.edgeType,r="bezier"===t.edgeType,i="multibezier"===t.edgeType,a="segments"===t.edgeType,o="compound"===t.edgeType,s="self"===t.edgeType;if(n?(x=t.haystackPts[0],y=t.haystackPts[1],b=t.haystackPts[2],w=t.haystackPts[3]):(x=t.arrowStartX,y=t.arrowStartY,b=t.arrowEndX,w=t.arrowEndY),d=t.midX,h=t.midY,a)g=x-t.segpts[0],v=y-t.segpts[1];else if(i||o||s||r){var l=t.allpts,c=rh(l[0],l[2],l[4],.1),u=rh(l[1],l[3],l[5],.1);g=x-c,v=y-u}else g=x-d,v=y-h;t.srcArrowAngle=ro(g,v);var d=t.midX,h=t.midY;if(n&&(d=(x+b)/2,h=(y+w)/2),g=b-x,v=w-y,a){var l=t.allpts;if(l.length/2%2==0){var f=l.length/2,p=f-2;g=l[f]-l[p],v=l[f+1]-l[p+1]}else if(t.isRound)g=t.midVector[1],v=-t.midVector[0];else{var f=l.length/2-1,p=f-2;g=l[f]-l[p],v=l[f+1]-l[p+1]}}else if(i||o||s){var g,v,x,y,b,w,d,h,N,j,k,C,l=t.allpts;if(t.ctrlpts.length/2%2==0){var E=l.length/2-1,T=E+2,S=T+2;N=rh(l[E],l[T],l[S],0),j=rh(l[E+1],l[T+1],l[S+1],0),k=rh(l[E],l[T],l[S],1e-4),C=rh(l[E+1],l[T+1],l[S+1],1e-4)}else{var T=l.length/2-1,E=T-2,S=T+2;N=rh(l[E],l[T],l[S],.4999),j=rh(l[E+1],l[T+1],l[S+1],.4999),k=rh(l[E],l[T],l[S],.5),C=rh(l[E+1],l[T+1],l[S+1],.5)}g=k-N,v=C-j}if(t.midtgtArrowAngle=ro(g,v),t.midDispX=g,t.midDispY=v,g*=-1,v*=-1,a){var l=t.allpts;if(l.length/2%2==0);else if(!t.isRound){var f=l.length/2-1,_=f+2;g=-(l[_]-l[f]),v=-(l[_+1]-l[f+1])}}if(t.midsrcArrowAngle=ro(g,v),a)g=b-t.segpts[t.segpts.length-2],v=w-t.segpts[t.segpts.length-1];else if(i||o||s||r){var l=t.allpts,A=l.length,c=rh(l[A-6],l[A-4],l[A-2],.9),u=rh(l[A-5],l[A-3],l[A-1],.9);g=b-c,v=w-u}else g=b-d,v=w-h;t.tgtArrowAngle=ro(g,v)},s2.getArrowWidth=s2.getArrowHeight=function(e,t){var n=this.arrowWidthCache=this.arrowWidthCache||{},r=n[e+", "+t];return r||(r=Math.max(Math.pow(13.37*e,.9),29)*t,n[e+", "+t]=r),r};var s5,s3,s4,s6,s9,s7,s8,le,lt,ln,lr,li,la,lo,ls,ll,lc,lu,ld,lh,lf,lp,lg,lm,lv,lx,ly,lb,lw,lN,lj,lk,lC,lE,lT,lS,l_,lA,lD,lM,lP,lR,lL,lI,lO,lB,lF,lz,lV,lH,lU,lG,lY,lX,lW,lq,l$,lK,lZ,lQ,lJ,l0,l1,l2,l5,l3,l4,l6,l9,l7,l8,ce,ct,cn,cr,ci,ca,co,cs,cl,cc,cu,cd,ch,cf,cp,cg,cm,cv,cx,cy,cb,cw,cN,cj,ck,cC,cE,cT,cS,c_,cA,cD,cM,cP,cR,cL,cI,cO,cB,cF,cz,cV,cH,cU,cG,cY,cX,cW,cq,c$,cK,cZ,cQ,cJ,c0,c1,c2,c5,c3,c4,c6,c9,c7,c8,ue,ut,un,ur,ui,ua,uo,us,ul,uc,uu,ud,uh,uf,up,ug,um,uv,ux,uy,ub,uw,uN,uj,uk={},uC={},uE=function(e,t,n){n.x=t.x-e.x,n.y=t.y-e.y,n.len=Math.sqrt(n.x*n.x+n.y*n.y),n.nx=n.x/n.len,n.ny=n.y/n.len,n.ang=Math.atan2(n.ny,n.nx)},uT=function(e,t){t.x=-1*e.x,t.y=-1*e.y,t.nx=-1*e.nx,t.ny=-1*e.ny,t.ang=e.ang>0?-(Math.PI-e.ang):Math.PI+e.ang},uS=function(e,t,n,r,i){if(e!==h?uE(t,e,uk):uT(uC,uk),uE(t,n,uC),up=uk.nx*uC.ny-uk.ny*uC.nx,ug=uk.nx*uC.nx- -(uk.ny*uC.ny),1e-6>Math.abs(ux=Math.asin(Math.max(-1,Math.min(1,up))))){uh=t.x,uf=t.y,ub=uN=0;return}um=1,uv=!1,ug<0?ux<0?ux=Math.PI+ux:(ux=Math.PI-ux,um=-1,uv=!0):ux>0&&(um=-1,uv=!0),uN=void 0!==t.radius?t.radius:r,uy=ux/2,uj=Math.min(uk.len/2,uC.len/2),ub=i?(uw=Math.abs(Math.cos(uy)*uN/Math.sin(uy)))>uj?Math.abs((uw=uj)*Math.sin(uy)/Math.cos(uy)):uN:Math.abs((uw=Math.min(uj,uN))*Math.sin(uy)/Math.cos(uy)),u=t.x+uC.nx*uw,d=t.y+uC.ny*uw,uh=u-uC.ny*ub*um,uf=d+uC.nx*ub*um,l=t.x+uk.nx*uw,c=t.y+uk.ny*uw,h=t};function u_(e,t){0===t.radius?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function uA(e,t,n,r){var i=!(arguments.length>4)||void 0===arguments[4]||arguments[4];return 0===r||0===t.radius?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(uS(e,t,n,r,i),{cx:uh,cy:uf,radius:ub,startX:l,startY:c,stopX:u,stopY:d,startAngle:uk.ang+Math.PI/2*um,endAngle:uC.ang-Math.PI/2*um,counterClockwise:uv})}var uD=Math.sqrt(.02),uM={};function uP(e){var t=[];if(null!=e){for(var n=0;n<e.length;n+=2){var r=e[n],i=e[n+1];t.push({x:r,y:i})}return t}}uM.findMidptPtsEtc=function(e,t){var n,r=t.posPts,i=t.intersectionPts,a=t.vectorNormInverse,o=e.pstyle("source-endpoint"),s=e.pstyle("target-endpoint"),l=null!=o.units&&null!=s.units;switch(e.pstyle("edge-distances").value){case"node-position":n=r;break;case"intersection":n=i;break;case"endpoints":if(l){var c,u,d,h=tj(this.manualEndptToPx(e.source()[0],o),2),f=h[0],p=h[1],g=tj(this.manualEndptToPx(e.target()[0],s),2),v=g[0],x=g[1];c=x-p,d=Math.sqrt((u=v-f)*u+c*c),a={x:-c/d,y:u/d},n={x1:f,y1:p,x2:v,y2:x}}else nL("Edge ".concat(e.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),n=i}return{midptPts:n,vectorNormInverse:a}},uM.findHaystackPoints=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n._private,i=r.rscratch;if(!i.haystack){var a=2*Math.random()*Math.PI;i.source={x:Math.cos(a),y:Math.sin(a)},i.target={x:Math.cos(a=2*Math.random()*Math.PI),y:Math.sin(a)}}var o=r.source,s=r.target,l=o.position(),c=s.position(),u=o.width(),d=s.width(),h=o.height(),f=s.height(),p=n.pstyle("haystack-radius").value/2;i.haystackPts=i.allpts=[i.source.x*u*p+l.x,i.source.y*h*p+l.y,i.target.x*d*p+c.x,i.target.y*f*p+c.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType="haystack",i.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},uM.findSegmentsPoints=function(e,t){var n=e._private.rscratch,r=e.pstyle("segment-weights"),i=e.pstyle("segment-distances"),a=e.pstyle("segment-radii"),o=e.pstyle("radius-type"),s=Math.min(r.pfValue.length,i.pfValue.length),l=a.pfValue[a.pfValue.length-1],c=o.pfValue[o.pfValue.length-1];n.edgeType="segments",n.segpts=[],n.radii=[],n.isArcRadius=[];for(var u=0;u<s;u++){var d=r.pfValue[u],h=i.pfValue[u],f=1-d,p=this.findMidptPtsEtc(e,t),g=p.midptPts,v=p.vectorNormInverse,x={x:g.x1*f+g.x2*d,y:g.y1*f+g.y2*d};n.segpts.push(x.x+v.x*h,x.y+v.y*h),n.radii.push(void 0!==a.pfValue[u]?a.pfValue[u]:l),n.isArcRadius.push((void 0!==o.pfValue[u]?o.pfValue[u]:c)==="arc-radius")}},uM.findLoopPoints=function(e,t,n,r){var i=e._private.rscratch,a=t.dirCounts,o=t.srcPos,s=e.pstyle("control-point-distances"),l=s?s.pfValue[0]:void 0,c=e.pstyle("loop-direction").pfValue,u=e.pstyle("loop-sweep").pfValue,d=e.pstyle("control-point-step-size").pfValue;i.edgeType="self";var h=n,f=d;r&&(h=0,f=l);var p=c-Math.PI/2,g=p-u/2,v=p+u/2,x=String(c+"_"+u);h=void 0===a[x]?a[x]=0:++a[x],i.ctrlpts=[o.x+1.4*Math.cos(g)*f*(h/3+1),o.y+1.4*Math.sin(g)*f*(h/3+1),o.x+1.4*Math.cos(v)*f*(h/3+1),o.y+1.4*Math.sin(v)*f*(h/3+1)]},uM.findCompoundLoopPoints=function(e,t,n,r){var i=e._private.rscratch;i.edgeType="compound";var a=t.srcPos,o=t.tgtPos,s=t.srcW,l=t.srcH,c=t.tgtW,u=t.tgtH,d=e.pstyle("control-point-step-size").pfValue,h=e.pstyle("control-point-distances"),f=h?h.pfValue[0]:void 0,p=n,g=d;r&&(p=0,g=f);var v={x:a.x-s/2,y:a.y-l/2},x={x:o.x-c/2,y:o.y-u/2},y={x:Math.min(v.x,x.x),y:Math.min(v.y,x.y)},b=Math.max(.5,Math.log(.01*s)),w=Math.max(.5,Math.log(.01*c));i.ctrlpts=[y.x,y.y-1.7995514309304248*g*(p/3+1)*b,y.x-1.7995514309304248*g*(p/3+1)*w,y.y]},uM.findStraightEdgePoints=function(e){e._private.rscratch.edgeType="straight"},uM.findBezierPoints=function(e,t,n,r,i){var a=e._private.rscratch,o=e.pstyle("control-point-step-size").pfValue,s=e.pstyle("control-point-distances"),l=e.pstyle("control-point-weights"),c=s&&l?Math.min(s.value.length,l.value.length):1,u=s?s.pfValue[0]:void 0,d=l.value[0];a.edgeType=r?"multibezier":"bezier",a.ctrlpts=[];for(var h=0;h<c;h++){var f=(.5-t.eles.length/2+n)*o*(i?-1:1),p=void 0,g=rl(f);r&&(u=s?s.pfValue[h]:o,d=l.value[h]);var v=void 0!==(p=r?u:void 0!==u?g*u:void 0)?p:f,x=1-d,y=d,b=this.findMidptPtsEtc(e,t),w=b.midptPts,N=b.vectorNormInverse,j={x:w.x1*x+w.x2*y,y:w.y1*x+w.y2*y};a.ctrlpts.push(j.x+N.x*v,j.y+N.y*v)}},uM.findTaxiPoints=function(e,t){var n,r=e._private.rscratch;r.edgeType="segments";var i="vertical",a="horizontal",o="leftward",s="rightward",l="downward",c="upward",u=t.posPts,d=t.srcW,h=t.srcH,f=t.tgtW,p=t.tgtH,g="node-position"!==e.pstyle("edge-distances").value,v=e.pstyle("taxi-direction").value,x=v,y=e.pstyle("taxi-turn"),b="%"===y.units,w=y.pfValue,N=e.pstyle("taxi-turn-min-distance").pfValue,j=u.x2-u.x1,k=u.y2-u.y1,C=function(e,t){return e>0?Math.max(e-t,0):Math.min(e+t,0)},E=C(j,g?(d+f)/2:0),T=C(k,g?(h+p)/2:0),S=!1;"auto"===x?v=Math.abs(E)>Math.abs(T)?a:i:x===c||x===l?(v=i,S=!0):(x===o||x===s)&&(v=a,S=!0);var _=v===i,A=_?T:E,D=_?k:j,M=rl(D),P=!1;!(S&&(b||w<0))&&(x===l&&D<0||x===c&&D>0||x===o&&D>0||x===s&&D<0)&&(M*=-1,A=M*Math.abs(A),P=!0);var R=function(e){return Math.abs(e)<N||Math.abs(e)>=Math.abs(A)},L=R(n=b?(w<0?1+w:w)*A:(w<0?A:0)+w*M),I=R(Math.abs(A)-Math.abs(n));if((L||I)&&!P)if(_){var O=Math.abs(j)<=f/2;if(Math.abs(D)<=h/2){var B=(u.x1+u.x2)/2;r.segpts=[B,u.y1,B,u.y2]}else if(O){var F=(u.y1+u.y2)/2;r.segpts=[u.x1,F,u.x2,F]}else r.segpts=[u.x1,u.y2]}else{var z=Math.abs(k)<=p/2;if(Math.abs(D)<=d/2){var V=(u.y1+u.y2)/2;r.segpts=[u.x1,V,u.x2,V]}else if(z){var H=(u.x1+u.x2)/2;r.segpts=[H,u.y1,H,u.y2]}else r.segpts=[u.x2,u.y1]}else if(_){var U=u.y1+n+(g?h/2*M:0);r.segpts=[u.x1,U,u.x2,U]}else{var G=u.x1+n+(g?d/2*M:0);r.segpts=[G,u.y1,G,u.y2]}if(r.isRound){var Y=e.pstyle("taxi-radius").value,X="arc-radius"===e.pstyle("radius-type").value[0];r.radii=Array(r.segpts.length/2).fill(Y),r.isArcRadius=Array(r.segpts.length/2).fill(X)}},uM.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,i=t.tgtPos,a=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,c=t.srcShape,u=t.tgtShape,d=t.srcCornerRadius,h=t.tgtCornerRadius,f=t.srcRs,p=t.tgtRs,g=!tF(n.startX)||!tF(n.startY),v=!tF(n.arrowStartX)||!tF(n.arrowStartY),x=!tF(n.endX)||!tF(n.endY),y=!tF(n.arrowEndX)||!tF(n.arrowEndY),b=3*(this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth),w=rc({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),N=w<b,j=rc({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.endX,y:n.endY}),k=j<b,C=!1;if(g||v||N){C=!0;var E={x:n.ctrlpts[0]-r.x,y:n.ctrlpts[1]-r.y},T=Math.sqrt(E.x*E.x+E.y*E.y),S={x:E.x/T,y:E.y/T},_=Math.max(a,o),A={x:n.ctrlpts[0]+2*S.x*_,y:n.ctrlpts[1]+2*S.y*_},D=c.intersectLine(r.x,r.y,a,o,A.x,A.y,0,d,f);N?(n.ctrlpts[0]=n.ctrlpts[0]+S.x*(b-w),n.ctrlpts[1]=n.ctrlpts[1]+S.y*(b-w)):(n.ctrlpts[0]=D[0]+S.x*b,n.ctrlpts[1]=D[1]+S.y*b)}if(x||y||k){C=!0;var M={x:n.ctrlpts[0]-i.x,y:n.ctrlpts[1]-i.y},P=Math.sqrt(M.x*M.x+M.y*M.y),R={x:M.x/P,y:M.y/P},L=Math.max(a,o),I={x:n.ctrlpts[0]+2*R.x*L,y:n.ctrlpts[1]+2*R.y*L},O=u.intersectLine(i.x,i.y,s,l,I.x,I.y,0,h,p);k?(n.ctrlpts[0]=n.ctrlpts[0]+R.x*(b-j),n.ctrlpts[1]=n.ctrlpts[1]+R.y*(b-j)):(n.ctrlpts[0]=O[0]+R.x*b,n.ctrlpts[1]=O[1]+R.y*b)}C&&this.findEndpoints(e)}},uM.storeAllpts=function(e){var t=e._private.rscratch;if("multibezier"===t.edgeType||"bezier"===t.edgeType||"self"===t.edgeType||"compound"===t.edgeType){t.allpts=[],t.allpts.push(t.startX,t.startY);for(var n,r=0;r+1<t.ctrlpts.length;r+=2)t.allpts.push(t.ctrlpts[r],t.ctrlpts[r+1]),r+3<t.ctrlpts.length&&t.allpts.push((t.ctrlpts[r]+t.ctrlpts[r+2])/2,(t.ctrlpts[r+1]+t.ctrlpts[r+3])/2);(t.allpts.push(t.endX,t.endY),t.ctrlpts.length/2%2==0)?(n=t.allpts.length/2-1,t.midX=t.allpts[n],t.midY=t.allpts[n+1]):(n=t.allpts.length/2-3,t.midX=rh(t.allpts[n],t.allpts[n+2],t.allpts[n+4],.5),t.midY=rh(t.allpts[n+1],t.allpts[n+3],t.allpts[n+5],.5))}else if("straight"===t.edgeType)t.allpts=[t.startX,t.startY,t.endX,t.endY],t.midX=(t.startX+t.endX+t.arrowStartX+t.arrowEndX)/4,t.midY=(t.startY+t.endY+t.arrowStartY+t.arrowEndY)/4;else if("segments"===t.edgeType){if(t.allpts=[],t.allpts.push(t.startX,t.startY),t.allpts.push.apply(t.allpts,t.segpts),t.allpts.push(t.endX,t.endY),t.isRound){t.roundCorners=[];for(var i=2;i+3<t.allpts.length;i+=2){var a=t.radii[i/2-1],o=t.isArcRadius[i/2-1];t.roundCorners.push(uA({x:t.allpts[i-2],y:t.allpts[i-1]},{x:t.allpts[i],y:t.allpts[i+1],radius:a},{x:t.allpts[i+2],y:t.allpts[i+3]},a,o))}}if(t.segpts.length%4==0){var s=t.segpts.length/2,l=s-2;t.midX=(t.segpts[l]+t.segpts[s])/2,t.midY=(t.segpts[l+1]+t.segpts[s+1])/2}else{var c=t.segpts.length/2-1;if(t.isRound){var u={x:t.segpts[c],y:t.segpts[c+1]},d=t.roundCorners[c/2];if(0===d.radius){var h={x:t.segpts[c+2],y:t.segpts[c+3]};t.midX=u.x,t.midY=u.y,t.midVector=[u.y-h.y,h.x-u.x]}else{var f=[u.x-d.cx,u.y-d.cy],p=d.radius/Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2));f=f.map(function(e){return e*p}),t.midX=d.cx+f[0],t.midY=d.cy+f[1],t.midVector=f}}else t.midX=t.segpts[c],t.midY=t.segpts[c+1]}}},uM.checkForInvalidEdgeWarning=function(e){var t=e[0]._private.rscratch;t.nodesOverlap||tF(t.startX)&&tF(t.startY)&&tF(t.endX)&&tF(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,nL("Edge `"+e.id()+"` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."))},uM.findEdgeControlPoints=function(e){var t=this;if(e&&0!==e.length){for(var n=this,r=n.cy.hasCompoundNodes(),i=new nW,a=function(e,t){return[].concat(tk(e),[+!!t]).join("-")},o=[],s=[],l=0;l<e.length;l++){var c=e[l],u=c._private,d=c.pstyle("curve-style").value;if(!c.removed()&&c.takesUpSpace()){if("haystack"===d){s.push(c);continue}var h="unbundled-bezier"===d||tJ(d,"segments")||"straight"===d||"straight-triangle"===d||tJ(d,"taxi"),f="unbundled-bezier"===d||"bezier"===d,p=u.source,g=u.target,v=[p.poolIndex(),g.poolIndex()].sort(),x=a(v,h),y=i.get(x);null==y&&(y={eles:[]},o.push({pairId:v,edgeIsUnbundled:h}),i.set(x,y)),y.eles.push(c),h&&(y.hasUnbundled=!0),f&&(y.hasBezier=!0)}}for(var b=0;b<o.length;b++)!function(){var e,s=o[b],l=a(s.pairId,s.edgeIsUnbundled),c=i.get(l);if(!c.hasUnbundled){var u=c.eles[0].parallelEdges().filter(function(e){return e.isBundledBezier()});nH(c.eles),u.forEach(function(e){return c.eles.push(e)}),c.eles.sort(function(e,t){return e.poolIndex()-t.poolIndex()})}var d=c.eles[0],h=d.source(),f=d.target();if(h.poolIndex()>f.poolIndex()){var p=h;h=f,f=p}var g=c.srcPos=h.position(),v=c.tgtPos=f.position(),x=c.srcW=h.outerWidth(),y=c.srcH=h.outerHeight(),w=c.tgtW=f.outerWidth(),N=c.tgtH=f.outerHeight(),j=c.srcShape=n.nodeShapes[t.getNodeShape(h)],k=c.tgtShape=n.nodeShapes[t.getNodeShape(f)],C=c.srcCornerRadius="auto"===h.pstyle("corner-radius").value?"auto":h.pstyle("corner-radius").pfValue,E=c.tgtCornerRadius="auto"===f.pstyle("corner-radius").value?"auto":f.pstyle("corner-radius").pfValue,T=c.tgtRs=f._private.rscratch,S=c.srcRs=h._private.rscratch;c.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var _=0;_<c.eles.length;_++){var A=c.eles[_],D=A[0]._private.rscratch,M=A.pstyle("curve-style").value,P="unbundled-bezier"===M||tJ(M,"segments")||tJ(M,"taxi"),R=!h.same(A.source());if(!c.calculatedIntersection&&h!==f&&(c.hasBezier||c.hasUnbundled)){c.calculatedIntersection=!0;var L=j.intersectLine(g.x,g.y,x,y,v.x,v.y,0,C,S),I=c.srcIntn=L,O=k.intersectLine(v.x,v.y,w,N,g.x,g.y,0,E,T),B=c.tgtIntn=O,F=c.intersectionPts={x1:L[0],x2:O[0],y1:L[1],y2:O[1]},z=c.posPts={x1:g.x,x2:v.x,y1:g.y,y2:v.y},V=O[1]-L[1],H=O[0]-L[0],U=Math.sqrt(H*H+V*V);tF(U)&&U>=uD||(U=Math.sqrt(Math.max(H*H,.01)+Math.max(V*V,.01)));var G=c.vector={x:H,y:V},Y=c.vectorNorm={x:G.x/U,y:G.y/U},X={x:-Y.y,y:Y.x};c.nodesOverlap=!tF(U)||k.checkPoint(L[0],L[1],0,w,N,v.x,v.y,E,T)||j.checkPoint(O[0],O[1],0,x,y,g.x,g.y,C,S),c.vectorNormInverse=X,e={nodesOverlap:c.nodesOverlap,dirCounts:c.dirCounts,calculatedIntersection:!0,hasBezier:c.hasBezier,hasUnbundled:c.hasUnbundled,eles:c.eles,srcPos:v,srcRs:T,tgtPos:g,tgtRs:S,srcW:w,srcH:N,tgtW:x,tgtH:y,srcIntn:B,tgtIntn:I,srcShape:k,tgtShape:j,posPts:{x1:z.x2,y1:z.y2,x2:z.x1,y2:z.y1},intersectionPts:{x1:F.x2,y1:F.y2,x2:F.x1,y2:F.y1},vector:{x:-G.x,y:-G.y},vectorNorm:{x:-Y.x,y:-Y.y},vectorNormInverse:{x:-X.x,y:-X.y}}}var W=R?e:c;D.nodesOverlap=W.nodesOverlap,D.srcIntn=W.srcIntn,D.tgtIntn=W.tgtIntn,D.isRound=M.startsWith("round"),r&&(h.isParent()||h.isChild()||f.isParent()||f.isChild())&&(h.parents().anySame(f)||f.parents().anySame(h)||h.same(f)&&h.isParent())?t.findCompoundLoopPoints(A,W,_,P):h===f?t.findLoopPoints(A,W,_,P):M.endsWith("segments")?t.findSegmentsPoints(A,W):M.endsWith("taxi")?t.findTaxiPoints(A,W):"straight"!==M&&(P||c.eles.length%2!=1||_!==Math.floor(c.eles.length/2))?t.findBezierPoints(A,W,_,P,R):t.findStraightEdgePoints(A),t.findEndpoints(A),t.tryToCorrectInvalidPoints(A,W),t.checkForInvalidEdgeWarning(A),t.storeAllpts(A),t.storeEdgeProjections(A),t.calculateArrowAngles(A),t.recalculateEdgeLabelProjections(A),t.calculateLabelAngles(A)}}();this.findHaystackPoints(s)}},uM.getSegmentPoints=function(e){var t=e[0]._private.rscratch;if(this.recalculateRenderedStyle(e),"segments"===t.edgeType)return uP(t.segpts)},uM.getControlPoints=function(e){var t=e[0]._private.rscratch;this.recalculateRenderedStyle(e);var n=t.edgeType;if("bezier"===n||"multibezier"===n||"self"===n||"compound"===n)return uP(t.ctrlpts)},uM.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var uR={};uR.manualEndptToPx=function(e,t){var n=e.position(),r=e.outerWidth(),i=e.outerHeight(),a=e._private.rscratch;if(2===t.value.length){var o=[t.pfValue[0],t.pfValue[1]];return"%"===t.units[0]&&(o[0]=o[0]*r),"%"===t.units[1]&&(o[1]=o[1]*i),o[0]+=n.x,o[1]+=n.y,o}var s=t.pfValue[0];s=-Math.PI/2+s;var l=2*Math.max(r,i),c=[n.x+Math.cos(s)*l,n.y+Math.sin(s)*l];return this.nodeShapes[this.getNodeShape(e)].intersectLine(n.x,n.y,r,i,c[0],c[1],0,"auto"===e.pstyle("corner-radius").value?"auto":e.pstyle("corner-radius").pfValue,a)},uR.findEndpoints=function(e){var t,n,r,i,a,o,s,l,c,u=e.source()[0],d=e.target()[0],h=u.position(),f=d.position(),p=e.pstyle("target-arrow-shape").value,g=e.pstyle("source-arrow-shape").value,v=e.pstyle("target-distance-from-node").pfValue,x=e.pstyle("source-distance-from-node").pfValue,y=u._private.rscratch,b=d._private.rscratch,w=e.pstyle("curve-style").value,N=e._private.rscratch,j=N.edgeType,k=tJ(w,"taxi"),C="self"===j||"compound"===j,E="bezier"===j||"multibezier"===j||C,T="bezier"!==j,S="straight"===j||"segments"===j,_="segments"===j,A=C||k,D=e.pstyle("source-endpoint"),M=A?"outside-to-node":D.value,P="auto"===u.pstyle("corner-radius").value?"auto":u.pstyle("corner-radius").pfValue,R=e.pstyle("target-endpoint"),L=A?"outside-to-node":R.value,I="auto"===d.pstyle("corner-radius").value?"auto":d.pstyle("corner-radius").pfValue;N.srcManEndpt=D,N.tgtManEndpt=R;var O=null!=(t=(null==R||null==(n=R.pfValue)?void 0:n.length)===2?R.pfValue:null)?t:[0,0],B=null!=(r=(null==D||null==(i=D.pfValue)?void 0:i.length)===2?D.pfValue:null)?r:[0,0];if(E){var F=[N.ctrlpts[0],N.ctrlpts[1]];o=T?[N.ctrlpts[N.ctrlpts.length-2],N.ctrlpts[N.ctrlpts.length-1]]:F,s=F}else if(S){var z=_?N.segpts.slice(0,2):[f.x+O[0],f.y+O[1]];o=_?N.segpts.slice(N.segpts.length-2):[h.x+B[0],h.y+B[1]],s=z}if("inside-to-node"===L)a=[f.x,f.y];else if(R.units)a=this.manualEndptToPx(d,R);else if("outside-to-line"===L)a=N.tgtIntn;else if("outside-to-node"===L||"outside-to-node-or-label"===L?l=o:("outside-to-line"===L||"outside-to-line-or-label"===L)&&(l=[h.x,h.y]),a=this.nodeShapes[this.getNodeShape(d)].intersectLine(f.x,f.y,d.outerWidth(),d.outerHeight(),l[0],l[1],0,I,b),"outside-to-node-or-label"===L||"outside-to-line-or-label"===L){var V=d._private.rscratch,H=V.labelWidth,U=V.labelHeight,G=V.labelX,Y=V.labelY,X=H/2,W=U/2,q=d.pstyle("text-valign").value;"top"===q?Y-=W:"bottom"===q&&(Y+=W);var $=d.pstyle("text-halign").value;"left"===$?G-=X:"right"===$&&(G+=X);var K=rX(l[0],l[1],[G-X,Y-W,G+X,Y-W,G+X,Y+W,G-X,Y+W],f.x,f.y);if(K.length>0){var Z=ru(h,rt(a)),Q=ru(h,rt(K)),J=Z;Q<Z&&(a=K,J=Q),K.length>2&&ru(h,{x:K[2],y:K[3]})<J&&(a=[K[2],K[3]])}}var ee=rq(a,o,this.arrowShapes[p].spacing(e)+v),et=rq(a,o,this.arrowShapes[p].gap(e)+v);if(N.endX=et[0],N.endY=et[1],N.arrowEndX=ee[0],N.arrowEndY=ee[1],"inside-to-node"===M)a=[h.x,h.y];else if(D.units)a=this.manualEndptToPx(u,D);else if("outside-to-line"===M)a=N.srcIntn;else if("outside-to-node"===M||"outside-to-node-or-label"===M?c=s:("outside-to-line"===M||"outside-to-line-or-label"===M)&&(c=[f.x,f.y]),a=this.nodeShapes[this.getNodeShape(u)].intersectLine(h.x,h.y,u.outerWidth(),u.outerHeight(),c[0],c[1],0,P,y),"outside-to-node-or-label"===M||"outside-to-line-or-label"===M){var en=u._private.rscratch,er=en.labelWidth,ei=en.labelHeight,ea=en.labelX,eo=en.labelY,es=er/2,el=ei/2,ec=u.pstyle("text-valign").value;"top"===ec?eo-=el:"bottom"===ec&&(eo+=el);var eu=u.pstyle("text-halign").value;"left"===eu?ea-=es:"right"===eu&&(ea+=es);var ed=rX(c[0],c[1],[ea-es,eo-el,ea+es,eo-el,ea+es,eo+el,ea-es,eo+el],h.x,h.y);if(ed.length>0){var eh=ru(f,rt(a)),ef=ru(f,rt(ed)),ep=eh;ef<eh&&(a=[ed[0],ed[1]],ep=ef),ed.length>2&&ru(f,{x:ed[2],y:ed[3]})<ep&&(a=[ed[2],ed[3]])}}var eg=rq(a,s,this.arrowShapes[g].spacing(e)+x),em=rq(a,s,this.arrowShapes[g].gap(e)+x);N.startX=em[0],N.startY=em[1],N.arrowStartX=eg[0],N.arrowStartY=eg[1],(E||T||S)&&(tF(N.startX)&&tF(N.startY)&&tF(N.endX)&&tF(N.endY)?N.badLine=!1:N.badLine=!0)},uR.getSourceEndpoint=function(e){var t=e[0]._private.rscratch;return(this.recalculateRenderedStyle(e),"haystack"===t.edgeType)?{x:t.haystackPts[0],y:t.haystackPts[1]}:{x:t.arrowStartX,y:t.arrowStartY}},uR.getTargetEndpoint=function(e){var t=e[0]._private.rscratch;return(this.recalculateRenderedStyle(e),"haystack"===t.edgeType)?{x:t.haystackPts[2],y:t.haystackPts[3]}:{x:t.arrowEndX,y:t.arrowEndY}};var uL={};uL.storeEdgeProjections=function(e){var t=e._private,n=t.rscratch,r=n.edgeType;if(t.rstyle.bezierPts=null,t.rstyle.linePts=null,t.rstyle.haystackPts=null,"multibezier"===r||"bezier"===r||"self"===r||"compound"===r){t.rstyle.bezierPts=[];for(var i=0;i+5<n.allpts.length;i+=4)!function(e,t,n){for(var r=function(e,t,n,r){return rh(e,t,n,r)},i=t._private.rstyle.bezierPts,a=0;a<e.bezierProjPcts.length;a++){var o=e.bezierProjPcts[a];i.push({x:r(n[0],n[2],n[4],o),y:r(n[1],n[3],n[5],o)})}}(this,e,n.allpts.slice(i,i+6))}else if("segments"===r)for(var a=t.rstyle.linePts=[],i=0;i+1<n.allpts.length;i+=2)a.push({x:n.allpts[i],y:n.allpts[i+1]});else if("haystack"===r){var o=n.haystackPts;t.rstyle.haystackPts=[{x:o[0],y:o[1]},{x:o[2],y:o[3]}]}t.rstyle.arrowWidth=this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth},uL.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var uI={};uI.recalculateNodeLabelProjection=function(e){var t,n;if(!tX(e.pstyle("label").strValue)){var r=e._private,i=e.width(),a=e.height(),o=e.padding(),s=e.position(),l=e.pstyle("text-halign").strValue,c=e.pstyle("text-valign").strValue,u=r.rscratch,d=r.rstyle;switch(l){case"left":t=s.x-i/2-o;break;case"right":t=s.x+i/2+o;break;default:t=s.x}switch(c){case"top":n=s.y-a/2-o;break;case"bottom":n=s.y+a/2+o;break;default:n=s.y}u.labelX=t,u.labelY=n,d.labelX=t,d.labelY=n,this.calculateLabelAngles(e),this.applyLabelDimensions(e)}};var uO=function(e,t){var n=Math.atan(t/e);return 0===e&&n<0&&(n*=-1),n},uB=function(e,t){return uO(t.x-e.x,t.y-e.y)},uF=function(e,t,n,r){var i=rg(0,r-.001,1),a=rg(0,r+.001,1);return uB(rf(e,t,n,i),rf(e,t,n,a))};uI.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,i=this,a={mid:e.pstyle("label").strValue,source:e.pstyle("source-label").strValue,target:e.pstyle("target-label").strValue};if(a.mid||a.source||a.target){t={x:r.midX,y:r.midY};var o=function(e,t,r){nY(n.rscratch,e,t,r),nY(n.rstyle,e,t,r)};o("labelX",null,t.x),o("labelY",null,t.y),o("labelAutoAngle",null,uO(r.midDispX,r.midDispY));var s=function(){if(s.cache)return s.cache;for(var e=[],t=0;t+5<r.allpts.length;t+=4){var a={x:r.allpts[t],y:r.allpts[t+1]},o={x:r.allpts[t+2],y:r.allpts[t+3]},l={x:r.allpts[t+4],y:r.allpts[t+5]};e.push({p0:a,p1:o,p2:l,startDist:0,length:0,segments:[]})}var c=n.rstyle.bezierPts,u=i.bezierProjPcts.length;function d(e,t,n,r,i){var a=rc(t,n),o=e.segments[e.segments.length-1],s={p0:t,p1:n,t0:r,t1:i,startDist:o?o.startDist+o.length:0,length:a};e.segments.push(s),e.length+=a}for(var h=0;h<e.length;h++){var f=e[h],p=e[h-1];p&&(f.startDist=p.startDist+p.length),d(f,f.p0,c[h*u],0,i.bezierProjPcts[0]);for(var g=0;g<u-1;g++)d(f,c[h*u+g],c[h*u+g+1],i.bezierProjPcts[g],i.bezierProjPcts[g+1]);d(f,c[h*u+u-1],f.p2,i.bezierProjPcts[u-1],1)}return s.cache=e},l=function(n){var i="source"===n;if(a[n]){var l=e.pstyle(n+"-text-offset").pfValue;switch(r.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var c,u,d=s(),h=0,f=0,p=0;p<d.length;p++){for(var g=d[i?p:d.length-1-p],v=0;v<g.segments.length;v++){var x=g.segments[i?v:g.segments.length-1-v],y=p===d.length-1&&v===g.segments.length-1;if(h=f,(f+=x.length)>=l||y){u={cp:g,segment:x};break}}if(u)break}var b=u.cp,w=u.segment,N=(l-h)/w.length,j=w.t1-w.t0,k=i?w.t0+j*N:w.t1-j*N;k=rg(0,k,1),t=rf(b.p0,b.p1,b.p2,k),c=uF(b.p0,b.p1,b.p2,k);break;case"straight":case"segments":case"haystack":for(var C,E,T,S,_=0,A=r.allpts.length,D=0;D+3<A&&(i?(C={x:r.allpts[D],y:r.allpts[D+1]},E={x:r.allpts[D+2],y:r.allpts[D+3]}):(C={x:r.allpts[A-2-D],y:r.allpts[A-1-D]},E={x:r.allpts[A-4-D],y:r.allpts[A-3-D]}),T=rc(C,E),S=_,!((_+=T)>=l));D+=2);var M=(l-S)/T;t=rp(C,E,M=rg(0,M,1)),c=uB(C,E)}o("labelX",n,t.x),o("labelY",n,t.y),o("labelAutoAngle",n,c)}};l("source"),l("target"),this.applyLabelDimensions(e)}},uI.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},uI.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=nN(r,e._private.labelDimsKey);if(nG(n.rscratch,"prefixedLabelDimsKey",t)!==i){nY(n.rscratch,"prefixedLabelDimsKey",t,i);var a=this.calculateLabelDimensions(e,r),o=e.pstyle("line-height").pfValue,s=e.pstyle("text-wrap").strValue,l=nG(n.rscratch,"labelWrapCachedLines",t)||[],c="wrap"!==s?1:Math.max(l.length,1),u=a.height/c,d=a.width,h=a.height+(c-1)*(o-1)*u;nY(n.rstyle,"labelWidth",t,d),nY(n.rscratch,"labelWidth",t,d),nY(n.rstyle,"labelHeight",t,h),nY(n.rscratch,"labelHeight",t,h),nY(n.rscratch,"labelLineHeight",t,u*o)}},uI.getLabelText=function(e,t){var n=e._private,r=t?t+"-":"",i=e.pstyle(r+"label").strValue,a=e.pstyle("text-transform").value,o=function(e,r){return r?(nY(n.rscratch,e,t,r),r):nG(n.rscratch,e,t)};if(!i)return"";"none"==a||("uppercase"==a?i=i.toUpperCase():"lowercase"==a&&(i=i.toLowerCase()));var s=e.pstyle("text-wrap").value;if("wrap"===s){var l=o("labelKey");if(null!=l&&o("labelWrapKey")===l)return o("labelWrapCachedText");for(var c=i.split("\n"),u=e.pstyle("text-max-width").pfValue,d="anywhere"===e.pstyle("text-overflow-wrap").value,h=[],f=/[\s\u200b]+|$/g,p=0;p<c.length;p++){var g=c[p],v=this.calculateLabelDimensions(e,g).width;if(d&&(g=g.split("").join("​")),v>u){var x,y=g.matchAll(f),b="",w=0,N=tw(y);try{for(N.s();!(x=N.n()).done;){var j=x.value,k=j[0],C=g.substring(w,j.index);w=j.index+k.length;var E=0===b.length?C:b+C+k;this.calculateLabelDimensions(e,E).width<=u?b+=C+k:(b&&h.push(b),b=C+k)}}catch(e){N.e(e)}finally{N.f()}b.match(/^[\s\u200b]+$/)||h.push(b)}else h.push(g)}o("labelWrapCachedLines",h),i=o("labelWrapCachedText",h.join("\n")),o("labelWrapKey",l)}else if("ellipsis"===s){var T=e.pstyle("text-max-width").pfValue,S="",_=!1;if(this.calculateLabelDimensions(e,i).width<T)return i;for(var A=0;A<i.length&&!(this.calculateLabelDimensions(e,S+i[A]+"…").width>T);A++)S+=i[A],A===i.length-1&&(_=!0);return _||(S+="…"),S}return i},uI.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},uI.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=e.pstyle("font-style").strValue,i=e.pstyle("font-size").pfValue,a=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=this.labelCalcCanvas,l=this.labelCalcCanvasContext;if(!s){s=this.labelCalcCanvas=n.createElement("canvas"),l=this.labelCalcCanvasContext=s.getContext("2d");var c=s.style;c.position="absolute",c.left="-9999px",c.top="-9999px",c.zIndex="-1",c.visibility="hidden",c.pointerEvents="none"}l.font="".concat(r," ").concat(o," ").concat(i,"px ").concat(a);for(var u=0,d=0,h=t.split("\n"),f=0;f<h.length;f++){var p=h[f];u=Math.max(Math.ceil(l.measureText(p).width),u),d+=i}return{width:u+=0,height:d+=0}},uI.calculateLabelAngle=function(e,t){var n=e._private.rscratch,r=e.isEdge(),i=e.pstyle((t?t+"-":"")+"text-rotation"),a=i.strValue;return"none"===a?0:r&&"autorotate"===a?n.labelAutoAngle:"autorotate"===a?0:i.pfValue},uI.calculateLabelAngles=function(e){var t=e.isEdge(),n=e._private.rscratch;n.labelAngle=this.calculateLabelAngle(e),t&&(n.sourceLabelAngle=this.calculateLabelAngle(e,"source"),n.targetLabelAngle=this.calculateLabelAngle(e,"target"))};var uz={},uV=!1;uz.getNodeShape=function(e){var t=e.pstyle("shape").value;if("cutrectangle"===t&&(28>e.width()||28>e.height()))return uV||(nL("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),uV=!0),"rectangle";if(e.isParent())if("rectangle"===t||"roundrectangle"===t||"round-rectangle"===t||"cutrectangle"===t||"cut-rectangle"===t||"barrel"===t)return t;else return"rectangle";if("polygon"===t){var n=e.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(n).name}return t};var uH={};uH.registerCalculationListeners=function(){var e=this.cy,t=e.collection(),n=this,r=function(e){var n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(t.merge(e),n)for(var r=0;r<e.length;r++){var i=e[r]._private.rstyle;i.clean=!1,i.cleanConnected=!1}};n.binder(e).on("bounds.* dirty.*",function(e){r(e.target)}).on("style.* background.*",function(e){r(e.target,!1)});var i=function(i){if(i){var a=n.onUpdateEleCalcsFns;t.cleanStyle();for(var o=0;o<t.length;o++){var s=t[o],l=s._private.rstyle;s.isNode()&&!l.cleanConnected&&(r(s.connectedEdges()),l.cleanConnected=!0)}if(a)for(var c=0;c<a.length;c++)(0,a[c])(i,t);n.recalculateRenderedStyle(t),t=e.collection()}};n.flushRenderedStyleQueue=function(){i(!0)},n.beforeRender(i,n.beforeRenderPriorities.eleCalcs)},uH.onUpdateEleCalcs=function(e){(this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[]).push(e)},uH.recalculateRenderedStyle=function(e,t){var n=function(e){return e._private.rstyle.cleanConnected};if(0!==e.length){var r=[],i=[];if(!this.destroyed){void 0===t&&(t=!0);for(var a=0;a<e.length;a++){var o=e[a],s=o._private,l=s.rstyle;!o.isEdge()||n(o.source())&&n(o.target())||(l.clean=!1),o.isEdge()&&o.isBundledBezier()&&o.parallelEdges().some(function(e){return!e._private.rstyle.clean&&e.isBundledBezier()})&&(l.clean=!1),t&&l.clean||o.removed()||"none"!==o.pstyle("display").value&&("nodes"===s.group?i.push(o):r.push(o),l.clean=!0)}for(var c=0;c<i.length;c++){var u=i[c],d=u._private.rstyle,h=u.position();this.recalculateNodeLabelProjection(u),d.nodeX=h.x,d.nodeY=h.y,d.nodeW=u.pstyle("width").pfValue,d.nodeH=u.pstyle("height").pfValue}this.recalculateEdgeProjections(r);for(var f=0;f<r.length;f++){var p=r[f]._private,g=p.rstyle,v=p.rscratch;g.srcX=v.arrowStartX,g.srcY=v.arrowStartY,g.tgtX=v.arrowEndX,g.tgtY=v.arrowEndY,g.midX=v.midX,g.midY=v.midY,g.labelAngle=v.labelAngle,g.sourceLabelAngle=v.sourceLabelAngle,g.targetLabelAngle=v.targetLabelAngle}}}};var uU={};uU.updateCachedGrabbedEles=function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=e[n],i=r._private.rscratch;r.grabbed()&&!r.isParent()?t.push(r):i.inDragLayer?e.drag.push(r):e.nondrag.push(r)}for(var n=0;n<t.length;n++){var r=t[n];e.drag.push(r)}}},uU.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null},uU.getCachedZSortedEles=function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(oN),t.interactive=t.filter(function(e){return e.interactive()}),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t};var uG={};[s1,s2,uM,uR,uL,uI,uz,uH,uU].forEach(function(e){t6(uG,e)});var uY={};uY.getCachedImage=function(e,t,n){var r=this.imageCache=this.imageCache||{},i=r[e];if(i)return i.image.complete||i.image.addEventListener("load",n),i.image;var a=(i=r[e]=r[e]||{}).image=new Image;a.addEventListener("load",n),a.addEventListener("error",function(){a.error=!0});var o="data:";return e.substring(0,o.length).toLowerCase()!==o&&(a.crossOrigin=t="null"===t?null:t),a.src=e,a};var uX={};uX.registerBinding=function(e,t,n,r){var i=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(e)){for(var a=[],o=0;o<e.length;o++){var s=e[o];if(void 0!==s){var l=this.binder(s);a.push(l.on.apply(l,i))}}return a}var l=this.binder(e);return l.on.apply(l,i)},uX.binder=function(e){var t=this,n=t.cy.window(),r=e===n||e===n.document||e===n.document.body||!("u"<typeof HTMLElement)&&e instanceof HTMLElement;if(null==t.supportsPassiveEvents){var i=!1;try{var a=Object.defineProperty({},"passive",{get:function(){return i=!0,!0}});n.addEventListener("test",null,a)}catch(e){}t.supportsPassiveEvents=i}var o=function(n,i,a){var o=Array.prototype.slice.call(arguments);return r&&t.supportsPassiveEvents&&(o[2]={capture:null!=a&&a,passive:!1,once:!1}),t.bindings.push({target:e,args:o}),(e.addEventListener||e.on).apply(e,o),this};return{on:o,addEventListener:o,addListener:o,bind:o}},uX.nodeIsDraggable=function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},uX.nodeIsGrabbable=function(e){return this.nodeIsDraggable(e)&&e.interactive()},uX.load=function(){var e,t,n,r,i,a,o,s,l,c,u,d,h,f,p,g,v,x,y,b,w,N,j,k,C,E=this,T=E.cy.window(),S=function(e){return e.selected()},_=function(e,t,n,r){null==e&&(e=E.cy);for(var i=0;i<t.length;i++){var a=t[i];e.emit({originalEvent:n,type:a,position:r})}},A=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},D=function(e,t){var n=!0;if(E.cy.hasCompoundNodes()&&e&&e.pannable())for(var r=0;t&&r<t.length;r++){var e=t[r];if(e.isNode()&&e.isParent()&&!e.pannable()){n=!1;break}}else n=!0;return n},M=function(e){e[0]._private.grabbed=!0},P=function(e){e[0]._private.grabbed=!1},R=function(e){e[0]._private.rscratch.inDragLayer=!0},L=function(e){e[0]._private.rscratch.inDragLayer=!1},I=function(e){e[0]._private.rscratch.isGrabTarget=!0},O=function(e){e[0]._private.rscratch.isGrabTarget=!1},B=function(e,t){var n=t.addToList;!n.has(e)&&e.grabbable()&&!e.locked()&&(n.merge(e),M(e))},F=function(e,t){if(e.cy().hasCompoundNodes()&&(null!=t.inDragLayer||null!=t.addToList)){var n=e.descendants();t.inDragLayer&&(n.forEach(R),n.connectedEdges().forEach(R)),t.addToList&&B(n,t)}},z=function(e,t){t=t||{};var n=e.cy().hasCompoundNodes();t.inDragLayer&&(e.forEach(R),e.neighborhood().stdFilter(function(e){return!n||e.isEdge()}).forEach(R)),t.addToList&&e.forEach(function(e){B(e,t)}),F(e,t),H(e,{inDragLayer:t.inDragLayer}),E.updateCachedGrabbedEles()},V=function(e){e&&(E.getCachedZSortedEles().forEach(function(e){P(e),L(e),O(e)}),E.updateCachedGrabbedEles())},H=function(e,t){if((null!=t.inDragLayer||null!=t.addToList)&&e.cy().hasCompoundNodes()){var n=e.ancestors().orphans();if(!n.same(e)){var r=n.descendants().spawnSelf().merge(n).unmerge(e).unmerge(e.descendants()),i=r.connectedEdges();t.inDragLayer&&(i.forEach(R),r.forEach(R)),t.addToList&&r.forEach(function(e){B(e,t)})}}},U=function(){null!=document.activeElement&&null!=document.activeElement.blur&&document.activeElement.blur()},G="u">typeof MutationObserver,Y="u">typeof ResizeObserver;G?(E.removeObserver=new MutationObserver(function(e){for(var t=0;t<e.length;t++){var n=e[t].removedNodes;if(n){for(var r=0;r<n.length;r++)if(n[r]===E.container){E.destroy();break}}}}),E.container.parentNode&&E.removeObserver.observe(E.container.parentNode,{childList:!0})):E.registerBinding(E.container,"DOMNodeRemoved",function(e){E.destroy()});var X=nd(function(){E.cy.resize()},100);G&&(E.styleObserver=new MutationObserver(X),E.styleObserver.observe(E.container,{attributes:!0})),E.registerBinding(T,"resize",X),Y&&(E.resizeObserver=new ResizeObserver(X),E.resizeObserver.observe(E.container));for(var W=function(){E.invalidateContainerClientCoordsCache()},q=E.container;null!=q;){e=q,E.registerBinding(e,"transitionend",W),E.registerBinding(e,"animationend",W),E.registerBinding(e,"scroll",W),q=q.parentNode}E.registerBinding(E.container,"contextmenu",function(e){e.preventDefault()});var $=function(e){for(var t=E.findContainerClientCoords(),n=t[0],r=t[1],i=t[2],a=t[3],o=e.touches?e.touches:[e],s=!1,l=0;l<o.length;l++){var c=o[l];if(n<=c.clientX&&c.clientX<=n+i&&r<=c.clientY&&c.clientY<=r+a){s=!0;break}}if(!s)return!1;for(var u=E.container,d=e.target.parentNode,h=!1;d;){if(d===u){h=!0;break}d=d.parentNode}return!!h};E.registerBinding(E.container,"mousedown",function(e){if($(e)&&(1!==E.hoverData.which||1===e.which)){e.preventDefault(),U(),E.hoverData.capture=!0,E.hoverData.which=e.which;var t=E.cy,n=[e.clientX,e.clientY],r=E.projectIntoViewport(n[0],n[1]),i=E.selection,a=E.findNearestElements(r[0],r[1],!0,!1),o=a[0],s=E.dragData.possibleDragElements;E.hoverData.mdownPos=r,E.hoverData.mdownGPos=n;var l=function(t){return{originalEvent:e,type:t,position:{x:r[0],y:r[1]}}};if(3==e.which){E.hoverData.cxtStarted=!0;var c={originalEvent:e,type:"cxttapstart",position:{x:r[0],y:r[1]}};o?(o.activate(),o.emit(c),E.hoverData.down=o):t.emit(c),E.hoverData.downTime=new Date().getTime(),E.hoverData.cxtDragged=!1}else if(1==e.which){if(o&&o.activate(),null!=o&&E.nodeIsGrabbable(o)){if(I(o),o.selected()){s=E.dragData.possibleDragElements=t.collection();var u=t.$(function(e){return e.isNode()&&e.selected()&&E.nodeIsGrabbable(e)});z(u,{addToList:s}),o.emit(l("grabon")),u.forEach(function(e){e.emit(l("grab"))})}else z(o,{addToList:s=E.dragData.possibleDragElements=t.collection()}),o.emit(l("grabon")).emit(l("grab"));E.redrawHint("eles",!0),E.redrawHint("drag",!0)}E.hoverData.down=o,E.hoverData.downs=a,E.hoverData.downTime=new Date().getTime(),_(o,["mousedown","tapstart","vmousedown"],e,{x:r[0],y:r[1]}),null==o?(i[4]=1,E.data.bgActivePosistion={x:r[0],y:r[1]},E.redrawHint("select",!0),E.redraw()):o.pannable()&&(i[4]=1),E.hoverData.tapholdCancelled=!1,clearTimeout(E.hoverData.tapholdTimeout),E.hoverData.tapholdTimeout=setTimeout(function(){if(!E.hoverData.tapholdCancelled){var e=E.hoverData.down;e?e.emit(l("taphold")):t.emit(l("taphold"))}},E.tapholdDuration)}i[0]=i[2]=r[0],i[1]=i[3]=r[1]}},!1);var K=function(e){var t=e.getRootNode();if(t&&11===t.nodeType&&void 0!==t.host)return t}(E.container);E.registerBinding([T,K],"mousemove",function(e){var t,n;if(E.hoverData.capture||$(e)){var r=!1,i=E.cy,a=i.zoom(),o=[e.clientX,e.clientY],s=E.projectIntoViewport(o[0],o[1]),l=E.hoverData.mdownPos,c=E.hoverData.mdownGPos,u=E.selection,d=null;E.hoverData.draggingEles||E.hoverData.dragging||E.hoverData.selecting||(d=E.findNearestElement(s[0],s[1],!0,!1));var h=E.hoverData.last,f=E.hoverData.down,p=[s[0]-u[2],s[1]-u[3]],g=E.dragData.possibleDragElements;if(c){var v=o[0]-c[0],x=o[1]-c[1];E.hoverData.isOverThresholdDrag=t=v*v+x*x>=E.desktopTapThreshold2}var y=A(e);t&&(E.hoverData.tapholdCancelled=!0),r=!0,_(d,["mousemove","vmousemove","tapdrag"],e,{x:s[0],y:s[1]});var b=function(t){return{originalEvent:e,type:t,position:{x:s[0],y:s[1]}}},w=function(){E.data.bgActivePosistion=void 0,E.hoverData.selecting||i.emit(b("boxstart")),u[4]=1,E.hoverData.selecting=!0,E.redrawHint("select",!0),E.redraw()};if(3===E.hoverData.which){if(t){var N=b("cxtdrag");f?f.emit(N):i.emit(N),E.hoverData.cxtDragged=!0,(!E.hoverData.cxtOver||d!==E.hoverData.cxtOver)&&(E.hoverData.cxtOver&&E.hoverData.cxtOver.emit(b("cxtdragout")),E.hoverData.cxtOver=d,d&&d.emit(b("cxtdragover")))}}else if(E.hoverData.dragging){if(r=!0,i.panningEnabled()&&i.userPanningEnabled()){if(E.hoverData.justStartedPan){var j=E.hoverData.mdownPos;n={x:(s[0]-j[0])*a,y:(s[1]-j[1])*a},E.hoverData.justStartedPan=!1}else n={x:p[0]*a,y:p[1]*a};i.panBy(n),i.emit(b("dragpan")),E.hoverData.dragged=!0}s=E.projectIntoViewport(e.clientX,e.clientY)}else if(1==u[4]&&(null==f||f.pannable()))t&&(!E.hoverData.dragging&&i.boxSelectionEnabled()&&(y||!i.panningEnabled()||!i.userPanningEnabled())?w():!E.hoverData.selecting&&i.panningEnabled()&&i.userPanningEnabled()&&D(f,E.hoverData.downs)&&(E.hoverData.dragging=!0,E.hoverData.justStartedPan=!0,u[4]=0,E.data.bgActivePosistion=rt(l),E.redrawHint("select",!0),E.redraw()),f&&f.pannable()&&f.active()&&f.unactivate());else{if(f&&f.pannable()&&f.active()&&f.unactivate(),f&&f.grabbed()||d==h||(h&&_(h,["mouseout","tapdragout"],e,{x:s[0],y:s[1]}),d&&_(d,["mouseover","tapdragover"],e,{x:s[0],y:s[1]}),E.hoverData.last=d),f)if(t){if(i.boxSelectionEnabled()&&y)f&&f.grabbed()&&(V(g),f.emit(b("freeon")),g.emit(b("free")),E.dragData.didDrag&&(f.emit(b("dragfreeon")),g.emit(b("dragfree")))),w();else if(f&&f.grabbed()&&E.nodeIsDraggable(f)){var k,C=!E.dragData.didDrag;C&&E.redrawHint("eles",!0),E.dragData.didDrag=!0,E.hoverData.draggingEles||z(g,{inDragLayer:!0});var T={x:0,y:0};if(tF(p[0])&&tF(p[1])&&(T.x+=p[0],T.y+=p[1],C)){var S=E.hoverData.dragDelta;S&&tF(S[0])&&tF(S[1])&&(T.x+=S[0],T.y+=S[1])}E.hoverData.draggingEles=!0,g.silentShift(T).emit(b("position")).emit(b("drag")),E.redrawHint("drag",!0),E.redraw()}}else 0===(k=E.hoverData.dragDelta=E.hoverData.dragDelta||[]).length?(k.push(p[0]),k.push(p[1])):(k[0]+=p[0],k[1]+=p[1]);r=!0}if(u[2]=s[0],u[3]=s[1],r)return e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),!1}},!1),E.registerBinding(T,"mouseup",function(e){if((1!==E.hoverData.which||1===e.which||!E.hoverData.capture)&&E.hoverData.capture){E.hoverData.capture=!1;var i=E.cy,a=E.projectIntoViewport(e.clientX,e.clientY),o=E.selection,s=E.findNearestElement(a[0],a[1],!0,!1),l=E.dragData.possibleDragElements,c=E.hoverData.down,u=A(e);E.data.bgActivePosistion&&(E.redrawHint("select",!0),E.redraw()),E.hoverData.tapholdCancelled=!0,E.data.bgActivePosistion=void 0,c&&c.unactivate();var d=function(t){return{originalEvent:e,type:t,position:{x:a[0],y:a[1]}}};if(3===E.hoverData.which){var h=d("cxttapend");if(c?c.emit(h):i.emit(h),!E.hoverData.cxtDragged){var f=d("cxttap");c?c.emit(f):i.emit(f)}E.hoverData.cxtDragged=!1,E.hoverData.which=null}else if(1===E.hoverData.which){if(_(s,["mouseup","tapend","vmouseup"],e,{x:a[0],y:a[1]}),E.dragData.didDrag||E.hoverData.dragged||E.hoverData.selecting||E.hoverData.isOverThresholdDrag||(_(c,["click","tap","vclick"],e,{x:a[0],y:a[1]}),n=!1,e.timeStamp-r<=i.multiClickDebounceTime()?(t&&clearTimeout(t),n=!0,r=null,_(c,["dblclick","dbltap","vdblclick"],e,{x:a[0],y:a[1]})):(t=setTimeout(function(){n||_(c,["oneclick","onetap","voneclick"],e,{x:a[0],y:a[1]})},i.multiClickDebounceTime()),r=e.timeStamp)),null!=c||E.dragData.didDrag||E.hoverData.selecting||E.hoverData.dragged||A(e)||(i.$(S).unselect(["tapunselect"]),l.length>0&&E.redrawHint("eles",!0),E.dragData.possibleDragElements=l=i.collection()),s!=c||E.dragData.didDrag||E.hoverData.selecting||null==s||!s._private.selectable||(E.hoverData.dragging||("additive"===i.selectionType()||u?s.selected()?s.unselect(["tapunselect"]):s.select(["tapselect"]):u||(i.$(S).unmerge(s).unselect(["tapunselect"]),s.select(["tapselect"]))),E.redrawHint("eles",!0)),E.hoverData.selecting){var p=i.collection(E.getAllInBox(o[0],o[1],o[2],o[3]));E.redrawHint("select",!0),p.length>0&&E.redrawHint("eles",!0),i.emit(d("boxend"));"additive"===i.selectionType()||u||i.$(S).unmerge(p).unselect(),p.emit(d("box")).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(d("boxselect")),E.redraw()}if(E.hoverData.dragging&&(E.hoverData.dragging=!1,E.redrawHint("select",!0),E.redrawHint("eles",!0),E.redraw()),!o[4]){E.redrawHint("drag",!0),E.redrawHint("eles",!0);var g=c&&c.grabbed();V(l),g&&(c.emit(d("freeon")),l.emit(d("free")),E.dragData.didDrag&&(c.emit(d("dragfreeon")),l.emit(d("dragfree"))))}}o[4]=0,E.hoverData.down=null,E.hoverData.cxtStarted=!1,E.hoverData.draggingEles=!1,E.hoverData.selecting=!1,E.hoverData.isOverThresholdDrag=!1,E.dragData.didDrag=!1,E.hoverData.dragged=!1,E.hoverData.dragDelta=[],E.hoverData.mdownPos=null,E.hoverData.mdownGPos=null,E.hoverData.which=null}},!1);var Z=[],Q=1e5,J=function(e,t){for(var n=0;n<e.length;n++)if(e[n]%t!=0)return!1;return!0},ee=function(e){for(var t=Math.abs(e[0]),n=1;n<e.length;n++)if(Math.abs(e[n])!==t)return!1;return!0},et=function(e){var t=!1,n=e.deltaY;if(null==n&&(null!=e.wheelDeltaY?n=e.wheelDeltaY/4:null!=e.wheelDelta&&(n=e.wheelDelta/4)),0!==n){if(null==i)if(Z.length>=4){if(!(i=J(Z,5))){var r=Math.abs(Z[0]);i=ee(Z)&&r>5}if(i)for(var a=0;a<Z.length;a++)Q=Math.min(Math.abs(Z[a]),Q)}else Z.push(n),t=!0;else i&&(Q=Math.min(Math.abs(n),Q));if(!E.scrollingPage){var o=E.cy,s=o.zoom(),l=o.pan(),c=E.projectIntoViewport(e.clientX,e.clientY),u=[c[0]*s+l.x,c[1]*s+l.y];if(E.hoverData.draggingEles||E.hoverData.dragging||E.hoverData.cxtStarted||0!==E.selection[4])return void e.preventDefault();if(o.panningEnabled()&&o.userPanningEnabled()&&o.zoomingEnabled()&&o.userZoomingEnabled()){e.preventDefault(),E.data.wheelZooming=!0,clearTimeout(E.data.wheelTimeout),E.data.wheelTimeout=setTimeout(function(){E.data.wheelZooming=!1,E.redrawHint("eles",!0),E.redraw()},150),t&&Math.abs(n)>5&&(n=5*rl(n)),d=-(n/250),i&&(d/=Q,d*=3),d*=E.wheelSensitivity,1===e.deltaMode&&(d*=33);var d,h=o.zoom()*Math.pow(10,d);"gesturechange"===e.type&&(h=E.gestureStartZoom*e.scale),o.zoom({level:h,renderedPosition:{x:u[0],y:u[1]}}),o.emit({type:"gesturechange"===e.type?"pinchzoom":"scrollzoom",originalEvent:e,position:{x:c[0],y:c[1]}})}}}};E.registerBinding(E.container,"wheel",et,!0),E.registerBinding(T,"scroll",function(e){E.scrollingPage=!0,clearTimeout(E.scrollingPageTimeout),E.scrollingPageTimeout=setTimeout(function(){E.scrollingPage=!1},250)},!0),E.registerBinding(E.container,"gesturestart",function(e){E.gestureStartZoom=E.cy.zoom(),E.hasTouchStarted||e.preventDefault()},!0),E.registerBinding(E.container,"gesturechange",function(e){E.hasTouchStarted||et(e)},!0),E.registerBinding(E.container,"mouseout",function(e){var t=E.projectIntoViewport(e.clientX,e.clientY);E.cy.emit({originalEvent:e,type:"mouseout",position:{x:t[0],y:t[1]}})},!1),E.registerBinding(E.container,"mouseover",function(e){var t=E.projectIntoViewport(e.clientX,e.clientY);E.cy.emit({originalEvent:e,type:"mouseover",position:{x:t[0],y:t[1]}})},!1);var en=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},er=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(E.registerBinding(E.container,"touchstart",y=function(e){if(E.hasTouchStarted=!0,$(e)){U(),E.touchData.capture=!0,E.data.bgActivePosistion=void 0;var t=E.cy,n=E.touchData.now,r=E.touchData.earlier;if(e.touches[0]){var i=E.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);n[0]=i[0],n[1]=i[1]}if(e.touches[1]){var i=E.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);n[2]=i[0],n[3]=i[1]}if(e.touches[2]){var i=E.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);n[4]=i[0],n[5]=i[1]}var y=function(t){return{originalEvent:e,type:t,position:{x:n[0],y:n[1]}}};if(e.touches[1]){E.touchData.singleTouchMoved=!0,V(E.dragData.touchDragEles);var b=E.findContainerClientCoords();f=b[0],p=b[1],g=b[2],v=b[3],a=e.touches[0].clientX-f,o=e.touches[0].clientY-p,s=e.touches[1].clientX-f,l=e.touches[1].clientY-p,x=0<=a&&a<=g&&0<=s&&s<=g&&0<=o&&o<=v&&0<=l&&l<=v;var w=t.pan(),N=t.zoom();if(c=en(a,o,s,l),u=er(a,o,s,l),h=[((d=[(a+s)/2,(o+l)/2])[0]-w.x)/N,(d[1]-w.y)/N],u<4e4&&!e.touches[2]){var j=E.findNearestElement(n[0],n[1],!0,!0),k=E.findNearestElement(n[2],n[3],!0,!0);j&&j.isNode()?(j.activate().emit(y("cxttapstart")),E.touchData.start=j):k&&k.isNode()?(k.activate().emit(y("cxttapstart")),E.touchData.start=k):t.emit(y("cxttapstart")),E.touchData.start&&(E.touchData.start._private.grabbed=!1),E.touchData.cxt=!0,E.touchData.cxtDragged=!1,E.data.bgActivePosistion=void 0,E.redraw();return}}if(e.touches[2])t.boxSelectionEnabled()&&e.preventDefault();else if(e.touches[1]);else if(e.touches[0]){var C=E.findNearestElements(n[0],n[1],!0,!0),T=C[0];if(null!=T&&(T.activate(),E.touchData.start=T,E.touchData.starts=C,E.nodeIsGrabbable(T))){var S=E.dragData.touchDragEles=t.collection(),A=null;E.redrawHint("eles",!0),E.redrawHint("drag",!0),T.selected()?z(A=t.$(function(e){return e.selected()&&E.nodeIsGrabbable(e)}),{addToList:S}):z(T,{addToList:S}),I(T),T.emit(y("grabon")),A?A.forEach(function(e){e.emit(y("grab"))}):T.emit(y("grab"))}_(T,["touchstart","tapstart","vmousedown"],e,{x:n[0],y:n[1]}),null==T&&(E.data.bgActivePosistion={x:i[0],y:i[1]},E.redrawHint("select",!0),E.redraw()),E.touchData.singleTouchMoved=!1,E.touchData.singleTouchStartTime=+new Date,clearTimeout(E.touchData.tapholdTimeout),E.touchData.tapholdTimeout=setTimeout(function(){!1!==E.touchData.singleTouchMoved||E.pinching||E.touchData.selecting||_(E.touchData.start,["taphold"],e,{x:n[0],y:n[1]})},E.tapholdDuration)}if(e.touches.length>=1){for(var D=E.touchData.startPosition=[null,null,null,null,null,null],M=0;M<n.length;M++)D[M]=r[M]=n[M];var P=e.touches[0];E.touchData.startGPosition=[P.clientX,P.clientY]}}},!1),E.registerBinding(T,"touchmove",b=function(e){var t=E.touchData.capture;if(t||$(e)){var n=E.selection,r=E.cy,i=E.touchData.now,d=E.touchData.earlier,g=r.zoom();if(e.touches[0]){var v=E.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=v[0],i[1]=v[1]}if(e.touches[1]){var v=E.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);i[2]=v[0],i[3]=v[1]}if(e.touches[2]){var v=E.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);i[4]=v[0],i[5]=v[1]}var y=function(t){return{originalEvent:e,type:t,position:{x:i[0],y:i[1]}}},b=E.touchData.startGPosition;if(t&&e.touches[0]&&b){for(var w=[],N=0;N<i.length;N++)w[N]=i[N]-d[N];var j=e.touches[0].clientX-b[0],k=j*j,C=e.touches[0].clientY-b[1];et=k+C*C>=E.touchTapThreshold2}if(t&&E.touchData.cxt){e.preventDefault();var T=e.touches[0].clientX-f,S=e.touches[0].clientY-p,A=e.touches[1].clientX-f,M=e.touches[1].clientY-p,P=er(T,S,A,M);if(P/u>=2.25||P>=22500){E.touchData.cxt=!1,E.data.bgActivePosistion=void 0,E.redrawHint("select",!0);var R=y("cxttapend");E.touchData.start?(E.touchData.start.unactivate().emit(R),E.touchData.start=null):r.emit(R)}}if(t&&E.touchData.cxt){var R=y("cxtdrag");E.data.bgActivePosistion=void 0,E.redrawHint("select",!0),E.touchData.start?E.touchData.start.emit(R):r.emit(R),E.touchData.start&&(E.touchData.start._private.grabbed=!1),E.touchData.cxtDragged=!0;var L=E.findNearestElement(i[0],i[1],!0,!0);(!E.touchData.cxtOver||L!==E.touchData.cxtOver)&&(E.touchData.cxtOver&&E.touchData.cxtOver.emit(y("cxtdragout")),E.touchData.cxtOver=L,L&&L.emit(y("cxtdragover")))}else if(t&&e.touches[2]&&r.boxSelectionEnabled())e.preventDefault(),E.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,E.touchData.selecting||r.emit(y("boxstart")),E.touchData.selecting=!0,E.touchData.didSelect=!0,n[4]=1,n&&0!==n.length&&void 0!==n[0]?(n[2]=(i[0]+i[2]+i[4])/3,n[3]=(i[1]+i[3]+i[5])/3):(n[0]=(i[0]+i[2]+i[4])/3,n[1]=(i[1]+i[3]+i[5])/3,n[2]=(i[0]+i[2]+i[4])/3+1,n[3]=(i[1]+i[3]+i[5])/3+1),E.redrawHint("select",!0),E.redraw();else if(t&&e.touches[1]&&!E.touchData.didSelect&&r.zoomingEnabled()&&r.panningEnabled()&&r.userZoomingEnabled()&&r.userPanningEnabled()){e.preventDefault(),E.data.bgActivePosistion=void 0,E.redrawHint("select",!0);var I=E.dragData.touchDragEles;if(I){E.redrawHint("drag",!0);for(var O=0;O<I.length;O++){var B=I[O]._private;B.grabbed=!1,B.rscratch.inDragLayer=!1}}var F=E.touchData.start,T=e.touches[0].clientX-f,S=e.touches[0].clientY-p,A=e.touches[1].clientX-f,M=e.touches[1].clientY-p,H=en(T,S,A,M),U=H/c;if(x){var G=T-a,Y=S-o,X=A-s,W=M-l,q=r.zoom(),K=q*U,Z=r.pan(),Q=h[0]*q+Z.x,J=h[1]*q+Z.y,ee={x:-K/q*(Q-Z.x-(G+X)/2)+Q,y:-K/q*(J-Z.y-(Y+W)/2)+J};if(F&&F.active()){var I=E.dragData.touchDragEles;V(I),E.redrawHint("drag",!0),E.redrawHint("eles",!0),F.unactivate().emit(y("freeon")),I.emit(y("free")),E.dragData.didDrag&&(F.emit(y("dragfreeon")),I.emit(y("dragfree")))}r.viewport({zoom:K,pan:ee,cancelOnFailedZoom:!0}),r.emit(y("pinchzoom")),c=H,a=T,o=S,s=A,l=M,E.pinching=!0}if(e.touches[0]){var v=E.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=v[0],i[1]=v[1]}if(e.touches[1]){var v=E.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);i[2]=v[0],i[3]=v[1]}if(e.touches[2]){var v=E.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);i[4]=v[0],i[5]=v[1]}}else if(e.touches[0]&&!E.touchData.didSelect){var et,L,ei=E.touchData.start,ea=E.touchData.last;if(E.hoverData.draggingEles||E.swipePanning||(L=E.findNearestElement(i[0],i[1],!0,!0)),t&&null!=ei&&e.preventDefault(),t&&null!=ei&&E.nodeIsDraggable(ei))if(et){var I=E.dragData.touchDragEles,eo=!E.dragData.didDrag;eo&&z(I,{inDragLayer:!0}),E.dragData.didDrag=!0;var es={x:0,y:0};if(tF(w[0])&&tF(w[1])&&(es.x+=w[0],es.y+=w[1],eo)){E.redrawHint("eles",!0);var el=E.touchData.dragDelta;el&&tF(el[0])&&tF(el[1])&&(es.x+=el[0],es.y+=el[1])}E.hoverData.draggingEles=!0,I.silentShift(es).emit(y("position")).emit(y("drag")),E.redrawHint("drag",!0),E.touchData.startPosition[0]==d[0]&&E.touchData.startPosition[1]==d[1]&&E.redrawHint("eles",!0),E.redraw()}else{var el=E.touchData.dragDelta=E.touchData.dragDelta||[];0===el.length?(el.push(w[0]),el.push(w[1])):(el[0]+=w[0],el[1]+=w[1])}if(_(ei||L,["touchmove","tapdrag","vmousemove"],e,{x:i[0],y:i[1]}),ei&&ei.grabbed()||L==ea||(ea&&ea.emit(y("tapdragout")),L&&L.emit(y("tapdragover"))),E.touchData.last=L,t)for(var O=0;O<i.length;O++)i[O]&&E.touchData.startPosition[O]&&et&&(E.touchData.singleTouchMoved=!0);if(t&&(null==ei||ei.pannable())&&r.panningEnabled()&&r.userPanningEnabled()){D(ei,E.touchData.starts)&&(e.preventDefault(),E.data.bgActivePosistion||(E.data.bgActivePosistion=rt(E.touchData.startPosition)),E.swipePanning?(r.panBy({x:w[0]*g,y:w[1]*g}),r.emit(y("dragpan"))):et&&(E.swipePanning=!0,r.panBy({x:j*g,y:C*g}),r.emit(y("dragpan")),ei&&(ei.unactivate(),E.redrawHint("select",!0),E.touchData.start=null)));var v=E.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=v[0],i[1]=v[1]}}for(var N=0;N<i.length;N++)d[N]=i[N];t&&e.touches.length>0&&!E.hoverData.draggingEles&&!E.swipePanning&&null!=E.data.bgActivePosistion&&(E.data.bgActivePosistion=void 0,E.redrawHint("select",!0),E.redraw())}},!1),E.registerBinding(T,"touchcancel",w=function(e){var t=E.touchData.start;E.touchData.capture=!1,t&&t.unactivate()}),E.registerBinding(T,"touchend",N=function(e){var t,n=E.touchData.start;if(E.touchData.capture){0===e.touches.length&&(E.touchData.capture=!1),e.preventDefault();var r=E.selection;E.swipePanning=!1,E.hoverData.draggingEles=!1;var i=E.cy,a=i.zoom(),o=E.touchData.now,s=E.touchData.earlier;if(e.touches[0]){var l=E.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);o[0]=l[0],o[1]=l[1]}if(e.touches[1]){var l=E.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);o[2]=l[0],o[3]=l[1]}if(e.touches[2]){var l=E.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);o[4]=l[0],o[5]=l[1]}var c=function(t){return{originalEvent:e,type:t,position:{x:o[0],y:o[1]}}};if(n&&n.unactivate(),E.touchData.cxt){if(t=c("cxttapend"),n?n.emit(t):i.emit(t),!E.touchData.cxtDragged){var u=c("cxttap");n?n.emit(u):i.emit(u)}E.touchData.start&&(E.touchData.start._private.grabbed=!1),E.touchData.cxt=!1,E.touchData.start=null,E.redraw();return}if(!e.touches[2]&&i.boxSelectionEnabled()&&E.touchData.selecting){E.touchData.selecting=!1;var d=i.collection(E.getAllInBox(r[0],r[1],r[2],r[3]));r[0]=void 0,r[1]=void 0,r[2]=void 0,r[3]=void 0,r[4]=0,E.redrawHint("select",!0),i.emit(c("boxend")),d.emit(c("box")).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(c("boxselect")),d.nonempty()&&E.redrawHint("eles",!0),E.redraw()}if(null!=n&&n.unactivate(),e.touches[2])E.data.bgActivePosistion=void 0,E.redrawHint("select",!0);else if(e.touches[1]);else if(e.touches[0]);else if(!e.touches[0]){E.data.bgActivePosistion=void 0,E.redrawHint("select",!0);var h=E.dragData.touchDragEles;if(null!=n){var f=n._private.grabbed;V(h),E.redrawHint("drag",!0),E.redrawHint("eles",!0),f&&(n.emit(c("freeon")),h.emit(c("free")),E.dragData.didDrag&&(n.emit(c("dragfreeon")),h.emit(c("dragfree")))),_(n,["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]}),n.unactivate(),E.touchData.start=null}else _(E.findNearestElement(o[0],o[1],!0,!0),["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]});var p=E.touchData.startPosition[0]-o[0],g=E.touchData.startPosition[1]-o[1];E.touchData.singleTouchMoved||(n||i.$(":selected").unselect(["tapunselect"]),_(n,["tap","vclick"],e,{x:o[0],y:o[1]}),j=!1,e.timeStamp-C<=i.multiClickDebounceTime()?(k&&clearTimeout(k),j=!0,C=null,_(n,["dbltap","vdblclick"],e,{x:o[0],y:o[1]})):(k=setTimeout(function(){j||_(n,["onetap","voneclick"],e,{x:o[0],y:o[1]})},i.multiClickDebounceTime()),C=e.timeStamp)),null!=n&&!E.dragData.didDrag&&n._private.selectable&&(p*p+g*g)*a*a<E.touchTapThreshold2&&!E.pinching&&("single"===i.selectionType()?(i.$(S).unmerge(n).unselect(["tapunselect"]),n.select(["tapselect"])):n.selected()?n.unselect(["tapunselect"]):n.select(["tapselect"]),E.redrawHint("eles",!0)),E.touchData.singleTouchMoved=!0}for(var v=0;v<o.length;v++)s[v]=o[v];E.dragData.didDrag=!1,0===e.touches.length&&(E.touchData.dragDelta=[],E.touchData.startPosition=[null,null,null,null,null,null],E.touchData.startGPosition=null,E.touchData.didSelect=!1),e.touches.length<2&&(1===e.touches.length&&(E.touchData.startGPosition=[e.touches[0].clientX,e.touches[0].clientY]),E.pinching=!1,E.redrawHint("eles",!0),E.redraw())}},!1),"u"<typeof TouchEvent){var ei=[],ea=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},eo=function(e){ei.push({event:e,touch:ea(e)})},es=function(e){for(var t=0;t<ei.length;t++)if(ei[t].event.pointerId===e.pointerId)return void ei.splice(t,1)},el=function(e){var t=ei.filter(function(t){return t.event.pointerId===e.pointerId})[0];t.event=e,t.touch=ea(e)},ec=function(e){e.touches=ei.map(function(e){return e.touch})},eu=function(e){return"mouse"===e.pointerType||4===e.pointerType};E.registerBinding(E.container,"pointerdown",function(e){eu(e)||(e.preventDefault(),eo(e),ec(e),y(e))}),E.registerBinding(E.container,"pointerup",function(e){eu(e)||(es(e),ec(e),N(e))}),E.registerBinding(E.container,"pointercancel",function(e){eu(e)||(es(e),ec(e),w(e))}),E.registerBinding(E.container,"pointermove",function(e){eu(e)||(e.preventDefault(),el(e),ec(e),b(e))})}};var uW={};uW.generatePolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl("polygon",e,t,n,r,i,this.points)},intersectLine:function(e,t,n,r,i,a,o,s){return rX(i,a,this.points,e,t,n/2,r/2,o)},checkPoint:function(e,t,n,r,i,a,o,s){return rI(e,t,this.points,a,o,r,i,[0,-1],n)},hasMiterBounds:"rectangle"!==e,miterBounds:function(e,t,n,r,i,a){var o,s,l;return o=this.points,s=function(e,t){if(e.length<3)throw Error("Need at least 3 vertices");var n=function(e,t){return{x:e.x+t.x,y:e.y+t.y}},r=function(e,t){return{x:e.x-t.x,y:e.y-t.y}},i=function(e,t){return{x:e.x*t,y:e.y*t}},a=function(e,t){return e.x*t.y-e.y*t.x},o=e.map(function(e){return{x:e.x,y:e.y}});0>function(e){for(var t=0,n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length];t+=r.x*i.y-i.x*r.y}return t/2}(o)&&o.reverse();for(var s=o.length,l=[],c=0;c<s;c++){var u=o[c],d=r(o[(c+1)%s],u),h=function(e){var t=rT(e.x,e.y);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}}({x:d.y,y:-d.x});l.push(h)}for(var f=l.map(function(e,r){return{p1:n(o[r],i(e,t)),p2:n(o[(r+1)%s],i(e,t))}}),p=[],g=0;g<s;g++){var v=f[(g-1+s)%s],x=f[g],y=function(e,t,o,s){var l=r(t,e),c=r(s,o),u=a(l,c);if(1e-9>Math.abs(u))return n(e,i(l,.5));var d=a(r(o,e),c)/u;return n(e,i(l,d))}(v.p1,v.p2,x.p1,x.p2);p.push(y)}return p}(rY(o,e,t,n,r),i),l=rm(),s.forEach(function(e){return ry(l,e.x,e.y)}),l}}},uW.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o,s){return rz(i,a,e,t,n/2+o,r/2+o)},checkPoint:function(e,t,n,r,i,a,o,s){return rV(e,t,r,i,a,o,n)}}},uW.generateRoundPolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,getOrCreateCorners:function(e,n,r,i,a,o,s){if(void 0!==o[s]&&o[s+"-cx"]===e&&o[s+"-cy"]===n)return o[s];o[s]=Array(t.length/2),o[s+"-cx"]=e,o[s+"-cy"]=n;var l=r/2,c=i/2;a="auto"===a?rJ(r,i):a;for(var u=Array(t.length/2),d=0;d<t.length/2;d++)u[d]={x:e+l*t[2*d],y:n+c*t[2*d+1]};var h,f,p,g,v=u.length;for(h=0,f=u[v-1];h<v;h++)p=u[h%v],g=u[(h+1)%v],o[s][h]=uA(f,p,g,a),f=p,p=g;return o[s]},draw:function(e,t,n,r,i,a,o){this.renderer.nodeShapeImpl("round-polygon",e,t,n,r,i,this.points,this.getOrCreateCorners(t,n,r,i,a,o,"drawCorners"))},intersectLine:function(e,t,n,r,i,a,o,s,l){return rW(i,a,this.points,e,t,n,r,o,this.getOrCreateCorners(e,t,n,r,s,l,"corners"))},checkPoint:function(e,t,n,r,i,a,o,s,l){return rO(e,t,this.points,a,o,r,i,this.getOrCreateCorners(a,o,r,i,s,l,"corners"))}}},uW.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:r$(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,a)},intersectLine:function(e,t,n,r,i,a,o,s){return rS(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){var l=r/2,c=i/2,u=2*(s=Math.min(l,c,s="auto"===s?rQ(r,i):s));return!!(rI(e,t,this.points,a,o,r,i-u,[0,-1],n)||rI(e,t,this.points,a,o,r-u,i,[0,-1],n)||rV(e,t,u,u,a-l+s,o-c+s,n)||rV(e,t,u,u,a+l-s,o-c+s,n)||rV(e,t,u,u,a+l-s,o+c-s,n)||rV(e,t,u,u,a-l+s,o+c-s,n))}}},uW.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:r0(),points:r$(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,null,a)},generateCutTrianglePts:function(e,t,n,r,i){var a="auto"===i?this.cornerLength:i,o=t/2,s=e/2,l=n-s,c=n+s,u=r-o,d=r+o;return{topLeft:[l,u+a,l+a,u,l+a,u+a],topRight:[c-a,u,c,u+a,c-a,u+a],bottomRight:[c,d-a,c-a,d,c-a,d-a],bottomLeft:[l+a,d,l,d-a,l+a,d-a]}},intersectLine:function(e,t,n,r,i,a,o,s){var l=this.generateCutTrianglePts(n+2*o,r+2*o,e,t,s);return rX(i,a,[].concat.apply([],[l.topLeft.splice(0,4),l.topRight.splice(0,4),l.bottomRight.splice(0,4),l.bottomLeft.splice(0,4)]),e,t)},checkPoint:function(e,t,n,r,i,a,o,s){var l="auto"===s?this.cornerLength:s;if(rI(e,t,this.points,a,o,r,i-2*l,[0,-1],n)||rI(e,t,this.points,a,o,r-2*l,i,[0,-1],n))return!0;var c=this.generateCutTrianglePts(r,i,a,o);return rL(e,t,c.topLeft)||rL(e,t,c.topRight)||rL(e,t,c.bottomRight)||rL(e,t,c.bottomLeft)}}},uW.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:r$(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o,s){var l=this.generateBarrelBezierPts(n+2*o,r+2*o,e,t),c=function(e){var t=rf({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.15),n=rf({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.5),r=rf({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.85);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]};return rX(i,a,[].concat(c(l.topLeft),c(l.topRight),c(l.bottomRight),c(l.bottomLeft)),e,t)},generateBarrelBezierPts:function(e,t,n,r){var i=t/2,a=e/2,o=n-a,s=n+a,l=r-i,c=r+i,u=r1(e,t),d=u.heightOffset,h=u.widthOffset,f=u.ctrlPtOffsetPct*e,p={topLeft:[o,l+d,o+f,l,o+h,l],topRight:[s-h,l,s-f,l,s,l+d],bottomRight:[s,c-d,s-f,c,s-h,c],bottomLeft:[o+h,c,o+f,c,o,c-d]};return p.topLeft.isTop=!0,p.topRight.isTop=!0,p.bottomLeft.isBottom=!0,p.bottomRight.isBottom=!0,p},checkPoint:function(e,t,n,r,i,a,o,s){var l=r1(r,i),c=l.heightOffset,u=l.widthOffset;if(rI(e,t,this.points,a,o,r,i-2*c,[0,-1],n)||rI(e,t,this.points,a,o,r-2*u,i,[0,-1],n))return!0;for(var d=this.generateBarrelBezierPts(r,i,a,o),h=Object.keys(d),f=0;f<h.length;f++){var p=d[h[f]],g=function(e,t,n){var r=n[4],i=n[2],a=n[0],o=n[5],s=n[1],l=Math.min(r,a),c=Math.max(r,a),u=Math.min(o,s),d=Math.max(o,s);if(l<=e&&e<=c&&u<=t&&t<=d){var h=[r-2*i+a,2*(i-r),r],f=rD(h[0],h[1],h[2],e).filter(function(e){return 0<=e&&e<=1});if(f.length>0)return f[0]}return null}(e,t,p);if(null!=g){var v=rh(p[5],p[3],p[1],g);if(p.isTop&&v<=t||p.isBottom&&t<=v)return!0}}return!1}}},uW.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:r$(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,a)},intersectLine:function(e,t,n,r,i,a,o,s){var l=e-(n/2+o),c=t-(r/2+o),u=e+(n/2+o),d=rG(i,a,e,t,l,c,u,c,!1);return d.length>0?d:rS(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){var l=2*(s="auto"===s?rQ(r,i):s);if(rI(e,t,this.points,a,o,r,i-l,[0,-1],n)||rI(e,t,this.points,a,o,r-l,i,[0,-1],n))return!0;var c=r/2+2*n,u=i/2+2*n;return!!(rL(e,t,[a-c,o-u,a-c,o,a+c,o,a+c,o-u])||rV(e,t,l,l,a+r/2-s,o+i/2-s,n)||rV(e,t,l,l,a-r/2+s,o+i/2-s,n))}}},uW.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",r$(3,0)),this.generateRoundPolygon("round-triangle",r$(3,0)),this.generatePolygon("rectangle",r$(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",n),this.generateRoundPolygon("round-diamond",n),this.generatePolygon("pentagon",r$(5,0)),this.generateRoundPolygon("round-pentagon",r$(5,0)),this.generatePolygon("hexagon",r$(6,0)),this.generateRoundPolygon("round-hexagon",r$(6,0)),this.generatePolygon("heptagon",r$(7,0)),this.generateRoundPolygon("round-heptagon",r$(7,0)),this.generatePolygon("octagon",r$(8,0)),this.generateRoundPolygon("round-octagon",r$(8,0));var r=Array(20),i=rZ(5,0),a=rZ(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s<a.length/2;s++)a[2*s]*=o,a[2*s+1]*=o;for(var s=0;s<5;s++)r[4*s]=i[2*s],r[4*s+1]=i[2*s+1],r[4*s+2]=a[2*s],r[4*s+3]=a[2*s+1];r=rK(r),this.generatePolygon("star",r),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.generatePolygon("right-rhomboid",[-.333,-1,1,-1,.333,1,-1,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]);var l=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon("tag",l),this.generateRoundPolygon("round-tag",l),e.makePolygon=function(e){var n,r="polygon-"+e.join("$");return(n=this[r])?n:t.generatePolygon(r,e)}};var uq={};uq.timeToRender=function(){return this.redrawTotalTime/this.redrawCount},uq.redraw=function(e){e=e||nF(),void 0===this.averageRedrawTime&&(this.averageRedrawTime=0),void 0===this.lastRedrawTime&&(this.lastRedrawTime=0),void 0===this.lastDrawTime&&(this.lastDrawTime=0),this.requestedFrame=!0,this.renderOptions=e},uq.beforeRender=function(e,t){if(!this.destroyed){null==t&&nP("Priority is not optional for beforeRender");var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort(function(e,t){return t.priority-e.priority})}};var u$=function(e,t,n){for(var r=e.beforeRenderCallbacks,i=0;i<r.length;i++)r[i].fn(t,n)};uq.startRenderLoop=function(){var e=this,t=e.cy;if(!e.renderLoopStarted){e.renderLoopStarted=!0;var n=function(r){if(!e.destroyed){if(t.batching());else if(e.requestedFrame&&!e.skipFrame){u$(e,!0,r);var i=nf();e.render(e.renderOptions);var a=e.lastDrawTime=nf();void 0===e.averageRedrawTime&&(e.averageRedrawTime=a-i),void 0===e.redrawCount&&(e.redrawCount=0),e.redrawCount++,void 0===e.redrawTotalTime&&(e.redrawTotalTime=0);var o=a-i;e.redrawTotalTime+=o,e.lastRedrawTime=o,e.averageRedrawTime=e.averageRedrawTime/2+o/2,e.requestedFrame=!1}else u$(e,!1,r);e.skipFrame=!1,ng(n)}};ng(n)}};var uK=function(e){this.init(e)},uZ=uK.prototype;uZ.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],uZ.init=function(e){this.options=e,this.cy=e.cy;var t=this.container=e.cy.container(),n=this.cy.window();if(n){var r=n.document,i=r.head,a="__________cytoscape_stylesheet",o="__________cytoscape_container",s=null!=r.getElementById(a);if(0>t.className.indexOf(o)&&(t.className=(t.className||"")+" "+o),!s){var l=r.createElement("style");l.id=a,l.textContent="."+o+" { position: relative; }",i.insertBefore(l,i.children[0])}"static"===n.getComputedStyle(t).getPropertyValue("position")&&nL("A Cytoscape container has style position:static and so can not use UI extensions properly")}this.selection=[void 0,void 0,void 0,void 0,0],this.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],this.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},this.dragData={possibleDragElements:[]},this.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},this.redraws=0,this.showFps=e.showFps,this.debug=e.debug,this.webgl=e.webgl,this.hideEdgesOnViewport=e.hideEdgesOnViewport,this.textureOnViewport=e.textureOnViewport,this.wheelSensitivity=e.wheelSensitivity,this.motionBlurEnabled=e.motionBlur,this.forcedPixelRatio=tF(e.pixelRatio)?e.pixelRatio:null,this.motionBlur=e.motionBlur,this.motionBlurOpacity=e.motionBlurOpacity,this.motionBlurTransparency=1-this.motionBlurOpacity,this.motionBlurPxRatio=1,this.mbPxRBlurry=1,this.minMbLowQualFrames=4,this.fullQualityMb=!1,this.clearedForMotionBlur=[],this.desktopTapThreshold=e.desktopTapThreshold,this.desktopTapThreshold2=e.desktopTapThreshold*e.desktopTapThreshold,this.touchTapThreshold=e.touchTapThreshold,this.touchTapThreshold2=e.touchTapThreshold*e.touchTapThreshold,this.tapholdDuration=500,this.bindings=[],this.beforeRenderCallbacks=[],this.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},this.registerNodeShapes(),this.registerArrowShapes(),this.registerCalculationListeners()},uZ.notify=function(e,t){var n=this.cy;if(!this.destroyed){if("init"===e)return void this.load();if("destroy"===e)return void this.destroy();("add"===e||"remove"===e||"move"===e&&n.hasCompoundNodes()||"load"===e||"zorder"===e||"mount"===e)&&this.invalidateCachedZSortedEles(),"viewport"===e&&this.redrawHint("select",!0),"gc"===e&&this.redrawHint("gc",!0),("load"===e||"resize"===e||"mount"===e)&&(this.invalidateContainerClientCoordsCache(),this.matchCanvasSize(this.container)),this.redrawHint("eles",!0),this.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()}},uZ.destroy=function(){this.destroyed=!0,this.cy.stopAnimationLoop();for(var e=0;e<this.bindings.length;e++){var t=this.bindings[e],n=t.target;(n.off||n.removeEventListener).apply(n,t.args)}if(this.bindings=[],this.beforeRenderCallbacks=[],this.onUpdateEleCalcsFns=[],this.removeObserver&&this.removeObserver.disconnect(),this.styleObserver&&this.styleObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect(),this.labelCalcDiv)try{document.body.removeChild(this.labelCalcDiv)}catch(e){}},uZ.isHeadless=function(){return!1},[s0,uG,uY,uX,uW,uq].forEach(function(e){t6(uZ,e)});var uQ=1e3/60,uJ=function(e){return function(){var t=this,n=this.renderer;if(!t.dequeueingSetup){t.dequeueingSetup=!0;var r=nd(function(){n.redrawHint("eles",!0),n.redrawHint("drag",!0),n.redraw()},e.deqRedrawThreshold),i=e.priority||nM;n.beforeRender(function(i,a){var o=nf(),s=n.averageRedrawTime,l=n.lastRedrawTime,c=[],u=n.cy.extent(),d=n.getPixelRatio();for(i||n.flushRenderedStyleQueue();;){var h=nf(),f=h-o,p=h-a;if(l<uQ){var g=uQ-(i?s:0);if(p>=e.deqFastCost*g)break}else if(i){if(f>=e.deqCost*l||f>=e.deqAvgCost*s)break}else if(p>=e.deqNoDrawCost*uQ)break;var v=e.deq(t,d,u);if(v.length>0)for(var x=0;x<v.length;x++)c.push(v[x]);else break}c.length>0&&(e.onDeqd(t,c),!i&&e.shouldRedraw(t,c,d,u)&&r())},i(t))}}},u0=tb(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nA;ty(this,e),this.idsByKey=new nW,this.keyForId=new nW,this.cachesByLvl=new nW,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n},[{key:"getIdsFor",value:function(e){null==e&&nP("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new n$,t.set(e,n)),n}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new nW,t.set(e,r),n.push(e)),r}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r}},{key:"getForCachedKey",value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:"setCache",value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:"set",value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:"invalidateKey",value:function(e){var t=this;this.lvls.forEach(function(n){return t.deleteCache(e,n)})}},{key:"invalidate",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||0===this.getNumberOfIdsForKey(n)}}]),u1={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},u2=nz({getKey:null,doesEleInvalidateKey:nA,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:n_,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),u5=function(e,t){this.renderer=e,this.onDequeues=[];var n=u2(t);t6(this,n),this.lookup=new u0(n.getKey,n.doesEleInvalidateKey),this.setupDequeueing()},u3=u5.prototype;u3.reasons=u1,u3.getTextureQueue=function(e){return this.eleImgCaches=this.eleImgCaches||{},this.eleImgCaches[e]=this.eleImgCaches[e]||[]},u3.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},u3.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new n1(function(e,t){return t.reqs-e.reqs})},u3.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},u3.getElement=function(e,t,n,r,i){var a,o,s,l=this,c=this.renderer,u=c.cy.zoom(),d=this.lookup;if(!t||0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed()||!l.allowEdgeTxrCaching&&e.isEdge()||!l.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(rs(u*n))),r<-4)r=-4;else if(u>=7.99||r>3)return null;var h=Math.pow(2,r),f=t.h*h,p=t.w*h,g=c.eleTextBiggerThanMin(e,h);if(!this.isVisible(e,g))return null;var v=d.get(e,r);if(v&&v.invalidated&&(v.invalidated=!1,v.texture.invalidatedWidth-=v.width),v)return v;if(a=f<=25?25:f<=50?50:50*Math.ceil(f/50),f>1024||p>1024)return null;var x=l.getTextureQueue(a),y=x[x.length-2],b=function(){return l.recycleTexture(a,p)||l.addTexture(a,p)};y||(y=x[x.length-1]),y||(y=b()),y.width-y.usedWidth<p&&(y=b());for(var w=function(e){return e&&e.scaledLabelShown===g},N=i&&i===u1.dequeue,j=i&&i===u1.highQuality,k=i&&i===u1.downscale,C=r+1;C<=3;C++){var E=d.get(e,C);if(E){o=E;break}}var T=o&&o.level===r+1?o:null,S=function(){y.context.drawImage(T.texture.canvas,T.x,0,T.width,T.height,y.usedWidth,0,p,f)};if(y.context.setTransform(1,0,0,1,0,0),y.context.clearRect(y.usedWidth,0,p,a),w(T))S();else if(w(o))if(!j)return l.queueElement(e,o.level-1),o;else{for(var _=o.level;_>r;_--)T=l.getElement(e,t,n,_,u1.downscale);S()}else{if(!N&&!j&&!k)for(var A=r-1;A>=-4;A--){var D=d.get(e,A);if(D){s=D;break}}if(w(s))return l.queueElement(e,r),s;y.context.translate(y.usedWidth,0),y.context.scale(h,h),this.drawElement(y.context,e,t,g,!1),y.context.scale(1/h,1/h),y.context.translate(-y.usedWidth,0)}return v={x:y.usedWidth,texture:y,level:r,scale:h,width:p,height:f,scaledLabelShown:g},y.usedWidth+=Math.ceil(p+8),y.eleCaches.push(v),d.set(e,r,v),l.checkTextureFullness(y),v},u3.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},u3.invalidateElement=function(e){var t=this.lookup,n=[];if(t.isInvalid(e)){for(var r=-4;r<=3;r++){var i=t.getForCachedKey(e,r);i&&n.push(i)}if(t.invalidate(e))for(var a=0;a<n.length;a++){var o=n[a],s=o.texture;s.invalidatedWidth+=o.width,o.invalidated=!0,this.checkTextureUtility(s)}this.removeFromQueue(e)}},u3.checkTextureUtility=function(e){e.invalidatedWidth>=.2*e.width&&this.retireTexture(e)},u3.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?nV(t,e):e.fullnessChecks++},u3.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;nV(n,e),e.retired=!0;for(var i=e.eleCaches,a=0;a<i.length;a++){var o=i[a];r.deleteCache(o.key,o.level)}nH(i),this.getRetiredTextureQueue(t).push(e)},u3.addTexture=function(e,t){var n=this.getTextureQueue(e),r={};return n.push(r),r.eleCaches=[],r.height=e,r.width=Math.max(1024,t),r.usedWidth=0,r.invalidatedWidth=0,r.fullnessChecks=0,r.canvas=this.renderer.makeOffscreenCanvas(r.width,r.height),r.context=r.canvas.getContext("2d"),r},u3.recycleTexture=function(e,t){for(var n=this.getTextureQueue(e),r=this.getRetiredTextureQueue(e),i=0;i<r.length;i++){var a=r[i];if(a.width>=t)return a.retired=!1,a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,nH(a.eleCaches),a.context.setTransform(1,0,0,1,0,0),a.context.clearRect(0,0,a.width,a.height),nV(r,a),n.push(a),a}},u3.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),i=this.getKey(e),a=r[i];if(a)a.level=Math.max(a.level,t),a.eles.merge(e),a.reqs++,n.updateItem(a);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:i};n.push(o),r[i]=o}},u3.dequeue=function(e){for(var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=[],i=this.lookup,a=0;a<1;a++)if(t.size()>0){var o=t.pop(),s=o.key,l=o.eles[0],c=i.hasCache(l,o.level);if(n[s]=null,c)continue;r.push(o);var u=this.getBoundingBox(l);this.getElement(l,u,e,o.level,u1.dequeue)}else break;return r},u3.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),i=n[r];null!=i&&(1===i.eles.length?(i.reqs=nS,t.updateItem(i),t.pop(),n[r]=null):i.eles.unmerge(e))},u3.onDequeue=function(e){this.onDequeues.push(e)},u3.offDequeue=function(e){nV(this.onDequeues,e)},u3.setupDequeueing=uJ({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n<e.onDequeues.length;n++)(0,e.onDequeues[n])(t)},shouldRedraw:function(e,t,n,r){for(var i=0;i<t.length;i++)for(var a=t[i].eles,o=0;o<a.length;o++)if(rj(a[o].boundingBox(),r))return!0;return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var u4=function(e){var t=this,n=t.renderer=e,r=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=nf()-500,t.skipping=!1,t.eleTxrDeqs=r.collection(),t.scheduleElementRefinement=nd(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},50),n.beforeRender(function(e,n){n-t.lastInvalidationTime<=250?t.skipping=!0:t.skipping=!1},n.beforeRenderPriorities.lyrTxrSkip),t.layersQueue=new n1(function(e,t){return t.reqs-e.reqs}),t.setupDequeueing()},u6=u4.prototype,u9=0;u6.makeLayer=function(e,t){var n=Math.pow(2,t),r=Math.ceil(e.w*n),i=Math.ceil(e.h*n),a=this.renderer.makeOffscreenCanvas(r,i),o={id:u9=++u9%0x1fffffffffffff,bb:e,level:t,width:r,height:i,canvas:a,context:a.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=o.context,l=-o.bb.x1,c=-o.bb.y1;return s.scale(n,n),s.translate(l,c),o},u6.getLayers=function(e,t,n){var r,i,a=this,o=a.renderer.cy.zoom(),s=a.firstGet;if(a.firstGet=!1,null==n){if((n=Math.ceil(rs(o*t)))<-4)n=-4;else if(o>=3.99||n>2)return null}a.validateLayersElesOrdering(n,e);var l=a.layersByLevel,c=Math.pow(2,n),u=l[n]=l[n]||[];if(a.levelIsComplete(n,e))return u;var d=function(t){if(a.validateLayersElesOrdering(t,e),a.levelIsComplete(t,e))return i=l[t],!0},h=function(e){if(!i)for(var t=n+e;-4<=t&&t<=2&&!d(t);t+=e);};h(1),h(-1);for(var f=u.length-1;f>=0;f--){var p=u[f];p.invalid&&nV(u,p)}var g=function(){if(!r){r=rm();for(var t=0;t<e.length;t++)rx(r,e[t].boundingBox())}return r};if(a.skipping&&!s)return null;for(var v=null,x=e.length/1,y=!s,b=0;b<e.length;b++){var w=e[b],N=w._private.rscratch,j=N.imgLayerCaches=N.imgLayerCaches||{},k=j[n];if(k){v=k;continue}if((!v||v.eles.length>=x||!rE(v.bb,w.boundingBox()))&&!(v=function(e){var t=(e=e||{}).after;g();var i=Math.ceil(r.w*c),o=Math.ceil(r.h*c);if(i>32767||o>32767||i*o>16e6)return null;var s=a.makeLayer(r,n);if(null!=t){var l=u.indexOf(t)+1;u.splice(l,0,s)}else(void 0===e.insert||e.insert)&&u.unshift(s);return s}({insert:!0,after:v})))return null;i||y?a.queueLayer(v,w):a.drawEleInLayer(v,w,n,t),v.eles.push(w),j[n]=v}return i||(y?null:u)},u6.getEleLevelForLayerLevel=function(e,t){return e},u6.drawEleInLayer=function(e,t,n,r){var i=this.renderer,a=e.context,o=t.boundingBox();0!==o.w&&0!==o.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(a,!1),i.drawCachedElement(a,t,null,null,n,!0),i.setImgSmoothing(a,!0))},u6.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,i=0;i<n.length;i++){var a=n[i];if(a.reqs>0||a.invalid)return!1;r+=a.eles.length}return r===t.length},u6.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r<n.length;r++){for(var i=n[r],a=-1,o=0;o<t.length;o++)if(i.eles[0]===t[o]){a=o;break}if(a<0){this.invalidateLayer(i);continue}for(var s=a,o=0;o<i.eles.length;o++)if(i.eles[o]!==t[s+o]){this.invalidateLayer(i);break}}},u6.updateElementsInLayers=function(e,t){for(var n=tH(e[0]),r=0;r<e.length;r++)for(var i=n?null:e[r],a=n?e[r]:e[r].ele,o=a._private.rscratch,s=o.imgLayerCaches=o.imgLayerCaches||{},l=-4;l<=2;l++){var c=s[l];c&&(i&&this.getEleLevelForLayerLevel(c.level)!==i.level||t(c,a,i))}},u6.haveLayers=function(){for(var e=!1,t=-4;t<=2;t++){var n=this.layersByLevel[t];if(n&&n.length>0){e=!0;break}}return e},u6.invalidateElements=function(e){var t=this;0===e.length||(t.lastInvalidationTime=nf(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},u6.invalidateLayer=function(e){if(this.lastInvalidationTime=nf(),!e.invalid){var t=e.level,n=e.eles;nV(this.layersByLevel[t],e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var r=0;r<n.length;r++){var i=n[r]._private.rscratch.imgLayerCaches;i&&(i[t]=null)}}},u6.refineElementTextures=function(e){var t=this;t.updateElementsInLayers(e,function(e,n,r){var i=e.replacement;if(i||((i=e.replacement=t.makeLayer(e.bb,e.level)).replaces=e,i.eles=e.eles),!i.reqs)for(var a=0;a<i.eles.length;a++)t.queueLayer(i,i.eles[a])})},u6.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},u6.queueLayer=function(e,t){var n=this.layersQueue,r=e.elesQueue,i=r.hasId=r.hasId||{};if(!e.replacement){if(t){if(i[t.id()])return;r.push(t),i[t.id()]=!0}e.reqs?(e.reqs++,n.updateItem(e)):(e.reqs=1,n.push(e))}},u6.dequeue=function(e){for(var t=this.layersQueue,n=[],r=0;r<1&&0!==t.size();){var i=t.peek();if(i.replacement||i.replaces&&i!==i.replaces.replacement||i.invalid){t.pop();continue}var a=i.elesQueue.shift();a&&(this.drawEleInLayer(i,a,i.level,e),r++),0===n.length&&n.push(!0),0===i.elesQueue.length&&(t.pop(),i.reqs=0,i.replaces&&this.applyLayerReplacement(i),this.requestRedraw())}return n},u6.applyLayerReplacement=function(e){var t=this.layersByLevel[e.level],n=e.replaces,r=t.indexOf(n);if(!(r<0)&&!n.invalid){t[r]=e;for(var i=0;i<e.eles.length;i++){var a=e.eles[i]._private,o=a.imgLayerCaches=a.imgLayerCaches||{};o&&(o[e.level]=e)}this.requestRedraw()}},u6.requestRedraw=nd(function(){var e=this.renderer;e.redrawHint("eles",!0),e.redrawHint("drag",!0),e.redraw()},100),u6.setupDequeueing=uJ({deqRedrawThreshold:50,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t){return e.dequeue(t)},onDeqd:nM,shouldRedraw:n_,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var u7={};function u8(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function de(e,t,n){for(var r,i=0;i<t.length;i++){var a=t[i];0===i&&(r=a),e.lineTo(a.x,a.y)}e.quadraticCurveTo(n.x,n.y,r.x,r.y)}function dt(e,t,n){e.beginPath&&e.beginPath();for(var r=0;r<t.length;r++){var i=t[r];e.lineTo(i.x,i.y)}var a=n[0];e.moveTo(a.x,a.y);for(var r=1;r<n.length;r++){var i=n[r];e.lineTo(i.x,i.y)}e.closePath&&e.closePath()}function dn(e,t,n,r,i){e.beginPath&&e.beginPath(),e.arc(n,r,i,0,2*Math.PI,!1);var a=t[0];e.moveTo(a.x,a.y);for(var o=0;o<t.length;o++){var s=t[o];e.lineTo(s.x,s.y)}e.closePath&&e.closePath()}function dr(e,t,n,r){e.arc(t,n,r,0,2*Math.PI,!1)}u7.arrowShapeImpl=function(e){return(f||(f={polygon:u8,"triangle-backcurve":de,"triangle-tee":dt,"circle-triangle":dn,"triangle-cross":dt,circle:dr}))[e]};var di={};di.drawElement=function(e,t,n,r,i,a){t.isNode()?this.drawNode(e,t,n,r,i,a):this.drawEdge(e,t,n,r,i,a)},di.drawElementOverlay=function(e,t){t.isNode()?this.drawNodeOverlay(e,t):this.drawEdgeOverlay(e,t)},di.drawElementUnderlay=function(e,t){t.isNode()?this.drawNodeUnderlay(e,t):this.drawEdgeUnderlay(e,t)},di.drawCachedElementPortion=function(e,t,n,r,i,a,o,s){var l=n.getBoundingBox(t);if(0!==l.w&&0!==l.h){var c=n.getElement(t,l,r,i,a);if(null!=c){var u,d,h,f,p,g,v=s(this,t);if(0===v)return;var x=o(this,t),y=l.x1,b=l.y1,w=l.w,N=l.h;if(0!==x){var j=n.getRotationPoint(t);h=j.x,f=j.y,e.translate(h,f),e.rotate(x),(p=this.getImgSmoothing(e))||this.setImgSmoothing(e,!0);var k=n.getRotationOffset(t);u=k.x,d=k.y}else u=y,d=b;1!==v&&(g=e.globalAlpha,e.globalAlpha=g*v),e.drawImage(c.texture.canvas,c.x,0,c.width,c.height,u,d,w,N),1!==v&&(e.globalAlpha=g),0!==x&&(e.rotate(-x),e.translate(-h,-f),p||this.setImgSmoothing(e,!1))}else n.drawElement(e,t)}};var da=function(){return 0},ds=function(e,t){return e.getTextAngle(t,null)},dl=function(e,t){return e.getTextAngle(t,"source")},dc=function(e,t){return e.getTextAngle(t,"target")},du=function(e,t){return t.effectiveOpacity()},dd=function(e,t){return t.pstyle("text-opacity").pfValue*t.effectiveOpacity()};di.drawCachedElement=function(e,t,n,r,i,a){var o=this.data,s=o.eleTxrCache,l=o.lblTxrCache,c=o.slbTxrCache,u=o.tlbTxrCache,d=t.boundingBox(),h=!0===a?s.reasons.highQuality:null;if(0!==d.w&&0!==d.h&&t.visible()&&(!r||rj(d,r))){var f=t.isEdge(),p=t.element()._private.rscratch.badLine;this.drawElementUnderlay(e,t),this.drawCachedElementPortion(e,t,s,n,i,h,da,du),f&&p||this.drawCachedElementPortion(e,t,l,n,i,h,ds,dd),f&&!p&&(this.drawCachedElementPortion(e,t,c,n,i,h,dl,dd),this.drawCachedElementPortion(e,t,u,n,i,h,dc,dd)),this.drawElementOverlay(e,t)}},di.drawElements=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];this.drawElement(e,r)}},di.drawCachedElements=function(e,t,n,r){for(var i=0;i<t.length;i++){var a=t[i];this.drawCachedElement(e,a,n,r)}},di.drawCachedNodes=function(e,t,n,r){for(var i=0;i<t.length;i++){var a=t[i];a.isNode()&&this.drawCachedElement(e,a,n,r)}},di.drawLayeredElements=function(e,t,n,r){var i=this.data.lyrTxrCache.getLayers(t,n);if(i)for(var a=0;a<i.length;a++){var o=i[a],s=o.bb;0!==s.w&&0!==s.h&&e.drawImage(o.canvas,s.x1,s.y1,s.w,s.h)}else this.drawCachedElements(e,t,n,r)};var dh={};dh.drawEdge=function(e,t,n){var r,i=!(arguments.length>3)||void 0===arguments[3]||arguments[3],a=!(arguments.length>4)||void 0===arguments[4]||arguments[4],o=!(arguments.length>5)||void 0===arguments[5]||arguments[5],s=this,l=t._private.rscratch;if((!o||t.visible())&&!(l.badLine||null==l.allpts||isNaN(l.allpts[0]))){n&&(r=n,e.translate(-r.x1,-r.y1));var c=o?t.pstyle("opacity").value:1,u=o?t.pstyle("line-opacity").value:1,d=t.pstyle("curve-style").value,h=t.pstyle("line-style").value,f=t.pstyle("width").pfValue,p=t.pstyle("line-cap").value,g=t.pstyle("line-outline-width").value,v=t.pstyle("line-outline-color").value,x=c*u,y=c*u,b=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x;"straight-triangle"===d?(s.eleStrokeStyle(e,t,n),s.drawEdgeTrianglePath(t,e,l.allpts)):(e.lineWidth=f,e.lineCap=p,s.eleStrokeStyle(e,t,n),s.drawEdgePath(t,e,l.allpts,h),e.lineCap="butt")},w=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;s.drawArrowheads(e,t,n)};if(e.lineJoin="round","yes"===t.pstyle("ghost").value){var N=t.pstyle("ghost-offset-x").pfValue,j=t.pstyle("ghost-offset-y").pfValue,k=x*t.pstyle("ghost-opacity").value;e.translate(N,j),b(k),w(k),e.translate(-N,-j)}else!function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x;if(e.lineWidth=f+g,e.lineCap=p,g>0)s.colorStrokeStyle(e,v[0],v[1],v[2],n);else{e.lineCap="butt";return}"straight-triangle"===d?s.drawEdgeTrianglePath(t,e,l.allpts):(s.drawEdgePath(t,e,l.allpts,h),e.lineCap="butt")}();a&&s.drawEdgeUnderlay(e,t),b(),w(),a&&s.drawEdgeOverlay(e,t),s.drawElementText(e,t,null,i),n&&e.translate(r.x1,r.y1)}};var df=function(e){if(!["overlay","underlay"].includes(e))throw Error("Invalid state");return function(t,n){if(n.visible()){var r=n.pstyle("".concat(e,"-opacity")).value;if(0!==r){var i=this.usePaths(),a=n._private.rscratch,o=n.pstyle("".concat(e,"-padding")).pfValue,s=n.pstyle("".concat(e,"-color")).value;t.lineWidth=2*o,"self"!==a.edgeType||i?t.lineCap="round":t.lineCap="butt",this.colorStrokeStyle(t,s[0],s[1],s[2],r),this.drawEdgePath(n,t,a.allpts,"solid")}}}};dh.drawEdgeOverlay=df("overlay"),dh.drawEdgeUnderlay=df("underlay"),dh.drawEdgePath=function(e,t,n,r){var i=e._private.rscratch,a=t,o=!1,s=this.usePaths(),l=e.pstyle("line-dash-pattern").pfValue,c=e.pstyle("line-dash-offset").pfValue;if(s){var u=n.join("$");i.pathCacheKey&&i.pathCacheKey===u?(f=t=i.pathCache,o=!0):(f=t=new Path2D,i.pathCacheKey=u,i.pathCache=f)}if(a.setLineDash)switch(r){case"dotted":a.setLineDash([1,1]);break;case"dashed":a.setLineDash(l),a.lineDashOffset=c;break;case"solid":a.setLineDash([])}if(!o&&!i.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),i.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var d=2;d+3<n.length;d+=4)t.quadraticCurveTo(n[d],n[d+1],n[d+2],n[d+3]);break;case"straight":case"haystack":for(var h=2;h+1<n.length;h+=2)t.lineTo(n[h],n[h+1]);break;case"segments":if(i.isRound){var f,p,g=tw(i.roundCorners);try{for(g.s();!(p=g.n()).done;){var v=p.value;u_(t,v)}}catch(e){g.e(e)}finally{g.f()}t.lineTo(n[n.length-2],n[n.length-1])}else for(var x=2;x+1<n.length;x+=2)t.lineTo(n[x],n[x+1])}t=a,s?t.stroke(f):t.stroke(),t.setLineDash&&t.setLineDash([])},dh.drawEdgeTrianglePath=function(e,t,n){t.fillStyle=t.strokeStyle;for(var r=e.pstyle("width").pfValue,i=0;i+1<n.length;i+=2){var a=[n[i+2]-n[i],n[i+3]-n[i+1]],o=Math.sqrt(a[0]*a[0]+a[1]*a[1]),s=[a[1]/o,-a[0]/o],l=[s[0]*r/2,s[1]*r/2];t.beginPath(),t.moveTo(n[i]-l[0],n[i+1]-l[1]),t.lineTo(n[i]+l[0],n[i+1]+l[1]),t.lineTo(n[i+2],n[i+3]),t.closePath(),t.fill()}},dh.drawArrowheads=function(e,t,n){var r=t._private.rscratch,i="haystack"===r.edgeType;i||this.drawArrowhead(e,t,"source",r.arrowStartX,r.arrowStartY,r.srcArrowAngle,n),this.drawArrowhead(e,t,"mid-target",r.midX,r.midY,r.midtgtArrowAngle,n),this.drawArrowhead(e,t,"mid-source",r.midX,r.midY,r.midsrcArrowAngle,n),i||this.drawArrowhead(e,t,"target",r.arrowEndX,r.arrowEndY,r.tgtArrowAngle,n)},dh.drawArrowhead=function(e,t,n,r,i,a,o){if(!(isNaN(r)||null==r||isNaN(i)||null==i||isNaN(a))&&null!=a){var s=t.pstyle(n+"-arrow-shape").value;if("none"!==s){var l="hollow"===t.pstyle(n+"-arrow-fill").value?"both":"filled",c=t.pstyle(n+"-arrow-fill").value,u=t.pstyle("width").pfValue,d=t.pstyle(n+"-arrow-width"),h="match-line"===d.value?u:d.pfValue;"%"===d.units&&(h*=u);var f=t.pstyle("opacity").value;void 0===o&&(o=f);var p=e.globalCompositeOperation;(1!==o||"hollow"===c)&&(e.globalCompositeOperation="destination-out",this.colorFillStyle(e,255,255,255,1),this.colorStrokeStyle(e,255,255,255,1),this.drawArrowShape(t,e,l,u,s,h,r,i,a),e.globalCompositeOperation=p);var g=t.pstyle(n+"-arrow-color").value;this.colorFillStyle(e,g[0],g[1],g[2],o),this.colorStrokeStyle(e,g[0],g[1],g[2],o),this.drawArrowShape(t,e,c,u,s,h,r,i,a)}}},dh.drawArrowShape=function(e,t,n,r,i,a,o,s,l){var c,u=this.usePaths()&&"triangle-cross"!==i,d=!1,h=t,f=e.pstyle("arrow-scale").value,p=this.getArrowWidth(r,f),g=this.arrowShapes[i];if(u){var v=this.arrowPathCache=this.arrowPathCache||[],x=nN(i),y=v[x];null!=y?(c=t=y,d=!0):(c=t=new Path2D,v[x]=c)}!d&&(t.beginPath&&t.beginPath(),u?g.draw(t,1,0,{x:0,y:0},1):g.draw(t,p,l,{x:o,y:s},r),t.closePath&&t.closePath()),t=h,u&&(t.translate(o,s),t.rotate(l),t.scale(p,p)),("filled"===n||"both"===n)&&(u?t.fill(c):t.fill()),("hollow"===n||"both"===n)&&(t.lineWidth=a/(u?p:1),t.lineJoin="miter",u?t.stroke(c):t.stroke()),u&&(t.scale(1/p,1/p),t.rotate(-l),t.translate(-o,-s))};var dp={};dp.safeDrawImage=function(e,t,n,r,i,a,o,s,l,c){if(!(i<=0)&&!(a<=0)&&!(l<=0)&&!(c<=0))try{e.drawImage(t,n,r,i,a,o,s,l,c)}catch(e){nL(e)}},dp.drawInscribedImage=function(e,t,n,r,i){var a=n.position(),o=a.x,s=a.y,l=n.cy().style(),c=l.getIndexedStyle.bind(l),u=c(n,"background-fit","value",r),d=c(n,"background-repeat","value",r),h=n.width(),f=n.height(),p=2*n.padding(),g=h+("inner"===c(n,"background-width-relative-to","value",r)?0:p),v=f+("inner"===c(n,"background-height-relative-to","value",r)?0:p),x=n._private.rscratch,y="node"===c(n,"background-clip","value",r),b=c(n,"background-image-opacity","value",r)*i,w=c(n,"background-image-smoothing","value",r),N=n.pstyle("corner-radius").value;"auto"!==N&&(N=n.pstyle("corner-radius").pfValue);var j=t.width||t.cachedW,k=t.height||t.cachedH;(null==j||null==k)&&(document.body.appendChild(t),j=t.cachedW=t.width||t.offsetWidth,k=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var C=j,E=k;if("auto"!==c(n,"background-width","value",r)&&(C="%"===c(n,"background-width","units",r)?c(n,"background-width","pfValue",r)*g:c(n,"background-width","pfValue",r)),"auto"!==c(n,"background-height","value",r)&&(E="%"===c(n,"background-height","units",r)?c(n,"background-height","pfValue",r)*v:c(n,"background-height","pfValue",r)),0!==C&&0!==E){if("contain"===u){var T=Math.min(g/C,v/E);C*=T,E*=T}else if("cover"===u){var T=Math.max(g/C,v/E);C*=T,E*=T}var S=o-g/2,_=c(n,"background-position-x","units",r),A=c(n,"background-position-x","pfValue",r);"%"===_?S+=(g-C)*A:S+=A;var D=c(n,"background-offset-x","units",r),M=c(n,"background-offset-x","pfValue",r);"%"===D?S+=(g-C)*M:S+=M;var P=s-v/2,R=c(n,"background-position-y","units",r),L=c(n,"background-position-y","pfValue",r);"%"===R?P+=(v-E)*L:P+=L;var I=c(n,"background-offset-y","units",r),O=c(n,"background-offset-y","pfValue",r);"%"===I?P+=(v-E)*O:P+=O,x.pathCache&&(S-=o,P-=s,o=0,s=0);var B=e.globalAlpha;e.globalAlpha=b;var F=this.getImgSmoothing(e),z=!1;if("no"===w&&F?(this.setImgSmoothing(e,!1),z=!0):"yes"!==w||F||(this.setImgSmoothing(e,!0),z=!0),"no-repeat"===d)y&&(e.save(),x.pathCache?e.clip(x.pathCache):(this.nodeShapes[this.getNodeShape(n)].draw(e,o,s,g,v,N,x),e.clip())),this.safeDrawImage(e,t,0,0,j,k,S,P,C,E),y&&e.restore();else{var V=e.createPattern(t,d);e.fillStyle=V,this.nodeShapes[this.getNodeShape(n)].draw(e,o,s,g,v,N,x),e.translate(S,P),e.fill(),e.translate(-S,-P)}e.globalAlpha=B,z&&this.setImgSmoothing(e,F)}};var dg={};function dm(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:5,o=Math.min(a,r/2,i/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}dg.eleTextBiggerThanMin=function(e,t){return t||(t=Math.pow(2,Math.ceil(rs(e.cy().zoom()*this.getPixelRatio())))),!(e.pstyle("font-size").pfValue*t<e.pstyle("min-zoomed-font-size").pfValue)},dg.drawElementText=function(e,t,n,r,i){var a,o=!(arguments.length>5)||void 0===arguments[5]||arguments[5];if(null==r){if(o&&!this.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;e.textAlign=this.getLabelJustification(t),e.textBaseline="bottom"}else{var l=t.element()._private.rscratch.badLine,c=t.pstyle("label"),u=t.pstyle("source-label"),d=t.pstyle("target-label");if(l||(!c||!c.value)&&(!u||!u.value)&&(!d||!d.value))return;e.textAlign="center",e.textBaseline="bottom"}var h=!n;n&&(a=n,e.translate(-a.x1,-a.y1)),null==i?(this.drawText(e,t,null,h,o),t.isEdge()&&(this.drawText(e,t,"source",h,o),this.drawText(e,t,"target",h,o))):this.drawText(e,t,i,h,o),n&&e.translate(a.x1,a.y1)},dg.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if((t=this.fontCaches[n]).context===e)return t;return t={context:e},this.fontCaches.push(t),t},dg.setupTextStyle=function(e,t){var n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],r=t.pstyle("font-style").strValue,i=t.pstyle("font-size").pfValue+"px",a=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=n?t.effectiveOpacity()*t.pstyle("text-opacity").value:1,l=t.pstyle("text-outline-opacity").value*s,c=t.pstyle("color").value,u=t.pstyle("text-outline-color").value;e.font=r+" "+o+" "+i+" "+a,e.lineJoin="round",this.colorFillStyle(e,c[0],c[1],c[2],s),this.colorStrokeStyle(e,u[0],u[1],u[2],l)},dg.getTextAngle=function(e,t){var n,r=e._private.rscratch,i=t?t+"-":"",a=e.pstyle(i+"text-rotation");if("autorotate"===a.strValue){var o=nG(r,"labelAngle",t);n=e.isEdge()?o:0}else n="none"===a.strValue?0:a.pfValue;return n},dg.drawText=function(e,t,n){var r=!(arguments.length>3)||void 0===arguments[3]||arguments[3],i=!(arguments.length>4)||void 0===arguments[4]||arguments[4],a=t._private.rscratch,o=i?t.effectiveOpacity():1;if(!i||0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s=nG(a,"labelX",n),l=nG(a,"labelY",n),c=this.getLabelText(t,n);if(null!=c&&""!==c&&!isNaN(s)&&!isNaN(l)){this.setupTextStyle(e,t,i);var u,d,h,f=n?n+"-":"",p=nG(a,"labelWidth",n),g=nG(a,"labelHeight",n),v=t.pstyle(f+"text-margin-x").pfValue,x=t.pstyle(f+"text-margin-y").pfValue,y=t.isEdge(),b=t.pstyle("text-halign").value,w=t.pstyle("text-valign").value;switch(y&&(b="center",w="center"),s+=v,l+=x,0!==(h=r?this.getTextAngle(t,n):0)&&(u=s,d=l,e.translate(u,d),e.rotate(h),s=0,l=0),w){case"top":break;case"center":l+=g/2;break;case"bottom":l+=g}var N=t.pstyle("text-background-opacity").value,j=t.pstyle("text-border-opacity").value,k=t.pstyle("text-border-width").pfValue,C=t.pstyle("text-background-padding").pfValue,E=t.pstyle("text-background-shape").strValue,T="round-rectangle"===E||"roundrectangle"===E;if(N>0||k>0&&j>0){var S,_,A=e.fillStyle,D=e.strokeStyle,M=e.lineWidth,P=t.pstyle("text-background-color").value,R=t.pstyle("text-border-color").value,L=t.pstyle("text-border-style").value,I=N>0,O=k>0&&j>0,B=s-C;switch(b){case"left":B-=p;break;case"center":B-=p/2}var F=l-g-C,z=p+2*C,V=g+2*C;if(I&&(e.fillStyle="rgba(".concat(P[0],",").concat(P[1],",").concat(P[2],",").concat(N*o,")")),O&&(e.strokeStyle="rgba(".concat(R[0],",").concat(R[1],",").concat(R[2],",").concat(j*o,")"),e.lineWidth=k,e.setLineDash))switch(L){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=k/4,e.setLineDash([]);break;default:e.setLineDash([])}if(T?(e.beginPath(),dm(e,B,F,z,V,2)):"circle"===E?(e.beginPath(),S=B,_=Math.min(z,V),e.beginPath(),e.arc(S+z/2,F+V/2,_/2,0,2*Math.PI),e.closePath()):(e.beginPath(),e.rect(B,F,z,V)),I&&e.fill(),O&&e.stroke(),O&&"double"===L){var H=k/2;e.beginPath(),T?dm(e,B+H,F+H,z-2*H,V-2*H,2):e.rect(B+H,F+H,z-2*H,V-2*H),e.stroke()}e.fillStyle=A,e.strokeStyle=D,e.lineWidth=M,e.setLineDash&&e.setLineDash([])}var U=2*t.pstyle("text-outline-width").pfValue;if(U>0&&(e.lineWidth=U),"wrap"===t.pstyle("text-wrap").value){var G=nG(a,"labelWrapCachedLines",n),Y=nG(a,"labelLineHeight",n),X=p/2,W=this.getLabelJustification(t);switch("auto"===W||("left"===b?"left"===W?s+=-p:"center"===W&&(s+=-X):"center"===b?"left"===W?s+=-X:"right"===W&&(s+=X):"right"===b&&("center"===W?s+=X:"right"===W&&(s+=p))),w){case"top":case"center":case"bottom":l-=(G.length-1)*Y}for(var q=0;q<G.length;q++)U>0&&e.strokeText(G[q],s,l),e.fillText(G[q],s,l),l+=Y}else U>0&&e.strokeText(c,s,l),e.fillText(c,s,l);0!==h&&(e.rotate(-h),e.translate(-u,-d))}}};var dv={};dv.drawNode=function(e,t,n){var r,i,a,o,s=!(arguments.length>3)||void 0===arguments[3]||arguments[3],l=!(arguments.length>4)||void 0===arguments[4]||arguments[4],c=!(arguments.length>5)||void 0===arguments[5]||arguments[5],u=this,d=t._private,h=d.rscratch,f=t.position();if(tF(f.x)&&tF(f.y)&&(!c||t.visible())){var p=c?t.effectiveOpacity():1,g=u.usePaths(),v=!1,x=t.padding();r=t.width()+2*x,i=t.height()+2*x,n&&(o=n,e.translate(-o.x1,-o.y1));for(var y=t.pstyle("background-image").value,b=Array(y.length),w=Array(y.length),N=0,j=0;j<y.length;j++){var k=y[j];if(b[j]=null!=k&&"none"!==k){var C=t.cy().style().getIndexedStyle(t,"background-image-crossorigin","value",j);N++,w[j]=u.getCachedImage(k,C,function(){d.backgroundTimestamp=Date.now(),t.emitAndNotify("background")})}}var E=t.pstyle("background-blacken").value,T=t.pstyle("border-width").pfValue,S=t.pstyle("background-opacity").value*p,_=t.pstyle("border-color").value,A=t.pstyle("border-style").value,D=t.pstyle("border-join").value,M=t.pstyle("border-cap").value,P=t.pstyle("border-position").value,R=t.pstyle("border-dash-pattern").pfValue,L=t.pstyle("border-dash-offset").pfValue,I=t.pstyle("border-opacity").value*p,O=t.pstyle("outline-width").pfValue,B=t.pstyle("outline-color").value,F=t.pstyle("outline-style").value,z=t.pstyle("outline-opacity").value*p,V=t.pstyle("outline-offset").value,H=t.pstyle("corner-radius").value;"auto"!==H&&(H=t.pstyle("corner-radius").pfValue);var U=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:S;u.eleFillStyle(e,t,n)},G=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:I;u.colorStrokeStyle(e,_[0],_[1],_[2],t)},Y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:z;u.colorStrokeStyle(e,B[0],B[1],B[2],t)},X=function(e,t,n,r){var i,a=u.nodePathCache=u.nodePathCache||[],o=nj("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+H),s=a[o],l=!1;return null!=s?(l=!0,h.pathCache=i=s):(i=new Path2D,a[o]=h.pathCache=i),{path:i,cacheHit:l}},W=t.pstyle("shape").strValue,q=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(f.x,f.y);var $=X(r,i,W,q);a=$.path,v=$.cacheHit}var K=function(){if(!v){var n=f;g&&(n={x:0,y:0}),u.nodeShapes[u.getNodeShape(t)].draw(a||e,n.x,n.y,r,i,H,h)}g?e.fill(a):e.fill()},Z=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,r=!(arguments.length>1)||void 0===arguments[1]||arguments[1],i=d.backgrounding,a=0,o=0;o<w.length;o++){var s=t.cy().style().getIndexedStyle(t,"background-image-containment","value",o);if(r&&"over"===s||!r&&"inside"===s){a++;continue}b[o]&&w[o].complete&&!w[o].error&&(a++,u.drawInscribedImage(e,w[o],t,o,n))}d.backgrounding=a!==N,i!==d.backgrounding&&t.updateStyle(!1)},Q=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;u.hasPie(t)&&(u.drawPie(e,t,a),n&&!g&&u.nodeShapes[u.getNodeShape(t)].draw(e,f.x,f.y,r,i,H,h))},J=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;u.hasStripe(t)&&(e.save(),g?e.clip(h.pathCache):(u.nodeShapes[u.getNodeShape(t)].draw(e,f.x,f.y,r,i,H,h),e.clip()),u.drawStripe(e,t,a),e.restore(),n&&!g&&u.nodeShapes[u.getNodeShape(t)].draw(e,f.x,f.y,r,i,H,h))},ee=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,n=E>0?0:255;0!==E&&(u.colorFillStyle(e,n,n,n,(E>0?E:-E)*t),g?e.fill(a):e.fill())},et=function(){if(T>0){if(e.lineWidth=T,e.lineCap=M,e.lineJoin=D,e.setLineDash)switch(A){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash(R),e.lineDashOffset=L;break;case"solid":case"double":e.setLineDash([])}if("center"!==P){if(e.save(),e.lineWidth*=2,"inside"===P)g?e.clip(a):e.clip();else{var t=new Path2D;t.rect(-r/2-T,-i/2-T,r+2*T,i+2*T),t.addPath(a),e.clip(t,"evenodd")}g?e.stroke(a):e.stroke(),e.restore()}else g?e.stroke(a):e.stroke();if("double"===A){e.lineWidth=T/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(a):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},en=function(){if(O>0){if(e.lineWidth=O,e.lineCap="butt",e.setLineDash)switch(F){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var n=f;g&&(n={x:0,y:0});var a=u.getNodeShape(t),o=T;"inside"===P&&(o=0),"outside"===P&&(o*=2);var s=(r+o+(O+V))/r,l=(i+o+(O+V))/i,c=r*s,d=i*l,h=u.nodeShapes[a].points;if(g&&(C=X(c,d,a,h).path),"ellipse"===a)u.drawEllipsePath(C||e,n.x,n.y,c,d);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(a)){var p=0,v=0,x=0;"round-diamond"===a?p=(o+V+O)*1.4:"round-heptagon"===a?(p=(o+V+O)*1.075,x=-(o/2+V+O)/35):"round-hexagon"===a?p=(o+V+O)*1.12:"round-pentagon"===a?(p=(o+V+O)*1.13,x=-(o/2+V+O)/15):"round-tag"===a?(p=(o+V+O)*1.12,v=(o/2+O+V)*.07):"round-triangle"===a&&(p=Math.PI/2*(o+V+O),x=-(o+V/2+O)/Math.PI),0!==p&&(s=(r+p)/r,c=r*s,["round-hexagon","round-tag"].includes(a)||(l=(i+p)/i,d=i*l)),H="auto"===H?rJ(c,d):H;for(var y=c/2,b=d/2,w=H+(o+O+V)/2,N=Array(h.length/2),j=Array(h.length/2),k=0;k<h.length/2;k++)N[k]={x:n.x+v+y*h[2*k],y:n.y+x+b*h[2*k+1]};var C,E,S,_,A,D=N.length;for(E=0,S=N[D-1];E<D;E++)_=N[E%D],A=N[(E+1)%D],j[E]=uA(S,_,A,w),S=_,_=A;u.drawRoundPolygonPath(C||e,n.x+v,n.y+x,r*s,i*l,h,j)}else["roundrectangle","round-rectangle"].includes(a)?(H="auto"===H?rQ(c,d):H,u.drawRoundRectanglePath(C||e,n.x,n.y,c,d,H+(o+O+V)/2)):["cutrectangle","cut-rectangle"].includes(a)?(H="auto"===H?r0():H,u.drawCutRectanglePath(C||e,n.x,n.y,c,d,null,H+(o+O+V)/4)):["bottomroundrectangle","bottom-round-rectangle"].includes(a)?(H="auto"===H?rQ(c,d):H,u.drawBottomRoundRectanglePath(C||e,n.x,n.y,c,d,H+(o+O+V)/2)):"barrel"===a?u.drawBarrelPath(C||e,n.x,n.y,c,d):(h=a.startsWith("polygon")||["rhomboid","right-rhomboid","round-tag","tag","vee"].includes(a)?rB(rF(h,(o+O+V)/r)):rB(rF(h,-((o+O+V)/r))),u.drawPolygonPath(C||e,n.x,n.y,r,i,h));if(g?e.stroke(C):e.stroke(),"double"===F){e.lineWidth=o/3;var M=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(C):e.stroke(),e.globalCompositeOperation=M}e.setLineDash&&e.setLineDash([])}};if("yes"===t.pstyle("ghost").value){var er=t.pstyle("ghost-offset-x").pfValue,ei=t.pstyle("ghost-offset-y").pfValue,ea=t.pstyle("ghost-opacity").value,eo=ea*p;e.translate(er,ei),Y(),en(),U(ea*S),K(),Z(eo,!0),G(ea*I),et(),Q(0!==E||0!==T),J(0!==E||0!==T),Z(eo,!1),ee(eo),e.translate(-er,-ei)}g&&e.translate(-f.x,-f.y),l&&u.drawNodeUnderlay(e,t,f,r,i),g&&e.translate(f.x,f.y),Y(),en(),U(),K(),Z(p,!0),G(),et(),Q(0!==E||0!==T),J(0!==E||0!==T),Z(p,!1),ee(),g&&e.translate(-f.x,-f.y),u.drawElementText(e,t,null,s),l&&u.drawNodeOverlay(e,t,f,r,i),n&&e.translate(o.x1,o.y1)}};var dx=function(e){if(!["overlay","underlay"].includes(e))throw Error("Invalid state");return function(t,n,r,i,a){if(n.visible()){var o=n.pstyle("".concat(e,"-padding")).pfValue,s=n.pstyle("".concat(e,"-opacity")).value,l=n.pstyle("".concat(e,"-color")).value,c=n.pstyle("".concat(e,"-shape")).value,u=n.pstyle("".concat(e,"-corner-radius")).value;if(s>0){if(r=r||n.position(),null==i||null==a){var d=n.padding();i=n.width()+2*d,a=n.height()+2*d}this.colorFillStyle(t,l[0],l[1],l[2],s),this.nodeShapes[c].draw(t,r.x,r.y,i+2*o,a+2*o,u),t.fill()}}}};dv.drawNodeOverlay=dx("overlay"),dv.drawNodeUnderlay=dx("underlay"),dv.hasPie=function(e){return(e=e[0])._private.hasPie},dv.hasStripe=function(e){return(e=e[0])._private.hasStripe},dv.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var i,a=t.cy().style(),o=t.pstyle("pie-size"),s=t.pstyle("pie-hole"),l=t.pstyle("pie-start-angle").pfValue,c=r.x,u=r.y,d=Math.min(t.width(),t.height())/2,h=0;if(this.usePaths()&&(c=0,u=0),"%"===o.units?d*=o.pfValue:void 0!==o.pfValue&&(d=o.pfValue/2),"%"===s.units?i=d*s.pfValue:void 0!==s.pfValue&&(i=s.pfValue/2),!(i>=d))for(var f=1;f<=a.pieBackgroundN;f++){var p=t.pstyle("pie-"+f+"-background-size").value,g=t.pstyle("pie-"+f+"-background-color").value,v=t.pstyle("pie-"+f+"-background-opacity").value*n,x=p/100;x+h>1&&(x=1-h);var y=1.5*Math.PI+2*Math.PI*h,b=2*Math.PI*x,w=(y+=l)+b;0===p||h>=1||h+x>1||(0===i?(e.beginPath(),e.moveTo(c,u),e.arc(c,u,d,y,w)):(e.beginPath(),e.arc(c,u,d,y,w),e.arc(c,u,i,w,y,!0)),e.closePath(),this.colorFillStyle(e,g[0],g[1],g[2],v),e.fill(),h+=x)}},dv.drawStripe=function(e,t,n,r){t=t[0],r=r||t.position();var i=t.cy().style(),a=r.x,o=r.y,s=t.width(),l=t.height(),c=0,u=this.usePaths();e.save();var d=t.pstyle("stripe-direction").value,h=t.pstyle("stripe-size");switch(d){case"vertical":break;case"righward":e.rotate(-Math.PI/2)}var f=s,p=l;"%"===h.units?(f*=h.pfValue,p*=h.pfValue):void 0!==h.pfValue&&(f=h.pfValue,p=h.pfValue),u&&(a=0,o=0),o-=f/2,a-=p/2;for(var g=1;g<=i.stripeBackgroundN;g++){var v=t.pstyle("stripe-"+g+"-background-size").value,x=t.pstyle("stripe-"+g+"-background-color").value,y=t.pstyle("stripe-"+g+"-background-opacity").value*n,b=v/100;b+c>1&&(b=1-c),0===v||c>=1||c+b>1||(e.beginPath(),e.rect(a,o+p*c,f,p*b),e.closePath(),this.colorFillStyle(e,x[0],x[1],x[2],y),e.fill(),c+=b)}e.restore()};var dy={};function db(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(r));return r}function dw(e,t,n){void 0===n&&(n=t);var r=e.makeOffscreenCanvas(t,n),i=r.context=r.getContext("2d");return r.clear=function(){return i.clearRect(0,0,r.width,r.height)},r.clear(),r}function dN(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function dj(e){return"solid"===e.pstyle("background-fill").value&&"none"===e.pstyle("background-image").strValue&&(0===e.pstyle("border-width").value||0===e.pstyle("border-opacity").value||"solid"===e.pstyle("border-style").value)}function dk(e,t,n){var r=e[0]/255,i=e[1]/255,a=e[2]/255,o=n||[,,,,];return o[0]=r*t,o[1]=i*t,o[2]=a*t,o[3]=t,o}function dC(e,t){var n=t||[,,,,];return n[0]=(255&e)/255,n[1]=(e>>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function dE(e,t){switch(t){case"float":return[1,e.FLOAT,4];case"vec2":return[2,e.FLOAT,4];case"vec3":return[3,e.FLOAT,4];case"vec4":return[4,e.FLOAT,4];case"int":return[1,e.INT,4];case"ivec2":return[2,e.INT,4]}}function dT(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function dS(e,t,n,r){var i=tj(dE(e,n),3),a=i[0],o=i[1],s=i[2],l=dT(e,o,t*a),c=a*s,u=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,t*c,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),o===e.FLOAT?e.vertexAttribPointer(r,a,o,!1,c,0):o===e.INT&&e.vertexAttribIPointer(r,a,o,c,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=Array(t),h=0;h<t;h++)d[h]=function(e,t,n,r,i,a){switch(t){case e.FLOAT:return new Float32Array(n.buffer,a*r,i);case e.INT:return new Int32Array(n.buffer,a*r,i)}}(e,o,l,c,a,h);return u.dataArray=l,u.stride=c,u.size=a,u.getView=function(e){return d[e]},u.setPoint=function(e,t,n){var r=d[e];r[0]=t,r[1]=n},u.bufferSubData=function(t){e.bindBuffer(e.ARRAY_BUFFER,u),t?e.bufferSubData(e.ARRAY_BUFFER,0,l,0,t*a):e.bufferSubData(e.ARRAY_BUFFER,0,l)},u}dy.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=this.cy.window(),n=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(t.devicePixelRatio||1)/n},dy.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;i<n.length;i++)if((t=n[i]).context===e){r=!1;break}return r&&(t={context:e},n.push(t)),t},dy.createGradientStyleFor=function(e,t,n,r,i){var a,o=this.usePaths(),s=n.pstyle(t+"-gradient-stop-colors").value,l=n.pstyle(t+"-gradient-stop-positions").pfValue;if("radial-gradient"===r)if(n.isEdge()){var c=n.sourceEndpoint(),u=n.targetEndpoint(),d=n.midpoint(),h=rc(c,d),f=rc(u,d);a=e.createRadialGradient(d.x,d.y,0,d.x,d.y,Math.max(h,f))}else{var p=o?{x:0,y:0}:n.position(),g=n.paddedWidth(),v=n.paddedHeight();a=e.createRadialGradient(p.x,p.y,0,p.x,p.y,Math.max(g,v))}else if(n.isEdge()){var x=n.sourceEndpoint(),y=n.targetEndpoint();a=e.createLinearGradient(x.x,x.y,y.x,y.y)}else{var b=o?{x:0,y:0}:n.position(),w=n.paddedWidth(),N=n.paddedHeight(),j=w/2,k=N/2;switch(n.pstyle("background-gradient-direction").value){case"to-bottom":a=e.createLinearGradient(b.x,b.y-k,b.x,b.y+k);break;case"to-top":a=e.createLinearGradient(b.x,b.y+k,b.x,b.y-k);break;case"to-left":a=e.createLinearGradient(b.x+j,b.y,b.x-j,b.y);break;case"to-right":a=e.createLinearGradient(b.x-j,b.y,b.x+j,b.y);break;case"to-bottom-right":case"to-right-bottom":a=e.createLinearGradient(b.x-j,b.y-k,b.x+j,b.y+k);break;case"to-top-right":case"to-right-top":a=e.createLinearGradient(b.x-j,b.y+k,b.x+j,b.y-k);break;case"to-bottom-left":case"to-left-bottom":a=e.createLinearGradient(b.x+j,b.y-k,b.x-j,b.y+k);break;case"to-top-left":case"to-left-top":a=e.createLinearGradient(b.x+j,b.y+k,b.x-j,b.y-k)}}if(!a)return null;for(var C=l.length===s.length,E=s.length,T=0;T<E;T++)a.addColorStop(C?l[T]:T/(E-1),"rgba("+s[T][0]+","+s[T][1]+","+s[T][2]+","+i+")");return a},dy.gradientFillStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"background",t,n,r);if(!i)return null;e.fillStyle=i},dy.colorFillStyle=function(e,t,n,r,i){e.fillStyle="rgba("+t+","+n+","+r+","+i+")"},dy.eleFillStyle=function(e,t,n){var r=t.pstyle("background-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientFillStyle(e,t,r,n);else{var i=t.pstyle("background-color").value;this.colorFillStyle(e,i[0],i[1],i[2],n)}},dy.gradientStrokeStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"line",t,n,r);if(!i)return null;e.strokeStyle=i},dy.colorStrokeStyle=function(e,t,n,r,i){e.strokeStyle="rgba("+t+","+n+","+r+","+i+")"},dy.eleStrokeStyle=function(e,t,n){var r=t.pstyle("line-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientStrokeStyle(e,t,r,n);else{var i=t.pstyle("line-color").value;this.colorStrokeStyle(e,i[0],i[1],i[2],n)}},dy.matchCanvasSize=function(e){var t,n=this.data,r=this.findContainerClientCoords(),i=r[2],a=r[3],o=this.getPixelRatio(),s=this.motionBlurPxRatio;(e===this.data.bufferCanvases[this.MOTIONBLUR_BUFFER_NODE]||e===this.data.bufferCanvases[this.MOTIONBLUR_BUFFER_DRAG])&&(o=s);var l=i*o,c=a*o;if(l!==this.canvasWidth||c!==this.canvasHeight){this.fontCaches=null;var u=n.canvasContainer;u.style.width=i+"px",u.style.height=a+"px";for(var d=0;d<this.CANVAS_LAYERS;d++)(t=n.canvases[d]).width=l,t.height=c,t.style.width=i+"px",t.style.height=a+"px";for(var d=0;d<this.BUFFER_COUNT;d++)(t=n.bufferCanvases[d]).width=l,t.height=c,t.style.width=i+"px",t.style.height=a+"px";this.textureMult=1,o<=1&&(t=n.bufferCanvases[this.TEXTURE_BUFFER],this.textureMult=2,t.width=l*this.textureMult,t.height=c*this.textureMult),this.canvasWidth=l,this.canvasHeight=c,this.pixelRatio=o}},dy.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},dy.clearCanvas=function(){var e=this,t=e.data;function n(t){t.clearRect(0,0,e.canvasWidth,e.canvasHeight)}n(t.contexts[e.NODE]),n(t.contexts[e.DRAG])},dy.render=function(e){var t=this;e=e||nF();var n=t.cy,r=e.forcedContext,i=e.drawAllLayers,a=e.drawOnlyNodeLayer,o=e.forcedZoom,s=e.forcedPan,l=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,c=t.data,u=c.canvasNeedsRedraw,d=t.textureOnViewport&&!r&&(t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming),h=void 0!==e.motionBlur?e.motionBlur:t.motionBlur,f=t.motionBlurPxRatio,p=n.hasCompoundNodes(),g=t.hoverData.draggingEles,v=!!t.hoverData.selecting||!!t.touchData.selecting,x=h=h&&!r&&t.motionBlurEnabled&&!v;r||(t.prevPxRatio!==l&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container),t.redrawHint("eles",!0),t.redrawHint("drag",!0)),t.prevPxRatio=l),!r&&t.motionBlurTimeout&&clearTimeout(t.motionBlurTimeout),h&&(null==t.mbFrames&&(t.mbFrames=0),t.mbFrames++,t.mbFrames<3&&(x=!1),t.mbFrames>t.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!d&&(u[t.NODE]=!0,u[t.SELECT_BOX]=!0);var y=n.style(),b=n.zoom(),w=void 0!==o?o:b,N=n.pan(),j={x:N.x,y:N.y},k={zoom:b,pan:{x:N.x,y:N.y}},C=t.prevViewport;void 0===C||k.zoom!==C.zoom||k.pan.x!==C.pan.x||k.pan.y!==C.pan.y||g&&!p||(t.motionBlurPxRatio=1),s&&(j=s),w*=l,j.x*=l,j.y*=l;var E=t.getCachedZSortedEles();function T(e,n,r,i,a){var o=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",t.colorFillStyle(e,255,255,255,t.motionBlurTransparency),e.fillRect(n,r,i,a),e.globalCompositeOperation=o}function S(e,n){var a,l,u,d;t.clearingMotionBlur||e!==c.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]&&e!==c.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]?(a=j,l=w,u=t.canvasWidth,d=t.canvasHeight):(a={x:N.x*f,y:N.y*f},l=b*f,u=t.canvasWidth*f,d=t.canvasHeight*f),e.setTransform(1,0,0,1,0,0),"motionBlur"===n?T(e,0,0,u,d):!r&&(void 0===n||n)&&e.clearRect(0,0,u,d),i||(e.translate(a.x,a.y),e.scale(l,l)),s&&e.translate(s.x,s.y),o&&e.scale(o,o)}if(d||(t.textureDrawLastFrame=!1),d){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var _=t.data.bufferContexts[t.TEXTURE_BUFFER];_.setTransform(1,0,0,1,0,0),_.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:_,drawOnlyNodeLayer:!0,forcedPxRatio:l*t.textureMult});var k=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight};k.mpan={x:(0-k.pan.x)/k.zoom,y:(0-k.pan.y)/k.zoom}}u[t.DRAG]=!1,u[t.NODE]=!1;var A=c.contexts[t.NODE],D=t.textureCache.texture,k=t.textureCache.viewport;A.setTransform(1,0,0,1,0,0),h?T(A,0,0,k.width,k.height):A.clearRect(0,0,k.width,k.height);var M=y.core("outside-texture-bg-color").value,P=y.core("outside-texture-bg-opacity").value;t.colorFillStyle(A,M[0],M[1],M[2],P),A.fillRect(0,0,k.width,k.height);var b=n.zoom();S(A,!1),A.clearRect(k.mpan.x,k.mpan.y,k.width/k.zoom/l,k.height/k.zoom/l),A.drawImage(D,k.mpan.x,k.mpan.y,k.width/k.zoom/l,k.height/k.zoom/l)}else t.textureOnViewport&&!r&&(t.textureCache=null);var R=n.extent(),L=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),I=t.hideEdgesOnViewport&&L,O=[];if(O[t.NODE]=!u[t.NODE]&&h&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,O[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),O[t.DRAG]=!u[t.DRAG]&&h&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,O[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),u[t.NODE]||i||a||O[t.NODE]){var B=h&&!O[t.NODE]&&1!==f,A=r||(B?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:c.contexts[t.NODE]);S(A,h&&!B?"motionBlur":void 0),I?t.drawCachedNodes(A,E.nondrag,l,R):t.drawLayeredElements(A,E.nondrag,l,R),t.debug&&t.drawDebugPoints(A,E.nondrag),i||h||(u[t.NODE]=!1)}if(!a&&(u[t.DRAG]||i||O[t.DRAG])){var B=h&&!O[t.DRAG]&&1!==f,A=r||(B?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:c.contexts[t.DRAG]);S(A,h&&!B?"motionBlur":void 0),I?t.drawCachedNodes(A,E.drag,l,R):t.drawCachedElements(A,E.drag,l,R),t.debug&&t.drawDebugPoints(A,E.drag),i||h||(u[t.DRAG]=!1)}if(this.drawSelectionRectangle(e,S),h&&1!==f){var F=c.contexts[t.NODE],z=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],V=c.contexts[t.DRAG],H=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],U=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!x?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):T(e,0,0,t.canvasWidth,t.canvasHeight),e.drawImage(n,0,0,t.canvasWidth*f,t.canvasHeight*f,0,0,t.canvasWidth,t.canvasHeight)};(u[t.NODE]||O[t.NODE])&&(U(F,z,O[t.NODE]),u[t.NODE]=!1),(u[t.DRAG]||O[t.DRAG])&&(U(V,H,O[t.DRAG]),u[t.DRAG]=!1)}t.prevViewport=k,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),h&&(t.motionBlurTimeout=setTimeout(function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!d,t.mbFrames=0,u[t.NODE]=!0,u[t.DRAG]=!0,t.redraw()},100)),r||n.emit("render")},dy.drawSelectionRectangle=function(e,t){var n=this.cy,r=this.data,i=n.style(),a=e.drawOnlyNodeLayer,o=e.drawAllLayers,s=r.canvasNeedsRedraw,l=e.forcedContext;if(this.showFps||!a&&s[this.SELECT_BOX]&&!o){var c=l||r.contexts[this.SELECT_BOX];if(t(c),1==this.selection[4]&&(this.hoverData.selecting||this.touchData.selecting)){var u=this.cy.zoom(),d=i.core("selection-box-border-width").value/u;c.lineWidth=d,c.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",c.fillRect(this.selection[0],this.selection[1],this.selection[2]-this.selection[0],this.selection[3]-this.selection[1]),d>0&&(c.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",c.strokeRect(this.selection[0],this.selection[1],this.selection[2]-this.selection[0],this.selection[3]-this.selection[1]))}if(r.bgActivePosistion&&!this.hoverData.selecting){var u=this.cy.zoom(),h=r.bgActivePosistion;c.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",c.beginPath(),c.arc(h.x,h.y,i.core("active-bg-size").pfValue/u,0,2*Math.PI),c.fill()}var f=this.lastRedrawTime;if(this.showFps&&f){var g=Math.round(1e3/(f=Math.round(f))),v="1 frame = "+f+" ms = "+g+" fps";c.setTransform(1,0,0,1,0,0),c.fillStyle="rgba(255, 0, 0, 0.75)",c.strokeStyle="rgba(255, 0, 0, 0.75)",c.font="30px Arial",p||(p=c.measureText(v).actualBoundingBoxAscent),c.fillText(v,0,p),c.strokeRect(0,p+10,250,20),c.fillRect(0,p+10,250*Math.min(g/60,1),20)}o||(s[this.SELECT_BOX]=!1)}};var d_="u">typeof Float32Array?Float32Array:Array;function dA(){var e=new d_(9);return d_!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function dD(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function dM(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=n[0],f=n[1];return e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=h*r+f*o+c,e[7]=h*i+f*s+u,e[8]=h*a+f*l+d,e}function dP(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=Math.sin(n),f=Math.cos(n);return e[0]=f*r+h*o,e[1]=f*i+h*s,e[2]=f*a+h*l,e[3]=f*o-h*r,e[4]=f*s-h*i,e[5]=f*l-h*a,e[6]=c,e[7]=u,e[8]=d,e}function dR(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var dL=tb(function e(t,n,r,i){ty(this,e),this.debugID=Math.floor(1e4*Math.random()),this.r=t,this.texSize=n,this.texRows=r,this.texHeight=Math.floor(n/r),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(t,n,n),this.scratch=i(t,n,this.texHeight,"scratch")},[{key:"lock",value:function(){this.locked=!0}},{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(e){var t=e.w,n=e.h,r=this.texHeight,i=this.texSize,a=r/n,o=t*a,s=n*a;return o>i&&(a=i/t,o=t*a,s=n*a),{scale:a,texW:o,texH:s}}},{key:"draw",value:function(e,t,n){var r,i,a,o,s,l,c,u=this;if(this.locked)throw Error("can't draw, atlas is locked");var d=this.texSize,h=this.texRows,f=this.texHeight,p=this.getScale(t),g=p.scale,v=p.texW,x=p.texH,y=function(e,r){if(n&&r){var i=r.context,a=e.x,o=f*e.row;i.save(),i.translate(a,o),i.scale(g,g),n(i,t),i.restore()}},b=[null,null],w=function(){y(u.freePointer,u.canvas),b[0]={x:u.freePointer.x,y:u.freePointer.row*f,w:v,h:x},b[1]={x:u.freePointer.x+v,y:u.freePointer.row*f,w:0,h:x},u.freePointer.x+=v,u.freePointer.x==d&&(u.freePointer.x=0,u.freePointer.row++)},N=function(){u.freePointer.x=0,u.freePointer.row++};if(this.freePointer.x+v<=d)w();else{if(this.freePointer.row>=h-1)return!1;this.freePointer.x===d?(N(),w()):this.enableWrapping?(r=u.scratch,i=u.canvas,r.clear(),y({x:0,row:0},r),o=v-(a=d-u.freePointer.x),s=u.freePointer.x,l=u.freePointer.row*f,i.context.drawImage(r,0,0,a,f,s,l,a,f),b[0]={x:s,y:l,w:a,h:x},c=(u.freePointer.row+1)*f,i&&i.context.drawImage(r,a,0,o,f,0,c,o,f),b[1]={x:0,y:c,w:o,h:x},u.freePointer.x=o,u.freePointer.row++):(N(),w())}return this.keyToLocation.set(e,b),this.needsBuffer=!0,b}},{key:"getOffsets",value:function(e){return this.keyToLocation.get(e)}},{key:"isEmpty",value:function(){return 0===this.freePointer.x&&0===this.freePointer.row}},{key:"canFit",value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return!(this.freePointer.x+r>t)||this.freePointer.row<n-1}},{key:"bufferIfNeeded",value:function(e){var t;this.texture||(this.texture=(this.debugID,(t=e.createTexture()).buffer=function(n){e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},t.deleteTexture=function(){e.deleteTexture(t)},t)),this.needsBuffer&&(this.texture.buffer(this.canvas),this.needsBuffer=!1,this.locked&&(this.canvas=null,this.scratch=null))}},{key:"dispose",value:function(){this.texture&&(this.texture.deleteTexture(),this.texture=null),this.canvas=null,this.scratch=null,this.locked=!0}}]),dI=tb(function e(t,n,r,i){ty(this,e),this.r=t,this.texSize=n,this.texRows=r,this.createTextureCanvas=i,this.atlases=[],this.styleKeyToAtlas=new Map,this.markedKeys=new Set},[{key:"getKeys",value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:"_createAtlas",value:function(){return new dL(this.r,this.texSize,this.texRows,this.createTextureCanvas)}},{key:"_getScratchCanvas",value:function(){if(!this.scratch){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas,i=Math.floor(t/n);this.scratch=r(e,t,i,"scratch")}return this.scratch}},{key:"draw",value:function(e,t,n){var r=this.styleKeyToAtlas.get(e);return r||((r=this.atlases[this.atlases.length-1])&&r.canFit(t)||(r&&r.lock(),r=this._createAtlas(),this.atlases.push(r)),r.draw(e,t,n),this.styleKeyToAtlas.set(e,r)),r}},{key:"getAtlas",value:function(e){return this.styleKeyToAtlas.get(e)}},{key:"hasAtlas",value:function(e){return this.styleKeyToAtlas.has(e)}},{key:"markKeyForGC",value:function(e){this.markedKeys.add(e)}},{key:"gc",value:function(){var e=this,t=this.markedKeys;if(0===t.size)return void console.log("nothing to garbage collect");var n,r=[],i=new Map,a=null,o=tw(this.atlases);try{for(o.s();!(n=o.n()).done;)if(function(){var o=n.value,s=o.getKeys(),l=function(e,t){return e.intersection?e.intersection(t):new Set(tk(e).filter(function(e){return t.has(e)}))}(t,s);if(0===l.size)return r.push(o),s.forEach(function(e){return i.set(e,o)}),1;a||(a=e._createAtlas(),r.push(a));var c,u=tw(s);try{for(u.s();!(c=u.n()).done;){var d=c.value;if(!l.has(d)){var h=o.getOffsets(d),f=tj(h,2),p=f[0],g=f[1];a.canFit({w:p.w+g.w,h:p.h})||(a.lock(),a=e._createAtlas(),r.push(a)),o.canvas&&(e._copyTextureToNewAtlas(d,o,a),i.set(d,a))}}}catch(e){u.e(e)}finally{u.f()}o.dispose()}())continue}catch(e){o.e(e)}finally{o.f()}this.atlases=r,this.styleKeyToAtlas=i,this.markedKeys=new Set}},{key:"_copyTextureToNewAtlas",value:function(e,t,n){var r=tj(t.getOffsets(e),2),i=r[0],a=r[1];if(0===a.w)n.draw(e,i,function(e){e.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h)});else{var o=this._getScratchCanvas();o.clear(),o.context.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h),o.context.drawImage(t.canvas,a.x,a.y,a.w,a.h,i.w,0,a.w,a.h);var s=i.w+a.w,l=i.h;n.draw(e,{w:s,h:l},function(e){e.drawImage(o,0,0,s,l,0,0,s,l)})}}},{key:"getCounts",value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}]),dO=tb(function e(t,n){ty(this,e),this.r=t,this.globalOptions=n,this.atlasSize=n.webglTexSize,this.maxAtlasesPerBatch=n.webglTexPerBatch,this.renderTypes=new Map,this.collections=new Map,this.typeAndIdToKey=new Map},[{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"addAtlasCollection",value:function(e,t){var n=this.globalOptions,r=n.webglTexSize,i=n.createTextureCanvas,a=t.texRows,o=this._cacheScratchCanvas(i),s=new dI(this.r,r,a,o);this.collections.set(e,s)}},{key:"addRenderType",value:function(e,t){var n=t.collection;if(!this.collections.has(n))throw Error("invalid atlas collection name '".concat(n,"'"));var r=t6({type:e,atlasCollection:this.collections.get(n)},t);this.renderTypes.set(e,r)}},{key:"getRenderTypeOpts",value:function(e){return this.renderTypes.get(e)}},{key:"getAtlasCollection",value:function(e){return this.collections.get(e)}},{key:"_cacheScratchCanvas",value:function(e){var t=-1,n=-1,r=null;return function(i,a,o,s){return s?(r&&a==t&&o==n||(t=a,n=o,r=e(i,a,o)),r):e(i,a,o)}}},{key:"_key",value:function(e,t){return"".concat(e,"-").concat(t)}},{key:"invalidate",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.forceRedraw,a=void 0!==i&&i,o=r.filterEle,s=void 0===o?function(){return!0}:o,l=r.filterType,c=void 0===l?function(){return!0}:l,u=!1,d=!1,h=tw(e);try{for(h.s();!(t=h.n()).done;){var f=t.value;if(s(f)){var p,g=tw(this.renderTypes.values());try{for(g.s();!(p=g.n()).done;)!function(){var e=p.value,t=e.type;if(c(t)){var r=n.collections.get(e.collection),i=e.getKey(f),o=Array.isArray(i)?i:[i];if(a)o.forEach(function(e){return r.markKeyForGC(e)}),d=!0;else{var s=e.getID?e.getID(f):f.id(),l=n._key(t,s),h=n.typeAndIdToKey.get(l);void 0!==h&&!function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(o,h)&&(u=!0,n.typeAndIdToKey.delete(l),h.forEach(function(e){return r.markKeyForGC(e)}))}}}()}catch(e){g.e(e)}finally{g.f()}}}}catch(e){h.e(e)}finally{h.f()}return d&&(this.gc(),u=!1),u}},{key:"gc",value:function(){var e,t=tw(this.collections.values());try{for(t.s();!(e=t.n()).done;)e.value.gc()}catch(e){t.e(e)}finally{t.f()}}},{key:"getOrCreateAtlas",value:function(e,t,n,r){var i=this.renderTypes.get(t),a=this.collections.get(i.collection),o=!1,s=a.draw(r,n,function(t){i.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),i.drawElement(t,e,n,!0,!0),t.restore()):i.drawElement(t,e,n,!0,!0),o=!0});if(o){var l=i.getID?i.getID(e):e.id(),c=this._key(t,l);this.typeAndIdToKey.has(c)?this.typeAndIdToKey.get(c).push(r):this.typeAndIdToKey.set(c,[r])}return s}},{key:"getAtlasInfo",value:function(e,t){var n=this,r=this.renderTypes.get(t),i=r.getKey(e);return(Array.isArray(i)?i:[i]).map(function(i){var a=r.getBoundingBox(e,i),o=n.getOrCreateAtlas(e,t,a,i),s=tj(o.getOffsets(i),2),l=s[0];return{atlas:o,tex:l,tex1:l,tex2:s[1],bb:a}})}},{key:"getDebugInfo",value:function(){var e,t=[],n=tw(this.collections);try{for(n.s();!(e=n.n()).done;){var r=tj(e.value,2),i=r[0],a=r[1].getCounts(),o=a.keyCount,s=a.atlasCount;t.push({type:i,keyCount:o,atlasCount:s})}}catch(e){n.e(e)}finally{n.f()}return t}}]),dB=tb(function e(t){ty(this,e),this.globalOptions=t,this.atlasSize=t.webglTexSize,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.batchAtlases=[]},[{key:"getMaxAtlasesPerBatch",value:function(){return this.maxAtlasesPerBatch}},{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},function(e,t){return t})}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)}},{key:"getAtlasIndexForBatch",value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw Error("cannot add more atlases to batch");this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}}]),dF={name:"screen",screen:!0},dz={name:"picking",picking:!0},dV=tb(function e(t,n,r){ty(this,e),this.r=t,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=dw,this.atlasManager=new dO(t,r),this.batchManager=new dB(r),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(dF),this.pickingProgram=this._createShaderProgram(dz),this.vao=this._createVAO()},[{key:"addAtlasCollection",value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:"addTextureAtlasRenderType",value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:"addSimpleShapeRenderType",value:function(e,t){this.simpleShapeOptions.set(e,t)}},{key:"invalidate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.type,r=this.atlasManager;return n?r.invalidate(e,{filterType:function(e){return e===n},forceRedraw:!0}):r.invalidate(e)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(e){var t=this.gl,n="#version 300 es\n precision highp float;\n\n uniform mat3 uPanZoomMatrix;\n uniform int uAtlasSize;\n \n // instanced\n in vec2 aPosition; // a vertex from the unit square\n \n in mat3 aTransform; // used to transform verticies, eg into a bounding box\n in int aVertType; // the type of thing we are rendering\n\n // the z-index that is output when using picking mode\n in vec4 aIndex;\n \n // For textures\n in int aAtlasId; // which shader unit/atlas to use\n in vec4 aTex; // x/y/w/h of texture in atlas\n\n // for edges\n in vec4 aPointAPointB;\n in vec4 aPointCPointD;\n in vec2 aLineWidth; // also used for node border width\n\n // simple shapes\n in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]\n in vec4 aColor; // also used for edges\n in vec4 aBorderColor; // aLineWidth is used for border width\n\n // output values passed to the fragment shader\n out vec2 vTexCoord;\n out vec4 vColor;\n out vec2 vPosition;\n // flat values are not interpolated\n flat out int vAtlasId; \n flat out int vVertType;\n flat out vec2 vTopRight;\n flat out vec2 vBotLeft;\n flat out vec4 vCornerRadius;\n flat out vec4 vBorderColor;\n flat out vec2 vBorderWidth;\n flat out vec4 vIndex;\n \n void main(void) {\n int vid = gl_VertexID;\n vec2 position = aPosition; // TODO make this a vec3, simplifies some code below\n\n if(aVertType == ".concat(0,") {\n float texX = aTex.x; // texture coordinates\n float texY = aTex.y;\n float texW = aTex.z;\n float texH = aTex.w;\n\n if(vid == 1 || vid == 2 || vid == 4) {\n texX += texW;\n }\n if(vid == 2 || vid == 4 || vid == 5) {\n texY += texH;\n }\n\n float d = float(uAtlasSize);\n vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(4," || aVertType == ").concat(7," \n || aVertType == ").concat(5," || aVertType == ").concat(6,") { // simple shapes\n\n // the bounding box is needed by the fragment shader\n vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat\n vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat\n vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated\n\n // calculations are done in the fragment shader, just pass these along\n vColor = aColor;\n vCornerRadius = aCornerRadius;\n vBorderColor = aBorderColor;\n vBorderWidth = aLineWidth;\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(1,") {\n vec2 source = aPointAPointB.xy;\n vec2 target = aPointAPointB.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n // stretch the unit square into a long skinny rectangle\n vec2 xBasis = target - source;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;\n\n gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);\n vColor = aColor;\n } \n else if(aVertType == ").concat(2,") {\n vec2 pointA = aPointAPointB.xy;\n vec2 pointB = aPointAPointB.zw;\n vec2 pointC = aPointCPointD.xy;\n vec2 pointD = aPointCPointD.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 p0, p1, p2, pos;\n if(position.x == 0.0) { // The left side of the unit square\n p0 = pointA;\n p1 = pointB;\n p2 = pointC;\n pos = position;\n } else { // The right side of the unit square, use same approach but flip the geometry upside down\n p0 = pointD;\n p1 = pointC;\n p2 = pointB;\n pos = vec2(0.0, -position.y);\n }\n\n vec2 p01 = p1 - p0;\n vec2 p12 = p2 - p1;\n vec2 p21 = p1 - p2;\n\n // Find the normal vector.\n vec2 tangent = normalize(normalize(p12) + normalize(p01));\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n // Find the vector perpendicular to p0 -> p1.\n vec2 p01Norm = normalize(vec2(-p01.y, p01.x));\n\n // Determine the bend direction.\n float sigma = sign(dot(p01 + p21, normal));\n float width = aLineWidth[0];\n\n if(sign(pos.y) == -sigma) {\n // This is an intersecting vertex. Adjust the position so that there's no overlap.\n vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n } else {\n // This is a non-intersecting vertex. Treat it like a mitre join.\n vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n }\n\n vColor = aColor;\n } \n else if(aVertType == ").concat(3," && vid < 3) {\n // massage the first triangle into an edge arrow\n if(vid == 0)\n position = vec2(-0.15, -0.3);\n if(vid == 1)\n position = vec2( 0.0, 0.0);\n if(vid == 2)\n position = vec2( 0.15, -0.3);\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space\n }\n\n vAtlasId = aAtlasId;\n vVertType = aVertType;\n vIndex = aIndex;\n }\n "),r=this.batchManager.getIndexArray(),i=function(e,t,n){var r=db(e,e.VERTEX_SHADER,t),i=db(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS))throw Error("Could not initialize shaders");return a}(t,n,"#version 300 es\n precision highp float;\n\n // declare texture unit for each texture atlas in the batch\n ".concat(r.map(function(e){return"uniform sampler2D uTexture".concat(e,";")}).join("\n "),"\n\n uniform vec4 uBGColor;\n uniform float uZoom;\n\n in vec2 vTexCoord;\n in vec4 vColor;\n in vec2 vPosition; // model coordinates\n\n flat in int vAtlasId;\n flat in vec4 vIndex;\n flat in int vVertType;\n flat in vec2 vTopRight;\n flat in vec2 vBotLeft;\n flat in vec4 vCornerRadius;\n flat in vec4 vBorderColor;\n flat in vec2 vBorderWidth;\n\n out vec4 outColor;\n\n ").concat("\n float circleSD(vec2 p, float r) {\n return distance(vec2(0), p) - r; // signed distance\n }\n","\n ").concat("\n float rectangleSD(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);\n }\n","\n ").concat("\n float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {\n cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;\n cr.x = (p.y > 0.0) ? cr.x : cr.y;\n vec2 q = abs(p) - b + cr.x;\n return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;\n }\n","\n ").concat("\n float ellipseSD(vec2 p, vec2 ab) {\n p = abs( p ); // symmetry\n\n // find root with Newton solver\n vec2 q = ab*(p-ab);\n float w = (q.x<q.y)? 1.570796327 : 0.0;\n for( int i=0; i<5; i++ ) {\n vec2 cs = vec2(cos(w),sin(w));\n vec2 u = ab*vec2( cs.x,cs.y);\n vec2 v = ab*vec2(-cs.y,cs.x);\n w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));\n }\n \n // compute final point and distance\n float d = length(p-ab*vec2(cos(w),sin(w)));\n \n // return signed distance\n return (dot(p/ab,p/ab)>1.0) ? d : -d;\n }\n","\n\n vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha\n return vec4( \n top.rgb + (bot.rgb * (1.0 - top.a)),\n top.a + (bot.a * (1.0 - top.a)) \n );\n }\n\n vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance\n // scale to the zoom level so that borders don't look blurry when zoomed in\n // note 1.5 is an aribitrary value chosen because it looks good\n return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); \n }\n\n void main(void) {\n if(vVertType == ").concat(0,") {\n // look up the texel from the texture unit\n ").concat(r.map(function(e){return"if(vAtlasId == ".concat(e,") outColor = texture(uTexture").concat(e,", vTexCoord);")}).join("\n else "),"\n } \n else if(vVertType == ").concat(3,") {\n // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';\n outColor = blend(vColor, uBGColor);\n outColor.a = 1.0; // make opaque, masks out line under arrow\n }\n else if(vVertType == ").concat(4," && vBorderWidth == vec2(0.0)) { // simple rectangle with no border\n outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done\n }\n else if(vVertType == ").concat(4," || vVertType == ").concat(7," \n || vVertType == ").concat(5," || vVertType == ").concat(6,") { // use SDF\n\n float outerBorder = vBorderWidth[0];\n float innerBorder = vBorderWidth[1];\n float borderPadding = outerBorder * 2.0;\n float w = vTopRight.x - vBotLeft.x - borderPadding;\n float h = vTopRight.y - vBotLeft.y - borderPadding;\n vec2 b = vec2(w/2.0, h/2.0); // half width, half height\n vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center\n\n float d; // signed distance\n if(vVertType == ").concat(4,") {\n d = rectangleSD(p, b);\n } else if(vVertType == ").concat(7," && w == h) {\n d = circleSD(p, b.x); // faster than ellipse\n } else if(vVertType == ").concat(7,") {\n d = ellipseSD(p, b);\n } else {\n d = roundRectangleSD(p, b, vCornerRadius.wzyx);\n }\n\n // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling\n // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box\n if(d > 0.0) {\n if(d > outerBorder) {\n discard;\n } else {\n outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);\n }\n } else {\n if(d > innerBorder) {\n vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;\n vec4 innerBorderColor = blend(vBorderColor, vColor);\n outColor = distInterp(innerBorderColor, outerColor, d);\n } \n else {\n vec4 outerColor;\n if(innerBorder == 0.0 && outerBorder == 0.0) {\n outerColor = vec4(0);\n } else if(innerBorder == 0.0) {\n outerColor = vBorderColor;\n } else {\n outerColor = blend(vBorderColor, vColor);\n }\n outColor = distInterp(vColor, outerColor, d - innerBorder);\n }\n }\n }\n else {\n outColor = vColor;\n }\n\n ").concat(e.picking?"if(outColor.a == 0.0) discard;\n else outColor = vIndex;":"","\n }\n "));i.aPosition=t.getAttribLocation(i,"aPosition"),i.aIndex=t.getAttribLocation(i,"aIndex"),i.aVertType=t.getAttribLocation(i,"aVertType"),i.aTransform=t.getAttribLocation(i,"aTransform"),i.aAtlasId=t.getAttribLocation(i,"aAtlasId"),i.aTex=t.getAttribLocation(i,"aTex"),i.aPointAPointB=t.getAttribLocation(i,"aPointAPointB"),i.aPointCPointD=t.getAttribLocation(i,"aPointCPointD"),i.aLineWidth=t.getAttribLocation(i,"aLineWidth"),i.aColor=t.getAttribLocation(i,"aColor"),i.aCornerRadius=t.getAttribLocation(i,"aCornerRadius"),i.aBorderColor=t.getAttribLocation(i,"aBorderColor"),i.uPanZoomMatrix=t.getUniformLocation(i,"uPanZoomMatrix"),i.uAtlasSize=t.getUniformLocation(i,"uAtlasSize"),i.uBGColor=t.getUniformLocation(i,"uBGColor"),i.uZoom=t.getUniformLocation(i,"uZoom"),i.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)i.uTextures.push(t.getUniformLocation(i,"uTexture".concat(a)));return i}},{key:"_createVAO",value:function(){var e,t,n,r,i,a,o=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=o.length/2;var s=this.maxInstances,l=this.gl,c=this.program,u=l.createVertexArray();return l.bindVertexArray(u),e=c.aPosition,n=(t=tj(dE(l,"vec2"),2))[0],i=dT(l,r=t[1],o),a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,a),l.bufferData(l.ARRAY_BUFFER,i,l.STATIC_DRAW),r===l.FLOAT?l.vertexAttribPointer(e,n,r,!1,0,0):r===l.INT&&l.vertexAttribIPointer(e,n,r,0,0),l.enableVertexAttribArray(e),l.bindBuffer(l.ARRAY_BUFFER,null),this.transformBuffer=function(e,t,n){for(var r=new Float32Array(9*t),i=Array(t),a=0;a<t;a++){var o=9*a*4;i[a]=new Float32Array(r.buffer,o,9)}var s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,r.byteLength,e.DYNAMIC_DRAW);for(var l=0;l<3;l++){var c=n+l;e.enableVertexAttribArray(c),e.vertexAttribPointer(c,3,e.FLOAT,!1,36,12*l),e.vertexAttribDivisor(c,1)}return e.bindBuffer(e.ARRAY_BUFFER,null),s.getMatrixView=function(e){return i[e]},s.setData=function(e,t){i[t].set(e,0)},s.bufferSubData=function(){e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferSubData(e.ARRAY_BUFFER,0,r)},s}(l,s,c.aTransform),this.indexBuffer=dS(l,s,"vec4",c.aIndex),this.vertTypeBuffer=dS(l,s,"int",c.aVertType),this.atlasIdBuffer=dS(l,s,"int",c.aAtlasId),this.texBuffer=dS(l,s,"vec4",c.aTex),this.pointAPointBBuffer=dS(l,s,"vec4",c.aPointAPointB),this.pointCPointDBuffer=dS(l,s,"vec4",c.aPointCPointD),this.lineWidthBuffer=dS(l,s,"vec2",c.aLineWidth),this.colorBuffer=dS(l,s,"vec4",c.aColor),this.cornerRadiusBuffer=dS(l,s,"vec4",c.aCornerRadius),this.borderColorBuffer=dS(l,s,"vec4",c.aBorderColor),l.bindVertexArray(null),u}},{key:"buffers",get:function(){var e=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(e){return tJ(e,"Buffer")}).map(function(t){return e[t]})),this._buffers}},{key:"startFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dF;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(e,t){return!!e.visible()&&(!t||!t.isVisible||t.isVisible(e))}},{key:"drawTexture",value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(1===o)return;if(2==o)return void this.drawPickingRectangle(e,t,n)}var s,l=tw(r.getAtlasInfo(e,n));try{for(l.s();!(s=l.n()).done;){var c=s.value,u=c.atlas,d=c.tex1,h=c.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var f=i.getAtlasIndexForBatch(u),p=0,g=[[d,!0],[h,!1]];p<g.length;p++){var v=tj(g[p],2),x=v[0],y=v[1];if(0!=x.w){var b=this.instanceCount;this.vertTypeBuffer.getView(b)[0]=0;var w=this.indexBuffer.getView(b);dC(t,w),this.atlasIdBuffer.getView(b)[0]=f;var N=this.texBuffer.getView(b);N[0]=x.x,N[1]=x.y,N[2]=x.w,N[3]=x.h;var j=this.transformBuffer.getMatrixView(b);this.setTransformMatrix(e,j,a,c,y),this.instanceCount++,!y&&this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){l.e(e)}finally{l.f()}}}},{key:"setTransformMatrix",value:function(e,t,n,r){var i=!(arguments.length>4)||void 0===arguments[4]||arguments[4],a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,l=r.tex2,c=s.w/(s.w+l.w);i||(c=1-c);var u=this._getAdjustedBB(o,a,i,c);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),h=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,h,n,e)}}},{key:"_applyTransformMatrix",value:function(e,t,n,r){dD(e);var i,a,o=n.getRotation?n.getRotation(r):0;if(0!==o){var s=n.getRotationPoint(r);dM(e,e,[s.x,s.y]),dP(e,e,o);var l=n.getRotationOffset(r);i=l.x+(t.xOffset||0),a=l.y+(t.yOffset||0)}else i=t.x1,a=t.y1;dM(e,e,[i,a]),dR(e,e,[t.w,t.h])}},{key:"_getAdjustedBB",value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,l=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var c=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(i+=c=o-u,o=u),{x1:i,y1:a,w:o,h:s,xOffset:c,yOffset:l}}},{key:"drawPickingRectangle",value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=4,dC(t,this.indexBuffer.getView(i)),dk([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(void 0===a||r.isSimple&&!r.isSimple(e))return void this.drawTexture(e,t,n);var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,5===a||6===a){var s=r.getBoundingBox(e),l=this._getCornerRadius(e,i.radius,s),c=this.cornerRadiusBuffer.getView(o);c[0]=l,c[1]=l,c[2]=l,c[3]=l,6===a&&(c[0]=0,c[2]=0)}dC(t,this.indexBuffer.getView(o)),dk(e.pstyle(i.color).value,e.pstyle(i.opacity).value,this.colorBuffer.getView(o));var u=this.lineWidthBuffer.getView(o);if(u[0]=0,u[1]=0,i.border){var d=e.pstyle("border-width").value;if(d>0){dk(e.pstyle("border-color").value,e.pstyle("border-opacity").value,this.borderColorBuffer.getView(o));var h=e.pstyle("border-position").value;if("inside"===h)u[0]=0,u[1]=-d;else if("outside"===h)u[0]=d,u[1]=0;else{var f=d/2;u[0]=f,u[1]=-f}}}var p=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,p,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"_getVertTypeForShape",value:function(e,t){switch(e.pstyle(t).value){case"rectangle":return 4;case"ellipse":return 7;case"roundrectangle":case"round-rectangle":return 5;case"bottom-round-rectangle":return 6;default:return}}},{key:"_getCornerRadius",value:function(e,t,n){var r=n.w,i=n.h;return"auto"===e.pstyle(t).value?rQ(r,i):Math.min(e.pstyle(t).pfValue,i/2,r/2)}},{key:"drawEdgeArrow",value:function(e,t,n){if(e.visible()){var r,i,a,o=e._private.rscratch;if(("source"===n?(r=o.arrowStartX,i=o.arrowStartY,a=o.srcArrowAngle):(r=o.arrowEndX,i=o.arrowEndY,a=o.tgtArrowAngle),!(isNaN(r)||null==r||isNaN(i)||null==i||isNaN(a))&&null!=a)&&"none"!==e.pstyle(n+"-arrow-shape").value){var s=e.pstyle(n+"-arrow-color").value,l=e.pstyle("opacity").value,c=e.pstyle("line-opacity").value,u=e.pstyle("width").pfValue,d=e.pstyle("arrow-scale").value,h=this.r.getArrowWidth(u,d),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);dD(p),dM(p,p,[r,i]),dR(p,p,[h,h]),dP(p,p,a),this.vertTypeBuffer.getView(f)[0]=3,dC(t,this.indexBuffer.getView(f)),dk(s,l*c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"drawEdgeLine",value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle("opacity").value,i=e.pstyle("line-opacity").value,a=e.pstyle("width").pfValue,o=e.pstyle("line-color").value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),4==n.length){var l=this.instanceCount;this.vertTypeBuffer.getView(l)[0]=1,dC(t,this.indexBuffer.getView(l)),dk(o,s,this.colorBuffer.getView(l)),this.lineWidthBuffer.getView(l)[0]=a;var c=this.pointAPointBBuffer.getView(l);c[0]=n[0],c[1]=n[1],c[2]=n[2],c[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var u=0;u<n.length-2;u+=2){var d=this.instanceCount;this.vertTypeBuffer.getView(d)[0]=2,dC(t,this.indexBuffer.getView(d)),dk(o,s,this.colorBuffer.getView(d)),this.lineWidthBuffer.getView(d)[0]=a;var h=n[u-2],f=n[u-1],p=n[u],g=n[u+1],v=n[u+2],x=n[u+3],y=n[u+4],b=n[u+5];0==u&&(h=2*p-v+.001,f=2*g-x+.001),u==n.length-4&&(y=2*v-p+.001,b=2*x-g+.001);var w=this.pointAPointBBuffer.getView(d);w[0]=h,w[1]=f,w[2]=p,w[3]=g;var N=this.pointCPointDBuffer.getView(d);N[0]=v,N[1]=x,N[2]=y,N[3]=b,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(e){var t=e._private.rscratch;return!(t.badLine||null==t.allpts||isNaN(t.allpts[0]))}},{key:"_getEdgePoints",value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(4==n.length)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:"_getNumSegments",value:function(e){return Math.min(15,this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(e,t){if(4==e.length)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(0==r)n[0]=e[0],n[1]=e[1];else if(r==t)n[2*r]=e[e.length-2],n[2*r+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,2*r)}return n}},{key:"_setCurvePoint",value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a<i.length;a+=2){var o=(1-t)*e[a]+t*e[a+2],s=(1-t)*e[a+1]+t*e[a+3];i[a]=o,i[a+1]=s}return this._setCurvePoint(i,t,n,r)}}},{key:"endBatch",value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(0!==r){var i,a,o=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(o),e.bindVertexArray(t);var s,l=tw(this.buffers);try{for(l.s();!(s=l.n()).done;)s.value.bufferSubData(r)}catch(e){l.e(e)}finally{l.f()}for(var c=this.batchManager.getAtlases(),u=0;u<c.length;u++)c[u].bufferIfNeeded(e);for(var d=0;d<c.length;d++)e.activeTexture(e.TEXTURE0+d),e.bindTexture(e.TEXTURE_2D,c[d].texture),e.uniform1i(o.uTextures[d],d);e.uniform1f(o.uZoom,(a=(i=this.r).pixelRatio,i.cy.zoom()*a)),e.uniformMatrix3fv(o.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(o.uAtlasSize,this.batchManager.getAtlasSize());var h=dk(this.bgColor,1);e.uniform4fv(o.uBGColor,h),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:c.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}]),dH={};function dU(e,t){return nG(e._private.rscratch,"labelWrapCachedLines",t)||[]}dH.initWebgl=function(e,t){var n,r,i,a,o,s,l,c,u=this,d=u.data.contexts[u.WEBGL];e.bgColor=ne((n=u.cy.container())&&n.style&&n.style.backgroundColor||"white"),e.webglTexSize=Math.min(e.webglTexSize,d.getParameter(d.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,d.getParameter(d.MAX_TEXTURE_IMAGE_UNITS)),u.webglDebug=e.webglDebug,u.webglDebugShowAtlases=e.webglDebugShowAtlases,l=d.createFramebuffer(),d.bindFramebuffer(d.FRAMEBUFFER,l),c=d.createTexture(),d.bindTexture(d.TEXTURE_2D,c),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,c,0),d.bindFramebuffer(d.FRAMEBUFFER,null),l.setFramebufferAttachmentSizes=function(e,t){d.bindTexture(d.TEXTURE_2D,c),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,e,t,0,d.RGBA,d.UNSIGNED_BYTE,null)},u.pickingFrameBuffer=l,u.pickingFrameBuffer.needsDraw=!0,u.drawing=new dV(u,d,e);var h=function(e){return function(t){return u.getTextAngle(t,e)}},f=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},p=function(e){return function(t){return t.pstyle("".concat(e,"-opacity")).value>0}},g=function(e){return"yes"===e.pstyle("text-events").strValue?2:1},v=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};u.drawing.addAtlasCollection("node",{texRows:e.webglTexRowsNodes}),u.drawing.addAtlasCollection("label",{texRows:e.webglTexRows}),u.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),u.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:v,isSimple:dj,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),u.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:v,isVisible:p("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),u.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:v,isVisible:p("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),u.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:g,getKey:dG(t.getLabelKey,null),getBoundingBox:dY(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:h(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:f("label")}),u.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:g,getKey:dG(t.getSourceLabelKey,"source"),getBoundingBox:dY(t.getSourceLabelBox,"source"),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:h("source"),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:f("source-label")}),u.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:g,getKey:dG(t.getTargetLabelKey,"target"),getBoundingBox:dY(t.getTargetLabelBox,"target"),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:h("target"),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:f("target-label")});var x=nd(function(){console.log("garbage collect flag set"),u.data.gc=!0},1e4);u.onUpdateEleCalcs(function(e,t){var n=!1;t&&t.length>0&&(n|=u.drawing.invalidate(t)),n&&x()}),i=(r=u).render,r.render=function(e){e=e||{};var t,n,a,o,s=r.cy;r.webgl&&(s.zoom()>7.99?((n=(t=r).data.contexts[t.WEBGL]).clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),i.call(r,e)):(a=r,(o=function(e){e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a.canvasWidth,a.canvasHeight),e.restore()})(a.data.contexts[a.NODE]),o(a.data.contexts[a.DRAG]),dq(r,e,dF)))},a=r.matchCanvasSize,r.matchCanvasSize=function(e){a.call(r,e),r.pickingFrameBuffer.setFramebufferAttachmentSizes(r.canvasWidth,r.canvasHeight),r.pickingFrameBuffer.needsDraw=!0},r.findNearestElements=function(e,t,n,i){return function(e,t,n){var r,i,a,o=function(e,t,n,r,i){var a=dN(e),o=a.pan,s=a.zoom,l=tj((g=t*s+o.x,v=n*s+o.y,[g,v=Math.round(e.canvasHeight-v)]),2),c=l[0],u=l[1],d=e.data.contexts[e.WEBGL];d.bindFramebuffer(d.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(d.viewport(0,0,d.canvas.width,d.canvas.height),dq(e,null,dz),e.pickingFrameBuffer.needsDraw=!1);var h=new Uint8Array(144);d.readPixels(c-3,u-3,6,6,d.RGBA,d.UNSIGNED_BYTE,h),d.bindFramebuffer(d.FRAMEBUFFER,null);for(var f=new Set,p=0;p<36;p++){var g,v,x,y=(x=h.slice(4*p,4*p+4))[0]+(x[1]<<8)+(x[2]<<16)+(x[3]<<24)-1;y>=0&&f.add(y)}return f}(e,t,n),s=e.getCachedZSortedEles(),l=tw(o);try{for(l.s();!(a=l.n()).done;){var c=s[a.value];if(!r&&c.isNode()&&(r=c),!i&&c.isEdge()&&(i=c),r&&i)break}}catch(e){l.e(e)}finally{l.f()}return[r,i].filter(Boolean)}(r,e,t)},o=r.invalidateCachedZSortedEles,r.invalidateCachedZSortedEles=function(){o.call(r),r.pickingFrameBuffer.needsDraw=!0},s=r.notify,r.notify=function(e,t){s.call(r,e,t),"viewport"===e||"bounds"===e?r.pickingFrameBuffer.needsDraw=!0:"background"===e&&r.drawing.invalidate(t,{type:"node-body"})}};var dG=function(e,t){return function(n){var r=e(n),i=dU(n,t);return i.length>1?i.map(function(e,t){return"".concat(r,"_").concat(t)}):r}},dY=function(e,t){return function(n,r){var i=e(n);if("string"==typeof r){var a=r.indexOf("_");if(a>0){var o=Number(r.substring(a+1)),s=dU(n,t),l=i.h/s.length,c=l*o,u=i.y1+c;return{x1:i.x1,w:i.w,y1:u,h:l,yOffset:c}}}return i}};function dX(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=dN(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function dW(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,"node-underlay"),r.drawNode(n,t,"node-body"),r.drawTexture(n,t,"label"),r.drawNode(n,t,"node-overlay")):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,"source"),r.drawEdgeArrow(n,t,"target"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"edge-source-label"),r.drawTexture(n,t,"edge-target-label"))}function dq(e,t,n){e.webglDebug&&(X=performance.now());var r=e.drawing,i=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&e.drawSelectionRectangle(t,function(t){return dX(e,t)}),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var a,o,s,l,c,u,d,h,f,p,g,v,x,y,b,w,N,j,k,C,E,T,S,_,A,D,M,P,R,L,I,O=e.data.contexts[e.WEBGL];n.screen?(O.clearColor(0,0,0,0),O.enable(O.BLEND),O.blendFunc(O.ONE,O.ONE_MINUS_SRC_ALPHA)):O.disable(O.BLEND),O.clear(O.COLOR_BUFFER_BIT|O.DEPTH_BUFFER_BIT),O.viewport(0,0,O.canvas.width,O.canvas.height);var B=(a=e.canvasWidth,o=e.canvasHeight,l=(s=dN(e)).pan,c=s.zoom,dM(u=dA(),u,[l.x,l.y]),dR(u,u,[c,c]),h=d=dA(),h[0]=2/a,h[1]=0,h[2]=0,h[3]=0,h[4]=-2/o,h[5]=0,h[6]=-1,h[7]=1,h[8]=1,p=f=dA(),g=d[0],v=d[1],x=d[2],y=d[3],b=d[4],w=d[5],N=d[6],j=d[7],k=d[8],C=u[0],E=u[1],T=u[2],S=u[3],_=u[4],A=u[5],D=u[6],M=u[7],P=u[8],p[0]=C*g+E*y+T*N,p[1]=C*v+E*b+T*j,p[2]=C*x+E*w+T*k,p[3]=S*g+_*y+A*N,p[4]=S*v+_*b+A*j,p[5]=S*x+_*w+A*k,p[6]=D*g+M*y+P*N,p[7]=D*v+M*b+P*j,p[8]=D*x+M*w+P*k,f),F=e.getCachedZSortedEles();if(i=F.length,r.startFrame(B,n),n.screen){for(var z=0;z<F.nondrag.length;z++)dW(e,z,F.nondrag[z]);for(var V=0;V<F.drag.length;V++)dW(e,V,F.drag[V])}else if(n.picking)for(var H=0;H<F.length;H++)dW(e,H,F[H]);r.endFrame(),n.screen&&e.webglDebugShowAtlases&&((R=e.data.contexts[e.NODE]).save(),dX(e,R),R.strokeStyle="rgba(0, 0, 0, 0.3)",R.beginPath(),R.moveTo(-1e3,0),R.lineTo(1e3,0),R.stroke(),R.beginPath(),R.moveTo(0,-1e3),R.lineTo(0,1e3),R.stroke(),R.restore(),I=0,(L=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s<o.length;s++){var l=o[s].canvas;if(l){var c=l.width,u=l.height,d=c*s,h=l.height*r;a.save(),a.scale(.4,.4),a.drawImage(l,d,h),a.strokeStyle="black",a.rect(d,h,c,u),a.stroke(),a.restore()}}})(e.drawing,"node",I++),L(e.drawing,"label",I++)),e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1}if(e.webglDebug){var U=Math.ceil(performance.now()-X),G=r.getDebugInfo(),Y=["".concat(i," elements"),"".concat(G.totalInstances," instances"),"".concat(G.batchCount," batches"),"".concat(G.totalAtlases," atlases"),"".concat(G.wrappedCount," wrapped textures"),"".concat(G.simpleCount," simple shapes")].join(", ");console.log("WebGL (".concat(n.name,") - frame time ").concat(U,"ms")),console.log("Totals:"),console.log(" ".concat(Y)),console.log("Texture Atlases Used:");var X,W,q=tw(G.atlasInfo);try{for(q.s();!(W=q.n()).done;){var $=W.value;console.log(" ".concat($.type,": ").concat($.keyCount," keys, ").concat($.atlasCount," atlases"))}}catch(e){q.e(e)}finally{q.f()}console.log("")}e.data.gc&&(console.log("Garbage Collect!"),e.data.gc=!1,r.gc())}var d$={};d$.drawPolygonPath=function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var l=1;l<a.length/2;l++)e.lineTo(t+o*a[2*l],n+s*a[2*l+1]);e.closePath()},d$.drawRoundPolygonPath=function(e,t,n,r,i,a,o){o.forEach(function(t){return u_(e,t)}),e.closePath()},d$.drawRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,l="auto"===a?rQ(r,i):Math.min(a,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,l),e.arcTo(t+o,n+s,t,n+s,l),e.arcTo(t-o,n+s,t-o,n,l),e.arcTo(t-o,n-s,t,n-s,l),e.lineTo(t,n-s),e.closePath()},d$.drawBottomRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,l="auto"===a?rQ(r,i):a;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,l),e.arcTo(t-o,n+s,t-o,n,l),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},d$.drawCutRectanglePath=function(e,t,n,r,i,a,o){var s=r/2,l=i/2,c="auto"===o?r0():o;e.beginPath&&e.beginPath(),e.moveTo(t-s+c,n-l),e.lineTo(t+s-c,n-l),e.lineTo(t+s,n-l+c),e.lineTo(t+s,n+l-c),e.lineTo(t+s-c,n+l),e.lineTo(t-s+c,n+l),e.lineTo(t-s,n+l-c),e.lineTo(t-s,n-l+c),e.closePath()},d$.drawBarrelPath=function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,l=t+a,c=n-o,u=n+o,d=r1(r,i),h=d.widthOffset,f=d.heightOffset,p=d.ctrlPtOffsetPct*h;e.beginPath&&e.beginPath(),e.moveTo(s,c+f),e.lineTo(s,u-f),e.quadraticCurveTo(s+p,u,s+h,u),e.lineTo(l-h,u),e.quadraticCurveTo(l-p,u,l,u-f),e.lineTo(l,c+f),e.quadraticCurveTo(l-p,c,l-h,c),e.lineTo(s+h,c),e.quadraticCurveTo(s+p,c,s,c+f),e.closePath()};for(var dK={},dZ={},dQ=Math.PI/40,dJ=0*Math.PI;dJ<2*Math.PI;dJ+=dQ)dK[dJ]=Math.sin(dJ),dZ[dJ]=Math.cos(dJ);d$.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,l=i/2,c=0*Math.PI;c<2*Math.PI;c+=dQ)a=t-s*dK[c]*0+s*dZ[c]*1,o=n+l*dZ[c]*0+l*dK[c]*1,0===c?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var d0={};function d1(e){var t=e.indexOf(",");return e.substr(t+1)}function d2(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case"blob-promise":return new i8(function(r,i){try{t.toBlob(function(e){null!=e?r(e):i(Error("`canvas.toBlob()` sent a null value in its callback"))},n,e.quality)}catch(e){i(e)}});case"blob":return function(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}(d1(r()),n);case"base64":return d1(r());default:return r()}}d0.createBuffer=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,[n,n.getContext("2d")]},d0.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=tF(e.maxWidth)||tF(e.maxHeight),s=this.getPixelRatio(),l=1;if(void 0!==e.scale)i*=e.scale,a*=e.scale,l=e.scale;else if(o){var c=1/0,u=1/0;tF(e.maxWidth)&&(c=l*e.maxWidth/i),tF(e.maxHeight)&&(u=l*e.maxHeight/a),i*=l=Math.min(c,u),a*=l}o||(i*=s,a*=s,l*=s);var d=document.createElement("canvas");d.width=i,d.height=a,d.style.width=i+"px",d.style.height=a+"px";var h=d.getContext("2d");if(i>0&&a>0){h.clearRect(0,0,i,a),h.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)h.translate(-n.x1*l,-n.y1*l),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(n.x1*l,n.y1*l);else{var p=t.pan(),g={x:p.x*l,y:p.y*l};l*=t.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,i,a),h.fill())}return d},d0.png=function(e){return d2(e,this.bufferCanvasImage(e),"image/png")},d0.jpg=function(e){return d2(e,this.bufferCanvasImage(e),"image/jpeg")};var d5={};d5.nodeShapeImpl=function(e,t,n,r,i,a,o,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,i,a);case"polygon":return this.drawPolygonPath(t,n,r,i,a,o);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,i,a,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,i,a,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case"barrel":return this.drawBarrelPath(t,n,r,i,a)}};var d3=d4.prototype;function d4(e){var t=this,n=t.cy.window().document;e.webgl&&(d3.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),t.data={canvases:Array(d3.CANVAS_LAYERS),contexts:Array(d3.CANVAS_LAYERS),canvasNeedsRedraw:Array(d3.CANVAS_LAYERS),bufferCanvases:Array(d3.BUFFER_COUNT),bufferContexts:Array(d3.CANVAS_LAYERS)};var r="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";t.data.canvasContainer=n.createElement("div");var a=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,a.position="relative",a.zIndex="0",a.overflow="hidden";var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=i;var s={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};t_&&t_.userAgent.match(/msie|trident|edge/i)&&(s["-ms-touch-action"]="none",s["touch-action"]="none");for(var l=0;l<d3.CANVAS_LAYERS;l++){var c=t.data.canvases[l]=n.createElement("canvas"),u=d3.CANVAS_TYPES[l];t.data.contexts[l]=c.getContext(u),t.data.contexts[l]||nP("Could not create canvas of type "+u),Object.keys(s).forEach(function(e){c.style[e]=s[e]}),c.style.position="absolute",c.setAttribute("data-id","layer"+l),c.style.zIndex=String(d3.CANVAS_LAYERS-l),t.data.canvasContainer.appendChild(c),t.data.canvasNeedsRedraw[l]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[d3.NODE].setAttribute("data-id","layer"+d3.NODE+"-node"),t.data.canvases[d3.SELECT_BOX].setAttribute("data-id","layer"+d3.SELECT_BOX+"-selectbox"),t.data.canvases[d3.DRAG].setAttribute("data-id","layer"+d3.DRAG+"-drag"),t.data.canvases[d3.WEBGL]&&t.data.canvases[d3.WEBGL].setAttribute("data-id","layer"+d3.WEBGL+"-webgl");for(var l=0;l<d3.BUFFER_COUNT;l++)t.data.bufferCanvases[l]=n.createElement("canvas"),t.data.bufferContexts[l]=t.data.bufferCanvases[l].getContext("2d"),t.data.bufferCanvases[l].style.position="absolute",t.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),t.data.bufferCanvases[l].style.zIndex=String(-l-1),t.data.bufferCanvases[l].style.visibility="hidden";t.pathsEnabled=!0;var d=rm(),h=function(e){return{x:-e.w/2,y:-e.h/2}},f=function(e){return e[0]._private.nodeKey},p=function(e){return e[0]._private.labelStyleKey},g=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},x=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},y=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"main",a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"source",a)},w=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"target",a)},N=function(e){return e.boundingBox(),e[0]._private.bodyBounds},j=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||d},k=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||d},C=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||d},E=function(e,t){return t},T=function(e){var t;return{x:((t=N(e)).x1+t.x2)/2,y:(t.y1+t.y2)/2}},S=function(e,t,n){var r=e?e+"-":"";return{x:t.x+n.pstyle(r+"text-margin-x").pfValue,y:t.y+n.pstyle(r+"text-margin-y").pfValue}},_=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},A=function(e){return S("",_(e,"labelX","labelY"),e)},D=function(e){return S("source",_(e,"sourceLabelX","sourceLabelY"),e)},M=function(e){return S("target",_(e,"targetLabelX","targetLabelY"),e)},P=function(e){return h(N(e))},R=function(e){return h(k(e))},L=function(e){return h(C(e))},I=function(e){var t=j(e),n=h(j(e));if(e.isNode()){switch(e.pstyle("text-halign").value){case"left":n.x=-t.w-(t.leftPad||0);break;case"right":n.x=-(t.rightPad||0)}switch(e.pstyle("text-valign").value){case"top":n.y=-t.h-(t.topPad||0);break;case"bottom":n.y=-(t.botPad||0)}}return n},O=t.data.eleTxrCache=new u5(t,{getKey:f,doesEleInvalidateKey:function(e){var t=e[0]._private;return t.oldBackgroundTimestamp!==t.backgroundTimestamp},drawElement:x,getBoundingBox:N,getRotationPoint:T,getRotationOffset:P,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),B=t.data.lblTxrCache=new u5(t,{getKey:p,drawElement:y,getBoundingBox:j,getRotationPoint:A,getRotationOffset:I,isVisible:E}),F=t.data.slbTxrCache=new u5(t,{getKey:g,drawElement:b,getBoundingBox:k,getRotationPoint:D,getRotationOffset:R,isVisible:E}),z=t.data.tlbTxrCache=new u5(t,{getKey:v,drawElement:w,getBoundingBox:C,getRotationPoint:M,getRotationOffset:L,isVisible:E}),V=t.data.lyrTxrCache=new u4(t);t.onUpdateEleCalcs(function(e,t){O.invalidateElements(t),B.invalidateElements(t),F.invalidateElements(t),z.invalidateElements(t),V.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var H=function(e){for(var t=0;t<e.length;t++)V.enqueueElementRefinement(e[t].ele)};O.onDequeue(H),B.onDequeue(H),F.onDequeue(H),z.onDequeue(H),e.webgl&&t.initWebgl(e,{getStyleKey:f,getLabelKey:p,getSourceLabelKey:g,getTargetLabelKey:v,drawElement:x,drawLabel:y,drawSourceLabel:b,drawTargetLabel:w,getElementBox:N,getLabelBox:j,getSourceLabelBox:k,getTargetLabelBox:C,getElementRotationPoint:T,getElementRotationOffset:P,getLabelRotationPoint:A,getSourceLabelRotationPoint:D,getTargetLabelRotationPoint:M,getLabelRotationOffset:I,getSourceLabelRotationOffset:R,getTargetLabelRotationOffset:L})}d3.CANVAS_LAYERS=3,d3.SELECT_BOX=0,d3.DRAG=1,d3.NODE=2,d3.WEBGL=3,d3.CANVAS_TYPES=["2d","2d","2d","webgl2"],d3.BUFFER_COUNT=3,d3.TEXTURE_BUFFER=0,d3.MOTIONBLUR_BUFFER_NODE=1,d3.MOTIONBLUR_BUFFER_DRAG=2,d3.redrawHint=function(e,t){switch(e){case"eles":this.data.canvasNeedsRedraw[d3.NODE]=t;break;case"drag":this.data.canvasNeedsRedraw[d3.DRAG]=t;break;case"select":this.data.canvasNeedsRedraw[d3.SELECT_BOX]=t;break;case"gc":this.data.gc=!0}};var d6="u">typeof Path2D;d3.path2dEnabled=function(e){if(void 0===e)return this.pathsEnabled;this.pathsEnabled=!!e},d3.usePaths=function(){return d6&&this.pathsEnabled},d3.setImgSmoothing=function(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)},d3.getImgSmoothing=function(e){return null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled:e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled},d3.makeOffscreenCanvas=function(e,t){var n;return("u"<typeof OffscreenCanvas?"undefined":tE(OffscreenCanvas))!=="undefined"?n=new OffscreenCanvas(e,t):((n=this.cy.window().document.createElement("canvas")).width=e,n.height=t),n},[u7,di,dh,dp,dg,dv,dy,dH,d$,d0,d5].forEach(function(e){t6(d3,e)});var d9=[{name:"null",impl:sZ},{name:"base",impl:uK},{name:"canvas",impl:d4}],d7={},d8={};function he(e,t,n){var r=n,i=function(n){nL("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if("core"===e)if(su.prototype[t])return i(t);else su.prototype[t]=n;else if("collection"===e)if(oU.prototype[t])return i(t);else oU.prototype[t]=n;else if("layout"===e){for(var a=function(e){this.options=e,n.call(this,e),tB(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],l=0;l<s.length;l++){var c=s[l];o[c]=o[c]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var u=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return u?u.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},h={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};t6(o,{createEmitter:function(){return this._private.emitter=new of(h,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),am.eventAliasesOn(o),r=a}else if("renderer"===e&&"null"!==t&&"base"!==t){var f=ht("renderer","base"),p=f.prototype,g=n.prototype,v=function(){f.apply(this,arguments),n.apply(this,arguments)},x=v.prototype;for(var y in p){var b=p[y];if(null!=g[y])return i(y);x[y]=b}for(var w in g)x[w]=g[w];p.clientFunctions.forEach(function(e){x[e]=x[e]||function(){nP("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=v}else if("__proto__"===e||"constructor"===e||"prototype"===e)return nP(e+" is an illegal type to be registered, possibly lead to prototype pollutions");return nn({map:d7,keys:[e,t],value:r})}function ht(e,t){return nr({map:d7,keys:[e,t]})}function hn(e,t,n,r,i){return nn({map:d8,keys:[e,t,n,r],value:i})}function hr(e,t,n,r){return nr({map:d8,keys:[e,t,n,r]})}var hi=function(){return 2==arguments.length?ht.apply(null,arguments):3==arguments.length?he.apply(null,arguments):4==arguments.length?hr.apply(null,arguments):5==arguments.length?hn.apply(null,arguments):void nP("Invalid extension access syntax")};su.prototype.extension=hi,[{type:"layout",extensions:sK},{type:"renderer",extensions:d9}].forEach(function(e){e.extensions.forEach(function(t){he(e.type,t.name,t.impl)})});var ha=function(){if(!(this instanceof ha))return new ha;this.length=0},ho=ha.prototype;ho.instanceString=function(){return"stylesheet"},ho.selector=function(e){return this[this.length++]={selector:e,properties:[]},this},ho.css=function(e,t){var n=this.length-1;if(tL(e))this[n].properties.push({name:e,value:t});else if(tB(e))for(var r=Object.keys(e),i=0;i<r.length;i++){var a=r[i],o=e[a];if(null!=o){var s=so.properties[a]||so.properties[tK(a)];if(null!=s){var l=s.name;this[n].properties.push({name:l,value:o})}}}return this},ho.style=ho.css,ho.generateStyle=function(e){var t=new so(e);return this.appendToStyle(t)},ho.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var hs=function(e){return(void 0===e&&(e={}),tB(e))?new su(e):tL(e)?hi.apply(hi,arguments):void 0};hs.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(hs),e.apply(null,t),this},hs.warnings=function(e){return nR(e)},hs.version="3.33.1",hs.stylesheet=hs.Stylesheet=ha;var hl=e.i(45108);function hc({data:e,height:t=600,showLabels:n=!0,onNodeClick:r,onNodeHover:i,nodeColorFn:a,nodeSizeFn:o,linkColorFn:s,linkWidthFn:l,maxNodes:c}){let u,[d,h]=(0,M.useState)(null),f=(0,M.useRef)(null),p=(0,M.useRef)(!1),g=(0,M.useRef)(""),[v,x]=(0,M.useState)(null),[y,b]=(0,M.useState)(null),[w,N]=(0,M.useState)(null),[j,k]=(0,M.useState)(!0),[C,E]=(0,M.useState)(!1),[T,S]=(0,M.useState)(!1),_=function(){let[e,t]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{let e=()=>{t(document.documentElement.classList.contains("dark"))};e();let n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),e}(),A=(0,M.useRef)(r),P=(0,M.useRef)(i),R=(0,M.useRef)(e),L=(0,M.useRef)(a),I=(0,M.useRef)(s),O=(0,M.useRef)(T);A.current=r,P.current=i,R.current=e,L.current=a,I.current=s,O.current=T;let B=(0,M.useMemo)(()=>{let t=[...e.nodes];c&&t.length>c&&(t=t.slice(0,c));let n=new Set(t.map(e=>e.id));return{nodes:t,links:e.links.filter(e=>n.has(e.source)&&n.has(e.target))}},[e,c]);(0,M.useEffect)(()=>(E(!0),()=>E(!1)),[]);let F=(0,M.useMemo)(()=>{let e=new Map;return B.links.forEach(t=>{e.set(t.source,(e.get(t.source)||0)+1),e.set(t.target,(e.get(t.target)||0)+1)}),[...B.nodes.map(t=>{let n=e.get(t.id)||0,r=o?o(t):Math.max(16,Math.min(40,16+4*n));return{data:{id:t.id,label:t.label||t.id.substring(0,8),color:a?a(t):t.color||"#0074d9",size:t.size||r,originalNode:t,connections:n}}}),...B.links.map((e,t)=>({data:{id:`edge-${t}`,source:e.source,target:e.target,color:s?s(e):e.color||"#0074d9",width:l?l(e):e.width||1,type:e.type,entity:e.entity,weight:e.weight,originalLink:e}}))]},[B,a,o,s,l]),z=(0,M.useMemo)(()=>JSON.stringify({nodeCount:B.nodes.length,linkCount:B.links.length,nodeIds:B.nodes.map(e=>e.id).sort().join(","),showLabels:n,isDarkMode:_,maxNodes:c}),[B.nodes,B.links,n,_,c]);return(0,M.useEffect)(()=>{let e=!1,t=setTimeout(()=>{if(e||!C||!d||p.current)return;if(g.current===z)return void console.log("Data signature unchanged, skipping graph initialization");let t=d.getBoundingClientRect();if(0===t.width||0===t.height){console.warn("Container has no dimensions, skipping cytoscape initialization"),k(!1);return}if(0===F.length)return void k(!1);if(f.current&&!f.current.destroyed()){let e=f.current.nodes().length,t=f.current.edges().length,n=F.filter(e=>!e.data.source).length,r=F.filter(e=>e.data.source).length;if(e===n&&t===r){console.log("Graph already initialized with same data, skipping reinitialization"),k(!1);return}console.log("Data changed, destroying existing graph"),f.current.destroy(),f.current=null}k(!0),p.current=!0;let r=_?"#ffffff":"#1f2937",i=_?"rgba(0,0,0,0.8)":"rgba(255,255,255,0.9)";try{console.log("Initializing cytoscape with container:",d),console.log("Elements count:",F.length),console.log("Sample elements:",F.slice(0,2));let e=hs({container:d,elements:[],selectionType:"single",userZoomingEnabled:!0,userPanningEnabled:!0,boxSelectionEnabled:!1,layout:{name:"preset"},style:[{selector:"node",style:{"background-color":"data(color)",width:"data(size)",height:"data(size)",label:n?"data(label)":"",color:r,"text-valign":"bottom","text-halign":"center","font-size":"8px","font-weight":500,"text-margin-y":3,"text-wrap":"wrap","text-max-width":"80px","text-background-color":i,"text-background-opacity":.9,"text-background-padding":"2px","text-background-shape":"roundrectangle","border-width":1,"border-color":_?"#ffffff20":"#00000020","border-opacity":.3}},{selector:"node:selected",style:{"border-width":3,"border-color":"#0074d9","border-opacity":1}},{selector:"edge",style:{width:"data(width)","line-color":"data(color)","target-arrow-color":"data(color)","target-arrow-shape":"triangle","target-arrow-size":6,"curve-style":"bezier",opacity:_?.6:.7}},{selector:".dimmed",style:{opacity:.2}},{selector:".focused",style:{"border-width":4,"border-color":"#ff6b35","border-opacity":1,"z-index":999}},{selector:".connected",style:{"border-width":2,"border-color":"#0074d9","border-opacity":.8,opacity:1}},{selector:"edge.connection",style:{width:2,opacity:1,"z-index":100}},{selector:"edge.connection:hover",style:{width:3,opacity:1,"z-index":200}},{selector:"edge:selected",style:{"overlay-opacity":0,"overlay-color":"transparent","overlay-padding":0}}]});f.current=e,console.log("Cytoscape initialized successfully"),F.length>0&&(console.log("Adding elements to cytoscape"),e.add(F),e.layout({name:"fcose",quality:"default",randomize:!1,animate:!0,animationDuration:1500,nodeSeparation:200,idealEdgeLength:()=>250,edgeElasticity:()=>.05,nestingFactor:.05,gravity:.05,numIter:2500,nodeOverlap:30,avoidOverlap:!0,nodeDimensionsIncludeLabels:!0,padding:20,boundingBox:void 0,tile:!0,tilingPaddingVertical:30,tilingPaddingHorizontal:30,uniformNodeDimensions:!1,packComponents:!1}).run(),e.fit()),e.on("tap","node",e=>{let t=e.target.data("originalNode");A.current&&t&&A.current(t)}),e.on("mouseover","node",e=>{let t=e.target.data("originalNode");x(t),P.current&&t&&P.current(t),d&&(d.style.cursor="pointer")}),e.on("mouseout","node",()=>{x(null),P.current&&P.current(null),d&&(d.style.cursor="default")}),e.on("mouseover","edge",e=>{let t=e.target;if(!O.current||!t.hasClass("connection"))return;let n=t.data("originalLink");if(n){b(n);let e=t.renderedMidpoint();N({x:e.x,y:e.y})}}),e.on("mouseout","edge",e=>{let t=e.target;O.current&&t.hasClass("connection")&&(b(null),N(null))}),e.on("select","edge",e=>{e.target.unselect()}),e.on("dblclick","node",t=>{let n=t.target,r=n.id();console.log("Double-clicked node:",r),S(!0),e.elements().removeClass("dimmed focused connected connection");let i=n.neighborhood(),a=i.nodes(),o=i.edges();e.elements().addClass("dimmed"),n.removeClass("dimmed").addClass("focused"),a.removeClass("dimmed").addClass("connected"),o.removeClass("dimmed").addClass("connection");let s=n.union(i);e.animate({fit:{eles:s,padding:100},center:{eles:n}},{duration:800,easing:"ease-out-cubic"})}),e.on("tap",t=>{t.target===e&&(console.log("Clicked background - resetting focus"),S(!1),e.elements().removeClass("dimmed focused connected connection"),e.animate({fit:{eles:e.elements(),padding:50}},{duration:600,easing:"ease-out"}))}),k(!1),p.current=!1,g.current=z}catch(e){console.error("Error initializing cytoscape:",e),k(!1),p.current=!1}},100);return()=>{e=!0,clearTimeout(t),p.current=!1,f.current&&(f.current.destroy(),f.current=null)}},[z,C,d]),(0,M.useEffect)(()=>{let e=()=>{f.current&&(f.current.resize(),f.current.fit(void 0,80))};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,D.jsxs)("div",{className:"relative w-full rounded-lg overflow-hidden border border-border",style:{height:t},children:[j&&(0,D.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background z-10",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."})]})}),C&&(0,D.jsx)("div",{ref:h,className:"w-full h-full",style:{backgroundImage:_?"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.08) 1px, transparent 0)":"radial-gradient(circle at 1px 1px, rgba(0,0,0,0.06) 1px, transparent 0)",backgroundSize:"20px 20px",backgroundColor:_?"#0f1419":"#f8fafc"}}),!j&&0===B.nodes.length&&(0,D.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,D.jsx)("div",{className:"text-center",children:(0,D.jsx)("p",{className:"text-muted-foreground",children:"No memories to display"})})}),y&&w&&(0,D.jsx)("div",{className:"absolute z-30 pointer-events-none",style:{left:w.x,top:w.y,transform:"translate(-50%, -100%) translateY(-8px)"},children:(0,D.jsxs)("div",{className:`px-3 py-2 rounded-lg shadow-lg text-sm ${_?"bg-gray-800 text-white":"bg-white text-gray-900 border border-gray-200"}`,children:[(0,D.jsx)("div",{className:"font-medium capitalize mb-1",children:["causes","caused_by","enables","prevents"].includes(u=y.type||"semantic")?`Causal (${u.replace("_"," ")})`:`${u} link`}),y.entity&&(0,D.jsxs)("div",{className:"text-xs opacity-80",children:["Entity: ",(0,D.jsx)("span",{className:"font-medium",children:y.entity})]}),void 0!==y.weight&&(0,D.jsxs)("div",{className:"text-xs opacity-80",children:["Weight: ",(0,D.jsx)("span",{className:"font-medium",children:y.weight.toFixed(3)})]})]})}),(0,D.jsx)("div",{className:"absolute bottom-4 right-4 text-xs text-muted-foreground/60 z-20",children:"Drag to pan • Scroll to zoom • Double-click node to focus • Click background to reset"})]})}function hu({factType:e}){let t,n,r,i,{currentBank:a}=(0,I.useBank)(),[o,s]=(0,M.useState)("graph"),[l,c]=(0,M.useState)(null),[u,d]=(0,M.useState)(!1),[h,f]=(0,M.useState)(""),[p,g]=(0,M.useState)(1),[v,x]=(0,M.useState)(null),[y,b]=(0,M.useState)(null),[w,N]=(0,M.useState)(1e3),[j,k]=(0,M.useState)(null),[C,E]=(0,M.useState)(!0),[T,S]=(0,M.useState)(void 0),[_,A]=(0,M.useState)(!0),[P,R]=(0,M.useState)(new Set(["semantic","temporal","entity","causal"])),L=e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,M.useEffect)(()=>{let e=e=>{"Escape"===e.key&&v&&x(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);let O=async t=>{if(a){d(!0);try{let n=await K.client.getGraph({bank_id:a,type:e,limit:t??w});if(c(n),"observation"===e){let e=await K.client.getBankStats(a);k({pending_consolidation:e.pending_consolidation||0,last_consolidated_at:e.last_consolidated_at||null})}}catch(e){}finally{d(!1)}}},B=(0,M.useMemo)(()=>{if(!l?.table_rows)return[];if(!h)return l.table_rows;let e=h.toLowerCase();return l.table_rows.filter(t=>t.text?.toLowerCase().includes(e))},[l,h]),F=(0,M.useMemo)(()=>new Set(B.map(e=>e.id)),[B]),z=(0,M.useMemo)(()=>{if(!l)return{nodes:[],links:[]};let e={nodes:(l.nodes||[]).map(e=>{let t=l.table_rows?.find(t=>t.id===e.data.id),n=e.data.label;return!n&&t?.text&&(n=t.text.length>40?t.text.substring(0,40)+"...":t.text),n||(n=e.data.id.substring(0,8)),{id:e.data.id,label:n,color:e.data.color,metadata:t}}),links:(l.edges||[]).map(e=>({source:e.data.source,target:e.data.target,color:e.data.color,type:e.data.linkType||("dashed"===e.data.lineStyle?"temporal":"semantic"),entity:e.data.entityName,weight:e.data.weight??e.data.similarity}))},t=e.nodes,n=e.links;if(h){let r=e.nodes.filter(e=>F.has(e.id)),i=new Set(r.map(e=>e.id));t=r,n=e.links.filter(e=>i.has(e.source)&&i.has(e.target))}return{nodes:t,links:n=n.filter(e=>{var t;let n=(t=e.type)?"semantic"===t||"temporal"===t||"entity"===t?t:["causes","caused_by","enables","prevents"].includes(t)?"causal":"semantic":"semantic";return P.has(n)})}},[l,h,F,P]),V=(0,M.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0,a={};return z.links.forEach(o=>{i++;let s=o.type||"unknown";"semantic"===s?e++:"temporal"===s?t++:"entity"===s?n++:"causes"===s||"caused_by"===s||"enables"===s||"prevents"===s?r++:a[s]=(a[s]||0)+1}),{semantic:e,temporal:t,entity:n,causal:r,total:i,otherTypes:a}},[z]),H=(0,M.useCallback)(e=>{let t=l?.table_rows?.find(t=>t.id===e.id);t&&x(t)},[l]),U=(0,M.useCallback)(e=>e.color||"#0074d9",[]),X=(0,M.useCallback)(e=>"temporal"===e.type?"#009296":"entity"===e.type?"#f59e0b":"causes"===e.type||"caused_by"===e.type||"enables"===e.type||"prevents"===e.type?"#8b5cf6":"#0074d9",[]);return(0,M.useEffect)(()=>{g(1)},[h]),(0,M.useEffect)(()=>{a&&O()},[e,a]),(0,M.useEffect)(()=>{l&&void 0===T&&(z.nodes.length>50?S(20):z.nodes.length>20&&S(20))},[l,z.nodes.length,T]),(0,D.jsxs)("div",{children:[u?(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(ei,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Loading memories..."})]}):l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"mb-4",children:(0,D.jsx)(Q.Input,{type:"text",value:h,onChange:e=>f(e.target.value),placeholder:"Filter memories by text...",className:"max-w-md"})}),(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:h?`${B.length} of ${l.table_rows?.length??0} loaded memories`:l.table_rows?.length<l.total_units?(0,D.jsxs)("span",{children:["Showing ",l.table_rows?.length??0," of ",l.total_units," total memories",(0,D.jsx)("button",{onClick:()=>{let e=Math.min(l.total_units,w+1e3);N(e),O(e)},className:"ml-2 text-primary hover:underline",children:"Load more"})]}):`${l.total_units} total memories`}),"observation"===e&&j&&(0,D.jsx)("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${0===j.pending_consolidation?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20":"bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20"}`,title:0===j.pending_consolidation?`All memories consolidated${j.last_consolidated_at?` (last: ${new Date(j.last_consolidated_at).toLocaleString()})`:""}`:`${j.pending_consolidation} memories pending consolidation`,children:0===j.pending_consolidation?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ea,{className:"w-3 h-3"}),"In Sync"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),j.pending_consolidation," Pending"]})})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,D.jsxs)("button",{onClick:()=>s("graph"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"graph"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,D.jsx)(es,{className:"w-4 h-4"}),"Graph"]}),(0,D.jsxs)("button",{onClick:()=>s("table"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"table"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,D.jsx)(el,{className:"w-4 h-4"}),"Table"]}),(0,D.jsxs)("button",{onClick:()=>s("timeline"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"timeline"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,D.jsx)(J,{className:"w-4 h-4"}),"Timeline"]})]})]}),"graph"===o&&(0,D.jsxs)("div",{className:"flex gap-0",children:[(0,D.jsx)("div",{className:"flex-1 min-w-0",children:(0,D.jsx)(hc,{data:z,height:700,showLabels:C,onNodeClick:H,maxNodes:T,nodeColorFn:U,linkColorFn:X})}),(0,D.jsx)("button",{onClick:()=>A(!_),className:"flex-shrink-0 w-5 h-[700px] bg-transparent hover:bg-muted/50 flex items-center justify-center transition-colors",title:_?"Hide panel":"Show panel",children:_?(0,D.jsx)(Y,{className:"w-3 h-3 text-muted-foreground/60"}):(0,D.jsx)(G,{className:"w-3 h-3 text-muted-foreground/60"})}),(0,D.jsx)("div",{className:`${_?"w-80":"w-0"} transition-all duration-300 overflow-hidden flex-shrink-0`,children:(0,D.jsx)("div",{className:"w-80 h-[700px] bg-card border-l border-border overflow-y-auto",children:v?(0,D.jsx)(tv,{memory:v,onClose:()=>x(null),inPanel:!0,bankId:a||void 0}):(0,D.jsxs)("div",{className:"p-4 space-y-5",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-semibold mb-3 text-foreground",children:"Graph"}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:"#0074d9"}}),(0,D.jsx)("span",{className:"text-foreground",children:"Nodes"})]}),(0,D.jsxs)("span",{className:"font-mono text-foreground",children:[Math.min(T??z.nodes.length,z.nodes.length),"/",z.nodes.length]})]}),(0,D.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mt-2 mb-1",children:["Links (",V.total,")"," ",(0,D.jsx)("span",{className:"text-muted-foreground/60",children:"· click to filter"})]}),(0,D.jsxs)("button",{onClick:()=>L("semantic"),className:`w-full flex items-center justify-between text-sm px-2 py-1 rounded transition-all ${P.has("semantic")?"hover:bg-muted":"opacity-40 hover:opacity-60"}`,children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("div",{className:"w-4 h-0.5 bg-[#0074d9]"}),(0,D.jsx)("span",{className:"text-foreground",children:"Semantic"})]}),(0,D.jsx)("span",{className:`font-mono ${0===V.semantic?"text-destructive":"text-foreground"}`,children:V.semantic})]}),(0,D.jsxs)("button",{onClick:()=>L("temporal"),className:`w-full flex items-center justify-between text-sm px-2 py-1 rounded transition-all ${P.has("temporal")?"hover:bg-muted":"opacity-40 hover:opacity-60"}`,children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("div",{className:"w-4 h-0.5 bg-[#009296]"}),(0,D.jsx)("span",{className:"text-foreground",children:"Temporal"})]}),(0,D.jsx)("span",{className:`font-mono ${0===V.temporal?"text-destructive":"text-foreground"}`,children:V.temporal})]}),(0,D.jsxs)("button",{onClick:()=>L("entity"),className:`w-full flex items-center justify-between text-sm px-2 py-1 rounded transition-all ${P.has("entity")?"hover:bg-muted":"opacity-40 hover:opacity-60"}`,children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("div",{className:"w-4 h-0.5 bg-[#f59e0b]"}),(0,D.jsx)("span",{className:"text-foreground",children:"Entity"})]}),(0,D.jsx)("span",{className:"font-mono text-foreground",children:V.entity})]}),(0,D.jsxs)("button",{onClick:()=>L("causal"),className:`w-full flex items-center justify-between text-sm px-2 py-1 rounded transition-all ${P.has("causal")?"hover:bg-muted":"opacity-40 hover:opacity-60"}`,children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("div",{className:"w-4 h-0.5 bg-[#8b5cf6]"}),(0,D.jsx)("span",{className:"text-foreground",children:"Causal"})]}),(0,D.jsx)("span",{className:`font-mono ${0===V.causal?"text-muted-foreground":"text-foreground"}`,children:V.causal})]}),Object.entries(V.otherTypes||{}).map(([e,t])=>(0,D.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,D.jsx)("span",{className:"text-muted-foreground capitalize ml-6",children:e}),(0,D.jsx)("span",{className:"font-mono text-muted-foreground",children:t})]},e))]})]}),(0,D.jsx)("div",{className:"border-t border-border"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-semibold mb-3 text-foreground",children:"Display"}),(0,D.jsx)("div",{className:"space-y-4",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsx)(ew,{htmlFor:"show-labels",className:"text-sm text-foreground",children:"Show labels"}),(0,D.jsx)(to,{id:"show-labels",checked:C,onCheckedChange:E})]})})]}),(0,D.jsx)("div",{className:"border-t border-border"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-semibold mb-3 text-foreground",children:"Performance"}),(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,D.jsx)(ew,{className:"text-sm text-foreground",children:"Max nodes"}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:z.nodes.length>50?`${T??50} / ${z.nodes.length}`:`${T??"All"} / ${z.nodes.length}`})]}),(0,D.jsx)(e4,{value:[z.nodes.length>50?T||20:T||Math.min(z.nodes.length,20)],min:10,max:Math.min(Math.max(z.nodes.length,10),50),step:10,onValueChange:([e])=>{let t=Math.min(z.nodes.length,50);z.nodes.length>50?S(e):S(e>=t?void 0:e)},className:"w-full"})]}),(0,D.jsxs)("p",{className:"text-xs text-muted-foreground",children:["All links between visible nodes are shown.",z.nodes.length>50&&(0,D.jsxs)("span",{className:"block text-amber-600 dark:text-amber-400 mt-1",children:["⚠️ Limited to 50 nodes for performance. Total:"," ",z.nodes.length]})]})]})]}),(0,D.jsx)("div",{className:"border-t border-border"}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground/60 text-center pt-2",children:"Click a node to see details"})]})})})]}),"table"===o&&(0,D.jsx)("div",{children:(0,D.jsx)("div",{className:"w-full",children:(0,D.jsx)("div",{className:"pb-4",children:B.length>0?(t=Math.ceil(B.length/100),r=(n=(p-1)*100)+100,i=B.slice(n,r),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,D.jsxs)(ec,{className:"table-fixed",children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{className:"bg-muted/50",children:[(0,D.jsx)(ef,{className:"w-[45%]",children:"observation"===e?"Observation":"Memory"}),(0,D.jsx)(ef,{className:"w-[20%]",children:"Entities"}),(0,D.jsx)(ef,{className:"w-[17%]",children:"Occurred"}),(0,D.jsx)(ef,{className:"w-[18%]",children:"Mentioned"})]})}),(0,D.jsx)(ed,{children:i.map((t,n)=>{let r=t.occurred_start?new Date(t.occurred_start).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null,i=t.mentioned_at?new Date(t.mentioned_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null;return(0,D.jsxs)(eh,{onClick:()=>b(t.id),className:"cursor-pointer hover:bg-muted/50",children:[(0,D.jsxs)(ep,{className:"py-2",children:[(0,D.jsx)("div",{className:"line-clamp-2 text-sm leading-snug text-foreground",children:t.text}),t.context&&"observation"!==e&&(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.context})]}),(0,D.jsx)(ep,{className:"py-2",children:t.entities?(0,D.jsxs)("div",{className:"flex gap-1 flex-wrap",children:[t.entities.split(", ").slice(0,2).map((e,t)=>(0,D.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:e},t)),t.entities.split(", ").length>2&&(0,D.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["+",t.entities.split(", ").length-2]})]}):(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:"-"})}),(0,D.jsx)(ep,{className:"text-xs py-2 text-foreground",children:r||(0,D.jsx)("span",{className:"text-muted-foreground",children:"-"})}),(0,D.jsx)(ep,{className:"text-xs py-2 text-foreground",children:i||(0,D.jsx)("span",{className:"text-muted-foreground",children:"-"})})]},t.id||n)})})]})}),t>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[n+1,"-",Math.min(r,B.length)," of"," ",B.length]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>g(1),disabled:1===p,className:"h-7 w-7 p-0",children:(0,D.jsx)(en,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>g(e=>Math.max(1,e-1)),disabled:1===p,className:"h-7 w-7 p-0",children:(0,D.jsx)(G,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[p," / ",t]}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>g(e=>Math.min(t,e+1)),disabled:p===t,className:"h-7 w-7 p-0",children:(0,D.jsx)(Y,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>g(t),disabled:p===t,className:"h-7 w-7 p-0",children:(0,D.jsx)(er,{className:"h-3 w-3"})})]})]})]})):(0,D.jsx)("div",{className:"text-center py-12 text-muted-foreground",children:l.table_rows?.length>0?"No memories match your filter":"No memories found"})})})}),"timeline"===o&&(0,D.jsx)(hd,{data:l,filteredRows:B,bankId:a||void 0})]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"📊"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"No data available"})]})}),(0,D.jsx)(tm,{memoryId:y,onClose:()=>b(null)})]})}function hd({data:e,filteredRows:t,bankId:n}){let[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)("month"),[s,l]=(0,M.useState)(0),c=(0,M.useRef)(null),{sortedItems:u,itemsWithoutDates:d}=(0,M.useMemo)(()=>t&&0!==t.length?{sortedItems:t.filter(e=>e.occurred_start).sort((e,t)=>new Date(e.occurred_start).getTime()-new Date(t.occurred_start).getTime()),itemsWithoutDates:t.filter(e=>!e.occurred_start)}:{sortedItems:[],itemsWithoutDates:[]},[t]),h=(0,M.useMemo)(()=>{if(0===u.length)return[];let e={};return u.forEach(t=>{let n=new Date(t.occurred_start),r=(e=>{let t=e.getFullYear(),n=e.getMonth(),r=e.getDate();switch(a){case"year":return`${t}`;case"month":return`${t}-${String(n+1).padStart(2,"0")}`;case"week":let i=new Date(e);return i.setDate(r-e.getDay()),`${i.getFullYear()}-W${String(Math.ceil(i.getDate()/7)).padStart(2,"0")}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`;case"day":return`${t}-${String(n+1).padStart(2,"0")}-${String(r).padStart(2,"0")}`}})(n);if(!e[r]){let t=n;if("week"===a){let e=r.split("-");t=new Date(parseInt(e[0]),parseInt(e[2])-1,parseInt(e[3]))}e[r]={items:[],date:t}}e[r].items.push(t)}),Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,{items:t,date:n}])=>({key:e,label:((e,t)=>{switch(a){case"year":return e;case"month":return t.toLocaleDateString("en-US",{year:"numeric",month:"short"});case"week":let n=new Date(t);return n.setDate(t.getDate()+6),`${t.toLocaleDateString("en-US",{month:"short",day:"numeric"})} - ${n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}`;case"day":return t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"})}})(e,n),items:t,date:n}))},[u,a]),f=(0,M.useMemo)(()=>0===u.length?null:{first:new Date(u[0].occurred_start),last:new Date(u[u.length-1].occurred_start)},[u]),p=e=>{let t=Math.max(0,Math.min(e,h.length-1));l(t);let n=document.getElementById(`timeline-group-${t}`);n?.scrollIntoView({behavior:"smooth",block:"start"})};if(0===u.length)return(0,D.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,D.jsx)(J,{className:"w-12 h-12 text-muted-foreground mb-3"}),(0,D.jsx)("div",{className:"text-base font-medium text-foreground mb-1",children:"No Timeline Data"}),(0,D.jsxs)("div",{className:"text-xs text-muted-foreground text-center max-w-md",children:["No memories have occurred_at dates.",d.length>0&&(0,D.jsxs)("span",{className:"block mt-1",children:[d.length," memories without dates in Table View."]})]})]});let g=e=>{let t=new Date(e);return{date:t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),time:t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}};return(0,D.jsxs)("div",{className:"px-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-3 gap-4",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[u.length," memories",d.length>0&&` \xb7 ${d.length} without dates`,f&&(0,D.jsxs)("span",{className:"ml-2 text-foreground",children:["(",f.first.toLocaleDateString("en-US",{month:"short",year:"numeric"})," ","→ ",f.last.toLocaleDateString("en-US",{month:"short",year:"numeric"}),")"]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsxs)("div",{className:"flex items-center border border-border rounded mr-2",children:[(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>{let e=["year","month","week","day"],t=e.indexOf(a);t>0&&o(e[t-1])},disabled:"year"===a,className:"h-7 w-7 p-0",title:"Zoom out",children:(0,D.jsx)(et,{className:"h-3 w-3"})}),(0,D.jsx)("span",{className:"text-[10px] px-2 min-w-[50px] text-center border-x border-border text-foreground",children:{year:"Year",month:"Month",week:"Week",day:"Day"}[a]}),(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>{let e=["year","month","week","day"],t=e.indexOf(a);t<e.length-1&&o(e[t+1])},disabled:"day"===a,className:"h-7 w-7 p-0",title:"Zoom in",children:(0,D.jsx)(ee,{className:"h-3 w-3"})})]}),(0,D.jsxs)("div",{className:"flex items-center border border-border rounded",children:[(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>p(0),disabled:h.length<=1,className:"h-7 w-7 p-0",title:"First",children:(0,D.jsx)(en,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>p(s-1),disabled:0===s,className:"h-7 w-7 p-0",title:"Previous",children:(0,D.jsx)(G,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-[10px] px-2 min-w-[60px] text-center border-x border-border text-foreground",children:[s+1," / ",h.length]}),(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>p(s+1),disabled:s>=h.length-1,className:"h-7 w-7 p-0",title:"Next",children:(0,D.jsx)(Y,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>p(h.length-1),disabled:h.length<=1,className:"h-7 w-7 p-0",title:"Last",children:(0,D.jsx)(er,{className:"h-3 w-3"})})]})]})]}),(0,D.jsxs)("div",{ref:c,className:"relative max-h-[550px] overflow-y-auto pr-2",children:[(0,D.jsx)("div",{className:"absolute left-[60px] top-0 bottom-0 w-0.5 bg-border"}),h.map((e,t)=>(0,D.jsxs)("div",{id:`timeline-group-${t}`,className:"mb-4",children:[(0,D.jsxs)("div",{className:"flex items-center mb-2 cursor-pointer hover:opacity-80",onClick:()=>l(t),children:[(0,D.jsx)("div",{className:"w-[60px] text-right pr-3",children:(0,D.jsx)("span",{className:"text-xs font-semibold text-primary",children:e.label})}),(0,D.jsx)("div",{className:"w-2 h-2 rounded-full bg-primary z-10"}),(0,D.jsxs)("span",{className:"ml-2 text-[10px] text-muted-foreground",children:[e.items.length," ",1===e.items.length?"item":"items"]})]}),(0,D.jsx)("div",{className:"space-y-1",children:e.items.map((e,t)=>(0,D.jsxs)("div",{onClick:()=>i(e),className:`flex items-start cursor-pointer group ${r?.id===e.id?"opacity-100":"hover:opacity-80"}`,children:[(0,D.jsxs)("div",{className:"w-[60px] text-right pr-3 pt-1 flex-shrink-0",children:[(0,D.jsx)("div",{className:"text-[10px] text-muted-foreground",children:g(e.occurred_start).date}),(0,D.jsx)("div",{className:"text-[9px] text-muted-foreground/70",children:g(e.occurred_start).time})]}),(0,D.jsx)("div",{className:"flex-shrink-0 pt-2",children:(0,D.jsx)("div",{className:`w-1.5 h-1.5 rounded-full z-10 ${r?.id===e.id?"bg-primary":"bg-muted-foreground/50 group-hover:bg-primary"}`})}),(0,D.jsxs)("div",{className:`ml-3 flex-1 p-2 rounded border transition-colors ${r?.id===e.id?"bg-primary/10 border-primary":"bg-card border-border hover:border-primary/50"}`,children:[(0,D.jsx)("p",{className:"text-xs text-foreground line-clamp-2 leading-relaxed",children:e.text}),e.context&&(0,D.jsx)("p",{className:"text-[10px] text-muted-foreground mt-1 truncate",children:e.context}),e.entities&&(0,D.jsxs)("div",{className:"flex gap-1 mt-1 flex-wrap",children:[e.entities.split(", ").slice(0,3).map((e,t)=>(0,D.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:e},t)),e.entities.split(", ").length>3&&(0,D.jsxs)("span",{className:"text-[9px] text-muted-foreground",children:["+",e.entities.split(", ").length-3]})]})]})]},e.id||t))})]},e.key))]})]}),r&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l-2 border-primary shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:(0,D.jsx)(tv,{memory:r,onClose:()=>i(null),inPanel:!0,bankId:n})})]})}hs.use(hl.default);var hh=e.i(26999),hf=Symbol("radix.slottable"),hp="AlertDialog",[hg,hm]=(0,eC.createContextScope)(hp,[hh.createDialogScope]),hv=(0,hh.createDialogScope)(),hx=e=>{let{__scopeAlertDialog:t,...n}=e,r=hv(t);return(0,D.jsx)(hh.Root,{...r,...n,modal:!0})};hx.displayName=hp,M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=hv(n);return(0,D.jsx)(hh.Trigger,{...i,...r,ref:t})}).displayName="AlertDialogTrigger";var hy=e=>{let{__scopeAlertDialog:t,...n}=e,r=hv(t);return(0,D.jsx)(hh.Portal,{...r,...n})};hy.displayName="AlertDialogPortal";var hb=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=hv(n);return(0,D.jsx)(hh.Overlay,{...i,...r,ref:t})});hb.displayName="AlertDialogOverlay";var hw="AlertDialogContent",[hN,hj]=hg(hw),hk=((t=({children:e})=>(0,D.jsx)(D.Fragment,{children:e})).displayName="AlertDialogContent.Slottable",t.__radixId=hf,t),hC=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=hv(n),o=M.useRef(null),s=(0,ek.useComposedRefs)(t,o),l=M.useRef(null);return(0,D.jsx)(hh.WarningProvider,{contentName:hw,titleName:hE,docsSlug:"alert-dialog",children:(0,D.jsx)(hN,{scope:n,cancelRef:l,children:(0,D.jsxs)(hh.Content,{role:"alertdialog",...a,...i,ref:s,onOpenAutoFocus:(0,ej.composeEventHandlers)(i.onOpenAutoFocus,e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,D.jsx)(hk,{children:r}),(0,D.jsx)(hP,{contentRef:o})]})})})});hC.displayName=hw;var hE="AlertDialogTitle",hT=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=hv(n);return(0,D.jsx)(hh.Title,{...i,...r,ref:t})});hT.displayName=hE;var hS="AlertDialogDescription",h_=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=hv(n);return(0,D.jsx)(hh.Description,{...i,...r,ref:t})});h_.displayName=hS;var hA=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=hv(n);return(0,D.jsx)(hh.Close,{...i,...r,ref:t})});hA.displayName="AlertDialogAction";var hD="AlertDialogCancel",hM=M.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=hj(hD,n),a=hv(n),o=(0,ek.useComposedRefs)(t,i);return(0,D.jsx)(hh.Close,{...a,...r,ref:o})});hM.displayName=hD;var hP=({contentRef:e})=>{let t=`\`${hw}\` requires a description for the component to be accessible for screen reader users.
2
-
3
- You can add a description to the \`${hw}\` by passing a \`${hS}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
4
-
5
- Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${hw}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
6
-
7
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return M.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null};let hR=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hb,{className:(0,W.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));hR.displayName=hb.displayName;let hL=M.forwardRef(({className:e,...t},n)=>(0,D.jsxs)(hy,{children:[(0,D.jsx)(hR,{}),(0,D.jsx)(hC,{ref:n,className:(0,W.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));hL.displayName=hC.displayName;let hI=({className:e,...t})=>(0,D.jsx)("div",{className:(0,W.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});hI.displayName="AlertDialogHeader";let hO=({className:e,...t})=>(0,D.jsx)("div",{className:(0,W.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});hO.displayName="AlertDialogFooter";let hB=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hT,{ref:n,className:(0,W.cn)("text-lg font-semibold",e),...t}));hB.displayName=hT.displayName;let hF=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(h_,{ref:n,className:(0,W.cn)("text-sm text-muted-foreground",e),...t}));hF.displayName=h_.displayName;let hz=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hA,{ref:n,className:(0,W.cn)((0,Z.buttonVariants)(),e),...t}));hz.displayName=hA.displayName;let hV=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hM,{ref:n,className:(0,W.cn)((0,Z.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));hV.displayName=hM.displayName;let hH=(0,F.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);function hU(){let{currentBank:e}=(0,I.useBank)(),[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(""),[s,l]=(0,M.useState)(0),[c,u]=(0,M.useState)(1),d=Math.ceil(s/50),h=(c-1)*50,[f,p]=(0,M.useState)(null),[g,v]=(0,M.useState)(!1),[x,y]=(0,M.useState)(null),[b,w]=(0,M.useState)(null),[N,j]=(0,M.useState)(null),k=async(t=1)=>{if(e){i(!0);try{let r=await K.client.listDocuments({bank_id:e,q:a,limit:50,offset:(t-1)*50});n(r.items||[]),l(r.total||0)}catch(e){}finally{i(!1)}}},C=e=>{u(e),k(e)},E=async t=>{if(e){v(!0),p({id:t});try{let n=await K.client.getDocument(t,e);p(n)}catch(e){p(null)}finally{v(!1)}}},T=async()=>{if(!e||!b)return;let t=b.id;y(t),w(null);try{let n=await K.client.deleteDocument(t,e);j({success:!0,message:`Deleted document and ${n.memory_units_deleted} memory units.`}),f?.id===t&&p(null),k(c)}catch(e){console.error("Error deleting document:",e),j({success:!1,message:"Error deleting document: "+e.message})}finally{y(null)}};return(0,M.useEffect)(()=>{e&&(u(1),k(1))},[e]),(0,M.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{u(1),k(1)},300);return()=>clearTimeout(t)},[a]),(0,D.jsxs)("div",{children:[r?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading documents..."})]})}):t.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[s," ",1===s?"document":"documents"]}),(0,D.jsxs)("div",{className:"w-full",children:[(0,D.jsx)("div",{className:"px-5 mb-4",children:(0,D.jsx)(Q.Input,{type:"text",value:a,onChange:e=>o(e.target.value),placeholder:"Search documents (ID)...",className:"max-w-2xl"})}),(0,D.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,D.jsxs)(ec,{children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{children:[(0,D.jsx)(ef,{children:"Document ID"}),(0,D.jsx)(ef,{children:"Created"}),(0,D.jsx)(ef,{children:"Tags"}),(0,D.jsx)(ef,{children:"Context"}),(0,D.jsx)(ef,{children:"Text Length"}),(0,D.jsx)(ef,{children:"Memory Units"})]})}),(0,D.jsx)(ed,{children:t.length>0?t.map(e=>(0,D.jsxs)(eh,{className:`cursor-pointer hover:bg-muted/50 ${f?.id===e.id?"bg-primary/10":""}`,onClick:()=>E(e.id),children:[(0,D.jsx)(ep,{title:e.id,className:"text-card-foreground",children:e.id.length>30?e.id.substring(0,30)+"...":e.id}),(0,D.jsx)(ep,{className:"text-card-foreground",children:e.created_at?new Date(e.created_at).toLocaleString():"N/A"}),(0,D.jsx)(ep,{className:"text-card-foreground",children:e.tags&&e.tags.length>0?(0,D.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map((e,t)=>(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:e},t)),e.tags.length>3&&(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",e.tags.length-3]})]}):"-"}),(0,D.jsx)(ep,{className:"text-card-foreground",children:e.retain_params?.context||"-"}),(0,D.jsxs)(ep,{className:"text-card-foreground",children:[e.text_length?.toLocaleString()," chars"]}),(0,D.jsx)(ep,{className:"text-card-foreground",children:e.memory_unit_count})]},e.id)):(0,D.jsx)(eh,{children:(0,D.jsx)(ep,{colSpan:6,className:"text-center",children:'Click "Load Documents" to view data'})})})]})}),d>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t px-5",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[h+1,"-",Math.min(h+50,s)," of ",s]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>C(1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(en,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>C(c-1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(G,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[c," / ",d]}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>C(c+1),disabled:c===d||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(Y,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>C(d),disabled:c===d||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(er,{className:"h-3 w-3"})})]})]})]})]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"No documents found"})]})}),t.length>0&&f&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l-2 border-primary shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:(0,D.jsxs)("div",{className:"p-5",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:"Document Details"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Original document text and metadata"})]}),(0,D.jsxs)(Z.Button,{variant:"secondary",size:"sm",onClick:()=>p(null),className:"h-9 px-3 gap-2",children:[(0,D.jsx)(tc.X,{className:"h-4 w-4"}),"Close"]})]}),g?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading document..."})]})}):(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Document ID"}),(0,D.jsx)("div",{className:"text-sm font-mono break-all text-card-foreground",children:f.id})]}),f.created_at&&(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:new Date(f.created_at).toLocaleString()})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Memory Units"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:f.memory_unit_count})]})]}),f.original_text&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm font-medium text-card-foreground",children:[f.original_text.length.toLocaleString()," characters"]})]}),f.retain_params&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Retain Parameters"}),(0,D.jsxs)("div",{className:"text-sm space-y-2 text-card-foreground",children:[f.retain_params.context&&(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"font-semibold",children:"Context:"})," ",f.retain_params.context]}),f.retain_params.event_date&&(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"font-semibold",children:"Event Date:"})," ",new Date(f.retain_params.event_date).toLocaleString()]}),f.retain_params.metadata&&(0,D.jsxs)("div",{className:"mt-2",children:[(0,D.jsx)("span",{className:"font-semibold",children:"Metadata:"}),(0,D.jsx)("pre",{className:"mt-1 text-xs bg-background p-2 rounded text-card-foreground",children:JSON.stringify(f.retain_params.metadata,null,2)})]})]})]}),f.tags&&f.tags.length>0&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:f.tags.map((e,t)=>(0,D.jsx)("span",{className:"text-sm px-3 py-1.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:e},t))})]}),(0,D.jsx)("div",{className:"pt-2 border-t border-border",children:(0,D.jsxs)(Z.Button,{variant:"destructive",size:"sm",onClick:()=>{w({id:f.id,memoryCount:f.memory_unit_count})},className:"w-full gap-2",disabled:x===f.id,children:[x===f.id?(0,D.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,D.jsx)(hH,{className:"h-4 w-4"}),"Delete Document"]})}),f.original_text&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Original Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border max-h-[400px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono leading-relaxed text-card-foreground",children:f.original_text})})]})]})]})}),(0,D.jsx)(hx,{open:!!b,onOpenChange:e=>!e&&w(null),children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Delete Document"}),(0,D.jsxs)(hF,{children:["Are you sure you want to delete document"," ",(0,D.jsxs)("span",{className:"font-mono font-semibold",children:['"',b?.id,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),"This will also delete"," ",b?.memoryCount!==void 0?(0,D.jsxs)("span",{className:"font-semibold",children:[b.memoryCount," memory units"]}):"all memory units"," ","extracted from this document.",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{children:"Cancel"}),(0,D.jsx)(hz,{onClick:T,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),(0,D.jsx)(hx,{open:!!N,onOpenChange:e=>!e&&j(null),children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:N?.success?"Document Deleted":"Error"}),(0,D.jsx)(hF,{children:N?.message})]}),(0,D.jsx)(hO,{children:(0,D.jsx)(hz,{onClick:()=>j(null),children:"OK"})})]})})]})}function hG(){let{currentBank:e}=(0,I.useBank)(),[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(null),[s,l]=(0,M.useState)(!1),[c,u]=(0,M.useState)(1),[d,h]=(0,M.useState)(0),f=Math.ceil(d/50),p=(c-1)*50,g=async(t=1)=>{if(e){i(!0);try{let r=await K.client.listEntities({bank_id:e,limit:50,offset:(t-1)*50});n(r.items||[]),h(r.total||0)}catch(e){}finally{i(!1)}}},v=async t=>{if(e){l(!0);try{let n=await K.client.getEntity(t,e);o(n)}catch(e){}finally{l(!1)}}},x=e=>{u(e),g(e)};(0,M.useEffect)(()=>{e&&(u(1),g(1),o(null))},[e]);let y=e=>e?new Date(e).toLocaleDateString():"N/A";return(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{children:r?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading entities..."})]})}):t.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[d," ",1===d?"entity":"entities"]}),(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)(ec,{children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{children:[(0,D.jsx)(ef,{children:"Name"}),(0,D.jsx)(ef,{children:"Mentions"}),(0,D.jsx)(ef,{children:"First Seen"}),(0,D.jsx)(ef,{children:"Last Seen"})]})}),(0,D.jsx)(ed,{children:t.map(e=>(0,D.jsxs)(eh,{onClick:()=>v(e.id),className:`cursor-pointer hover:bg-muted/50 ${a?.id===e.id?"bg-primary/10":""}`,children:[(0,D.jsx)(ep,{className:"font-medium text-card-foreground",children:e.canonical_name}),(0,D.jsx)(ep,{className:"text-card-foreground",children:e.mention_count}),(0,D.jsx)(ep,{className:"text-card-foreground",children:y(e.first_seen)}),(0,D.jsx)(ep,{className:"text-card-foreground",children:y(e.last_seen)})]},e.id))})]})}),f>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[p+1,"-",Math.min(p+50,d)," of ",d]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>x(1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(en,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>x(c-1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(G,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[c," / ",f]}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>x(c+1),disabled:c===f||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(Y,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>x(f),disabled:c===f||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(er,{className:"h-3 w-3"})})]})]})]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"No entities found"}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Entities are extracted from facts when memories are added."})]})})}),a&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l-2 border-primary shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:(0,D.jsxs)("div",{className:"p-5",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:a.canonical_name}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Entity details"})]}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"h-8 w-8 p-0",children:(0,D.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentions"}),(0,D.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:a.mention_count})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"First Seen"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:y(a.first_seen)})]})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Entity ID"}),(0,D.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:a.id})]})]})]})})]})}var hY=e.i(26330),hX=e.i(3536),hW=e.i(65491),hq=e.i(10772),h$=e.i(53660),hK=e.i(74606),hZ=Symbol("radix.slottable");function hQ(e){return M.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===hZ}var hJ=e.i(30207),h0=e.i(34620),h1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),h2=M.forwardRef((e,t)=>(0,D.jsx)(eA.Primitive.span,{...e,ref:t,style:{...h1,...e.style}}));h2.displayName="VisuallyHidden";var h5=e.i(86312),h3=e.i(85369),h4=[" ","Enter","ArrowUp","ArrowDown"],h6=[" ","Enter"],h9="Select",[h7,h8,fe]=(0,eD.createCollection)(h9),[ft,fn]=(0,eC.createContextScope)(h9,[fe,h$.createPopperScope]),fr=(0,h$.createPopperScope)(),[fi,fa]=ft(h9),[fo,fs]=ft(h9),fl=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:f,form:p}=e,g=fr(t),[v,x]=M.useState(null),[y,b]=M.useState(null),[w,N]=M.useState(!1),j=(0,eT.useDirection)(c),[k,C]=(0,eE.useControllableState)({prop:r,defaultProp:i??!1,onChange:a,caller:h9}),[E,T]=(0,eE.useControllableState)({prop:o,defaultProp:s,onChange:l,caller:h9}),S=M.useRef(null),_=!v||p||!!v.closest("form"),[A,P]=M.useState(new Set),R=Array.from(A).map(e=>e.props.value).join(";");return(0,D.jsx)(h$.Root,{...g,children:(0,D.jsxs)(fi,{required:f,scope:t,trigger:v,onTriggerChange:x,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:N,contentId:(0,hq.useId)(),value:E,onValueChange:T,open:k,onOpenChange:C,dir:j,triggerPointerDownPosRef:S,disabled:h,children:[(0,D.jsx)(h7.Provider,{scope:t,children:(0,D.jsx)(fo,{scope:e.__scopeSelect,onNativeOptionAdd:M.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:M.useCallback(e=>{P(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),_?(0,D.jsxs)(fW,{"aria-hidden":!0,required:f,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>T(e.target.value),disabled:h,form:p,children:[void 0===E?(0,D.jsx)("option",{value:""}):null,Array.from(A)]},R):null]})})};fl.displayName=h9;var fc="SelectTrigger",fu=M.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=fr(n),o=fa(fc,n),s=o.disabled||r,l=(0,ek.useComposedRefs)(t,o.onTriggerChange),c=h8(n),u=M.useRef("touch"),[d,h,f]=f$(e=>{let t=c().filter(e=>!e.disabled),n=t.find(e=>e.value===o.value),r=fK(t,e,n);void 0!==r&&o.onValueChange(r.value)}),p=e=>{s||(o.onOpenChange(!0),f()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,D.jsx)(h$.Anchor,{asChild:!0,...a,children:(0,D.jsx)(eA.Primitive.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:s,"data-disabled":s?"":void 0,"data-placeholder":fq(o.value)?"":void 0,...i,ref:l,onClick:(0,ej.composeEventHandlers)(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&p(e)}),onPointerDown:(0,ej.composeEventHandlers)(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(p(e),e.preventDefault())}),onKeyDown:(0,ej.composeEventHandlers)(i.onKeyDown,e=>{let t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||h(e.key),(!t||" "!==e.key)&&h4.includes(e.key)&&(p(),e.preventDefault())})})})});fu.displayName=fc;var fd="SelectValue",fh=M.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o="",...s}=e,l=fa(fd,n),{onValueNodeHasChildrenChange:c}=l,u=void 0!==a,d=(0,ek.useComposedRefs)(t,l.onValueNodeChange);return(0,h0.useLayoutEffect)(()=>{c(u)},[c,u]),(0,D.jsx)(eA.Primitive.span,{...s,ref:d,style:{pointerEvents:"none"},children:fq(l.value)?(0,D.jsx)(D.Fragment,{children:o}):a})});fh.displayName=fd;var ff=M.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,D.jsx)(eA.Primitive.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});ff.displayName="SelectIcon";var fp=e=>(0,D.jsx)(hK.Portal,{asChild:!0,...e});fp.displayName="SelectPortal";var fg="SelectContent",fm=M.forwardRef((e,t)=>{let n=fa(fg,e.__scopeSelect),[r,i]=M.useState();return((0,h0.useLayoutEffect)(()=>{i(new DocumentFragment)},[]),n.open)?(0,D.jsx)(fb,{...e,ref:t}):r?eg.createPortal((0,D.jsx)(fv,{scope:e.__scopeSelect,children:(0,D.jsx)(h7.Slot,{scope:e.__scopeSelect,children:(0,D.jsx)("div",{children:e.children})})}),r):null});fm.displayName=fg;var[fv,fx]=ft(fg),fy=((o=M.forwardRef((e,t)=>{let{children:n,...r}=e;if(M.isValidElement(n)){var i;let e,a,o=(i=n,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...a}:"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==M.Fragment&&(s.ref=t?(0,ek.composeRefs)(t,o):o),M.cloneElement(n,s)}return M.Children.count(n)>1?M.Children.only(null):null})).displayName="SelectContent.RemoveScroll.SlotClone",n=o,(r=M.forwardRef((e,t)=>{let{children:r,...i}=e,a=M.Children.toArray(r),o=a.find(hQ);if(o){let e=o.props.children,r=a.map(t=>t!==o?t:M.Children.count(e)>1?M.Children.only(null):M.isValidElement(e)?e.props.children:null);return(0,D.jsx)(n,{...i,ref:t,children:M.isValidElement(e)?M.cloneElement(e,void 0,r):null})}return(0,D.jsx)(n,{...i,ref:t,children:r})})).displayName="SelectContent.RemoveScroll.Slot",r),fb=M.forwardRef((e,t)=>{let{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:f,sticky:p,hideWhenDetached:g,avoidCollisions:v,...x}=e,y=fa(fg,n),[b,w]=M.useState(null),[N,j]=M.useState(null),k=(0,ek.useComposedRefs)(t,e=>w(e)),[C,E]=M.useState(null),[T,S]=M.useState(null),_=h8(n),[A,P]=M.useState(!1),R=M.useRef(!1);M.useEffect(()=>{if(b)return(0,h5.hideOthers)(b)},[b]),(0,hX.useFocusGuards)();let L=M.useCallback(e=>{let[t,...n]=_().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:"nearest"}),n===t&&N&&(N.scrollTop=0),n===r&&N&&(N.scrollTop=N.scrollHeight),n?.focus(),document.activeElement!==i))return},[_,N]),I=M.useCallback(()=>L([C,b]),[L,C,b]);M.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:O,triggerPointerDownPosRef:B}=y;M.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(B.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():b.contains(n.target)||O(!1),document.removeEventListener("pointermove",t),B.current=null};return null!==B.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[b,O,B]),M.useEffect(()=>{let e=()=>O(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[O]);let[F,z]=f$(e=>{let t=_().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=fK(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),V=M.useCallback((e,t,n)=>{let r=!R.current&&!n;(void 0!==y.value&&y.value===t||r)&&(E(e),r&&(R.current=!0))},[y.value]),H=M.useCallback(()=>b?.focus(),[b]),U=M.useCallback((e,t,n)=>{let r=!R.current&&!n;(void 0!==y.value&&y.value===t||r)&&S(e)},[y.value]),G="popper"===r?fN:fw,Y=G===fN?{side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:f,sticky:p,hideWhenDetached:g,avoidCollisions:v}:{};return(0,D.jsx)(fv,{scope:n,content:b,viewport:N,onViewportChange:j,itemRefCallback:V,selectedItem:C,onItemLeave:H,itemTextRefCallback:U,focusSelectedItem:I,selectedItemText:T,position:r,isPositioned:A,searchRef:F,children:(0,D.jsx)(h3.RemoveScroll,{as:fy,allowPinchZoom:!0,children:(0,D.jsx)(hW.FocusScope,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:(0,ej.composeEventHandlers)(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,D.jsx)(hY.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,D.jsx)(G,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:e=>e.preventDefault(),...x,...Y,onPlaced:()=>P(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:(0,ej.composeEventHandlers)(x.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=_().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});fb.displayName="SelectContentImpl";var fw=M.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=fa(fg,n),o=fx(fg,n),[s,l]=M.useState(null),[c,u]=M.useState(null),d=(0,ek.useComposedRefs)(t,e=>u(e)),h=h8(n),f=M.useRef(!1),p=M.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:x,focusSelectedItem:y}=o,b=M.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&c&&g&&v&&x){let e=a.trigger.getBoundingClientRect(),t=c.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=x.getBoundingClientRect();if("rtl"!==a.dir){let r=i.left-t.left,a=n.left-r,o=e.left-a,l=e.width+o,c=Math.max(l,t.width),u=eN(a,[10,Math.max(10,window.innerWidth-10-c)]);s.style.minWidth=l+"px",s.style.left=u+"px"}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,l=e.width+o,c=Math.max(l,t.width),u=eN(a,[10,Math.max(10,window.innerWidth-10-c)]);s.style.minWidth=l+"px",s.style.right=u+"px"}let o=h(),l=window.innerHeight-20,u=g.scrollHeight,d=window.getComputedStyle(c),p=parseInt(d.borderTopWidth,10),y=parseInt(d.paddingTop,10),b=parseInt(d.borderBottomWidth,10),w=p+y+u+parseInt(d.paddingBottom,10)+b,N=Math.min(5*v.offsetHeight,w),j=window.getComputedStyle(g),k=parseInt(j.paddingTop,10),C=parseInt(j.paddingBottom,10),E=e.top+e.height/2-10,T=v.offsetHeight/2,S=p+y+(v.offsetTop+T);if(S<=E){let e=o.length>0&&v===o[o.length-1].ref.current;s.style.bottom="0px";let t=Math.max(l-E,T+(e?C:0)+(c.clientHeight-g.offsetTop-g.offsetHeight)+b);s.style.height=S+t+"px"}else{let e=o.length>0&&v===o[0].ref.current;s.style.top="0px";let t=Math.max(E,p+g.offsetTop+(e?k:0)+T);s.style.height=t+(w-S)+"px",g.scrollTop=S-E+g.offsetTop}s.style.margin="10px 0",s.style.minHeight=N+"px",s.style.maxHeight=l+"px",r?.(),requestAnimationFrame(()=>f.current=!0)}},[h,a.trigger,a.valueNode,s,c,g,v,x,a.dir,r]);(0,h0.useLayoutEffect)(()=>b(),[b]);let[w,N]=M.useState();(0,h0.useLayoutEffect)(()=>{c&&N(window.getComputedStyle(c).zIndex)},[c]);let j=M.useCallback(e=>{e&&!0===p.current&&(b(),y?.(),p.current=!1)},[b,y]);return(0,D.jsx)(fj,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:f,onScrollButtonChange:j,children:(0,D.jsx)("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:(0,D.jsx)(eA.Primitive.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});fw.displayName="SelectItemAlignedPosition";var fN=M.forwardRef((e,t)=>{let{__scopeSelect:n,align:r="start",collisionPadding:i=10,...a}=e,o=fr(n);return(0,D.jsx)(h$.Content,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});fN.displayName="SelectPopperPosition";var[fj,fk]=ft(fg,{}),fC="SelectViewport",fE=M.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=fx(fC,n),o=fk(fC,n),s=(0,ek.useComposedRefs)(t,a.onViewportChange),l=M.useRef(0);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,D.jsx)(h7.Slot,{scope:n,children:(0,D.jsx)(eA.Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:s,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:(0,ej.composeEventHandlers)(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-20,i=Math.max(parseFloat(n.style.minHeight),parseFloat(n.style.height));if(i<r){let a=i+e,o=Math.min(r,a),s=a-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}l.current=t.scrollTop})})})]})});fE.displayName=fC;var fT="SelectGroup",[fS,f_]=ft(fT);M.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=(0,hq.useId)();return(0,D.jsx)(fS,{scope:n,id:i,children:(0,D.jsx)(eA.Primitive.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=fT;var fA="SelectLabel",fD=M.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=f_(fA,n);return(0,D.jsx)(eA.Primitive.div,{id:i.id,...r,ref:t})});fD.displayName=fA;var fM="SelectItem",[fP,fR]=ft(fM),fL=M.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=fa(fM,n),l=fx(fM,n),c=s.value===r,[u,d]=M.useState(a??""),[h,f]=M.useState(!1),p=(0,ek.useComposedRefs)(t,e=>l.itemRefCallback?.(e,r,i)),g=(0,hq.useId)(),v=M.useRef("touch"),x=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(""===r)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,D.jsx)(fP,{scope:n,value:r,disabled:i,textId:g,isSelected:c,onItemTextChange:M.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:(0,D.jsx)(h7.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,D.jsx)(eA.Primitive.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:p,onFocus:(0,ej.composeEventHandlers)(o.onFocus,()=>f(!0)),onBlur:(0,ej.composeEventHandlers)(o.onBlur,()=>f(!1)),onClick:(0,ej.composeEventHandlers)(o.onClick,()=>{"mouse"!==v.current&&x()}),onPointerUp:(0,ej.composeEventHandlers)(o.onPointerUp,()=>{"mouse"===v.current&&x()}),onPointerDown:(0,ej.composeEventHandlers)(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:(0,ej.composeEventHandlers)(o.onPointerMove,e=>{v.current=e.pointerType,i?l.onItemLeave?.():"mouse"===v.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:(0,ej.composeEventHandlers)(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:(0,ej.composeEventHandlers)(o.onKeyDown,e=>{(l.searchRef?.current===""||" "!==e.key)&&(h6.includes(e.key)&&x()," "===e.key&&e.preventDefault())})})})})});fL.displayName=fM;var fI="SelectItemText",fO=M.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=fa(fI,n),s=fx(fI,n),l=fR(fI,n),c=fs(fI,n),[u,d]=M.useState(null),h=(0,ek.useComposedRefs)(t,e=>d(e),l.onItemTextChange,e=>s.itemTextRefCallback?.(e,l.value,l.disabled)),f=u?.textContent,p=M.useMemo(()=>(0,D.jsx)("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=c;return(0,h0.useLayoutEffect)(()=>(g(p),()=>v(p)),[g,v,p]),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(eA.Primitive.span,{id:l.textId,...a,ref:h}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren?eg.createPortal(a.children,o.valueNode):null]})});fO.displayName=fI;var fB="SelectItemIndicator",fF=M.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return fR(fB,n).isSelected?(0,D.jsx)(eA.Primitive.span,{"aria-hidden":!0,...r,ref:t}):null});fF.displayName=fB;var fz="SelectScrollUpButton",fV=M.forwardRef((e,t)=>{let n=fx(fz,e.__scopeSelect),r=fk(fz,e.__scopeSelect),[i,a]=M.useState(!1),o=(0,ek.useComposedRefs)(t,r.onScrollButtonChange);return(0,h0.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),i?(0,D.jsx)(fG,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});fV.displayName=fz;var fH="SelectScrollDownButton",fU=M.forwardRef((e,t)=>{let n=fx(fH,e.__scopeSelect),r=fk(fH,e.__scopeSelect),[i,a]=M.useState(!1),o=(0,ek.useComposedRefs)(t,r.onScrollButtonChange);return(0,h0.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),i?(0,D.jsx)(fG,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});fU.displayName=fH;var fG=M.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=fx("SelectScrollButton",n),o=M.useRef(null),s=h8(n),l=M.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return M.useEffect(()=>()=>l(),[l]),(0,h0.useLayoutEffect)(()=>{let e=s().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[s]),(0,D.jsx)(eA.Primitive.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:(0,ej.composeEventHandlers)(i.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(r,50))}),onPointerMove:(0,ej.composeEventHandlers)(i.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(r,50))}),onPointerLeave:(0,ej.composeEventHandlers)(i.onPointerLeave,()=>{l()})})}),fY=M.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,D.jsx)(eA.Primitive.div,{"aria-hidden":!0,...r,ref:t})});fY.displayName="SelectSeparator";var fX="SelectArrow";M.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=fr(n),a=fa(fX,n),o=fx(fX,n);return a.open&&"popper"===o.position?(0,D.jsx)(h$.Arrow,{...i,...r,ref:t}):null}).displayName=fX;var fW=M.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=M.useRef(null),a=(0,ek.useComposedRefs)(r,i),o=(0,eS.usePrevious)(t);return M.useEffect(()=>{let e=i.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==t&&n){let r=new Event("change",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,D.jsx)(eA.Primitive.select,{...n,style:{...h1,...n.style},ref:a,defaultValue:t})});function fq(e){return""===e||void 0===e}function f$(e){let t=(0,hJ.useCallbackRef)(e),n=M.useRef(""),r=M.useRef(0),i=M.useCallback(e=>{let i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),a=M.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return M.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function fK(e,t,n){var r,i;let a=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=(r=e,i=Math.max(o,0),r.map((e,t)=>r[(i+t)%r.length]));1===a.length&&(s=s.filter(e=>e!==n));let l=s.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return l!==n?l:void 0}fW.displayName="SelectBubbleInput";let fZ=(0,F.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),fQ=(0,F.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),fJ=M.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(fu,{ref:r,className:(0,W.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,(0,D.jsx)(ff,{asChild:!0,children:(0,D.jsx)(fZ,{className:"h-4 w-4 opacity-50"})})]}));fJ.displayName=fu.displayName;let f0=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(fV,{ref:n,className:(0,W.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,D.jsx)(fQ,{className:"h-4 w-4"})}));f0.displayName=fV.displayName;let f1=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(fU,{ref:n,className:(0,W.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,D.jsx)(fZ,{className:"h-4 w-4"})}));f1.displayName=fU.displayName;let f2=M.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>(0,D.jsx)(fp,{children:(0,D.jsxs)(fm,{ref:i,className:(0,W.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[(0,D.jsx)(f0,{}),(0,D.jsx)(fE,{className:(0,W.cn)("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),(0,D.jsx)(f1,{})]})}));f2.displayName=fm.displayName,M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(fD,{ref:n,className:(0,W.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=fD.displayName;let f5=M.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(fL,{ref:r,className:(0,W.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(fF,{children:(0,D.jsx)(tl.Check,{className:"h-4 w-4"})})}),(0,D.jsx)(fO,{children:t})]}));f5.displayName=fL.displayName,M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(fY,{ref:n,className:(0,W.cn)("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=fY.displayName;var f3=e.i(32089);let f4=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));f4.displayName="Card";let f6=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("flex flex-col space-y-1.5 p-6",e),...t}));f6.displayName="CardHeader";let f9=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("text-2xl font-semibold leading-none tracking-tight",e),...t}));f9.displayName="CardTitle";let f7=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("text-sm text-muted-foreground",e),...t}));f7.displayName="CardDescription";let f8=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("p-6 pt-0",e),...t}));f8.displayName="CardContent",M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter";var pe=e.i(52571);let pt=(0,F.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),pn=(0,F.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),pr=(0,F.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),pi=(0,F.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var pa=e.i(1864);"function"==typeof SuppressedError&&SuppressedError;var po=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach(function(t){e.addRange(t)}),t&&t.focus()}},ps={"text/plain":"Text","text/html":"Url",default:"Text"},pl=function(e,t){var n,r,i,a,o,s,l,c,u=!1;t||(t={}),i=t.debug||!1;try{if(o=po(),s=document.createRange(),l=document.getSelection(),(c=document.createElement("span")).textContent=e,c.ariaHidden="true",c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),void 0===n.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var r=ps[t.format]||ps.default;window.clipboardData.setData(r,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(c),s.selectNodeContents(c),l.addRange(s),!document.execCommand("copy"))throw Error("copy command was unsuccessful");u=!0}catch(o){i&&console.error("unable to copy using execCommand: ",o),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(o){i&&console.error("unable to copy using clipboardData: ",o),i&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",r=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",a=n.replace(/#{\s*key\s*}/g,r),window.prompt(a,e)}}finally{l&&("function"==typeof l.removeRange?l.removeRange(s):l.removeAllRanges()),c&&document.body.removeChild(c),o()}return u};function pc(e){return"[object Object]"===Object.prototype.toString.call(e)}function pu(e){return Array.isArray(e)?e.length:pc(e)?Object.keys(e).length:0}function pd(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=pu(e);if("function"==typeof r){let i=pp(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||pc(e)&&o>i)}function ph(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Math.ceil(e.length/100);if("function"==typeof r){let i=pp(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||pc(e)&&o>i)}function pf(e,t,n){return"boolean"==typeof e?e:"number"==typeof e&&!!(t>e)||"collapsed"===e&&!!n||"expanded"===e&&!n}function pp(e,t){try{return e(...t)}catch(e){reportError(e)}}function pg(e){if(!0===e||pc(e)&&!0===e.add)return!0}function pm(e){if(!0===e||pc(e)&&!0===e.edit)return!0}function pv(e){if(!0===e||pc(e)&&!0===e.delete)return!0}function px(e){return!e||void 0===e.add||!!e.add}function py(e){return!e||void 0===e.edit||!!e.edit}function pb(e){return!e||void 0===e.delete||!!e.delete}function pw(e){return!e||void 0===e.enableClipboard||!!e.enableClipboard}function pN(){return(pN=Object.assign.bind()).apply(this,arguments)}var pj=function(e){return M.createElement("svg",pN({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),g||(g=M.createElement("path",{fill:"currentColor",d:"M12.473 5.806a.666.666 0 0 0-.946 0L8.473 8.86a.667.667 0 0 1-.946 0L4.473 5.806a.667.667 0 1 0-.946.94l3.06 3.06a2 2 0 0 0 2.826 0l3.06-3.06a.667.667 0 0 0 0-.94Z"})))};function pk(){return(pk=Object.assign.bind()).apply(this,arguments)}var pC=function(e){return M.createElement("svg",pk({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),v||(v=M.createElement("path",{fill:"currentColor",d:"M17.542 2.5h-4.75a3.963 3.963 0 0 0-3.959 3.958v4.75a3.963 3.963 0 0 0 3.959 3.959h4.75a3.963 3.963 0 0 0 3.958-3.959v-4.75A3.963 3.963 0 0 0 17.542 2.5Zm2.375 8.708a2.378 2.378 0 0 1-2.375 2.375h-4.75a2.378 2.378 0 0 1-2.375-2.375v-4.75a2.378 2.378 0 0 1 2.375-2.375h4.75a2.378 2.378 0 0 1 2.375 2.375v4.75Zm-4.75 6.334a3.963 3.963 0 0 1-3.959 3.958h-4.75A3.963 3.963 0 0 1 2.5 17.542v-4.75a3.963 3.963 0 0 1 3.958-3.959.791.791 0 1 1 0 1.584 2.378 2.378 0 0 0-2.375 2.375v4.75a2.378 2.378 0 0 0 2.375 2.375h4.75a2.378 2.378 0 0 0 2.375-2.375.792.792 0 1 1 1.584 0Z"})))};function pE(){return(pE=Object.assign.bind()).apply(this,arguments)}var pT=function(e){return M.createElement("svg",pE({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),x||(x=M.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.755 3.755 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.755 3.755 0 0 0 17.25 3Zm2.25 14.25a2.25 2.25 0 0 1-2.25 2.25H6.75a2.25 2.25 0 0 1-2.25-2.25V6.75A2.25 2.25 0 0 1 6.75 4.5h10.5a2.25 2.25 0 0 1 2.25 2.25v10.5Z"})),y||(y=M.createElement("path",{fill:"#14C786",d:"M10.312 14.45 7.83 11.906a.625.625 0 0 0-.896 0 .659.659 0 0 0 0 .918l2.481 2.546a1.264 1.264 0 0 0 .896.381 1.237 1.237 0 0 0 .895-.38l5.858-6.011a.658.658 0 0 0 0-.919.625.625 0 0 0-.896 0l-5.857 6.01Z"})))};function pS({node:e,nodeMeta:t}){let{customizeCopy:n,CopyComponent:r,CopiedComponent:i}=(0,M.useContext)(pq),[a,o]=(0,M.useState)(!1),s=r=>{r.stopPropagation();let i=n(e,t);"string"==typeof i&&i&&function(e){var t,n,r,i;t=this,n=void 0,r=void 0,i=function*(){try{yield navigator.clipboard.writeText(e)}catch(t){pl(e)}},new(r||(r=Promise))(function(e,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(t){var n;t.done?e(t.value):((n=t.value)instanceof r?n:new r(function(e){e(n)})).then(o,s)}l((i=i.apply(t,n||[])).next())})}(i),o(!0),setTimeout(()=>o(!1),3e3)};return a?"function"==typeof i?(0,D.jsx)(i,{className:"json-view--copy",style:{display:"inline-block"}}):(0,D.jsx)(pT,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof r?(0,D.jsx)(r,{onClick:s,className:"json-view--copy"}):(0,D.jsx)(pC,{onClick:s,className:"json-view--copy"})}function p_({indexOrName:e,value:t,depth:n,deleteHandle:r,editHandle:i,parent:a,parentPath:o}){let{displayArrayIndex:s}=(0,M.useContext)(pq),l=Array.isArray(a);return(0,D.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!l||l&&s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",Object.assign({className:"number"==typeof e?"json-view--index":"json-view--property"},{children:e})),":"," "]}):(0,D.jsx)(D.Fragment,{}),(0,D.jsx)(pX,{node:t,depth:n+1,deleteHandle:(e,t)=>r(e,t),editHandle:(e,t,n,r)=>i(e,t,n,r),parent:a,indexOrName:e,parentPath:o})]}))}function pA(){return(pA=Object.assign.bind()).apply(this,arguments)}var pD=function(e){return M.createElement("svg",pA({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),b||(b=M.createElement("path",{fill:"currentColor",d:"M18.75 6h-2.325a3.757 3.757 0 0 0-3.675-3h-1.5a3.757 3.757 0 0 0-3.675 3H5.25a.75.75 0 0 0 0 1.5H6v9.75A3.754 3.754 0 0 0 9.75 21h4.5A3.754 3.754 0 0 0 18 17.25V7.5h.75a.75.75 0 1 0 0-1.5Zm-7.5-1.5h1.5A2.255 2.255 0 0 1 14.872 6H9.128a2.255 2.255 0 0 1 2.122-1.5Zm5.25 12.75a2.25 2.25 0 0 1-2.25 2.25h-4.5a2.25 2.25 0 0 1-2.25-2.25V7.5h9v9.75Z"})),w||(w=M.createElement("path",{fill:"#DA0000",d:"M10.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75ZM13.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75Z"})))};function pM(){return(pM=Object.assign.bind()).apply(this,arguments)}var pP=function(e){return M.createElement("svg",pM({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),N||(N=M.createElement("path",{fill:"currentColor",d:"M21 6.75v10.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3h10.5A3.754 3.754 0 0 1 21 6.75Zm-1.5 0c0-1.24-1.01-2.25-2.25-2.25H6.75C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25V6.75Z"})),j||(j=M.createElement("path",{fill:"#14C786",d:"M15 12.75a.75.75 0 1 0 0-1.5h-2.25V9a.75.75 0 1 0-1.5 0v2.25H9a.75.75 0 1 0 0 1.5h2.25V15a.75.75 0 1 0 1.5 0v-2.25H15Z"})))};function pR(){return(pR=Object.assign.bind()).apply(this,arguments)}var pL=function(e){return M.createElement("svg",pR({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),k||(k=M.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})),C||(C=M.createElement("path",{fill:"#14C786",d:"m10.85 13.96-1.986-2.036a.5.5 0 0 0-.716 0 .527.527 0 0 0 0 .735l1.985 2.036a1.01 1.01 0 0 0 .717.305.99.99 0 0 0 .716-.305l4.686-4.808a.526.526 0 0 0 0-.735.5.5 0 0 0-.716 0l-4.687 4.809Z"})))};function pI(){return(pI=Object.assign.bind()).apply(this,arguments)}var pO=function(e){return M.createElement("svg",pI({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),E||(E=M.createElement("path",{fill:"#DA0000",d:"M15 9a.75.75 0 0 0-1.06 0L12 10.94 10.06 9A.75.75 0 0 0 9 10.06L10.94 12 9 13.94A.75.75 0 0 0 10.06 15L12 13.06 13.94 15A.75.75 0 0 0 15 13.94L13.06 12 15 10.06A.75.75 0 0 0 15 9Z"})),T||(T=M.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})))};function pB({originNode:e,node:t,depth:n,index:r,deleteHandle:i,customOptions:a,startIndex:o,parent:s,parentPath:l}){let{enableClipboard:c,src:u,onEdit:d,onChange:h,forceUpdate:f,displaySize:p,CustomOperation:g}=(0,M.useContext)(pq),v=[...l,String(r)],[x,y]=(0,M.useState)(!0),b=(0,M.useCallback)((t,r,i)=>{e[t]=r,d&&d({newValue:r,oldValue:i,depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),h&&h({type:"edit",depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),f()},[t,d,h,f]),w=t=>{e.splice(t,1),i&&i(t,l),f()},N=(0,D.jsxs)(D.Fragment,{children:[!x&&(0,D.jsxs)("span",Object.assign({onClick:()=>y(!0),className:"jv-size-chevron"},{children:[pf(p,n,x)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[pu(t)," Items"]})),(0,D.jsx)(pj,{className:"jv-chevron"})]})),!x&&c&&pw(a)&&(0,D.jsx)(pS,{node:t,nodeMeta:{depth:n,indexOrName:r,parent:s,parentPath:l,currentPath:v}}),"function"==typeof g?(0,D.jsx)(g,{node:t}):null]});return(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{children:"["}),N,x?(0,D.jsxs)("button",Object.assign({onClick:()=>y(!1),className:"jv-button"},{children:[o," ... ",o+t.length-1]})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:t.map((e,i)=>(0,D.jsx)(p_,{indexOrName:i+o,value:e,depth:n,parent:t,deleteHandle:w,editHandle:b,parentPath:l},String(r)+String(i)))})),(0,D.jsx)("span",{children:"]"})]})}function pF({node:e,depth:t,deleteHandle:n,indexOrName:r,customOptions:i,parent:a,parentPath:o}){let s=void 0!==r?[...o,String(r)]:o,l=[];for(let t=0;t<e.length;t+=100)l.push(e.slice(t,t+100));let{collapsed:c,enableClipboard:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,CustomOperation:v,onChange:x,forceUpdate:y,displaySize:b}=(0,M.useContext)(pq),[w,N]=(0,M.useState)(ph(e,t,r,c,d,i));(0,M.useEffect)(()=>{N(ph(e,t,r,c,d,i))},[c,d]);let[j,k]=(0,M.useState)(!1),[C,E]=(0,M.useState)(!1),T=()=>{e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),x&&x({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),y()},S=j||C,_=(0,D.jsxs)(D.Fragment,{children:[!w&&!S&&(0,D.jsxs)("span",Object.assign({onClick:()=>N(!0),className:"jv-size-chevron"},{children:[pf(b,t,w)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[e.length," Items"]})),(0,D.jsx)(pj,{className:"jv-chevron"})]})),S&&(0,D.jsx)(pL,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?T:()=>{k(!1),n&&n(r,o),f&&f({value:e,depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o}),x&&x({type:"delete",depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o})}}),S&&(0,D.jsx)(pO,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{k(!1),E(!1)}}),!w&&!S&&u&&pw(i)&&(0,D.jsx)(pS,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:a,parentPath:o,currentPath:s}}),!w&&!S&&pg(h)&&px(i)&&(0,D.jsx)(pP,{className:"json-view--edit",onClick:()=>{T()}}),!w&&!S&&pv(h)&&pb(i)&&n&&(0,D.jsx)(pD,{className:"json-view--edit",onClick:()=>k(!0)}),"function"==typeof v?(0,D.jsx)(v,{node:e}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"["}),_,w?(0,D.jsx)("button",Object.assign({onClick:()=>N(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:l.map((a,s)=>(0,D.jsx)(pB,{originNode:e,node:a,depth:t,index:s,startIndex:100*s,deleteHandle:n,customOptions:i,parentPath:o},String(r)+String(s)))})),(0,D.jsx)("span",{children:"]"}),w&&pf(b,t,w)&&(0,D.jsxs)("span",Object.assign({onClick:()=>N(!1),className:"jv-size"},{children:[e.length," Items"]}))]})}function pz({node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parent:a,parentPath:o}){let{collapsed:s,onCollapse:l,enableClipboard:c,ignoreLargeArray:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,onEdit:v,onChange:x,forceUpdate:y,displaySize:b,CustomOperation:w}=(0,M.useContext)(pq),N=void 0!==n?[...o,String(n)]:o;if(!u&&Array.isArray(e)&&e.length>100)return(0,D.jsx)(pF,{node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parentPath:N});let j=pc(e),[k,C]=(0,M.useState)(pd(e,t,n,s,d,i)),E=r=>{null==l||l({isCollapsing:!r,node:e,depth:t,indexOrName:n}),C(r)};(0,M.useEffect)(()=>{E(pd(e,t,n,s,d,i))},[s,d]);let T=(0,M.useCallback)((n,r,i)=>{Array.isArray(e)?e[+n]=r:e&&(e[n]=r),v&&v({newValue:r,oldValue:i,depth:t,src:p,indexOrName:n,parentType:j?"object":"array",parentPath:N}),x&&x({type:"edit",depth:t,src:p,indexOrName:n,parentType:j?"object":"array",parentPath:N}),y()},[e,v,x,y]),S=t=>{Array.isArray(e)?e.splice(+t,1):e&&delete e[t],y()},[_,A]=(0,M.useState)(!1),[P,R]=(0,M.useState)(!1),L=(0,M.useRef)(null),I=()=>{var n;if(j){let r=null==(n=L.current)?void 0:n.value;r&&(e[r]=null,L.current&&(L.current.value=""),R(!1),g&&g({indexOrName:r,depth:t,src:p,parentType:"object",parentPath:N}),x&&x({type:"add",indexOrName:r,depth:t,src:p,parentType:"object",parentPath:N}))}else Array.isArray(e)&&(e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:N}),x&&x({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:N}));y()},O=_||P,B=()=>{A(!1),R(!1)},F=(0,D.jsxs)(D.Fragment,{children:[!k&&!O&&(0,D.jsxs)("span",Object.assign({onClick:()=>E(!0),className:"jv-size-chevron"},{children:[pf(b,t,k)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[pu(e)," Items"]})),(0,D.jsx)(pj,{className:"jv-chevron"})]})),P&&j&&(0,D.jsx)("input",{className:"json-view--input",placeholder:"property",ref:L,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),I()):"Escape"===e.key&&B()}}),O&&(0,D.jsx)(pL,{className:"json-view--edit",style:{display:"inline-block"},onClick:P?I:()=>{A(!1),r&&r(n,N),f&&f({value:e,depth:t,src:p,indexOrName:n,parentType:j?"object":"array",parentPath:N}),x&&x({type:"delete",depth:t,src:p,indexOrName:n,parentType:j?"object":"array",parentPath:N})}}),O&&(0,D.jsx)(pO,{className:"json-view--edit",style:{display:"inline-block"},onClick:B}),!k&&!O&&c&&pw(i)&&(0,D.jsx)(pS,{node:e,nodeMeta:{depth:t,indexOrName:n,parent:a,parentPath:o,currentPath:N}}),!k&&!O&&pg(h)&&px(i)&&(0,D.jsx)(pP,{className:"json-view--edit",onClick:()=>{j?(R(!0),setTimeout(()=>{var e;return null==(e=L.current)?void 0:e.focus()})):I()}}),!k&&!O&&pv(h)&&pb(i)&&r&&(0,D.jsx)(pD,{className:"json-view--edit",onClick:()=>A(!0)}),"function"==typeof w?(0,D.jsx)(w,{node:e}):null]});return Array.isArray(e)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"["}),F,k?(0,D.jsx)("button",Object.assign({onClick:()=>E(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:e.map((r,i)=>(0,D.jsx)(p_,{indexOrName:i,value:r,depth:t,parent:e,deleteHandle:S,editHandle:T,parentPath:N},String(n)+String(i)))})),(0,D.jsx)("span",{children:"]"}),k&&pf(b,t,k)&&(0,D.jsxs)("span",Object.assign({onClick:()=>E(!1),className:"jv-size"},{children:[pu(e)," Items"]}))]}):j?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"{"}),F,k?(0,D.jsx)("button",Object.assign({onClick:()=>E(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(e).map(([r,i])=>(0,D.jsx)(p_,{indexOrName:r,value:i,depth:t,parent:e,deleteHandle:S,editHandle:T,parentPath:N},String(n)+String(r)))})),(0,D.jsx)("span",{children:"}"}),k&&pf(b,t,k)&&(0,D.jsxs)("span",Object.assign({onClick:()=>E(!1),className:"jv-size"},{children:[pu(e)," Items"]}))]}):(0,D.jsx)("span",{children:String(e)})}let pV=M.default.forwardRef(({str:e,className:t,ctrlClick:n},r)=>{let{collapseStringMode:i,collapseStringsAfterLength:a,customizeCollapseStringUI:o}=(0,M.useContext)(pq),[s,l]=(0,M.useState)(!0),c=(0,M.useRef)(null);a=a>0?a:0;let u=e.replace(/\s+/g," "),d="function"==typeof o?o(u,s):"string"==typeof o?o:"...",h=e=>{var t;if((e.ctrlKey||e.metaKey)&&n)n(e);else{let e=window.getSelection();if(e&&e.anchorOffset!==e.focusOffset&&(null==(t=e.anchorNode)?void 0:t.parentElement)===c.current)return;l(!s)}};if(e.length<=a)return(0,D.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']}));if("address"===i)return e.length<=10?(0,D.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']})):(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,6),d,u.slice(-4)]:e,'"']}));if("directly"===i)return(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,a),d]:e,'"']}));if("word"===i){let n=a,r=a+1,i=u,o=1;for(;;){if(/\W/.test(e[n])){i=e.slice(0,n);break}if(/\W/.test(e[r])){i=e.slice(0,r);break}if(6===o){i=e.slice(0,a);break}o++,n--,r++}return(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[i,d]:e,'"']}))}return(0,D.jsxs)("span",Object.assign({ref:c,className:t},{children:['"',e,'"']}))});function pH(){return(pH=Object.assign.bind()).apply(this,arguments)}var pU=function(e){return M.createElement("svg",pH({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),S||(S=M.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.754 3.754 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.754 3.754 0 0 0 17.25 3Zm2.25 14.25c0 1.24-1.01 2.25-2.25 2.25H6.75c-1.24 0-2.25-1.01-2.25-2.25V6.75c0-1.24 1.01-2.25 2.25-2.25h10.5c1.24 0 2.25 1.01 2.25 2.25v10.5Zm-6.09-9.466-5.031 5.03a2.981 2.981 0 0 0-.879 2.121v1.19c0 .415.336.75.75.75h1.19c.8 0 1.554-.312 2.12-.879l5.03-5.03a2.252 2.252 0 0 0 0-3.182c-.85-.85-2.331-.85-3.18 0Zm-2.91 7.151c-.28.28-.666.44-1.06.44H9v-.44c0-.4.156-.777.44-1.06l3.187-3.188 1.06 1.061-3.187 3.188Zm5.03-5.03-.782.783-1.06-1.061.782-.782a.766.766 0 0 1 1.06 0 .75.75 0 0 1 0 1.06Z"})))};function pG(){return(pG=Object.assign.bind()).apply(this,arguments)}var pY=function(e){return M.createElement("svg",pG({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),_||(_=M.createElement("path",{fill:"currentColor",d:"M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"})),A||(A=M.createElement("path",{fill:"currentColor",d:"M20.013 3h-3.946a.987.987 0 0 0 0 1.973h1.564l-6.342 6.342a1.004 1.004 0 0 0 0 1.396 1.004 1.004 0 0 0 1.396 0l6.342-6.342v1.564a.987.987 0 0 0 1.973 0V3.987A.987.987 0 0 0 20.013 3Z"})))};function pX({node:e,depth:t,deleteHandle:n,indexOrName:r,parent:i,editHandle:a,parentPath:o}){let s,{collapseStringsAfterLength:l,enableClipboard:c,editable:u,src:d,onDelete:h,onChange:f,customizeNode:p,matchesURL:g,urlRegExp:v,EditComponent:x,DoneComponent:y,CancelComponent:b,CustomOperation:w}=(0,M.useContext)(pq);if("function"==typeof p&&(s=pp(p,[{node:e,depth:t,indexOrName:r}])),s){if((0,M.isValidElement)(s))return s;else if("function"==typeof s){let n=s;return(0,D.jsx)(n,{node:e,depth:t,indexOrName:r})}}if(Array.isArray(e)||pc(e))return(0,D.jsx)(pz,{parent:i,node:e,depth:t,indexOrName:r,deleteHandle:n,parentPath:o,customOptions:"object"==typeof s?s:void 0});{var N;let p=typeof e,j=void 0!==r?[...o,String(r)]:o,[k,C]=(0,M.useState)(!1),[E,T]=(0,M.useState)(!1),S=(0,M.useRef)(null),_=()=>{C(!0),setTimeout(()=>{var e,t;null==(e=window.getSelection())||e.selectAllChildren(S.current),null==(t=S.current)||t.focus()})},A=(0,M.useCallback)(()=>{let t=S.current.innerText;try{let n=JSON.parse(t);a&&a(r,n,e,o)}catch(i){let n="string"===p?t.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):t;a&&a(r,n,e,o)}C(!1)},[a,r,e,o,p]),P=()=>{C(!1),T(!1)},R=()=>{T(!1),n&&n(r,o),h&&h({value:e,depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",parentPath:o}),f&&f({depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",type:"delete",parentPath:o})},L=(0,M.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),A()):"Escape"===e.key&&P()},[A]),I=k||E,O=!I&&pm(u)&&py(s)&&a?e=>{(e.ctrlKey||e.metaKey)&&_()}:void 0,B=(0,D.jsxs)(D.Fragment,{children:[I&&("function"==typeof y?(0,D.jsx)(y,{className:"json-view--edit",style:{display:"inline-block"},onClick:E?R:A}):(0,D.jsx)(pL,{className:"json-view--edit",style:{display:"inline-block"},onClick:E?R:A})),I&&("function"==typeof b?(0,D.jsx)(b,{className:"json-view--edit",style:{display:"inline-block"},onClick:P}):(0,D.jsx)(pO,{className:"json-view--edit",style:{display:"inline-block"},onClick:P})),!I&&c&&pw(s)&&(0,D.jsx)(pS,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:i,parentPath:o,currentPath:j}}),!I&&g&&"string"===p&&v.test(e)&&(!(N=s)||void 0===N.matchesURL||!!N.matchesURL)&&(0,D.jsx)("a",Object.assign({href:e,target:"_blank",className:"json-view--link"},{children:(0,D.jsx)(pY,{})})),!I&&pm(u)&&py(s)&&a&&("function"==typeof x?(0,D.jsx)(x,{className:"json-view--edit",onClick:_}):(0,D.jsx)(pU,{className:"json-view--edit",onClick:_})),!I&&pv(u)&&pb(s)&&n&&(0,D.jsx)(pD,{className:"json-view--edit",onClick:()=>T(!0)}),"function"==typeof w?(0,D.jsx)(w,{node:e}):null]}),F="json-view--string";switch(p){case"number":case"bigint":F="json-view--number";break;case"boolean":F="json-view--boolean";break;case"object":F="json-view--null"}"string"==typeof(null==s?void 0:s.className)&&(F+=" "+s.className),E&&(F+=" json-view--deleting");let z=String(e);"bigint"===p&&(z+="n");let V=(0,M.useMemo)(()=>(0,D.jsx)("span",{contentEditable:!0,className:F,dangerouslySetInnerHTML:{__html:"string"===p?`"${z}"`:z},ref:S,onKeyDown:L}),[z,p,L]);return"string"===p?(0,D.jsxs)(D.Fragment,{children:[k?V:e.length>l?(0,D.jsx)(pV,{str:e,ref:S,className:F,ctrlClick:O}):(0,D.jsxs)("span",Object.assign({className:F,onClick:O},{children:['"',z,'"']})),B]}):(0,D.jsxs)(D.Fragment,{children:[k?V:(0,D.jsx)("span",Object.assign({className:F,onClick:O},{children:z})),B]})}}let pW=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,pq=(0,M.createContext)({src:void 0,collapseStringsAfterLength:99,collapseStringMode:"directly",customizeCollapseStringUI:void 0,collapseObjectsAfterLength:20,collapsed:!1,onCollapse:void 0,enableClipboard:!0,editable:!1,onEdit:void 0,onDelete:void 0,onAdd:void 0,onChange:void 0,forceUpdate:()=>{},customizeNode:void 0,customizeCopy:()=>{},displaySize:void 0,displayArrayIndex:!0,matchesURL:!1,urlRegExp:pW,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function p$({src:e,collapseStringsAfterLength:t=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:i=99,collapsed:a,onCollapse:o,enableClipboard:s=!0,editable:l=!1,onEdit:c,onDelete:u,onAdd:d,onChange:h,dark:f=!1,theme:p="default",customizeNode:g,customizeCopy:v=e=>(function(e,t){if("string"==typeof e)return e;try{return JSON.stringify(e,(e,t)=>{switch(typeof t){case"bigint":return String(t)+"n";case"number":case"boolean":case"object":case"string":return t;default:return String(t)}},void 0)}catch(e){return`${e.name}: ${e.message}`||"JSON.stringify failed"}})(e),displaySize:x,displayArrayIndex:y=!0,style:b,className:w,matchesURL:N=!1,urlRegExp:j=pW,ignoreLargeArray:k=!1,CopyComponent:C,CopiedComponent:E,EditComponent:T,CancelComponent:S,DoneComponent:_,CustomOperation:A}){let[P,R]=(0,M.useState)(0),L=(0,M.useCallback)(()=>R(e=>++e),[]),[I,O]=(0,M.useState)(e);return(0,M.useEffect)(()=>O(e),[e]),(0,D.jsx)(pq.Provider,Object.assign({value:{src:I,collapseStringsAfterLength:t,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:i,collapsed:a,onCollapse:o,enableClipboard:s,editable:l,onEdit:c,onDelete:u,onAdd:d,onChange:h,forceUpdate:L,customizeNode:g,customizeCopy:v,displaySize:x,displayArrayIndex:y,matchesURL:N,urlRegExp:j,ignoreLargeArray:k,CopyComponent:C,CopiedComponent:E,EditComponent:T,CancelComponent:S,DoneComponent:_,CustomOperation:A}},{children:(0,D.jsx)("code",Object.assign({className:"json-view"+(f?" dark":"")+(p&&"default"!==p?" json-view_"+p:"")+(w?" "+w:""),style:b},{children:(0,D.jsx)(pX,{node:I,depth:1,editHandle:(e,t,n,r)=>{O(t),c&&c({newValue:t,oldValue:n,depth:1,src:I,indexOrName:e,parentType:null,parentPath:r}),h&&h({type:"edit",depth:1,src:I,indexOrName:e,parentType:null,parentPath:r})},deleteHandle:(e,t)=>{O(void 0),u&&u({value:I,depth:1,src:I,indexOrName:e,parentType:null,parentPath:t}),h&&h({depth:1,src:I,indexOrName:e,parentType:null,type:"delete",parentPath:t})},parentPath:[]})}))}))}var tu=tu;let pK=(0,F.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function pZ(){}function pQ(){}let pJ=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,p0=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,p1={};function p2(e,t){return((t||p1).jsx?p0:pJ).test(e)}let p5=/[ \t\n\f\r]/g;function p3(e){return""===e.replace(p5,"")}class p4{constructor(e,t){this.attribute=t,this.property=e}}p4.prototype.attribute="",p4.prototype.booleanish=!1,p4.prototype.boolean=!1,p4.prototype.commaOrSpaceSeparated=!1,p4.prototype.commaSeparated=!1,p4.prototype.defined=!1,p4.prototype.mustUseProperty=!1,p4.prototype.number=!1,p4.prototype.overloadedBoolean=!1,p4.prototype.property="",p4.prototype.spaceSeparated=!1,p4.prototype.space=void 0;let p6=0,p9=gi(),p7=gi(),p8=gi(),ge=gi(),gt=gi(),gn=gi(),gr=gi();function gi(){return 2**++p6}e.s(["boolean",0,p9,"booleanish",0,p7,"commaOrSpaceSeparated",0,gr,"commaSeparated",0,gn,"number",0,ge,"overloadedBoolean",0,p8,"spaceSeparated",0,gt],744);var ga=e.i(744);let go=Object.keys(ga);class gs extends p4{constructor(e,t,n,r){let i=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++i<go.length;){const e=go[i];!function(e,t,n){n&&(e[t]=n)}(this,go[i],(n&ga[e])===ga[e])}}}function gl(e){return e.toLowerCase()}gs.prototype.defined=!0;let gc=/[A-Z]/g,gu=/-[a-z]/g,gd=/^data[-\w.:]+$/i;function gh(e){return"-"+e.toLowerCase()}function gf(e){return e.charAt(1).toUpperCase()}let gp={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class gg{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function gm(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new gg(n,r,t)}function gv(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new gs(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[gl(r)]=r,n[gl(a.attribute)]=r}return new gg(t,n,e.space)}gg.prototype.normal={},gg.prototype.property={},gg.prototype.space=void 0;let gx=gv({properties:{ariaActiveDescendant:null,ariaAtomic:p7,ariaAutoComplete:null,ariaBusy:p7,ariaChecked:p7,ariaColCount:ge,ariaColIndex:ge,ariaColSpan:ge,ariaControls:gt,ariaCurrent:null,ariaDescribedBy:gt,ariaDetails:null,ariaDisabled:p7,ariaDropEffect:gt,ariaErrorMessage:null,ariaExpanded:p7,ariaFlowTo:gt,ariaGrabbed:p7,ariaHasPopup:null,ariaHidden:p7,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gt,ariaLevel:ge,ariaLive:null,ariaModal:p7,ariaMultiLine:p7,ariaMultiSelectable:p7,ariaOrientation:null,ariaOwns:gt,ariaPlaceholder:null,ariaPosInSet:ge,ariaPressed:p7,ariaReadOnly:p7,ariaRelevant:null,ariaRequired:p7,ariaRoleDescription:gt,ariaRowCount:ge,ariaRowIndex:ge,ariaRowSpan:ge,ariaSelected:p7,ariaSetSize:ge,ariaSort:null,ariaValueMax:ge,ariaValueMin:ge,ariaValueNow:ge,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function gy(e,t){return t in e?e[t]:t}function gb(e,t){return gy(e,t.toLowerCase())}let gw=gv({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gn,acceptCharset:gt,accessKey:gt,action:null,allow:null,allowFullScreen:p9,allowPaymentRequest:p9,allowUserMedia:p9,alt:null,as:null,async:p9,autoCapitalize:null,autoComplete:gt,autoFocus:p9,autoPlay:p9,blocking:gt,capture:null,charSet:null,checked:p9,cite:null,className:gt,cols:ge,colSpan:null,content:null,contentEditable:p7,controls:p9,controlsList:gt,coords:ge|gn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:p9,defer:p9,dir:null,dirName:null,disabled:p9,download:p8,draggable:p7,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:p9,formTarget:null,headers:gt,height:ge,hidden:p8,high:ge,href:null,hrefLang:null,htmlFor:gt,httpEquiv:gt,id:null,imageSizes:null,imageSrcSet:null,inert:p9,inputMode:null,integrity:null,is:null,isMap:p9,itemId:null,itemProp:gt,itemRef:gt,itemScope:p9,itemType:gt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:p9,low:ge,manifest:null,max:null,maxLength:ge,media:null,method:null,min:null,minLength:ge,multiple:p9,muted:p9,name:null,nonce:null,noModule:p9,noValidate:p9,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:p9,optimum:ge,pattern:null,ping:gt,placeholder:null,playsInline:p9,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:p9,referrerPolicy:null,rel:gt,required:p9,reversed:p9,rows:ge,rowSpan:ge,sandbox:gt,scope:null,scoped:p9,seamless:p9,selected:p9,shadowRootClonable:p9,shadowRootDelegatesFocus:p9,shadowRootMode:null,shape:null,size:ge,sizes:null,slot:null,span:ge,spellCheck:p7,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ge,step:null,style:null,tabIndex:ge,target:null,title:null,translate:null,type:null,typeMustMatch:p9,useMap:null,value:p7,width:ge,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gt,axis:null,background:null,bgColor:null,border:ge,borderColor:null,bottomMargin:ge,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:p9,declare:p9,event:null,face:null,frame:null,frameBorder:null,hSpace:ge,leftMargin:ge,link:null,longDesc:null,lowSrc:null,marginHeight:ge,marginWidth:ge,noResize:p9,noHref:p9,noShade:p9,noWrap:p9,object:null,profile:null,prompt:null,rev:null,rightMargin:ge,rules:null,scheme:null,scrolling:p7,standby:null,summary:null,text:null,topMargin:ge,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ge,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:p9,disableRemotePlayback:p9,prefix:null,property:null,results:ge,security:null,unselectable:null},space:"html",transform:gb}),gN=gv({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:gr,accentHeight:ge,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ge,amplitude:ge,arabicForm:null,ascent:ge,attributeName:null,attributeType:null,azimuth:ge,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ge,by:null,calcMode:null,capHeight:ge,className:gt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ge,diffuseConstant:ge,direction:null,display:null,dur:null,divisor:ge,dominantBaseline:null,download:p9,dx:null,dy:null,edgeMode:null,editable:null,elevation:ge,enableBackground:null,end:null,event:null,exponent:ge,externalResourcesRequired:null,fill:null,fillOpacity:ge,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:gn,g2:gn,glyphName:gn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ge,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ge,horizOriginX:ge,horizOriginY:ge,id:null,ideographic:ge,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ge,k:ge,k1:ge,k2:ge,k3:ge,k4:ge,kernelMatrix:gr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ge,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ge,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ge,overlineThickness:ge,paintOrder:null,panose1:null,path:null,pathLength:ge,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ge,pointsAtY:ge,pointsAtZ:ge,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:gr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:gr,rev:gr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:gr,requiredFeatures:gr,requiredFonts:gr,requiredFormats:gr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ge,specularExponent:ge,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ge,strikethroughThickness:ge,string:null,stroke:null,strokeDashArray:gr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ge,strokeOpacity:ge,strokeWidth:null,style:null,surfaceScale:ge,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:gr,tabIndex:ge,tableValues:null,target:null,targetX:ge,targetY:ge,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:gr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ge,underlineThickness:ge,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ge,values:null,vAlphabetic:ge,vMathematical:ge,vectorEffect:null,vHanging:ge,vIdeographic:ge,version:null,vertAdvY:ge,vertOriginX:ge,vertOriginY:ge,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ge,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gy}),gj=gv({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),gk=gv({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:gb}),gC=gv({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),gE=gm([gx,gw,gj,gk,gC],"html"),gT=gm([gx,gN,gj,gk,gC],"svg");var gS=e.i(15511);let g_=gD("end"),gA=gD("start");function gD(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function gM(e){return e&&"object"==typeof e?"position"in e||"type"in e?gR(e.position):"start"in e||"end"in e?gR(e):"line"in e||"column"in e?gP(e):"":""}function gP(e){return gL(e&&e.line)+":"+gL(e&&e.column)}function gR(e){return gP(e&&e.start)+"-"+gP(e&&e.end)}function gL(e){return e&&"number"==typeof e?e:1}class gI extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},a=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=gM(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}gI.prototype.file="",gI.prototype.name="",gI.prototype.reason="",gI.prototype.message="",gI.prototype.stack="",gI.prototype.column=void 0,gI.prototype.line=void 0,gI.prototype.ancestors=void 0,gI.prototype.cause=void 0,gI.prototype.fatal=void 0,gI.prototype.place=void 0,gI.prototype.ruleId=void 0,gI.prototype.source=void 0;let gO={}.hasOwnProperty,gB=new Map,gF=/[A-Z]/g,gz=new Set(["table","tbody","thead","tfoot","tr"]),gV=new Set(["td","th"]),gH="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gU(e,t,n){var r,i,a,o,s,l,c,u,d;let h,f,p,g,v,x,y,b,w,N,j;return"element"===t.type?(r=e,i=t,a=n,f=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=gT),r.ancestors.push(i),p=gW(r,i.tagName,!1),g=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&gO.call(t.properties,r)){let a=function(e,t,n){let r=function(e,t){let n=gl(t),r=t,i=p4;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&gd.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(gu,gf);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!gu.test(e)){let n=e.replace(gc,gh);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=gs}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,gS.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new gI("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=gH+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)gO.call(e,t)&&(n[function(e){let t=e.replace(gF,g$);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?gp[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(a){let[r,o]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof o&&gV.has(t.tagName)?n=o:i[r]=o}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),v=gX(r,i),gz.has(i.tagName)&&(v=v.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&p3(e.value):p3(e))})),gG(r,g,p,i),gY(g,v),r.ancestors.pop(),r.schema=h,r.create(i,p,g,a)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return pZ("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}gq(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(o=e,s=t,l=n,y=x=o.schema,"svg"===s.name&&"html"===x.space&&(o.schema=gT),o.ancestors.push(s),b=null===s.name?o.Fragment:gW(o,s.name,!0),w=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];pZ("ExpressionStatement"===t.type);let i=t.expression;pZ("ObjectExpression"===i.type);let a=i.properties[0];pZ("SpreadElement"===a.type),Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else gq(e,t.position);else{let i,a=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];pZ("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else gq(e,t.position);else i=null===r.value||r.value;n[a]=i}return n}(o,s),N=gX(o,s),gG(o,w,b,s),gY(w,N),o.ancestors.pop(),o.schema=x,o.create(s,b,w,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gq(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=n,gY(j={},gX(c,u)),c.create(u,c.Fragment,j,d)):"text"===t.type?t.value:void 0}function gG(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function gY(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function gX(e,t){let n=[],r=-1,i=e.passKeys?new Map:gB;for(;++r<t.children.length;){let a,o=t.children[r];if(e.passKeys){let e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){let t=i.get(e)||0;a=e+"-"+t,i.set(e,t+1)}}let s=gU(e,o,a);void 0!==s&&n.push(s)}return n}function gW(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=p2(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}pZ(e,"always a result"),r=e}else r=p2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return gO.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);gq(e)}function gq(e,t){let n=new gI("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=gH+"#cannot-handle-mdx-estrees-without-createevaluater",n}function g$(e){return"-"+e.toLowerCase()}let gK={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},gZ={};function gQ(e,t){let n=t||gZ;return gJ(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function gJ(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return g0(e.children,t,n)}return Array.isArray(e)?g0(e,t,n):""}function g0(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=gJ(e[i],t,n);return r.join("")}function g1(e,t,n,r){let i,a=e.length,o=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)(i=r.slice(o,o+1e4)).unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function g2(e,t){return e.length>0?(g1(e,e.length,0,t),e):t}let g5={}.hasOwnProperty;function g3(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(g5.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];if(a)for(r in a){g5.call(i,r)||(i[r]=[]);let e=a[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);g1(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}function g4(e){return null!==e&&e<-2}function g6(e){return -2===e||-1===e||32===e}function g9(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function g7(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return g6(r)?(e.enter(n),function r(o){return g6(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}g9(/[A-Za-z]/),g9(/[\dA-Za-z]/),g9(/[#-'*+\--9=?A-Z^-~]/),g9(/\d/),g9(/[\dA-Fa-f]/),g9(/[!-/:-@[-`{-~]/),g9(/\p{P}|\p{S}/u),g9(/\s/);let g8={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),g7(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return g4(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},me={tokenize:function(e){let t,n,r,i=this,a=[],o=0;return s;function s(t){if(o<a.length){let n=a[o];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(o++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&x();let r=i.events.length,a=r;for(;a--;)if("exit"===i.events[a][0]&&"chunkFlow"===i.events[a][1].type){n=i.events[a][1].end;break}v(o);let s=r;for(;s<i.events.length;)i.events[s][1].end={...n},s++;return g1(i.events,a+1,0,i.events.slice(r)),i.events.length=s,c(e)}return s(e)}function c(n){if(o===a.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return p(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(mt,u,d)(n)}function u(e){return t&&x(),v(o),h(e)}function d(e){return i.parser.lazy[i.now().line]=o!==a.length,r=i.now().offset,p(e)}function h(t){return i.containerState={},e.attempt(mt,f,p)(t)}function f(e){return o++,a.push([i.currentConstruct,i.containerState]),h(e)}function p(r){if(null===r){t&&x(),v(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){g(e.exit("chunkFlow"),!0),v(0),e.consume(n);return}return g4(n)?(e.consume(n),g(e.exit("chunkFlow")),o=0,i.interrupt=void 0,s):(e.consume(n),t)}(r)}function g(e,a){let s=i.sliceStream(e);if(a&&s.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(s),i.parser.lazy[e.start.line]){let e,n,a=t.events.length;for(;a--;)if(t.events[a][1].start.offset<r&&(!t.events[a][1].end||t.events[a][1].end.offset>r))return;let s=i.events.length,l=s;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(v(o),a=s;a<i.events.length;)i.events[a][1].end={...n},a++;g1(i.events,l+1,0,i.events.slice(s)),i.events.length=a}}function v(t){let n=a.length;for(;n-- >t;){let t=a[n];i.containerState=t[1],t[0].exit.call(i,e)}a.length=t}function x(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},mt={tokenize:function(e,t,n){return g7(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},mn=md(/[A-Za-z]/),mr=md(/[\dA-Za-z]/),mi=md(/[#-'*+\--9=?A-Z^-~]/),ma=md(/\d/),mo=md(/[\dA-Fa-f]/),ms=md(/[!-/:-@[-`{-~]/);function ml(e){return null!==e&&e<-2}function mc(e){return null!==e&&(e<0||32===e)}function mu(e){return -2===e||-1===e||32===e}function md(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mh(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return mu(r)?(e.enter(n),function r(o){return mu(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}md(/\p{P}|\p{S}/u),md(/\s/);let mf={partial:!0,tokenize:function(e,t,n){return function(t){return mu(t)?mh(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||ml(e)?t(e):n(e)}}};class mp{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&mg(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),mg(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),mg(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);mg(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);mg(this.left,t.reverse())}}}function mg(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function mm(e){let t,n,r,i,a,o,s,l={},c=-1,u=new mp(e);for(;++c<u.length;){for(;c in l;)c=l[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((r=0)<(o=t[1]._tokenizer.events).length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],a=e.get(t)[2],o=t-1,s=[],l=i._tokenizer;!l&&(l=a.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,u=[],d={},h=-1,f=i,p=0,g=0,v=[0];for(;f;){for(;e.get(++o)[1]!==f;);s.push(o),!f._tokenizer&&(n=a.sliceStream(f),f.next||n.push(null),r&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=f,f=f.next}for(f=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(g=h+1,v.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):v.pop(),h=v.length;h--;){let t=c.slice(v[h],v[h+1]),n=s.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),h=-1;++h<u.length;)d[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return d}(u,c)),c=l[c],s=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=u.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(u.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...u.get(n)[1].start},(a=u.slice(n,c)).unshift(t),u.splice(n,c-n+1,a))}}return g1(e,0,1/0,u.slice(0)),!s}let mv={resolve:function(e){return mm(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):ml(t)?e.check(mx,a,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},mx={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),mh(e,i,"linePrefix")};function i(i){if(null===i||ml(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},my={tokenize:function(e){let t=this,n=e.attempt(mf,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,g7(e,e.attempt(this.parser.constructs.flow,r,e.attempt(mv,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},mb={resolveAll:mk()},mw=mj("string"),mN=mj("text");function mj(e){return{resolveAll:mk("text"===e?mC:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return l(e)?i(e):o(e)}function o(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),s)}function s(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function mk(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function mC(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],a=t.sliceStream(i),o=a.length,s=-1,l=0;for(;o--;){let e=a[o];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let a={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}mS(/[A-Za-z]/),mS(/[\dA-Za-z]/),mS(/[#-'*+\--9=?A-Z^-~]/),mS(/\d/),mS(/[\dA-Fa-f]/),mS(/[!-/:-@[-`{-~]/);let mE=mS(/\p{P}|\p{S}/u),mT=mS(/\s/);function mS(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function m_(e){return null===e||null!==e&&(e<0||32===e)||mT(e)?1:mE(e)?2:void 0}function mA(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}let mD={name:"attention",resolveAll:function(e,t){let n,r,i,a,o,s,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[n][1].end},h={...e[u][1].start};mM(d,-s),mM(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},o={type:s>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},i={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:s>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[n][1].end={...a.start},e[u][1].start={...o.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=g2(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=g2(l,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",i,t]]),l=g2(l,mA(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=g2(l,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=g2(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,g1(e,n-1,u-n+3,l),u=n+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,a=m_(i);return function(o){return n=o,e.enter("attentionSequence"),function o(s){if(s===n)return e.consume(s),o;let l=e.exit("attentionSequence"),c=m_(s),u=!c||2===c&&a||r.includes(s),d=!a||2===a&&c||r.includes(i);return l._open=!!(42===n?u:u&&(a||!d)),l._close=!!(42===n?d:d&&(c||!u)),t(s)}(o)}}};function mM(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let mP={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return mu(t)?mh(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(mP,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return mu(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},mR={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return ms(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},mL=document.createElement("i");function mI(e){let t="&"+e+";";mL.innerHTML=t;let n=mL.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let mO={name:"characterReference",tokenize:function(e,t,n){let r,i,a=this,o=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=mr,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=mo,c):(e.enter("characterReferenceValue"),r=7,i=ma,c(t))}function c(s){if(59===s&&o){let r=e.exit("characterReferenceValue");return i!==mr||mI(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return i(s)&&o++<r?(e.consume(s),c):n(s)}}},mB={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},mF={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(t){return e.enter("codeFencedFence"),mu(t)?mh(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a>=s?(e.exit("codeFencedFenceSequence"),mu(i)?mh(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||ml(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},o=0,s=0;return function(t){var a;let c;return a=t,o=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=a,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s<3?n(i):(e.exit("codeFencedFenceSequence"),mu(i)?mh(e,l,"whitespace")(i):l(i))}(a)};function l(a){return null===a||ml(a)?(e.exit("codeFencedFence"),i.interrupt?t(a):e.check(mB,u,p)(a)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||ml(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):mu(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),mh(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(a))}function c(t){return null===t||ml(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||ml(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function u(t){return e.attempt(a,p,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return o>0&&mu(t)?mh(e,f,"linePrefix",o+1)(t):f(t)}function f(t){return null===t||ml(t)?e.check(mB,u,p)(t):(e.enter("codeFlowValue"),function t(n){return null===n||ml(n)?(e.exit("codeFlowValue"),f(n)):(e.consume(n),t)}(t))}function p(n){return e.exit("codeFenced"),t(n)}}},mz={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),mh(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?a(n):ml(n)?e.attempt(mV,t,a)(n):(e.enter("codeFlowValue"),function n(r){return null===r||ml(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function a(n){return e.exit("codeIndented"),t(n)}}},mV={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):ml(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):mh(e,a,"linePrefix",5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):ml(e)?i(e):n(e)}}};function mH(e){return null!==e&&(e<32||127===e)}function mU(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mG(e,t,n,r,i,a,o,s,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),d):null===t||32===t||41===t||mH(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),p(t))};function d(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||null!==t&&t<-2?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function p(i){return!u&&(null===i||41===i||null!==i&&(i<0||32===i))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(i)):u<c&&40===i?(e.consume(i),u++,p):41===i?(e.consume(i),u--,p):null===i||32===i||40===i||mH(i)?n(i):(e.consume(i),92===i?g:p)}function g(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function mY(e){return null!==e&&e<-2}function mX(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mW(e,t,n,r,i,a){let o,s=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),c};function c(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):mY(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||mY(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=-2!==t&&-1!==t&&32!==t),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function mq(e){return null!==e&&e<-2}function m$(e){return -2===e||-1===e||32===e}function mK(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mZ(e,t,n,r,i,a){let o;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=40===t?41:t,s):n(t)};function s(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){if(t===o)return e.exit(a),s(o);if(null===t)return n(t);if(mq(t)){var r,i;let n,a;return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r=l,i="linePrefix",n=1/0,a=0,function(t){return m$(t)?(e.enter(i),function t(o){return m$(o)&&a++<n?(e.consume(o),t):(e.exit(i),r(o))}(t)):r(t)}}return e.enter("chunkString",{contentType:"string"}),c(t)}function c(t){return t===o||null===t||mq(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===o||92===t?(e.consume(t),c):c(t)}}function mQ(e){return -2===e||-1===e||32===e}function mJ(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function m0(e,t){let n;return function r(i){var a,o;if(null!==i&&i<-2)return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r;if(mQ(i)){let t,s;return(a=r,o=n?"linePrefix":"lineSuffix",t=1/0,s=0,function(n){return mQ(n)?(e.enter(o),function n(r){return mQ(r)&&s++<t?(e.consume(r),n):(e.exit(o),a(r))}(n)):a(n)})(i)}return t(i)}}function m1(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}mU(/[A-Za-z]/),mU(/[\dA-Za-z]/),mU(/[#-'*+\--9=?A-Z^-~]/),mU(/\d/),mU(/[\dA-Fa-f]/),mU(/[!-/:-@[-`{-~]/),mU(/\p{P}|\p{S}/u),mU(/\s/),mX(/[A-Za-z]/),mX(/[\dA-Za-z]/),mX(/[#-'*+\--9=?A-Z^-~]/),mX(/\d/),mX(/[\dA-Fa-f]/),mX(/[!-/:-@[-`{-~]/),mX(/\p{P}|\p{S}/u),mX(/\s/),mK(/[A-Za-z]/),mK(/[\dA-Za-z]/),mK(/[#-'*+\--9=?A-Z^-~]/),mK(/\d/),mK(/[\dA-Fa-f]/),mK(/[!-/:-@[-`{-~]/),mK(/\p{P}|\p{S}/u),mK(/\s/),mJ(/[A-Za-z]/),mJ(/[\dA-Za-z]/),mJ(/[#-'*+\--9=?A-Z^-~]/),mJ(/\d/),mJ(/[\dA-Fa-f]/),mJ(/[!-/:-@[-`{-~]/),mJ(/\p{P}|\p{S}/u),mJ(/\s/);let m2={partial:!0,tokenize:function(e,t,n){return function(t){return mc(t)?m0(e,r)(t):n(t)};function r(t){return mZ(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return mu(t)?mh(e,a,"whitespace")(t):a(t)}function a(e){return null===e||ml(e)?t(e):n(e)}}},m5=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],m3=["pre","script","style","textarea"],m4={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(mf,t,n)}}},m6={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return ml(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},m9={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&g1(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,a,o=e.length,s=0;for(;o--;)if(n=e[o][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[o][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[o][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=o,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(i=o);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},u={type:"labelText",start:{...e[r+s+2][1].end},end:{...e[i-2][1].start}};return a=g2(a=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+s+3)),a=g2(a,[["enter",u,t]]),a=g2(a,mA(t.parser.constructs.insideSpan.null,e.slice(r+s+4,i-3),t)),a=g2(a,[["exit",u,t],e[i-2],e[i-1],["exit",c,t]]),a=g2(a,e.slice(i+1)),a=g2(a,[["exit",l,t]]),g1(e,r,e.length,a),e},tokenize:function(e,t,n){let r,i,a=this,o=a.events.length;for(;o--;)if(("labelImage"===a.events[o][1].type||"labelLink"===a.events[o][1].type)&&!a.events[o][1]._balanced){r=a.events[o][1];break}return function(t){return r?r._inactive?u(t):(i=a.parser.defined.includes(m1(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)};function s(t){return 40===t?e.attempt(m7,c,i?c:u)(t):91===t?e.attempt(m8,c,i?l:u)(t):i?c(t):u(t)}function l(t){return e.attempt(ve,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},m7={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return mc(t)?m0(e,i)(t):i(t)}function i(t){return 41===t?c(t):mG(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return mc(t)?m0(e,s)(t):c(t)}function o(e){return n(e)}function s(t){return 34===t||39===t||40===t?mZ(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return mc(t)?m0(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},m8={tokenize:function(e,t,n){let r=this;return function(t){return mW.call(r,e,i,a,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(m1(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},ve={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},vt={name:"labelStartImage",resolveAll:m9.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},vn={name:"labelStartLink",resolveAll:m9.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},vr={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),mh(e,t,"linePrefix")}}},vi={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(a){var o;return e.enter("thematicBreak"),r=o=a,function a(o){return o===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),mu(n)?mh(e,a,"whitespace")(n):a(n))}(o)):i>=3&&(null===o||ml(o))?(e.exit("thematicBreak"),t(o)):n(o)}(o)}}},va={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(mf,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,mh(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!mu(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(vs,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,mh(e,e.attempt(va,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,o=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:ma(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(vi,n,s)(t):s(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return ma(i)&&++o<10?(e.consume(i),t):(!r.interrupt||o<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),s(i)):n(i)}(t)}return n(t)};function s(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(mf,r.interrupt?n:l,e.attempt(vo,u,c))}function l(e){return r.containerState.initialBlankLine=!0,a++,u(e)}function c(t){return mu(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},vo={partial:!0,tokenize:function(e,t,n){let r=this;return mh(e,function(e){let i=r.events[r.events.length-1];return!mu(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},vs={partial:!0,tokenize:function(e,t,n){let r=this;return mh(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},vl={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(r=a)}else"content"===e[a][1].type&&e.splice(a,1),i||"definition"!==e[a][1].type||(i=a);let o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",o,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=o,e.push(["exit",o,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var o;let s,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){s="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||s)?(e.enter("setextHeadingLine"),r=t,o=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),mu(n)?mh(e,a,"lineSuffix")(n):a(n))}(o)):n(t)};function a(r){return null===r||ml(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,mW.call(i,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function a(t){return(r=m1(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o):n(t)}function o(t){return mc(t)?m0(e,s)(t):s(t)}function s(t){return mG(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(m2,c,c)(t)}function c(t){return mu(t)?mh(e,u,"whitespace")(t):u(t)}function u(a){return null===a||ml(a)?(e.exit("definition"),i.parser.defined.push(r),t(a)):n(a)}}}},"disable",0,{null:[]},"document",0,{42:va,43:va,45:va,48:va,49:va,50:va,51:va,52:va,53:va,54:va,55:va,56:va,57:va,62:mP},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,a=3;return"whitespace"===e[3][1].type&&(a+=2),i-2>a&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(a===i-1||i-4>a&&"whitespace"===e[i-2][1].type)&&(i-=a+1===i?2:4),i>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[i][1].end},r={type:"chunkText",start:e[a][1].start,end:e[i][1].end,contentType:"text"},g1(e,a,i-a+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var a;return e.enter("atxHeading"),a=i,e.enter("atxHeadingSequence"),function i(a){return 35===a&&r++<6?(e.consume(a),i):null===a||mc(a)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||ml(r)?(e.exit("atxHeading"),t(r)):mu(r)?mh(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||mc(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(a)):n(a)}(a)}}},42:vi,45:[vl,vi],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,a,o,s,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),i=!0,f):63===o?(e.consume(o),r=3,l.interrupt?t:P):mn(o)?(e.consume(o),a=String.fromCharCode(o),p):n(o)}function u(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,o=0,h):mn(i)?(e.consume(i),r=4,l.interrupt?t:P):n(i)}function d(r){return 45===r?(e.consume(r),l.interrupt?t:P):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(o++)?(e.consume(r),o===i.length)?l.interrupt?t:C:h:n(r)}function f(t){return mn(t)?(e.consume(t),a=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||mc(o)){let s=47===o,c=a.toLowerCase();return!s&&!i&&m3.includes(c)?(r=1,l.interrupt?t(o):C(o)):m5.includes(a.toLowerCase())?(r=6,s)?(e.consume(o),g):l.interrupt?t(o):C(o):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(o):i?function t(n){return mu(n)?(e.consume(n),t):j(n)}(o):v(o))}return 45===o||mr(o)?(e.consume(o),a+=String.fromCharCode(o),p):n(o)}function g(r){return 62===r?(e.consume(r),l.interrupt?t:C):n(r)}function v(t){return 47===t?(e.consume(t),j):58===t||95===t||mn(t)?(e.consume(t),x):mu(t)?(e.consume(t),v):j(t)}function x(t){return 45===t||46===t||58===t||95===t||mr(t)?(e.consume(t),x):y(t)}function y(t){return 61===t?(e.consume(t),b):mu(t)?(e.consume(t),y):v(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),s=t,w):mu(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||mc(n)?y(n):(e.consume(n),t)}(t)}function w(t){return t===s?(e.consume(t),s=null,N):null===t||ml(t)?n(t):(e.consume(t),w)}function N(e){return 47===e||62===e||mu(e)?v(e):n(e)}function j(t){return 62===t?(e.consume(t),k):n(t)}function k(t){return null===t||ml(t)?C(t):mu(t)?(e.consume(t),k):n(t)}function C(t){return 45===t&&2===r?(e.consume(t),_):60===t&&1===r?(e.consume(t),A):62===t&&4===r?(e.consume(t),R):63===t&&3===r?(e.consume(t),P):93===t&&5===r?(e.consume(t),M):ml(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(m4,L,E)(t)):null===t||ml(t)?(e.exit("htmlFlowData"),E(t)):(e.consume(t),C)}function E(t){return e.check(m6,T,L)(t)}function T(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),S}function S(t){return null===t||ml(t)?E(t):(e.enter("htmlFlowData"),C(t))}function _(t){return 45===t?(e.consume(t),P):C(t)}function A(t){return 47===t?(e.consume(t),a="",D):C(t)}function D(t){if(62===t){let n=a.toLowerCase();return m3.includes(n)?(e.consume(t),R):C(t)}return mn(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),D):C(t)}function M(t){return 93===t?(e.consume(t),P):C(t)}function P(t){return 62===t?(e.consume(t),R):45===t&&2===r?(e.consume(t),P):C(t)}function R(t){return null===t||ml(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),R)}function L(n){return e.exit("htmlFlow"),t(n)}}},61:vl,95:vi,96:mF,126:mF},"flowInitial",0,{[-2]:mz,[-1]:mz,32:mz},"insideSpan",0,{null:[mD,mb]},"string",0,{38:mO,92:mR},"text",0,{[-5]:vr,[-4]:vr,[-3]:vr,33:vt,38:mO,42:mD,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return mn(t)?(e.consume(t),a):64===t?n(t):s(t)}function a(t){return 43===t||45===t||46===t||mr(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,o):(43===n||45===n||46===n||mr(n))&&r++<32?(e.consume(n),t):(r=0,s(n))}(t)):s(t)}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||null!==r&&(r<32||127===r)?n(r):(e.consume(r),o)}function s(t){return 64===t?(e.consume(t),l):mi(t)?(e.consume(t),s):n(t)}function l(i){return mr(i)?function i(a){return 46===a?(e.consume(a),r=0,l):62===a?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(a){if((45===a||mr(a))&&r++<63){let n=45===a?t:i;return e.consume(a),n}return n(a)}(a)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,a,o=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),w):63===t?(e.consume(t),y):mn(t)?(e.consume(t),j):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,f):mn(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):ml(t)?(a=u,D(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?A(e):45===e?d(e):u(e)}function f(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),g):ml(t)?(a=p,D(t)):(e.consume(t),p)}function g(t){return 93===t?(e.consume(t),v):p(t)}function v(t){return 62===t?A(t):93===t?(e.consume(t),v):p(t)}function x(t){return null===t||62===t?A(t):ml(t)?(a=x,D(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):ml(t)?(a=y,D(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function w(t){return mn(t)?(e.consume(t),N):n(t)}function N(t){return 45===t||mr(t)?(e.consume(t),N):function t(n){return ml(n)?(a=t,D(n)):mu(n)?(e.consume(n),t):A(n)}(t)}function j(t){return 45===t||mr(t)?(e.consume(t),j):47===t||62===t||mc(t)?k(t):n(t)}function k(t){return 47===t?(e.consume(t),A):58===t||95===t||mn(t)?(e.consume(t),C):ml(t)?(a=k,D(t)):mu(t)?(e.consume(t),k):A(t)}function C(t){return 45===t||46===t||58===t||95===t||mr(t)?(e.consume(t),C):function t(n){return 61===n?(e.consume(n),E):ml(n)?(a=t,D(n)):mu(n)?(e.consume(n),t):k(n)}(t)}function E(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,T):ml(t)?(a=E,D(t)):mu(t)?(e.consume(t),E):(e.consume(t),S)}function T(t){return t===r?(e.consume(t),r=void 0,_):null===t?n(t):ml(t)?(a=T,D(t)):(e.consume(t),T)}function S(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||mc(t)?k(t):(e.consume(t),S)}function _(e){return 47===e||62===e||mc(e)?k(e):n(e)}function A(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function D(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return mu(t)?mh(e,P,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):P(t)}function P(t){return e.enter("htmlTextData"),a(t)}}}],91:vn,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return ml(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},mR],93:m9,95:mD,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),a++,t):(e.exit("codeTextSequence"),o(n))}(t)};function o(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),o):96===l?(i=e.enter("codeTextSequence"),r=0,function n(o){return 96===o?(e.consume(o),r++,n):r===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(o)):(i.type="codeTextData",s(o))}(l)):ml(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):(e.enter("codeTextData"),s(l))}function s(t){return null===t||32===t||96===t||ml(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),s)}}}}],4127);var vc=e.i(4127);let vu=/[\0\t\n\r]/g;function vd(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let vh=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vf(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return vd(n.slice(t?2:1),t?16:10)}return mI(n)||e}let vp={}.hasOwnProperty;function vg(e){return{line:e.line,column:e.column,offset:e.offset}}function vm(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+gM({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+gM({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+gM({start:t.start,end:t.end})+") is still open")}function vv(e){let t=this;t.parser=function(n){var r,i;let a,o,s,l;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(x),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(p),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(f),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(f,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(g),hardBreakTrailing:r(g),htmlFlow:r(v,i),htmlFlowData:c,htmlText:r(v,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(x),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(y),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(p),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:o(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:o(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:o(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=vd(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=mI(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=vg(e.end)},codeFenced:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:o(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=m1(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:o(),hardBreakEscape:o(d),hardBreakTrailing:o(d),htmlFlow:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(vh,vf),n.identifier=m1(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=vg(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),u.call(this,e))},link:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=m1(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:o(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:o(),thematicBreak:o()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(vp.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:a,exit:s,buffer:i,resume:l,data:n},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,n){let r,i,a,o,s=t-1,l=-1,c=!1;for(;++s<=n;){let t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,o=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||o||l||a||(a=s),o=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:o=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let o=s;for(i=void 0;o--;){let t=e[o];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=o}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}a&&(!i||a<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||s,0,["exit",r,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(s,0,["enter",i,t[2]]),s++,n++,a=void 0,o=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),u));for(u=-1;++u<e.length;){let n=t[e[u][0]];vp.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},o),e[u][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||vm).call(o,void 0,e[0])}for(r.position={start:vg(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:vg(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r};function r(e,t){return function(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:vg(t.start),end:void 0}}function o(e){return function(t){e&&e.call(this,t),s.call(this,t)}}function s(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||vm).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+gM({start:e.start,end:e.end})+"): it’s not open");n.position.end=vg(e.end)}function l(){return gQ(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:vg(e.start),end:void 0},t.push(n)),this.stack.push(n)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=vg(e.end)}function d(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function p(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function v(){return{type:"html",value:""}}function x(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!mm(e););return e}((function(e){let t={constructs:g3([vc,...(e||{}).extensions||[]]),content:n(g8),defined:[],document:n(me),flow:n(my),lazy:{},string:n(mw),text:n(mN)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],l={attempt:p(function(e,t){g(e,t.from)}),check:p(f),consume:function(e){g4(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,v()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){let t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:p(f,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,v()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let a,o=e[r];if("string"==typeof o)a=o;else switch(o){case -5:a="\r";break;case -4:a="\n";break;case -3:a="\r\n";break;case -2:a=t?" ":" ";break;case -1:if(!t&&n)continue;a=" ";break;default:a=String.fromCharCode(o)}n=-2===o,i.push(a)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(o=g2(o,e),function(){let e;for(;r._index<o.length;){let n=o[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==o[o.length-1])?[]:(g(t,0),c.events=mA(a,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;if(r===a)n=[e[r].slice(i,o)];else{if(n=e.slice(r,a),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}o>0&&n.push(e[a].slice(0,o))}return n}(o,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function f(e,t){t.restore()}function p(e,t){return function(n,i,a){var o;let u,d,f,p;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(o=n,function(e){let t=null!==e&&o[e],n=null!==e&&o.null;return g([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(u=e,d=0,0===e.length)?a:x(e[d])}function x(e){return function(n){let i,a,o,u,d;return(i=h(),a=c.previous,o=c.currentConstruct,u=c.events.length,d=Array.from(s),p={from:u,restore:function(){r=i,c.previous=a,c.currentConstruct=o,c.events.length=u,s=d,v()}},f=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,y,b)(n)}}function y(t){return e(f,p),i}function b(e){return(p.restore(),++d<u.length)?x(u[d]):a}}}function g(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&g1(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((o=1,s="",l=!0,function(e,t,n){let r,i,c,u,d,h=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,s="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(vu.lastIndex=c,u=(r=vu.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(u),!r){s=e.slice(c);break}if(10===d&&c===u&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),c<u&&(h.push(e.slice(c,u)),o+=u-c),d){case 0:h.push(65533),o++;break;case 9:for(i=4*Math.ceil(o/4),h.push(-2);o++<i;)h.push(-1);break;case 10:h.push(-4),o=1;break;default:a=!0,o=1}c=u+1}return n&&(a&&h.push(-5),s&&h.push(s),h.push(null)),h})(n,r,!0))))}}let vx="object"==typeof self?self:globalThis,vy=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[a,o]=e[i];switch(a){case 0:case -1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new vx[e](t),i)}case 8:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new vx[a](o),i)})(0)},{toString:vb}={},{keys:vw}=Object,vN=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=vb.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},vj=([e,t])=>0===e&&("function"===t||"symbol"===t),vk=(e,{json:t,lossy:n}={})=>{var r,i,a;let o,s,l=[];return(r=!(t||n),i=!!t,a=new Map,o=(e,t)=>{let n=l.push(e)-1;return a.set(t,n),n},s=e=>{if(a.has(e))return a.get(e);let[t,n]=vN(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return o([-1],e)}return o([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),o([n,[...t]],e)}let r=[],i=o([t,r],e);for(let t of e)r.push(s(t));return i}case 2:{if(n)switch(n){case"BigInt":return o([n,e.toString()],e);case"Boolean":case"Number":case"String":return o([n,e.valueOf()],e)}if(i&&"toJSON"in e)return s(e.toJSON());let a=[],l=o([t,a],e);for(let t of vw(e))(r||!vj(vN(e[t])))&&a.push([s(t),s(e[t])]);return l}case 3:return o([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return o([t,{source:n,flags:r}],e)}case 5:{let n=[],i=o([t,n],e);for(let[t,i]of e)(r||!(vj(vN(t))||vj(vN(i))))&&n.push([s(t),s(i)]);return i}case 6:{let n=[],i=o([t,n],e);for(let t of e)(r||!vj(vN(t)))&&n.push(s(t));return i}}let{message:l}=e;return o([t,{name:n,message:l}],e)})(e),l},vC="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?vy(vk(e,t)):structuredClone(e):(e,t)=>vy(vk(e,t));vT(/[A-Za-z]/);let vE=vT(/[\dA-Za-z]/);function vT(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function vS(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o="";if(37===a&&vE(e.charCodeAt(n+1))&&vE(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function v_(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function vA(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}vT(/[#-'*+\--9=?A-Z^-~]/),vT(/\d/),vT(/[\dA-Fa-f]/),vT(/[!-/:-@[-`{-~]/),vT(/\p{P}|\p{S}/u),vT(/\s/);let vD=function(e){var t,n;if(null==e)return vP;if("function"==typeof e)return vM(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=vD(e[n]);return vM(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,vM(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,vM(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function vM(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function vP(){return!0}let vR=[];function vL(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let a=vD(i),o=r?-1:1;(function e(i,s,l){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,h,f=vR;if((!t||a(i,s,l[l.length-1]||void 0))&&!1===(f=Array.isArray(c=n(i,l))?c:"number"==typeof c?[!0,c]:null==c?vR:[c])[0])return f;if("children"in i&&i.children&&i.children&&"skip"!==f[0])for(d=(r?i.children.length:-1)+o,h=l.concat(i);d>-1&&d<i.children.length;){if(!1===(u=e(i.children[d],d,h)())[0])return u;d="number"==typeof u[1]?u[1]:d+o}return f}})(e,void 0,[])()}function vI(e,t,n,r){let i,a,o;"function"==typeof t&&"function"!=typeof n?(a=void 0,o=t,i=n):(a=t,o=n,i=r),vL(e,a,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)},i)}function vO(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),a=i[0];a&&"text"===a.type?a.value="["+a.value:i.unshift({type:"text",value:"["});let o=i[i.length-1];return o&&"text"===o.type?o.value+=r:i.push({type:"text",value:r}),i}function vB(e){let t=e.spread;return null==t?e.children.length>1:t}function vF(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let vz={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a={type:"element",tagName:"pre",properties:{},children:[a=e.applyData(t,a)]},e.patch(t,a),a},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),a=vS(i.toLowerCase()),o=e.footnoteOrder.indexOf(i),s=e.footnoteCounts.get(i);void 0===s?(s=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=o+1,s+=1,e.footnoteCounts.set(i,s);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vO(e,t);let i={src:vS(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){let n={src:vS(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vO(e,t);let i={href:vS(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){let n={href:vS(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=vB(n[r])}return t}(n):vB(t),a={},o=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let e=r[s];(i||0!==s||"element"!==e.type||"p"!==e.tagName)&&o.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?o.push(e):o.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&o.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=gA(t.children[1]),o=g_(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,o=a?a.length:t.children.length,s=-1,l=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(vF(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(vF(t.slice(i),i>0,!1)),a.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:vV,yaml:vV,definition:vV,footnoteDefinition:vV};function vV(){}let vH={}.hasOwnProperty,vU={};function vG(e,t){e.position&&(t.position=function(e){let t=gA(e),n=g_(e);if(t&&n)return{start:t,end:n}}(e))}function vY(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,vC(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function vX(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function vW(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function vq(e,t){let n,r,i,a,o=(n=t||vU,r=new Map,i=new Map,a={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=vW(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=vW(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:vY,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...vz,...n.handlers},one:function(e,t){let n=e.type,r=a.handlers[n];if(vH.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=vC(n);return r.children=a.all(e),r}return vC(e)}return(a.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(vH.call(n,"hProperties")||vH.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(a,e,t)},options:n,patch:vG,wrap:vX},vI(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a),s=o.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||v_,r=e.options.footnoteBackLabel||vA,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),c=vS(o.toLowerCase()),u=0,d=[],h=e.footnoteCounts.get(o);for(;void 0!==h&&++u<=h;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let f=a[a.length-1];if(f&&"element"===f.type&&"p"===f.tagName){let e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...d)}else a.push(...d);let p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(i,p),s.push(p)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...vC(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(o),c=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return l&&(pZ("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function v$(e,t){return e&&"run"in e?async function(n,r){let i=vq(n,{file:r,...t});await e.run(i,r)}:function(n,r){return vq(n,{file:r,...e||t})}}function vK(e){if(e)throw e}var vZ=e.i(4100);function vQ(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let vJ=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');v5(e);let r=0,i=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else i<0&&(n=!0,i=a+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let o=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else o<0&&(n=!0,o=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(i=a):(s=-1,i=o));return r===i?i=o:i<0&&(i=e.length),e.slice(r,i)},v0=function(e){let t;if(v5(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},v1=function(e){let t;v5(e);let n=e.length,r=-1,i=0,a=-1,o=0;for(;n--;){let s=e.codePointAt(n);if(47===s){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===s?a<0?a=n:1!==o&&(o=1):a>-1&&(o=-1)}return a<0||r<0||0===o||1===o&&a===r-1&&a===i+1?"":e.slice(a,r)},v2=function(...e){var t;let n,r,i,a=-1;for(;++a<e.length;)v5(e[a]),e[a]&&(i=void 0===i?e[a]:i+"/"+e[a]);return void 0===i?".":(v5(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",a=0,o=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(o===l-1||1===s);else if(o!==l-1&&2===s){if(i.length<2||2!==a||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",a=0):a=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),o=l,s=0;continue}}else if(i.length>0){i="",a=0,o=l,s=0;continue}}t&&(i=i.length>0?i+"/..":"..",a=2)}else i.length>0?i+="/"+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else 46===n&&s>-1?s++:s=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function v5(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function v3(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let v4=["history","path","basename","stem","extname","dirname"];class v6{constructor(e){let t,n;t=e?v3(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<v4.length;){const e=v4[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)v4.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?vJ(this.path):void 0}set basename(e){v7(e,"basename"),v9(e,"basename"),this.path=v2(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?v0(this.path):void 0}set dirname(e){v8(this.basename,"dirname"),this.path=v2(e||"",this.basename)}get extname(){return"string"==typeof this.path?v1(this.path):void 0}set extname(e){if(v9(e,"extname"),v8(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=v2(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){v3(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!v3(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),v7(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?vJ(this.path,this.extname):void 0}set stem(e){v7(e,"stem"),v9(e,"stem"),this.path=v2(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new gI(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function v9(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function v7(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function v8(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let xe=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},xt={}.hasOwnProperty;class xn extends xe{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(a,...o){let s=e[++n],l=-1;if(a)return void r(a);for(;++l<t.length;)(null===o[l]||void 0===o[l])&&(o[l]=t[l]);t=o,s?(function(e,t){let n;return function(...t){let a,o=e.length>t.length;o&&t.push(r);try{a=e.apply(this,t)}catch(e){if(o&&n)throw e;return r(e)}o||(a&&a.then&&"function"==typeof a.then?a.then(i,r):a instanceof Error?r(a):i(a))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(s,i)(...o):r(null,...o)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new xn,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,vZ.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(xo("data",this.frozen),this.namespace[e]=t,this):xt.call(this.namespace,e)&&this.namespace[e]||void 0:e?(xo("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=xc(e),n=this.parser||this.Parser;return xi("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),xi("process",this.parser||this.Parser),xa("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=xc(e),o=n.parse(a);function s(e,n){e||!n?i(e):r?r(n):(pZ(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(o,a,function(e,t,r){var i,a;if(e||!t||!r)return s(e);let o=n.stringify(t,r);"string"==typeof(i=o)||(a=i)&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a?r.value=o:r.result=o,s(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),xi("processSync",this.parser||this.Parser),xa("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,vK(e),t=r}),xl("processSync","process",n),pZ(t,"we either bailed on an error or have a tree"),t}run(e,t,n){xs(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){pZ("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let o=xc(t);r.run(e,o,function(t,r,o){let s=r||e;t?a(t):i?i(s):(pZ(n,"`done` is defined if `resolve` is not"),n(void 0,s,o))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){vK(e),n=t,r=!0}),xl("runSync","run",r),pZ(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=xc(t),r=this.compiler||this.Compiler;return xa("stringify",r),xs(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(xo("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(r.settings=(0,vZ.default)(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)o(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;o(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function o(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];vQ(o)&&vQ(r)&&(r=(0,vZ.default)(!0,o,r)),n[i]=[e,r,...a]}}}}let xr=new xn().freeze();function xi(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function xa(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function xo(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xs(e){if(!vQ(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function xl(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function xc(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new v6(e)}let xu=[],xd={allowDangerousHtml:!0},xh=/^(https?|ircs?|mailto|xmpp)$/i,xf=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function xp(e){var t;let n,r,i,a,o,s=(n=(t=e).rehypePlugins||xu,r=t.remarkPlugins||xu,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...xd}:xd,xr().use(vv).use(r).use(v$,i).use(n)),l=(a=e.children||"",o=new v6,"string"==typeof a?o.value=a:pQ("Unexpected value `"+a+"` for `children` prop, expected `string`"),o);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,l=t.urlTransform||xg;for(let e of xf)Object.hasOwn(t,e.from)&&pQ("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&a&&pQ("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),vI(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return o?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in gK)if(Object.hasOwn(gK,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=gK[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let o=n?!n.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&r&&"number"==typeof t&&(o=!r(e,t,i)),o&&i&&"number"==typeof t)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,a;let o;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let s=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=s,r=t.jsxDEV,o=function(e,t,i,a){let o=Array.isArray(i.children),s=gA(e);return r(t,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:n,lineNumber:s?s.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,a=t.jsxs,o=function(e,t,n,r){let o=Array.isArray(n.children)?a:i;return r?o(t,n,r):o(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?gT:gE,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=gU(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:D.Fragment,components:i,ignoreInvalidStyle:!0,jsx:D.jsx,jsxs:D.jsxs,passKeys:!0,passNode:!0})}(s.runSync(s.parse(l),l),e)}function xg(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||xh.test(e.slice(0,t))?e:""}function xm(e,t){let n=String(e);if("string"!=typeof t)throw TypeError("Expected character");let r=0,i=n.indexOf(t);for(;-1!==i;)r++,i=n.indexOf(t,i+t.length);return r}xy(/[A-Za-z]/),xy(/[\dA-Za-z]/),xy(/[#-'*+\--9=?A-Z^-~]/),xy(/\d/),xy(/[\dA-Fa-f]/),xy(/[!-/:-@[-`{-~]/);let xv=xy(/\p{P}|\p{S}/u),xx=xy(/\s/);function xy(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let xb="phrasing",xw=["autolink","link","image","label"];function xN(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function xj(e){this.config.enter.autolinkProtocol.call(this,e)}function xk(e){this.config.exit.autolinkProtocol.call(this,e)}function xC(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];pZ("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function xE(e){this.config.exit.autolinkEmail.call(this,e)}function xT(e){this.exit(e)}function xS(e){!function(e,t,n){let r=vD((n||{}).ignore||[]),i=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){var i;let e=n[r];t.push(["string"==typeof(i=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(i),"g"):i,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),a=-1;for(;++a<i.length;)vL(e,"text",o);function o(e,t){let n,o=-1;for(;++o<t.length;){let e=t[o],i=n?n.children:void 0;if(r(e,i?i.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,l=n.children.indexOf(e),c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if("string"==typeof a&&(a=a.length>0?{type:"text",value:a}:void 0),!1===a?r.lastIndex=n+1:(s!==n&&u.push({type:"text",value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}return c?(s<e.value.length&&u.push({type:"text",value:e.value.slice(s)}),n.children.splice(l,1,...u)):u=[e],l+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,x_],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,xA]],{ignore:["link","linkReference"]})}function x_(e,t,n,r,i){let a,o="";if(!xD(i))return!1;if(/^w/i.test(t)&&(n=t+n,t="",o="http://"),(a=n.split(".")).length<2||a[a.length-1]&&(/_/.test(a[a.length-1])||!/[a-zA-Z\d]/.test(a[a.length-1]))||a[a.length-2]&&(/_/.test(a[a.length-2])||!/[a-zA-Z\d]/.test(a[a.length-2])))return!1;let s=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")"),i=xm(e,"("),a=xm(e,")");for(;-1!==r&&i>a;)e+=n.slice(0,r+1),r=(n=n.slice(r+1)).indexOf(")"),a++;return[e,n]}(n+r);if(!s[0])return!1;let l={type:"link",title:null,url:o+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}function xA(e,t,n,r){return!(!xD(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function xD(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||xx(n)||xv(n))&&(!t||47!==n)}function xM(){this.buffer()}function xP(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function xR(){this.buffer()}function xL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function xI(e){let t=this.resume(),n=this.stack[this.stack.length-1];pZ("footnoteReference"===n.type),n.identifier=m1(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xO(e){this.exit(e)}function xB(e){let t=this.resume(),n=this.stack[this.stack.length-1];pZ("footnoteDefinition"===n.type),n.identifier=m1(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xF(e){this.exit(e)}function xz(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("]")}function xV(e,t,n){return 0===t?e:xH(e,t,n)}function xH(e,t,n){return(n?"":" ")+e}xz.peek=function(){return"["};let xU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function xG(e){this.enter({type:"delete",children:[]},e)}function xY(e){this.exit(e)}function xX(e,t,n,r){let i=n.createTracker(r),a=n.enter("strikethrough"),o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),a(),o}function xW(e){return e.length}function xq(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}xX.peek=function(){return"~"};function x$(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,t=n.unsafe[a],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}x$.peek=function(){return"`"};vD(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let xK=function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),a=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(a=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+a);let o=a.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(o=4*Math.ceil(o/4));let s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,s.current()),function(e,t,n){return t?(n?"":" ".repeat(o))+e:(n?a:a+" ".repeat(o-a.length))+e});return l(),c};function xZ(e){let t=e._align;pZ(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function xQ(e){this.exit(e),this.data.inTable=void 0}function xJ(e){this.enter({type:"tableRow",children:[]},e)}function x0(e){this.exit(e)}function x1(e){this.enter({type:"tableCell",children:[]},e)}function x2(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,x5));let n=this.stack[this.stack.length-1];pZ("inlineCode"===n.type),n.value=t,this.exit(e)}function x5(e,t){return"|"===t?t:e}function x3(e){let t=this.stack[this.stack.length-2];pZ("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function x4(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];pZ("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let r,i=t.children,a=-1;for(;++a<i.length;){let e=i[a];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function x6(e,t,n,r){let i=e.children[0],a="boolean"==typeof e.checked&&i&&"paragraph"===i.type,o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=xK(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+o})),l}let x9=yn(/[A-Za-z]/),x7=yn(/[\dA-Za-z]/);function x8(e){return null!==e&&(e<0||32===e)}yn(/[#-'*+\--9=?A-Z^-~]/),yn(/\d/),yn(/[\dA-Fa-f]/),yn(/[!-/:-@[-`{-~]/);let ye=yn(/\p{P}|\p{S}/u),yt=yn(/\s/);function yn(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let yr={tokenize:function(e,t,n){let r=0;return function t(a){return(87===a||119===a)&&r<3?(r++,e.consume(a),t):46===a&&3===r?(e.consume(a),i):n(a)};function i(e){return null===e?n(e):t(e)}},partial:!0},yi={tokenize:function(e,t,n){let r,i,a;return o;function o(t){return 46===t||95===t?e.check(yo,l,s)(t):null===t||x8(t)||yt(t)||45!==t&&ye(t)?l(t):(a=!0,e.consume(t),o)}function s(t){return 95===t?r=!0:(i=r,r=void 0),e.consume(t),o}function l(e){return i||r||!a?n(e):t(e)}},partial:!0},ya={tokenize:function(e,t){let n=0,r=0;return i;function i(o){return 40===o?(n++,e.consume(o),i):41===o&&r<n?a(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===o?e.check(yo,t,a)(o):null===o||x8(o)||yt(o)?t(o):(e.consume(o),i)}function a(t){return 41===t&&r++,e.consume(t),i}},partial:!0},yo={tokenize:function(e,t,n){return r;function r(o){return 33===o||34===o||39===o||41===o||42===o||44===o||46===o||58===o||59===o||63===o||95===o||126===o?(e.consume(o),r):38===o?(e.consume(o),a):93===o?(e.consume(o),i):60===o||null===o||x8(o)||yt(o)?t(o):n(o)}function i(e){return null===e||40===e||91===e||x8(e)||yt(e)?t(e):r(e)}function a(t){return x9(t)?function t(i){return 59===i?(e.consume(i),r):x9(i)?(e.consume(i),t):n(i)}(t):n(t)}},partial:!0},ys={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return x7(e)?n(e):t(e)}},partial:!0},yl={name:"wwwAutolink",tokenize:function(e,t,n){let r=this;return function(t){return 87!==t&&119!==t||!yf.call(r,r.previous)||yv(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(yr,e.attempt(yi,e.attempt(ya,i),n),n)(t))};function i(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:yf},yc={name:"protocolAutolink",tokenize:function(e,t,n){let r=this,i="",a=!1;return function(t){return(72===t||104===t)&&yp.call(r,r.previous)&&!yv(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(t),e.consume(t),o):n(t)};function o(t){if(x9(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),o;if(58===t){let n=i.toLowerCase();if("http"===n||"https"===n)return e.consume(t),s}return n(t)}function s(t){return 47===t?(e.consume(t),a)?l:(a=!0,s):n(t)}function l(t){return null===t||null!==t&&(t<32||127===t)||x8(t)||yt(t)||ye(t)?n(t):e.attempt(yi,e.attempt(ya,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:yp},yu={name:"emailAutolink",tokenize:function(e,t,n){let r,i,a=this;return function(t){return!ym(t)||!yg.call(a,a.previous)||yv(a.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(r){return ym(r)?(e.consume(r),t):64===r?(e.consume(r),o):n(r)}(t))};function o(t){return 46===t?e.check(ys,l,s)(t):45===t||95===t||x7(t)?(i=!0,e.consume(t),o):l(t)}function s(t){return e.consume(t),r=!0,o}function l(o){return i&&r&&x9(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(o)):n(o)}},previous:yg},yd={},yh=48;for(;yh<123;)yd[yh]=yu,58==++yh?yh=65:91===yh&&(yh=97);function yf(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||x8(e)}function yp(e){return!x9(e)}function yg(e){return!(47===e||ym(e))}function ym(e){return 43===e||45===e||46===e||95===e||x7(e)}function yv(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function yx(e){return null!==e&&(e<0||32===e)}function yy(e){return -2===e||-1===e||32===e}function yb(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function yw(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return yy(r)?(e.enter(n),function r(o){return yy(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}yd[43]=yu,yd[45]=yu,yd[46]=yu,yd[95]=yu,yd[72]=[yu,yc],yd[104]=[yu,yc],yd[87]=[yu,yl],yd[119]=[yu,yl],yb(/[A-Za-z]/),yb(/[\dA-Za-z]/),yb(/[#-'*+\--9=?A-Z^-~]/),yb(/\d/),yb(/[\dA-Fa-f]/),yb(/[!-/:-@[-`{-~]/),yb(/\p{P}|\p{S}/u),yb(/\s/);let yN={tokenize:function(e,t,n){let r=this;return yw(e,function(e){let i=r.events[r.events.length-1];return i&&"gfmFootnoteDefinitionIndent"===i[1].type&&4===i[2].sliceSerialize(i[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function yj(e,t,n){let r,i=this,a=i.events.length,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);for(;a--;){let e=i.events[a][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!r||!r._balanced)return n(a);let s=m1(i.sliceSerialize({start:r.end,end:i.now()}));return 94===s.codePointAt(0)&&o.includes(s.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)):n(a)}}function yk(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){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 yC(e,t,n){let r,i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),o=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),s};function s(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(s){if(o>999||93===s&&!r||null===s||91===s||yx(s))return n(s);if(93===s){e.exit("chunkString");let r=e.exit("gfmFootnoteCallString");return a.includes(m1(i.sliceSerialize(r)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(s)}return yx(s)||(r=!0),o++,e.consume(s),92===s?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),o++,l):l(t)}}function yE(e,t,n){let r,i,a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]),s=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(s>999||93===t&&!i||null===t||91===t||yx(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return r=m1(a.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return yx(t)||(i=!0),s++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(r)||o.push(r),yw(e,h,"gfmFootnoteDefinitionWhitespace")):n(t)}function h(e){return t(e)}}function yT(e,t,n){return e.check(mf,t,e.attempt(yN,t,n))}function yS(e){e.exit("gfmFootnoteDefinition")}function y_(e){return null!==e&&e<-2}function yA(e){return null!==e&&(e<0||32===e)}function yD(e){return -2===e||-1===e||32===e}function yM(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function yP(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return yD(r)?(e.enter(n),function r(o){return yD(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}yM(/[A-Za-z]/),yM(/[\dA-Za-z]/),yM(/[#-'*+\--9=?A-Z^-~]/),yM(/\d/),yM(/[\dA-Fa-f]/),yM(/[!-/:-@[-`{-~]/),yM(/\p{P}|\p{S}/u),yM(/\s/);class yR{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let i=0;if(0!==n||0!==r.length){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,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}}function yL(e,t,n){let r,i=this,a=0,o=0;return function(e){let t=i.events.length-1;for(;t>-1;){let e=i.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let r=t>-1?i.events[t][1].type:null,a="tableHead"===r||"tableRow"===r?y:s;return a===y&&i.parser.lazy[i.now().line]?n(e):a(e)};function s(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(r=!0,o+=1),l(n)}function l(t){return null===t?n(t):y_(t)?o>1?(o=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):yD(t)?yP(e,l,"whitespace")(t):(o+=1,r&&(r=!1,a+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,l):(e.enter("data"),c(t))}function c(t){return null===t||124===t||yA(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return(i.interrupt=!1,i.parser.lazy[i.now().line])?n(t):(e.enter("tableDelimiterRow"),r=!1,yD(t))?yP(e,h,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t)}function h(t){return 45===t||58===t?p(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),f):n(t)}function f(t){return yD(t)?yP(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(o+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),g):45===t?(o+=1,g(t)):null===t||y_(t)?x(t):n(t)}function g(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(n))}(t)):n(t)}function v(t){return yD(t)?yP(e,x,"whitespace")(t):x(t)}function x(i){if(124===i)return h(i);if(null===i||y_(i))return r&&a===o?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):n(i);return n(i)}function y(t){return e.enter("tableRow"),b(t)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||y_(n)?(e.exit("tableRow"),t(n)):yD(n)?yP(e,b,"whitespace")(n):(e.enter("data"),w(n))}function w(t){return null===t||124===t||yA(t)?(e.exit("data"),b(t)):(e.consume(t),92===t?N:w)}function N(t){return 92===t||124===t?(e.consume(t),w):w(t)}}function yI(e,t){let n,r,i,a=-1,o=!0,s=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h=new yR;for(;++a<e.length;){let f=e[a],p=f[1];"enter"===f[0]?"tableHead"===p.type?(u=!1,0!==d&&(yB(h,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(o=!0,i=void 0,l=[0,0,0,0],c=[0,a+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",r,t]])),s="tableDelimiterRow"===p.type?2:r?3:1):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)?(o=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],i=yO(h,t,l,s,void 0,i),l=[0,0,0,0]),c[2]=a)):"tableCellDivider"===p.type&&(o?o=!1:(0!==l[1]&&(c[0]=c[1],i=yO(h,t,l,s,void 0,i)),c=[(l=c)[1],a,0,0])):"tableHead"===p.type?(u=!0,d=a):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=a,0!==l[1]?(c[0]=c[1],i=yO(h,t,l,s,a,i)):0!==c[1]&&(i=yO(h,t,c,s,a,i)),s=0):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(c[3]=a)}for(0!==d&&yB(h,t,d,n,r),h.consume(t.events),a=-1;++a<t.events.length;){let e=t.events[a];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if("enter"===i[0])"tableContent"===i[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===i[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===i[1].type)break}else"enter"===i[0]&&"tableDelimiterRow"===i[1].type&&(n=!0);t+=1}return r}(t.events,a))}return e}function yO(e,t,n,r,i,a){0!==n[0]&&(a.end=Object.assign({},yF(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));let o=yF(t.events,n[1]);if(a={type:1===r?"tableHeader":2===r?"tableDelimiter":"tableData",start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",a,t]]),0!==n[2]){let i=yF(t.events,n[2]),a=yF(t.events,n[3]),o={type:"tableContent",start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[["enter",o,t]]),2!==r){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 void 0!==i&&(a.end=Object.assign({},yF(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function yB(e,t,n,r,i){let a=[],o=yF(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 yF(e,t){let n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}function yz(e){return -2===e||-1===e||32===e}function yV(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}yV(/[A-Za-z]/),yV(/[\dA-Za-z]/),yV(/[#-'*+\--9=?A-Z^-~]/),yV(/\d/),yV(/[\dA-Fa-f]/),yV(/[!-/:-@[-`{-~]/),yV(/\p{P}|\p{S}/u),yV(/\s/);let yH={name:"tasklistCheck",tokenize:function(e,t,n){let r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),i):n(t)};function i(t){return null!==t&&(t<0||32===t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),a):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),a):n(t)}function a(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(t)}function o(r){return null!==r&&r<-2?t(r):yz(r)?e.check({tokenize:yU},t,n)(r):n(r)}}};function yU(e,t,n){var r,i;let a,o;return r=function(e){return null===e?n(e):t(e)},i="whitespace",a=1/0,o=0,function(t){return yz(t)?(e.enter(i),function t(n){return yz(n)&&o++<a?(e.consume(n),t):(e.exit(i),r(n))}(t)):r(t)}}let yG={};function yY(e){let t,n,r,i=e||yG,a=this.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),s=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),l=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(g3([{text:yd},{document:{91:{name:"gfmFootnoteDefinition",tokenize:yE,continuation:{tokenize:yT},exit:yS}},text:{91:{name:"gfmFootnoteCall",tokenize:yC},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:yj,resolveTo:yk}}},(t=(i||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,r){let i=this.previous,a=this.events,o=0;return function(s){return 126===i&&"characterEscape"!==a[a.length-1][1].type?r(s):(e.enter("strikethroughSequenceTemporary"),function a(s){let l=m_(i);if(126===s)return o>1?r(s):(e.consume(s),o++,a);if(o<2&&!t)return r(s);let c=e.exit("strikethroughSequenceTemporary"),u=m_(s);return c._open=!u||2===u&&!!l,c._close=!l||2===l&&!!u,n(s)}(s))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&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&&g1(o,o.length,0,mA(s,e.slice(r+1,n),t)),g1(o,o.length,0,[["exit",a,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",i,t]]),g1(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:yL,resolveAll:yI}}},{text:{91:yH}}])),s.push([{transforms:[xS],enter:{literalAutolink:xN,literalAutolinkEmail:xj,literalAutolinkHttp:xj,literalAutolinkWww:xj},exit:{literalAutolink:xT,literalAutolinkEmail:xE,literalAutolinkHttp:xk,literalAutolinkWww:xC}},{enter:{gfmFootnoteCallString:xM,gfmFootnoteCall:xP,gfmFootnoteDefinitionLabelString:xR,gfmFootnoteDefinition:xL},exit:{gfmFootnoteCallString:xI,gfmFootnoteCall:xO,gfmFootnoteDefinitionLabelString:xB,gfmFootnoteDefinition:xF}},{canContainEols:["delete"],enter:{strikethrough:xG},exit:{strikethrough:xY}},{enter:{table:xZ,tableData:x1,tableHeader:x1,tableRow:xJ},exit:{codeText:x2,table:xQ,tableData:x0,tableHeader:x0,tableRow:x0}},{exit:{taskListCheckValueChecked:x3,taskListCheckValueUnchecked:x3,paragraph:x4}}]),l.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:xb,notInConstruct:xw},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:xb,notInConstruct:xw},{character:":",before:"[ps]",after:"\\/",inConstruct:xb,notInConstruct:xw}]},(r=!1,i&&i.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:function(e,t,n,i){let a=n.createTracker(i),o=a.move("[^"),s=n.enter("footnoteDefinition"),l=n.enter("label");return o+=a.move(n.safe(n.associationId(e),{before:o,after:"]"})),l(),o+=a.move("]:"),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((r?"\n":" ")+n.indentLines(n.containerFlow(e,a.current()),r?xH:xV))),s(),o},footnoteReference:xz},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:xU}],handlers:{delete:xX}},function(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=x$(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return s(function(e,t,n){let r=e.children,i=-1,a=[],o=t.enter("table");for(;++i<r.length;)a[i]=l(r[i],t,n);return o(),a}(e,n,r),e.align)},tableCell:o,tableRow:function(e,t,n,r){let i=s([l(e,n,r)]);return i.slice(0,i.indexOf("\n"))}}};function o(e,t,n,r){let i=n.enter("tableCell"),o=n.enter("phrasing"),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function s(e,t){return function(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||xW,a=[],o=[],s=[],l=[],c=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>c&&(c=e[u].length);++a<e[u].length;){var d;let o=null==(d=e[u][a])?"":String(d);if(!1!==n.alignDelimiters){let e=i(o);r[a]=e,(void 0===l[a]||e>l[a])&&(l[a]=e)}t.push(o)}o[u]=t,s[u]=r}let h=-1;if("object"==typeof r&&"length"in r)for(;++h<c;)a[h]=xq(r[h]);else{let e=xq(r);for(;++h<c;)a[h]=e}h=-1;let f=[],p=[];for(;++h<c;){let e=a[h],t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let i=!1===n.alignDelimiters?1:Math.max(1,l[h]-t.length-r.length),o=t+"-".repeat(i)+r;!1!==n.alignDelimiters&&((i=t.length+i+r.length)>l[h]&&(l[h]=i),p[h]=i),f[h]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let g=[];for(;++u<o.length;){let e=o[u],t=s[u];h=-1;let r=[];for(;++h<c;){let i=e[h]||"",o="",s="";if(!1!==n.alignDelimiters){let e=l[h]-(t[h]||0),n=a[h];114===n?o=" ".repeat(e):99===n?e%2?(o=" ".repeat(e/2+.5),s=" ".repeat(e/2-.5)):s=o=" ".repeat(e/2):s=" ".repeat(e)}!1===n.delimiterStart||h||r.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==i)&&(!1!==n.delimiterStart||h)&&r.push(" "),!1!==n.alignDelimiters&&r.push(o),r.push(i),!1!==n.alignDelimiters&&r.push(s),!1!==n.padding&&r.push(" "),(!1!==n.delimiterEnd||h!==c-1)&&r.push("|")}g.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return g.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function l(e,t,n){let r=e.children,i=-1,a=[],s=t.enter("tableRow");for(;++i<r.length;)a[i]=o(r[i],e,t,n);return s(),a}}(i),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:x6}}]})}let yX=e=>{let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`};function yW({mentalModel:e}){return(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),e.trigger?.refresh_after_consolidation&&(0,D.jsxs)("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 text-xs font-medium",children:[(0,D.jsx)(pK,{className:"w-3 h-3"}),"Auto refresh"]})]}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:e.id}),e.source_query&&(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e.source_query})]}),(0,D.jsxs)("div",{className:"flex gap-8",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:yX(e.created_at)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Last Refreshed"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:yX(e.last_refreshed_at)})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded text-xs",children:e},t))})]})]})}function yq({mentalModelId:e,onClose:t}){let{currentBank:n}=(0,I.useBank)(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(!1),[s,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&n&&(async()=>{o(!0),l(null),i(null);try{let t=await K.client.getMentalModel(n,e);i(t)}catch(e){console.error("Error loading mental model:",e),l(e.message)}finally{o(!1)}})()},[e,n]);let c=null!==e;return(0,D.jsx)(td.Dialog,{open:c,onOpenChange:e=>!e&&t(),children:(0,D.jsxs)(td.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,D.jsx)(h2,{children:(0,D.jsx)(td.DialogTitle,{children:"Mental Model Details"})}),a?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)(tu.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):s?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)("div",{className:"text-center text-destructive",children:(0,D.jsxs)("div",{className:"text-sm",children:["Error: ",s]})})}):r?(0,D.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,D.jsx)(yW,{mentalModel:r})}):null]})})}function y$(){let e,t,n,r,i,a,o,s,l,c,u,{currentBank:d}=(0,I.useBank)(),[h,f]=(0,M.useState)(""),[p,g]=(0,M.useState)("mid"),[v,x]=(0,M.useState)(4096),[y,b]=(0,M.useState)(!0),[w,N]=(0,M.useState)(!0),[j,k]=(0,M.useState)("answer"),[C,E]=(0,M.useState)(null),[T,S]=(0,M.useState)(!1),[_,A]=(0,M.useState)(""),[P,R]=(0,M.useState)("any"),[L,O]=(0,M.useState)(""),[B,F]=(0,M.useState)(!1),[H,U]=(0,M.useState)(!1),[G,Y]=(0,M.useState)(null),[X,W]=(0,M.useState)(null),[q,$]=(0,M.useState)(null),[J,ee]=(0,M.useState)(!1),[et,en]=(0,M.useState)(null),[er,ei]=(0,M.useState)(null),[ea,es]=(0,M.useState)(!1),[el,ec]=(0,M.useState)(null),[eu,ed]=(0,M.useState)("world"),eh="General Feedback",ef=async e=>{if(en(e),ei(null),d&&e?.id){es(!0);try{let t=await K.client.listObservations(d),n=t.items?.find(t=>t.id===e.id);ei(n||e)}catch(t){console.error("Failed to load observation:",t),ei(e)}finally{es(!1)}}},ep=async()=>{if(d&&L.trim()){F(!0);try{let e=await K.client.listDirectives(d),t=e.items?.find(e=>e.name===eh);if(t){let e=t.content?`${t.content}
8
- ${L.trim()}`:L.trim();await K.client.updateDirective(d,t.id,{content:e})}else await K.client.createDirective(d,{name:eh,content:L.trim()});O(""),U(!0),setTimeout(()=>U(!1),3e3)}catch(e){}finally{F(!1)}}},eg=async()=>{if(d&&h){S(!0),k("answer");try{let e=_.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=await K.client.reflect({bank_id:d,query:h,budget:p,max_tokens:v,include_facts:y,include_tool_calls:w,...e.length>0&&{tags:e,tags_match:P}});E(t)}catch(e){}finally{S(!1)}}};return d?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(z,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(Q.Input,{type:"text",value:h,onChange:e=>f(e.target.value),placeholder:"What would you like to reflect on?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&eg()})]}),(0,D.jsx)(Z.Button,{onClick:eg,disabled:T||!h,className:"h-12 px-8",children:T?"Reflecting...":"Reflect"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Budget:"}),(0,D.jsxs)(fl,{value:p,onValueChange:e=>g(e),children:[(0,D.jsx)(fJ,{className:"w-24 h-8",children:(0,D.jsx)(fh,{})}),(0,D.jsxs)(f2,{children:[(0,D.jsx)(f5,{value:"low",children:"Low"}),(0,D.jsx)(f5,{value:"mid",children:"Mid"}),(0,D.jsx)(f5,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(Q.Input,{type:"number",value:v,onChange:e=>x(parseInt(e.target.value)||4096),className:"w-24 h-8"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:y,onCheckedChange:e=>b(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Source"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:w,onCheckedChange:e=>N(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Tools"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(tp.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(Q.Input,{type:"text",value:_,onChange:e=>A(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(fl,{value:P,onValueChange:e=>R(e),children:[(0,D.jsx)(fJ,{className:"w-40 h-8",children:(0,D.jsx)(fh,{})}),(0,D.jsxs)(f2,{children:[(0,D.jsx)(f5,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(f5,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(f5,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(f5,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),T&&(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Reflecting on memories..."})]})}),!T&&C&&(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[C.usage&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Input tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:C.usage.input_tokens?.toLocaleString()})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Output tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:C.usage.output_tokens?.toLocaleString()})]})]}),C.trace?.tool_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Tool calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:C.trace.tool_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.tool_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),C.trace?.llm_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"LLM calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:C.trace.llm_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.llm_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>k(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${j===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===e?"Answer":"trace"===e?"Trace":"JSON"},e))})]}),"answer"===j&&(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{children:(0,D.jsx)(f9,{children:"Answer"})}),(0,D.jsx)(f8,{children:(0,D.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:C.text})})})]}),(0,D.jsxs)(f4,{className:"border-blue-200 dark:border-blue-800",children:[(0,D.jsxs)(f6,{className:"py-4",children:[(0,D.jsxs)(f9,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(pn,{className:"w-4 h-4"}),"Add Directive"]}),(0,D.jsx)(f7,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,D.jsx)(f8,{className:"pt-0",children:H?(0,D.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,D.jsx)("span",{className:"text-lg",children:"✓"}),(0,D.jsxs)("span",{className:"text-sm font-medium",children:["Directive saved to ",eh]})]}):(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsx)(pa.Textarea,{value:L,onChange:e=>O(e.target.value),placeholder:"e.g., Always respond in formal English...",className:"flex-1 min-h-[60px] resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ep()}}),(0,D.jsx)(Z.Button,{onClick:ep,disabled:B||!L.trim(),className:"self-end",children:B?"Saving...":"Save"})]})})]})]}),"trace"===j&&(0,D.jsxs)("div",{className:"space-y-4",children:[C.observations_created&&C.observations_created.length>0&&(0,D.jsxs)(f4,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,D.jsxs)(f6,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,D.jsxs)(f9,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(pt,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",C.observations_created.length,")"]}),(0,D.jsx)(f7,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,D.jsx)(f8,{className:"pt-4",children:(0,D.jsx)("div",{className:"space-y-2",children:C.observations_created.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-emerald-50 dark:bg-emerald-950/50 rounded-lg border border-emerald-200 dark:border-emerald-800",children:[(0,D.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:e.name}),(0,D.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:e.description}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",e.id]})]},t))})})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,D.jsxs)(f4,{className:"h-fit",children:[(0,D.jsxs)(f6,{className:"pb-3",children:[(0,D.jsx)(f9,{className:"text-base",children:"Execution Trace"}),(0,D.jsxs)(f7,{className:"text-xs",children:[C.iterations||0," iteration",1!==(C.iterations||0)?"s":""," •"," ",(C.trace?.llm_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)+(C.trace?.tool_calls?.reduce((e,t)=>e+t.duration_ms,0)||0),"ms total"]})]}),(0,D.jsx)(f8,{children:w?C.trace?.llm_calls&&C.trace.llm_calls.length>0||C.trace?.tool_calls&&C.trace.tool_calls.length>0?(0,D.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(e=C.trace?.llm_calls||[],t=C.trace?.tool_calls||[],n=[],e.forEach((r,i)=>{let a=t.filter(e=>e.iteration===i+1),o=i===e.length-1,s=r.scope.includes("final")||o&&0===a.length,l=s?e.length:i+1;n.push({type:"llm",llm:r,iteration:l,isFinal:s}),a.length>0&&n.push({type:"tools",tools:a,iteration:i+1})}),n.map((e,t)=>(0,D.jsxs)("div",{className:"relative",children:[t<n.length-1&&(0,D.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===e.type?(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${e.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:e.isFinal?(0,D.jsx)(tl.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,D.jsx)("span",{className:"text-[10px] font-semibold",children:e.iteration})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsx)("span",{className:"font-medium text-sm",children:e.isFinal?"Response generated":"Agent decided"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),e.llm.duration_ms,"ms"]})]}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:e.isFinal?"Final answer":"Called tools below"})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-blue-500/15 text-blue-600 dark:text-blue-400 flex-shrink-0",children:(0,D.jsx)(pi,{className:"w-3 h-3",fill:"currentColor"})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Executing ",e.tools?.length," tool",e.tools?.length!==1?"s":""]}),e.tools?.map((e,t)=>(0,D.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.tool}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),e.duration_ms,"ms"]})]}),(0,D.jsxs)("div",{className:"p-2 space-y-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Input:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(p$,{src:e.input,collapsed:1,theme:"default"})})]}),e.output&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Output:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(p$,{src:e.output,collapsed:1,theme:"default"})})]})]})]},t))]})]})]},t)))}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(pe.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"No operations"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No LLM or tool calls were made during this reflection."})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(pe.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Tool Calls" to see trace.'})]})]})})]}),(0,D.jsxs)(f4,{className:"h-fit",children:[(0,D.jsxs)(f6,{className:"pb-3",children:[(0,D.jsx)(f9,{className:"text-base",children:"Based On"}),(0,D.jsxs)(f7,{className:"text-xs",children:[(C.based_on?.memories?.length||0)+(C.based_on?.observations?.filter(e=>"directive"!==e.subtype)?.length||0)+(C.based_on?.directives?.length||0)," ","items used"]})]}),(0,D.jsx)(f8,{children:y?C.based_on?.memories&&C.based_on.memories.length>0||C.based_on?.mental_models&&C.based_on.mental_models.length>0||C.based_on?.directives&&C.based_on.directives.length>0||C.based_on?.observations&&C.based_on.observations.length>0?(i=(r=C.based_on?.memories||[]).filter(e=>"world"===e.type),a=r.filter(e=>"experience"===e.type),o=C.based_on?.mental_models||[],s=(C.based_on?.observations||[]).filter(e=>"directive"!==e.subtype),c=[{id:"directives",label:"Directives",count:(l=C.based_on?.directives||[]).length},{id:"mental_models",label:"Mental Models",count:o.length},{id:"observations",label:"Observations",count:s.length},{id:"world",label:"World",count:i.length},{id:"experience",label:"Experience",count:a.length}],u=(()=>{switch(eu){case"directives":return l;case"mental_models":return o;case"observations":return s;case"world":return i;case"experience":return a;default:return[]}})(),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:c.map(e=>(0,D.jsxs)("button",{onClick:()=>ed(e.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${eu===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.label," (",e.count,")"]},e.id))}),u.length>0?(0,D.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:u.map((e,t)=>{let n,r;return(0,D.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==eu?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==eu&&("observations"===eu?ef(e):"mental_models"===eu?ec(e.id):Y(e.id))},children:"directives"===eu?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.content&&(0,D.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.content})]}):"observations"===eu?(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}):"mental_models"===eu?(r=(n=e.text?.indexOf(": ")??-1)>0?e.text.slice(0,n):e.id,(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:r}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.id})]})):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text}),e.context&&(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:e.context})]})},e.id||t)})}):(0,D.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:["No ",eu," items"]})]})):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-lg",children:[(0,D.jsx)(pe.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:"No facts found"}),(0,D.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:"No memories were used to generate this answer."})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(pe.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Source" to see memories.'})]})]})})]})]})]}),"json"===j&&(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{children:(0,D.jsx)(f9,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(f8,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(p$,{src:C,collapsed:2,theme:"default"})})})]})]}),!T&&!C&&(0,D.jsx)(f4,{className:"border-dashed",children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(z,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Reflect"}),(0,D.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a question above to query the memory bank and generate a disposition-aware response."})]})}),(0,D.jsx)(tm,{memoryId:G,onClose:()=>Y(null)}),X&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(pr,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"icon",onClick:()=>{W(null),$(null)},children:(0,D.jsx)(tc.X,{className:"w-4 h-4"})})]}),J?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,D.jsx)("p",{className:"mt-1 font-medium",children:q?.name||X.name})]}),q?.description&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,D.jsx)("p",{className:"mt-1 text-sm",children:q.description})]}),q?.tags&&q.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:q.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(tp.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),(q?.content||X.content)&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:q?.content||X.content})})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:X.id})]})]})]})}),et&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(pt,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Observation"})]}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"icon",onClick:()=>{en(null),ei(null)},children:(0,D.jsx)(tc.X,{className:"w-4 h-4"})})]}),ea?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Text"}),(0,D.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:er?.text||et.text})})]}),er?.tags&&er.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:er.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(tp.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),er?.source_memories&&er.source_memories.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Source Memories (",er.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-2",children:er.source_memories.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.text||("string"==typeof e?e:"")})},t))})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:et.id})]})]})]})}),(0,D.jsx)(yq,{mentalModelId:el,onClose:()=>ec(null)})]}):(0,D.jsx)(f4,{className:"border-dashed",children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(V,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start reflecting."})]})})}let yK=(0,F.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function yZ(){let e,t,n,r,i,a,o,s,l,c,u,d,h,f,{currentBank:p}=(0,I.useBank)(),[g,v]=(0,M.useState)(""),[x,y]=(0,M.useState)(["world"]),[b,w]=(0,M.useState)("mid"),[N,j]=(0,M.useState)(4096),[k,C]=(0,M.useState)(""),[E,T]=(0,M.useState)(!1),[S,_]=(0,M.useState)(!1),[A,P]=(0,M.useState)(""),[L,O]=(0,M.useState)("any"),[F,z]=(0,M.useState)(null),[G,X]=(0,M.useState)(null),[W,q]=(0,M.useState)(null),[$,ee]=(0,M.useState)(null),[et,en]=(0,M.useState)(null),[er,ei]=(0,M.useState)(!1),[ea,es]=(0,M.useState)("results"),[el,ec]=(0,M.useState)(null),[eu,ed]=(0,M.useState)(new Set),[eh,ef]=(0,M.useState)(new Set),ep=e=>{ed(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},eg=e=>{ef(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},em=e=>{let t=e.id||e.node_id;ec(F?.find(e=>e.id===t||e.node_id===t)||e)},ev=async()=>{if(!p)return void R.toast.error("Validation error",{description:"Please select a memory bank first"});if(g){if(0===x.length)return void R.toast.error("Validation error",{description:"Please select at least one type (World, Experience, or Observations)"});ei(!0);try{let e=A.split(",").map(e=>e.trim()).filter(e=>e.length>0),t={bank_id:p,query:g,types:x,budget:b,max_tokens:N,trace:!0,include:{entities:S?{max_tokens:500}:null,chunks:E?{max_tokens:8192}:null},...k&&{query_timestamp:k},...e.length>0&&{tags:e,tags_match:L}},n=await K.client.recall(t);z(n.results||[]),X(n.entities||null),q(n.chunks||null),ee(n.observations||null),en(n.trace||null),es("results")}catch(e){}finally{ei(!1)}}},ex=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return p?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(B.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(Q.Input,{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"What would you like to recall?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&ev()})]}),(0,D.jsx)(Z.Button,{onClick:ev,disabled:er||!g,className:"h-12 px-8",children:er?"Searching...":"Recall"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Types:"}),(0,D.jsxs)("div",{className:"flex gap-3",children:[["world","experience"].map(e=>(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:x.includes(e),onCheckedChange:()=>ex(e)}),(0,D.jsx)("span",{className:"text-sm capitalize",children:e})]},e)),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:x.includes("observation"),onCheckedChange:()=>ex("observation")}),(0,D.jsx)("span",{className:"text-sm",children:"Observations"})]})]})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(pK,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsxs)(fl,{value:b,onValueChange:e=>w(e),children:[(0,D.jsx)(fJ,{className:"w-24 h-8",children:(0,D.jsx)(fh,{})}),(0,D.jsxs)(f2,{children:[(0,D.jsx)(f5,{value:"low",children:"Low"}),(0,D.jsx)(f5,{value:"mid",children:"Mid"}),(0,D.jsx)(f5,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(Q.Input,{type:"number",value:N,onChange:e=>j(parseInt(e.target.value)),className:"w-24 h-8"})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(eo,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)(Q.Input,{type:"datetime-local",value:k,onChange:e=>C(e.target.value),className:"h-8",placeholder:"Query date"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:E,onCheckedChange:e=>T(e)}),(0,D.jsx)(H.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Chunks"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(f3.Checkbox,{checked:S,onCheckedChange:e=>_(e)}),(0,D.jsx)(U,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Entities"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(tp.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(Q.Input,{type:"text",value:A,onChange:e=>P(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(fl,{value:L,onValueChange:e=>O(e),children:[(0,D.jsx)(fJ,{className:"w-40 h-8",children:(0,D.jsx)(fh,{})}),(0,D.jsxs)(f2,{children:[(0,D.jsx)(f5,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(f5,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(f5,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(f5,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),er&&(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Searching memories..."})]})}),!er&&F&&(0,D.jsxs)("div",{className:"space-y-4",children:[et?.summary&&(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Results:"}),(0,D.jsx)("span",{className:"font-semibold",children:F.length})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Duration:"}),(0,D.jsxs)("span",{className:"font-semibold",children:[et.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Nodes visited:"}),(0,D.jsx)("span",{className:"font-semibold",children:et.summary.total_nodes_visited})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>es(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ea===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===e?"Results":"trace"===e?"Trace":"JSON"},e))})]}),"results"===ea&&(0,D.jsxs)("div",{className:"space-y-4",children:[$&&$.length>0&&(0,D.jsxs)(f4,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,D.jsx)(f6,{className:"py-3",children:(0,D.jsxs)(f9,{className:"text-base flex items-center gap-2",children:[(0,D.jsx)(V,{className:"h-4 w-4 text-orange-500"}),(0,D.jsx)("span",{children:"Observations"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",$.length,")"]})]})}),(0,D.jsx)(f8,{className:"pt-0 space-y-2",children:$.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,D.jsx)("p",{className:"text-sm text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,D.jsxs)("span",{children:["Proof count: ",e.proof_count||1]}),(0,D.jsxs)("span",{children:["Relevance: ",(e.relevance||0).toFixed(3)]})]})]},e.id||t))})]}),(0,D.jsx)("div",{className:"space-y-3",children:0!==F.length||$&&0!==$.length?F.map((e,t)=>{let n=et?.visits?.find(t=>t.node_id===e.id),r=n?n.weights.final_weight:e.score||0;return(0,D.jsx)(f4,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ec(e),children:(0,D.jsx)(f8,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-start gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-semibold text-primary",children:t+1})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:e.type||"world"}),e.context&&(0,D.jsx)("span",{className:"truncate max-w-xs",children:e.context}),e.occurred_start&&(0,D.jsx)("span",{children:new Date(e.occurred_start).toLocaleDateString()})]})]}),(0,D.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,D.jsx)("div",{className:"text-sm font-semibold",children:r.toFixed(3)}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:"score"})]}),(0,D.jsx)(Y,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},t)}):(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-12",children:[(0,D.jsx)(B.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"No memories found for this query."})]})})})]}),"trace"===ea&&et&&(0,D.jsxs)("div",{className:"space-y-4",children:[et.retrieval_results&&et.retrieval_results.length>0&&(e={},et.retrieval_results.forEach(t=>{let n=t.fact_type||"all";e[n]||(e[n]=[]),e[n].push(t)}),t=Object.keys(e),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,D.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,D.jsx)("span",{children:"PARALLEL RETRIEVAL"}),(0,D.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,D.jsx)("div",{className:"space-y-2",children:t.map((t,n)=>{let r=e[t],i=`lane-${t}`,a=eu.has(i),o=r.reduce((e,t)=>e+(t.results?.length||0),0),s=Math.max(...r.map(e=>e.duration_seconds||0)),l={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},c=l[t]||l.all;return(0,D.jsx)(f4,{className:`transition-colors ${a?"border-primary":c.border}`,children:(0,D.jsxs)(f8,{className:"py-3 px-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>ep(i),children:[(0,D.jsx)("div",{className:`w-8 h-8 rounded-lg ${c.bg} flex items-center justify-center`,children:(0,D.jsx)("span",{className:`text-sm font-bold ${c.text} capitalize`,children:t.charAt(0).toUpperCase()})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground capitalize",children:t}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r.length," methods"]})]}),(0,D.jsx)("div",{className:"flex gap-1.5 mt-1",children:r.map((e,t)=>(0,D.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[e.method_name,": ",e.results?.length||0]},t))})]}),(0,D.jsxs)("div",{className:"text-right",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:o}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[s.toFixed(2),"s"]})]}),a?(0,D.jsx)(fZ,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(Y,{className:"h-5 w-5 text-muted-foreground"})]}),a&&(0,D.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,D.jsx)("div",{className:`grid gap-3 ${1===r.length?"grid-cols-1":2===r.length?"grid-cols-2":3===r.length?"grid-cols-3":"grid-cols-4"}`,children:r.map((e,t)=>{let n,r,a,o,s=`${i}-method-${t}`,l=eu.has(s),c=e.results||[];return(0,D.jsxs)("div",{className:"flex flex-col",children:[(0,D.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${l?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:e=>{e.stopPropagation(),ep(s)},children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:e.method_name}),"temporal"===e.method_name&&e.metadata?.constraint&&(0,D.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,D.jsx)(J,{className:"h-3 w-3"}),e.metadata.constraint.start?new Date(e.metadata.constraint.start).toLocaleDateString():"any"," → ",e.metadata.constraint.end?new Date(e.metadata.constraint.end).toLocaleDateString():"any"]})]}),l?(0,D.jsx)(fZ,{className:"h-3 w-3 text-muted-foreground"}):(0,D.jsx)(Y,{className:"h-3 w-3 text-muted-foreground"})]}),(0,D.jsxs)("div",{className:"flex items-end justify-between",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:c.length}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[e.duration_seconds?.toFixed(2),"s"]})]})]}),l&&c.length>0&&(n=`results-${s}`,a=(r=eh.has(n))?c:c.slice(0,5),o=c.length>5,(0,D.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[a.map((e,t)=>(0,D.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:t=>{t.stopPropagation(),em(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:e.text}),(0,D.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,D.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(e.score||e.similarity||0).toFixed(4)})})]})]})},t)),o&&(0,D.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),eg(n)},children:r?"Show less":`View all ${c.length} results`})]}))]},s)})})})]})},i)})}),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)("div",{className:"flex items-center gap-2",children:t.map((e,t)=>{let n={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,D.jsx)("div",{className:"flex flex-col items-center",children:(0,D.jsx)("div",{className:`w-1 h-4 ${n[e]||n.all} rounded-full opacity-50`})},t)})})}),(0,D.jsx)("div",{className:"flex justify-center",children:(0,D.jsx)(yK,{className:"h-5 w-5 text-muted-foreground/50"})})]})),et.rrf_merged&&(n="rrf-merge",r=eu.has(n),(0,D.jsxs)("div",{children:[(0,D.jsx)(f4,{className:`cursor-pointer transition-colors ${r?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(n),children:(0,D.jsx)(f8,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"RRF Fusion"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"merge"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Reciprocal Rank Fusion of all retrieval results"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:et.rrf_merged.length}),r?(0,D.jsx)(fZ,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(Y,{className:"h-5 w-5 text-muted-foreground"})]})})}),r&&et.rrf_merged.length>0&&(i="results-rrf",o=(a=eh.has(i))?et.rrf_merged:et.rrf_merged.slice(0,5),s=et.rrf_merged.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[o.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),em(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["RRF Score: ",(e.rrf_score||e.score||0).toFixed(4)]})]})]})},t)),s&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),eg(i)},children:a?"Show less":`View all ${et.rrf_merged.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(yK,{className:"h-4 w-4 text-muted-foreground/50"})})]})),et.reranked&&(l="reranking",c=eu.has(l),(0,D.jsxs)("div",{children:[(0,D.jsx)(f4,{className:`cursor-pointer transition-colors ${c?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(l),children:(0,D.jsx)(f8,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Combined Scoring"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"rerank"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,D.jsx)("span",{className:"font-mono text-xs",children:"0.6×cross_encoder + 0.2×rrf + 0.1×temporal + 0.1×recency"})})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:et.reranked.length}),c?(0,D.jsx)(fZ,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(Y,{className:"h-5 w-5 text-muted-foreground"})]})})}),c&&et.reranked.length>0&&(u="results-rerank",h=(d=eh.has(u))?et.reranked:et.reranked.slice(0,5),f=et.reranked.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[h.map((e,t)=>{let n=e.score_components||{};return(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),em(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,D.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(e.rerank_score||e.score||0).toFixed(4)]}),void 0!==n.cross_encoder_score_normalized&&(0,D.jsxs)("span",{title:"Cross-encoder (60%)",children:["CE: ",n.cross_encoder_score_normalized.toFixed(3)]}),void 0!==n.rrf_normalized&&(0,D.jsxs)("span",{title:`RRF normalized (20%) - raw: ${n.rrf_score?.toFixed(4)||"N/A"}`,children:["RRF: ",n.rrf_normalized.toFixed(3)]}),void 0!==n.temporal&&(0,D.jsxs)("span",{title:"Temporal proximity (10%)",children:["Tmp: ",n.temporal.toFixed(3)]}),void 0!==n.recency&&(0,D.jsxs)("span",{title:"Recency (10%)",children:["Rec: ",n.recency.toFixed(3)]})]})]})]})},t)}),f&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),eg(u)},children:d?"Show less":`View all ${et.reranked.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(yK,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,D.jsx)(f4,{className:"border-primary bg-primary/5",children:(0,D.jsx)(f8,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Final Results"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:"output"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Top results after all processing steps"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-primary",children:F?.length||0})]})})})]}),"json"===ea&&(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{children:(0,D.jsx)(f9,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(f8,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(p$,{src:{results:F,...G&&{entities:G},...W&&{chunks:W},...$&&{observations:$},trace:et},collapsed:2,theme:"default"})})})]})]}),!er&&!F&&(0,D.jsx)(f4,{className:"border-dashed",children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(B.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Recall"}),(0,D.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a query above to search through your memories. Use filters to narrow down by fact type, budget, and more."})]})}),el&&(0,D.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,D.jsx)(tv,{memory:el,onClose:()=>ec(null),inPanel:!0,bankId:p||void 0})})]}):(0,D.jsx)(f4,{className:"border-dashed",children:(0,D.jsxs)(f8,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(V,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start recalling."})]})})}let yQ=(0,F.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var yJ=e.i(82458),yJ=yJ,y0=e.i(7233),tu=tu;let y1=(0,F.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),y2={skepticism:{label:"Skepticism",shortLabel:"S",description:"How skeptical vs trusting when forming observations",lowLabel:"Trusting",highLabel:"Skeptical"},literalism:{label:"Literalism",shortLabel:"L",description:"How literally to interpret information when forming observations",lowLabel:"Flexible",highLabel:"Literal"},empathy:{label:"Empathy",shortLabel:"E",description:"How much to consider emotional context when forming observations",lowLabel:"Detached",highLabel:"Empathetic"}};function y5(){let e=(0,P.useRouter)(),{currentBank:t,setCurrentBank:n,loadBanks:r}=(0,I.useBank)(),{features:i}=(0,O.useFeatures)();i?.observations;let[a,o]=(0,M.useState)(null),[s,l]=(0,M.useState)(null),[c,u]=(0,M.useState)([]),[d,h]=(0,M.useState)(0),[f,p]=(0,M.useState)([]),[g,v]=(0,M.useState)(0),[x,y]=(0,M.useState)(!1),[b,w]=(0,M.useState)(!1),[N,j]=(0,M.useState)(!1),[k,C]=(0,M.useState)(!1),[E,T]=(0,M.useState)(null),[S,_]=(0,M.useState)(null),[A,L]=(0,M.useState)(!1),[B,F]=(0,M.useState)(!1),[z,V]=(0,M.useState)(!1),[H,U]=(0,M.useState)(!1),[G,Y]=(0,M.useState)(!1),[X,W]=(0,M.useState)(!1),[q,$]=(0,M.useState)(null),[Q]=(0,M.useState)(10),[J,ee]=(0,M.useState)(0),[et,en]=(0,M.useState)(null),er=async(e=q,n=J)=>{if(t)try{let r=await K.client.listOperations(t,{status:e||void 0,limit:Q,offset:n});u(r.operations||[]),h(r.total||0)}catch(e){console.error("Error loading operations:",e)}},ea=async(e=!1)=>{if(t){if(e){try{let[e,n,r]=await Promise.all([K.client.getBankStats(t),K.client.listDirectives(t),K.client.listMentalModels(t)]);l(e),p(n.items||[]),v(r.items?.length||0)}catch(e){console.error("Error refreshing stats:",e)}return}y(!0);try{let[e,n,r,i]=await Promise.all([K.client.getBankProfile(t),K.client.getBankStats(t),K.client.listDirectives(t),K.client.listMentalModels(t)]);o(e),l(n),p(r.items||[]),v(i.items?.length||0),await er()}catch(e){}finally{y(!1)}}},es=async()=>{if(t){V(!0);try{await K.client.deleteBank(t),F(!1),n(null),await r(),e.push("/")}catch(e){}finally{V(!1)}}},el=async()=>{if(t){Y(!0);try{let e=await K.client.clearObservations(t);U(!1),await ea(),R.toast.success("Success",{description:e.message||"Observations cleared successfully"})}catch(e){}finally{Y(!1)}}},ec=async()=>{if(t&&S){L(!0);try{await K.client.deleteDirective(t,S.id),p(e=>e.filter(e=>e.id!==S.id)),E?.id===S.id&&T(null),_(null)}catch(e){}finally{L(!1)}}};return((0,M.useEffect)(()=>{if(t){ea();let e=setInterval(()=>ea(!0),5e3);return()=>clearInterval(e)}},[t]),(0,M.useEffect)(()=>{let e=e=>{"Escape"===e.key&&T(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),t)?x&&!a?(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"text-center py-10",children:[(0,D.jsx)(eo,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,D.jsx)("div",{className:"text-lg text-muted-foreground",children:"Loading profile..."})]})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-start justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(f9,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(pt,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,D.jsx)(f7,{children:"Traits that shape the reasoning and perspective"})]}),(0,D.jsx)(Z.Button,{onClick:()=>w(!0),variant:"ghost",size:"sm",children:(0,D.jsx)(y1,{className:"h-4 w-4"})})]})}),(0,D.jsx)(f8,{children:a&&(0,D.jsx)("div",{className:"space-y-4",children:Object.keys(y2).map(e=>(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:y2[e].label}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:y2[e].description})]}),(0,D.jsxs)("span",{className:"text-sm font-bold text-primary",children:[a.disposition[e],"/5"]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:y2[e].lowLabel}),(0,D.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,D.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(a.disposition[e]-1)/4*100}%`}})}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:y2[e].highLabel})]})]},e))})})]}),(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-start justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(f9,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yQ,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,D.jsx)(f7,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,D.jsx)(Z.Button,{onClick:()=>j(!0),variant:"ghost",size:"sm",children:(0,D.jsx)(y1,{className:"h-4 w-4"})})]})}),(0,D.jsx)(f8,{children:(0,D.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:a?.mission||"No mission set. Set a mission to derive structural mental models and personalize reflect responses."})})]})]}),(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(f9,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yJ.default,{className:"w-5 h-5 text-rose-500"}),"Directives"]}),(0,D.jsx)(f7,{children:"Hard rules that must be followed during reflect"})]}),(0,D.jsxs)(Z.Button,{onClick:()=>C(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,D.jsx)(y0.Plus,{className:"w-4 h-4 mr-1"}),"Add"]})]})}),(0,D.jsx)(f8,{children:f.length>0?(0,D.jsx)("div",{className:"grid grid-cols-2 gap-3",children:f.map(e=>(0,D.jsx)(f4,{className:`cursor-pointer transition-colors border-rose-500/30 ${E?.id===e.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>T(e),children:(0,D.jsx)(f8,{className:"p-3",children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)(yJ.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:e.content}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,D.jsx)(tp.Tag,{className:"w-3 h-3 text-muted-foreground"}),e.tags.map(e=>(0,D.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e},e))]})]})]})})},e.id))}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,D.jsx)(yJ.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:"No directives yet. Directives are hard rules that must be followed during reflect."})]})})]}),(0,D.jsx)(hx,{open:B,onOpenChange:F,children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Delete Memory Bank"}),(0,D.jsx)(hF,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."}),s&&(0,D.jsxs)("p",{children:["This will delete ",s.total_nodes," memories, ",s.total_documents," ","documents, and ",s.total_links," links."]})]})})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{disabled:z,children:"Cancel"}),(0,D.jsx)(hz,{onClick:es,disabled:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:z?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,D.jsx)(hx,{open:H,onOpenChange:U,children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Clear Observations"}),(0,D.jsx)(hF,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."}),s&&s.total_mental_models>0&&(0,D.jsxs)("p",{children:["This will delete ",s.total_mental_models," observations."]})]})})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{disabled:G,children:"Cancel"}),(0,D.jsx)(hz,{onClick:el,disabled:G,className:"bg-amber-500 text-white hover:bg-amber-600",children:G?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,D.jsx)(y6,{open:k,mode:"create",onClose:()=>C(!1),onCreated:e=>{p(t=>[e,...t]),C(!1)}}),(0,D.jsx)(hx,{open:!!S,onOpenChange:e=>!e&&_(null),children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Delete Directive"}),(0,D.jsxs)(hF,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',S?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hO,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hV,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hz,{onClick:ec,disabled:A,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[A?(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),E&&(0,D.jsx)(y9,{directive:E,onClose:()=>T(null),onDelete:()=>_({id:E.id,name:E.name}),onUpdated:e=>{p(t=>t.map(t=>t.id===e.id?e:t)),T(e)}}),b&&a&&(0,D.jsx)(y3,{disposition:a.disposition,onClose:()=>w(!1),onSaved:async()=>{await ea(),w(!1)}}),N&&a&&(0,D.jsx)(y4,{mission:a.mission||"",onClose:()=>j(!1),onSaved:async()=>{await ea(),j(!1)}})]}):(0,D.jsx)(f4,{children:(0,D.jsxs)(f8,{className:"p-10 text-center",children:[(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Please select a memory bank from the dropdown above to view its profile."})]})})}function y3({disposition:e,onClose:t,onSaved:n}){let{currentBank:r}=(0,I.useBank)(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(e),l=async()=>{if(r){a(!0);try{await K.client.updateBankProfile(r,{disposition:o}),n()}catch(e){}finally{a(!1)}}};return(0,D.jsx)(td.Dialog,{open:!0,onOpenChange:t,children:(0,D.jsxs)(td.DialogContent,{className:"max-w-xl",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Edit Disposition Traits"}),(0,D.jsx)(td.DialogDescription,{children:"Traits that shape the reasoning and perspective"})]}),(0,D.jsx)("div",{className:"space-y-4 py-4",children:Object.keys(y2).map(e=>(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:y2[e].label}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:y2[e].description})]}),(0,D.jsxs)("span",{className:"text-sm font-bold text-primary",children:[o[e],"/5"]})]}),(0,D.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,D.jsx)("span",{children:y2[e].lowLabel}),(0,D.jsx)("span",{children:y2[e].highLabel})]}),(0,D.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:o[e],onChange:t=>s(n=>({...n,[e]:parseInt(t.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},e))}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{onClick:t,variant:"outline",disabled:i,children:"Cancel"}),(0,D.jsx)(Z.Button,{onClick:l,disabled:i,children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function y4({mission:e,onClose:t,onSaved:n}){let{currentBank:r}=(0,I.useBank)(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(e),l=async()=>{if(r){a(!0);try{await K.client.updateBankProfile(r,{mission:o}),n()}catch(e){}finally{a(!1)}}};return(0,D.jsx)(td.Dialog,{open:!0,onOpenChange:t,children:(0,D.jsxs)(td.DialogContent,{className:"max-w-xl",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Edit Mission"}),(0,D.jsx)(td.DialogDescription,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,D.jsx)("div",{className:"space-y-2 py-4",children:(0,D.jsx)(pa.Textarea,{value:o,onChange:e=>s(e.target.value),placeholder:"e.g., I am a PM for the engineering team. I help coordinate sprints and track project progress...",rows:8,className:"resize-none"})}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{onClick:t,variant:"outline",disabled:i,children:"Cancel"}),(0,D.jsx)(Z.Button,{onClick:l,disabled:i,children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function y6({open:e,mode:t,directive:n,onClose:r,onCreated:i,onSaved:a}){let{currentBank:o}=(0,I.useBank)(),[s,l]=(0,M.useState)(!1),[c,u]=(0,M.useState)({name:"",content:"",tags:""});(0,M.useEffect)(()=>{"edit"===t&&n?u({name:n.name,content:n.content,tags:(n.tags||[]).join(", ")}):"create"===t&&u({name:"",content:"",tags:""})},[e,t,n]);let d=async()=>{if(o&&c.name.trim()&&c.content.trim()){l(!0);try{let e=c.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0);if("create"===t){let t=await K.client.createDirective(o,{name:c.name.trim(),content:c.content.trim(),tags:e.length>0?e:void 0});u({name:"",content:"",tags:""}),i?.(t)}else if(n){let t=await K.client.updateDirective(o,n.id,{name:c.name.trim(),content:c.content.trim(),tags:e});a?.(t),r()}}catch(e){}finally{l(!1)}}},h=()=>{"create"===t&&u({name:"",content:"",tags:""}),r()};return(0,D.jsx)(td.Dialog,{open:e,onOpenChange:e=>!e&&h(),children:(0,D.jsxs)(td.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsxs)(td.DialogTitle,{className:"flex items-center gap-2",children:[(0,D.jsx)(yJ.default,{className:"w-5 h-5 text-rose-500"}),"create"===t?"Create":"Edit"," Directive"]}),(0,D.jsx)(td.DialogDescription,{children:"Directives are hard rules that must be followed during reflect."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(Q.Input,{value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:"e.g., Competitor Policy"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Rule *"}),(0,D.jsx)(pa.Textarea,{value:c.content,onChange:e=>u({...c,content:e.target.value}),placeholder:"e.g., Never mention competitor products directly.",className:"min-h-[120px]"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(Q.Input,{value:c.tags,onChange:e=>u({...c,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{variant:"outline",onClick:h,disabled:s,children:"Cancel"}),(0,D.jsxs)(Z.Button,{onClick:d,disabled:s||!c.name.trim()||!c.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[s?(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"create"===t?"Create":"Save"]})]})]})})}function y9({directive:e,onClose:t,onDelete:n,onUpdated:r}){let[i,a]=(0,M.useState)(!1);return(0,D.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l-2 border-rose-500 shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)(yJ.default,{className:"w-5 h-5 text-rose-500"}),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-7 w-7 p-0",children:(0,D.jsx)(y1,{className:"h-3.5 w-3.5"})})]}),(0,D.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:"directive"})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,D.jsx)(hH,{className:"h-4 w-4"})}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(tc.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Rule"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,D.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]})]})]}),(0,D.jsx)(y6,{open:i,mode:"edit",directive:e,onClose:()=>a(!1),onSaved:r})]})}let y7=(0,ey.cva)("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),y8=M.forwardRef(({className:e,variant:t,...n},r)=>(0,D.jsx)("div",{ref:r,role:"alert",className:(0,W.cn)(y7({variant:t}),e),...n}));y8.displayName="Alert",M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("h5",{ref:n,className:(0,W.cn)("mb-1 font-medium leading-none tracking-tight",e),...t})).displayName="AlertTitle";let be=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,W.cn)("text-sm [&_p]:leading-relaxed",e),...t}));be.displayName="AlertDescription";var bt=e.i(96626),bn=e.i(42727),br=Symbol("radix.slottable");function bi(e){return M.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===br}var ba=["Enter"," "],bo=["ArrowUp","PageDown","End"],bs=["ArrowDown","PageUp","Home",...bo],bl={ltr:[...ba,"ArrowRight"],rtl:[...ba,"ArrowLeft"]},bc={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bu="Menu",[bd,bh,bf]=(0,eD.createCollection)(bu),[bp,bg]=(0,eC.createContextScope)(bu,[bf,h$.createPopperScope,bn.createRovingFocusGroupScope]),bm=(0,h$.createPopperScope)(),bv=(0,bn.createRovingFocusGroupScope)(),[bx,by]=bp(bu),[bb,bw]=bp(bu),bN=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=bm(t),[l,c]=M.useState(null),u=M.useRef(!1),d=(0,hJ.useCallbackRef)(a),h=(0,eT.useDirection)(i);return M.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,D.jsx)(h$.Root,{...s,children:(0,D.jsx)(bx,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,D.jsx)(bb,{scope:t,onClose:M.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:o,children:r})})})};bN.displayName=bu;var bj=M.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=bm(n);return(0,D.jsx)(h$.Anchor,{...i,...r,ref:t})});bj.displayName="MenuAnchor";var bk="MenuPortal",[bC,bE]=bp(bk,{forceMount:void 0}),bT=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=by(bk,t);return(0,D.jsx)(bC,{scope:t,forceMount:n,children:(0,D.jsx)(bt.Presence,{present:n||a.open,children:(0,D.jsx)(hK.Portal,{asChild:!0,container:i,children:r})})})};bT.displayName=bk;var bS="MenuContent",[b_,bA]=bp(bS),bD=M.forwardRef((e,t)=>{let n=bE(bS,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=by(bS,e.__scopeMenu),o=bw(bS,e.__scopeMenu);return(0,D.jsx)(bd.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(bt.Presence,{present:r||a.open,children:(0,D.jsx)(bd.Slot,{scope:e.__scopeMenu,children:o.modal?(0,D.jsx)(bM,{...i,ref:t}):(0,D.jsx)(bP,{...i,ref:t})})})})}),bM=M.forwardRef((e,t)=>{let n=by(bS,e.__scopeMenu),r=M.useRef(null),i=(0,ek.useComposedRefs)(t,r);return M.useEffect(()=>{let e=r.current;if(e)return(0,h5.hideOthers)(e)},[]),(0,D.jsx)(bL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:(0,ej.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),bP=M.forwardRef((e,t)=>{let n=by(bS,e.__scopeMenu);return(0,D.jsx)(bL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),bR=((s=M.forwardRef((e,t)=>{let{children:n,...r}=e;if(M.isValidElement(n)){var i;let e,a,o=(i=n,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...a}:"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==M.Fragment&&(s.ref=t?(0,ek.composeRefs)(t,o):o),M.cloneElement(n,s)}return M.Children.count(n)>1?M.Children.only(null):null})).displayName="MenuContent.ScrollLock.SlotClone",i=s,(a=M.forwardRef((e,t)=>{let{children:n,...r}=e,a=M.Children.toArray(n),o=a.find(bi);if(o){let e=o.props.children,n=a.map(t=>t!==o?t:M.Children.count(e)>1?M.Children.only(null):M.isValidElement(e)?e.props.children:null);return(0,D.jsx)(i,{...r,ref:t,children:M.isValidElement(e)?M.cloneElement(e,void 0,n):null})}return(0,D.jsx)(i,{...r,ref:t,children:n})})).displayName="MenuContent.ScrollLock.Slot",a),bL=M.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,disableOutsideScroll:p,...g}=e,v=by(bS,n),x=bw(bS,n),y=bm(n),b=bv(n),w=bh(n),[N,j]=M.useState(null),k=M.useRef(null),C=(0,ek.useComposedRefs)(t,k,v.onContentChange),E=M.useRef(0),T=M.useRef(""),S=M.useRef(0),_=M.useRef(null),A=M.useRef("right"),P=M.useRef(0),R=p?h3.RemoveScroll:M.Fragment;M.useEffect(()=>()=>window.clearTimeout(E.current),[]),(0,hX.useFocusGuards)();let L=M.useCallback(e=>{var t,n;return A.current===_.current?.side&&(t=e,!!(n=_.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],l=o.x,c=o.y,u=s.x,d=s.y;c>r!=d>r&&n<(u-l)*(r-c)/(d-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,D.jsx)(b_,{scope:n,searchRef:T,onItemEnter:M.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:M.useCallback(e=>{L(e)||(k.current?.focus(),j(null))},[L]),onTriggerLeave:M.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:S,onPointerGraceIntentChange:M.useCallback(e=>{_.current=e},[]),children:(0,D.jsx)(R,{...p?{as:bR,allowPinchZoom:!0}:void 0,children:(0,D.jsx)(hW.FocusScope,{asChild:!0,trapped:i,onMountAutoFocus:(0,ej.composeEventHandlers)(a,e=>{e.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,D.jsx)(hY.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,children:(0,D.jsx)(bn.Root,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:j,onEntryFocus:(0,ej.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,D.jsx)(h$.Content,{role:"menu","aria-orientation":"vertical","data-state":b9(v.open),"data-radix-menu-content":"",dir:x.dir,...y,...g,ref:C,style:{outline:"none",...g.style},onKeyDown:(0,ej.composeEventHandlers)(g.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,a,o,s,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=T.current+i,a=w().filter(e=>!e.disabled),o=document.activeElement,s=a.find(e=>e.ref.current===o)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,a=n?e.indexOf(n):-1,o=(r=Math.max(a,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(o=o.filter(e=>e!==n));let s=o.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return s!==n?s:void 0}(a.map(e=>e.textValue),t,s),c=a.find(e=>e.textValue===l)?.ref.current,function e(t){T.current=t,window.clearTimeout(E.current),""!==t&&(E.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let a=k.current;if(e.target!==a||!bs.includes(e.key))return;e.preventDefault();let o=w().filter(e=>!e.disabled).map(e=>e.ref.current);bo.includes(e.key)&&o.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(o)}),onBlur:(0,ej.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),T.current="")}),onPointerMove:(0,ej.composeEventHandlers)(e.onPointerMove,we(e=>{let t=e.target,n=P.current!==e.clientX;e.currentTarget.contains(t)&&n&&(A.current=e.clientX>P.current?"right":"left",P.current=e.clientX)}))})})})})})})});bD.displayName=bS;var bI=M.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eA.Primitive.div,{role:"group",...r,ref:t})});bI.displayName="MenuGroup";var bO=M.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eA.Primitive.div,{...r,ref:t})});bO.displayName="MenuLabel";var bB="MenuItem",bF="menu.itemSelect",bz=M.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=M.useRef(null),o=bw(bB,e.__scopeMenu),s=bA(bB,e.__scopeMenu),l=(0,ek.useComposedRefs)(t,a),c=M.useRef(!1);return(0,D.jsx)(bV,{...i,ref:l,disabled:n,onClick:(0,ej.composeEventHandlers)(e.onClick,()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(bF,{bubbles:!0,cancelable:!0});e.addEventListener(bF,e=>r?.(e),{once:!0}),(0,eA.dispatchDiscreteCustomEvent)(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,ej.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,ej.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==s.searchRef.current;n||t&&" "===e.key||ba.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});bz.displayName=bB;var bV=M.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=bA(bB,n),s=bv(n),l=M.useRef(null),c=(0,ek.useComposedRefs)(t,l),[u,d]=M.useState(!1),[h,f]=M.useState("");return M.useEffect(()=>{let e=l.current;e&&f((e.textContent??"").trim())},[a.children]),(0,D.jsx)(bd.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,D.jsx)(bn.Item,{asChild:!0,...s,focusable:!r,children:(0,D.jsx)(eA.Primitive.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:c,onPointerMove:(0,ej.composeEventHandlers)(e.onPointerMove,we(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,ej.composeEventHandlers)(e.onPointerLeave,we(e=>o.onItemLeave(e))),onFocus:(0,ej.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,ej.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),bH=M.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,D.jsx)(bK,{scope:e.__scopeMenu,checked:n,children:(0,D.jsx)(bz,{role:"menuitemcheckbox","aria-checked":b7(n)?"mixed":n,...i,ref:t,"data-state":b8(n),onSelect:(0,ej.composeEventHandlers)(i.onSelect,()=>r?.(!!b7(n)||!n),{checkForDefaultPrevented:!1})})})});bH.displayName="MenuCheckboxItem";var bU="MenuRadioGroup",[bG,bY]=bp(bU,{value:void 0,onValueChange:()=>{}}),bX=M.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=(0,hJ.useCallbackRef)(r);return(0,D.jsx)(bG,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,D.jsx)(bI,{...i,ref:t})})});bX.displayName=bU;var bW="MenuRadioItem",bq=M.forwardRef((e,t)=>{let{value:n,...r}=e,i=bY(bW,e.__scopeMenu),a=n===i.value;return(0,D.jsx)(bK,{scope:e.__scopeMenu,checked:a,children:(0,D.jsx)(bz,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":b8(a),onSelect:(0,ej.composeEventHandlers)(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});bq.displayName=bW;var b$="MenuItemIndicator",[bK,bZ]=bp(b$,{checked:!1}),bQ=M.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=bZ(b$,n);return(0,D.jsx)(bt.Presence,{present:r||b7(a.checked)||!0===a.checked,children:(0,D.jsx)(eA.Primitive.span,{...i,ref:t,"data-state":b8(a.checked)})})});bQ.displayName=b$;var bJ=M.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eA.Primitive.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});bJ.displayName="MenuSeparator";var b0=M.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=bm(n);return(0,D.jsx)(h$.Arrow,{...i,...r,ref:t})});b0.displayName="MenuArrow";var[b1,b2]=bp("MenuSub"),b5="MenuSubTrigger",b3=M.forwardRef((e,t)=>{let n=by(b5,e.__scopeMenu),r=bw(b5,e.__scopeMenu),i=b2(b5,e.__scopeMenu),a=bA(b5,e.__scopeMenu),o=M.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,c={__scopeMenu:e.__scopeMenu},u=M.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return M.useEffect(()=>u,[u]),M.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]),(0,D.jsx)(bj,{asChild:!0,...c,children:(0,D.jsx)(bV,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":b9(n.open),...e,ref:(0,ek.composeRefs)(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:(0,ej.composeEventHandlers)(e.onPointerMove,we(t=>{a.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||o.current||(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,ej.composeEventHandlers)(e.onPointerLeave,we(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,o=t[i?"left":"right"],l=t[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:o,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:o,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:(0,ej.composeEventHandlers)(e.onKeyDown,t=>{let i=""!==a.searchRef.current;e.disabled||i&&" "===t.key||bl[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});b3.displayName=b5;var b4="MenuSubContent",b6=M.forwardRef((e,t)=>{let n=bE(bS,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=by(bS,e.__scopeMenu),o=bw(bS,e.__scopeMenu),s=b2(b4,e.__scopeMenu),l=M.useRef(null),c=(0,ek.useComposedRefs)(t,l);return(0,D.jsx)(bd.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(bt.Presence,{present:r||a.open,children:(0,D.jsx)(bd.Slot,{scope:e.__scopeMenu,children:(0,D.jsx)(bL,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,ej.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:(0,ej.composeEventHandlers)(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:(0,ej.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=bc[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});function b9(e){return e?"open":"closed"}function b7(e){return"indeterminate"===e}function b8(e){return b7(e)?"indeterminate":e?"checked":"unchecked"}function we(e){return t=>"mouse"===t.pointerType?e(t):void 0}b6.displayName=b4;var wt="DropdownMenu",[wn,wr]=(0,eC.createContextScope)(wt,[bg]),wi=bg(),[wa,wo]=wn(wt),ws=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,l=wi(t),c=M.useRef(null),[u,d]=(0,eE.useControllableState)({prop:i,defaultProp:a??!1,onChange:o,caller:wt});return(0,D.jsx)(wa,{scope:t,triggerId:(0,hq.useId)(),triggerRef:c,contentId:(0,hq.useId)(),open:u,onOpenChange:d,onOpenToggle:M.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,D.jsx)(bN,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};ws.displayName=wt;var wl="DropdownMenuTrigger",wc=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=wo(wl,n),o=wi(n);return(0,D.jsx)(bj,{asChild:!0,...o,children:(0,D.jsx)(eA.Primitive.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:(0,ek.composeRefs)(t,a.triggerRef),onPointerDown:(0,ej.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:(0,ej.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});wc.displayName=wl;var wu=e=>{let{__scopeDropdownMenu:t,...n}=e,r=wi(t);return(0,D.jsx)(bT,{...r,...n})};wu.displayName="DropdownMenuPortal";var wd="DropdownMenuContent",wh=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wo(wd,n),a=wi(n),o=M.useRef(!1);return(0,D.jsx)(bD,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:(0,ej.composeEventHandlers)(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:(0,ej.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});wh.displayName=wd,M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bI,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var wf=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bO,{...i,...r,ref:t})});wf.displayName="DropdownMenuLabel";var wp=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bz,{...i,...r,ref:t})});wp.displayName="DropdownMenuItem";var wg=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bH,{...i,...r,ref:t})});wg.displayName="DropdownMenuCheckboxItem",M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bX,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var wm=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bq,{...i,...r,ref:t})});wm.displayName="DropdownMenuRadioItem";var wv=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bQ,{...i,...r,ref:t})});wv.displayName="DropdownMenuItemIndicator";var wx=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(bJ,{...i,...r,ref:t})});wx.displayName="DropdownMenuSeparator",M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(b0,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var wy=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(b3,{...i,...r,ref:t})});wy.displayName="DropdownMenuSubTrigger";var wb=M.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=wi(n);return(0,D.jsx)(b6,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});wb.displayName="DropdownMenuSubContent";let ww=(0,F.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);M.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,D.jsxs)(wy,{ref:i,className:(0,W.cn)("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,(0,D.jsx)(Y,{className:"ml-auto"})]})).displayName=wy.displayName,M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(wb,{ref:n,className:(0,W.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",e),...t})).displayName=wb.displayName;let wN=M.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,D.jsx)(wu,{children:(0,D.jsx)(wh,{ref:r,sideOffset:t,className:(0,W.cn)("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",e),...n})}));wN.displayName=wh.displayName;let wj=M.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(wp,{ref:r,className:(0,W.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n}));wj.displayName=wp.displayName,M.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,D.jsxs)(wg,{ref:i,className:(0,W.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(wv,{children:(0,D.jsx)(tl.Check,{className:"h-4 w-4"})})}),t]})).displayName=wg.displayName,M.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(wm,{ref:r,className:(0,W.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(wv,{children:(0,D.jsx)(ww,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=wm.displayName,M.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(wf,{ref:r,className:(0,W.cn)("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n})).displayName=wf.displayName;let wk=M.forwardRef(({className:e,...t},n)=>(0,D.jsx)(wx,{ref:n,className:(0,W.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));wk.displayName=wx.displayName;var tu=tu;let wC=(0,F.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),wE=(0,F.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),wT=(0,F.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),wS={retention:{title:"Retention Settings",description:"Control how memories are extracted and stored",fields:{retain_chunk_size:{label:"Chunk Size",type:"number",description:"Size of text chunks for processing (tokens)",min:500,max:8e3},retain_extraction_mode:{label:"Extraction Mode",type:"select",description:"How to extract facts from content",options:["concise","verbose","custom"]},retain_custom_instructions:{label:"Custom Instructions",type:"textarea",description:"Custom instructions for fact extraction (requires retain_extraction_mode='custom')",placeholder:"Focus on technical details and implementation specifics...",rows:3}}},consolidation:{title:"Consolidation Settings",description:"Control observation synthesis",fields:{enable_observations:{label:"Enable Observations",type:"boolean",description:"Enable automatic consolidation of facts into observations"}}}};function w_(){let{currentBank:e}=(0,I.useBank)(),[t,n]=(0,M.useState)(!0),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({}),[s,l]=(0,M.useState)(!1),[c,u]=(0,M.useState)(!1),[d,h]=(0,M.useState)(!1);(0,M.useEffect)(()=>{e&&f()},[e]);let f=async()=>{if(e){n(!0);try{let t=await K.client.getBankConfig(e);i(t.config),o(t.overrides)}catch(e){console.error("Failed to load config:",e)}finally{n(!1)}}},p=async()=>{if(e){h(!0);try{await K.client.resetBankConfig(e),await f(),u(!1)}catch(e){}finally{h(!1)}}};return e?t?(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)(tu.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(f4,{children:[(0,D.jsx)(f6,{className:"pb-3",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)(f9,{className:"text-base",children:"Configuration Settings"}),(0,D.jsx)(f7,{className:"text-xs",children:"Behavioral parameters for this memory bank"})]}),(0,D.jsxs)(ws,{children:[(0,D.jsx)(wc,{asChild:!0,children:(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",disabled:d,children:d?(0,D.jsx)(tu.default,{className:"h-4 w-4 animate-spin"}):(0,D.jsx)(wT,{className:"h-4 w-4"})})}),(0,D.jsxs)(wN,{align:"end",children:[(0,D.jsxs)(wj,{onClick:()=>l(!0),children:[(0,D.jsx)(y1,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,D.jsxs)(wj,{onClick:()=>{u(!0)},children:[(0,D.jsx)(wE,{className:"h-4 w-4 mr-2"}),"Reset to Defaults"]})]})]})]})}),(0,D.jsx)(f8,{className:"space-y-6",children:Object.entries(wS).map(([e,t])=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("h3",{className:"text-sm font-semibold",children:t.title}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:t.description})]}),(0,D.jsx)("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:Object.entries(t.fields).map(([e,t])=>{let n;return n=r[e],(0,D.jsxs)("div",{className:"flex items-start justify-between gap-4 p-3 border border-border rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("div",{className:"text-sm font-medium font-mono",children:e}),t.description&&(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),(0,D.jsx)("div",{className:"text-sm text-foreground font-mono flex-shrink-0",children:"boolean"===t.type?(0,D.jsx)("span",{className:n?"text-green-600":"text-muted-foreground",children:n?"Enabled":"Disabled"}):"textarea"===t.type?(0,D.jsx)("span",{className:"text-muted-foreground italic",children:n?`${n.substring(0,50)}${n.length>50?"...":""}`:"Not set"}):n||(0,D.jsx)("span",{className:"text-muted-foreground italic",children:"Not set"})})]},e)})})]},e))})]}),s&&(0,D.jsx)(wA,{bankId:e,initialConfig:r,overrides:a,onClose:()=>l(!1),onSaved:()=>{f(),l(!1)}}),(0,D.jsx)(hx,{open:c,onOpenChange:u,children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Reset Configuration"}),(0,D.jsx)(hF,{children:"Are you sure you want to reset all configuration overrides to defaults? This action cannot be undone."})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{disabled:d,children:"Cancel"}),(0,D.jsx)(hz,{onClick:p,disabled:d,children:d?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"h-4 w-4 mr-2 animate-spin"}),"Resetting..."]}):"Reset to Defaults"})]})]})})]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)("p",{className:"text-muted-foreground",children:"No bank selected"})})}function wA({bankId:e,initialConfig:t,overrides:n,onClose:r,onSaved:i}){let[a,o]=(0,M.useState)(!1),[s,l]=(0,M.useState)(null),[c,u]=(0,M.useState)(t),d=(e,t)=>{u({...c,[e]:t})},h=async()=>{o(!0),l(null);try{let t={};Object.keys(c).forEach(e=>{Object.values(wS).some(t=>Object.keys(t.fields).includes(e))&&(t[e]=c[e])}),await K.client.updateBankConfig(e,t),i()}catch(e){console.error("Failed to save config:",e),l(e.message||"Failed to save configuration"),o(!1)}};return(0,D.jsx)(td.Dialog,{open:!0,onOpenChange:r,children:(0,D.jsxs)(td.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Edit Configuration"}),(0,D.jsx)(td.DialogDescription,{children:"Customize behavioral settings for this bank. Changes only affect this bank and override global defaults."})]}),(0,D.jsxs)("div",{className:"space-y-6 py-4",children:[s&&(0,D.jsxs)(y8,{variant:"destructive",children:[(0,D.jsx)(wC,{className:"h-4 w-4"}),(0,D.jsx)(be,{children:s})]}),Object.entries(wS).map(([e,t])=>(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-semibold",children:t.title}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:t.description})]}),(0,D.jsx)("div",{className:"grid gap-4",children:Object.entries(t.fields).map(([e,t])=>{let n;return n=c[e],"boolean"===t.type?(0,D.jsx)("div",{className:"space-y-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)(ew,{htmlFor:e,className:"font-mono",children:e}),t.description&&(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description})]}),(0,D.jsx)("button",{onClick:()=>d(e,!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${n?"bg-primary":"bg-muted"}`,children:(0,D.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${n?"translate-x-6":"translate-x-1"}`})})]})},e):"select"===t.type?(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(ew,{htmlFor:e,className:"font-mono",children:e}),t.description&&(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description}),(0,D.jsxs)(fl,{value:n?.toString(),onValueChange:t=>d(e,t),children:[(0,D.jsx)(fJ,{children:(0,D.jsx)(fh,{})}),(0,D.jsx)(f2,{children:t.options.map(e=>(0,D.jsx)(f5,{value:e,children:e},e))})]})]},e):"textarea"===t.type?(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(ew,{htmlFor:e,className:"font-mono",children:e}),t.description&&(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description}),(0,D.jsx)(pa.Textarea,{id:e,value:n||"",onChange:t=>d(e,t.target.value||null),placeholder:t.placeholder,rows:t.rows||3,className:"font-mono text-sm"})]},e):(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(ew,{htmlFor:e,className:"font-mono",children:e}),t.description&&(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description}),(0,D.jsx)(Q.Input,{id:e,type:t.type||"text",value:n??"",onChange:n=>d(e,"number"===t.type?parseFloat(n.target.value):n.target.value),min:t.min,max:t.max})]},e)})})]},e))]}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{onClick:r,variant:"outline",disabled:a,children:"Cancel"}),(0,D.jsx)(Z.Button,{onClick:h,disabled:a,children:a?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}let wD=(0,F.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),wM=(0,F.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),wP=(0,F.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);function wR(){let{currentBank:e}=(0,I.useBank)(),{features:t}=(0,O.useFeatures)(),n=t?.observations??!1,[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(0),[s,l]=(0,M.useState)(0),[c,u]=(0,M.useState)(!1),d=async()=>{if(e){u(!0);try{let[t,n,r]=await Promise.all([K.client.getBankStats(e),K.client.listMentalModels(e),K.client.listDirectives(e)]);i(t),o(n.items?.length||0),l(r.items?.length||0)}catch(e){console.error("Error loading bank stats:",e)}finally{u(!1)}}};return((0,M.useEffect)(()=>{if(e){d();let e=setInterval(d,5e3);return()=>clearInterval(e)}},[e]),c&&!r)?(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)(eo,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})}):r?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,D.jsx)(f4,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,D.jsx)(f8,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/20",children:(0,D.jsx)(V,{className:"w-5 h-5 text-blue-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Memories"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:r.total_nodes})]})]})})}),(0,D.jsx)(f4,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,D.jsx)(f8,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/20",children:(0,D.jsx)(wD,{className:"w-5 h-5 text-purple-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Links"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:r.total_links})]})]})})}),(0,D.jsx)(f4,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,D.jsx)(f8,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/20",children:(0,D.jsx)(wM,{className:"w-5 h-5 text-emerald-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Documents"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:r.total_documents})]})]})})}),(0,D.jsx)(f4,{className:`bg-gradient-to-br ${r.pending_operations>0?"from-amber-500/10 to-amber-600/5 border-amber-500/20":"from-slate-500/10 to-slate-600/5 border-slate-500/20"}`,children:(0,D.jsx)(f8,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:`p-2 rounded-lg ${r.pending_operations>0?"bg-amber-500/20":"bg-slate-500/20"}`,children:(0,D.jsx)(wP,{className:`w-5 h-5 ${r.pending_operations>0?"text-amber-500 animate-pulse":"text-slate-500"}`})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Pending"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:r.pending_operations})]})]})})})]}),(0,D.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,D.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-semibold uppercase tracking-wide",children:"World Facts"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:r.nodes_by_fact_type?.world||0})]}),(0,D.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-semibold uppercase tracking-wide",children:"Experience"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-purple-600 dark:text-purple-400 mt-1",children:r.nodes_by_fact_type?.experience||0})]}),(0,D.jsxs)("div",{className:`rounded-xl p-4 text-center ${n?"bg-amber-500/10 border border-amber-500/20":"bg-muted/50 border border-muted"}`,title:n?void 0:"Observations feature is not enabled",children:[(0,D.jsxs)("p",{className:`text-xs font-semibold uppercase tracking-wide ${n?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:["Observations",!n&&(0,D.jsx)("span",{className:"ml-1 normal-case",children:"(Off)"})]}),(0,D.jsx)("p",{className:`text-2xl font-bold mt-1 ${n?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:n?r.total_mental_models||0:"—"})]}),(0,D.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-semibold uppercase tracking-wide",children:"Mental Models"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-cyan-600 dark:text-cyan-400 mt-1",children:a})]}),(0,D.jsxs)("div",{className:"bg-rose-500/10 border border-rose-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-semibold uppercase tracking-wide",children:"Directives"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-rose-600 dark:text-rose-400 mt-1",children:s})]})]})]}):null}var tu=tu;function wL(){let{currentBank:e}=(0,I.useBank)(),[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(0),[a,o]=(0,M.useState)(null),[s]=(0,M.useState)(10),[l,c]=(0,M.useState)(0),[u,d]=(0,M.useState)(null),[h,f]=(0,M.useState)(!1),[p,g]=(0,M.useState)(null),[v,x]=(0,M.useState)(!1),[y,b]=(0,M.useState)(!1),w=async(t=a,r=l)=>{if(e){f(!0);try{let a=await K.client.listOperations(e,{status:t||void 0,limit:s,offset:r});n(a.operations||[]),i(a.total||0)}catch(e){console.error("Error loading operations:",e)}finally{f(!1)}}},N=e=>{c(e),w(a,e)},j=async t=>{if(e){d(t);try{await K.client.cancelOperation(e,t),await w()}catch(e){}finally{d(null)}}},k=async t=>{if(e){b(!0),x(!0);try{let n=await K.client.getOperationStatus(e,t);g(n)}catch(e){console.error("Error loading operation details:",e),g({error:"Failed to load operation details"})}finally{b(!1)}}};return((0,M.useEffect)(()=>{if(e){w();let e=setInterval(()=>w(),5e3);return()=>clearInterval(e)}},[e]),e)?(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-lg font-semibold",children:"Background Operations"}),(0,D.jsx)("button",{onClick:()=>w(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",disabled:h,children:(0,D.jsx)(ei,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${h?"animate-spin":""}`})})]}),(0,D.jsxs)("p",{className:"text-sm text-muted-foreground",children:[r," operation",1!==r?"s":"",a?` (${a})`:""]})]}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:[{value:null,label:"All"},{value:"pending",label:"Pending"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map(e=>(0,D.jsx)("button",{onClick:()=>{var t;o(t=e.value),c(0),w(t,0)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${a===e.value?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e.label},e.value??"all"))})]}),(0,D.jsx)("div",{children:t.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)(ec,{children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{children:[(0,D.jsx)(ef,{className:"w-[100px]",children:"ID"}),(0,D.jsx)(ef,{children:"Type"}),(0,D.jsx)(ef,{children:"Created"}),(0,D.jsx)(ef,{children:"Status"}),(0,D.jsx)(ef,{className:"w-[80px]"})]})}),(0,D.jsx)(ed,{children:t.map(e=>(0,D.jsxs)(eh,{className:`cursor-pointer hover:bg-muted/50 ${"failed"===e.status?"bg-red-500/5":""}`,onClick:()=>k(e.id),children:[(0,D.jsx)(ep,{className:"font-mono text-xs text-muted-foreground",children:e.id.substring(0,8)}),(0,D.jsx)(ep,{className:"font-medium",children:e.task_type}),(0,D.jsx)(ep,{className:"text-sm text-muted-foreground",children:new Date(e.created_at).toLocaleString()}),(0,D.jsxs)(ep,{children:["pending"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),"pending"]}),"failed"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",title:e.error_message??void 0,children:[(0,D.jsx)(wC,{className:"w-3 h-3"}),"failed"]}),"completed"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,D.jsx)(ea,{className:"w-3 h-3"}),"completed"]})]}),(0,D.jsx)(ep,{children:"pending"===e.status&&(0,D.jsxs)(Z.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:t=>{t.stopPropagation(),j(e.id)},disabled:u===e.id,children:[u===e.id?(0,D.jsx)(tu.default,{className:"w-3 h-3 animate-spin"}):(0,D.jsx)(tc.X,{className:"w-3 h-3 mr-1"}),u===e.id?"":"Cancel"]})})]},e.id))})]})}),r>s&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,D.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",l+1,"-",Math.min(l+s,r)," of"," ",r]}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>N(Math.max(0,l-s)),disabled:0===l,children:"Previous"}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>N(l+s),disabled:l+s>=r,children:"Next"})]})]})]}):(0,D.jsxs)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:["No ",a?`${a} `:"","operations"]})}),(0,D.jsx)(td.Dialog,{open:v,onOpenChange:x,children:(0,D.jsxs)(td.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Operation Details"}),(0,D.jsx)(td.DialogDescription,{children:p?.operation_id&&(0,D.jsx)("span",{className:"font-mono text-xs",children:p.operation_id})})]}),y?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)(tu.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):p?(0,D.jsx)("div",{className:"space-y-4",children:p.error?(0,D.jsx)("div",{className:"text-red-600 dark:text-red-400",children:p.error}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),(0,D.jsxs)("div",{className:"mt-1",children:["pending"===p.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),"pending"]}),"failed"===p.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,D.jsx)(wC,{className:"w-3 h-3"}),"failed"]}),"completed"===p.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,D.jsx)(ea,{className:"w-3 h-3"}),"completed"]})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Type"}),(0,D.jsx)("div",{className:"mt-1 font-mono text-sm",children:p.operation_type})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Created"}),(0,D.jsx)("div",{className:"mt-1 text-sm",children:p.created_at?new Date(p.created_at).toLocaleString():"N/A"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Updated"}),(0,D.jsx)("div",{className:"mt-1 text-sm",children:p.updated_at?new Date(p.updated_at).toLocaleString():"N/A"})]}),p.completed_at&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Completed"}),(0,D.jsx)("div",{className:"mt-1 text-sm",children:new Date(p.completed_at).toLocaleString()})]}),p.result_metadata?.items_count!==void 0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Total Items"}),(0,D.jsx)("div",{className:"mt-1 text-sm",children:p.result_metadata.items_count})]})]}),p.error_message&&(0,D.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,D.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:"Error"}),(0,D.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:p.error_message})]}),p.child_operations&&p.child_operations.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Sub-batches (",p.result_metadata?.num_sub_batches||p.child_operations.length,")"]}),(0,D.jsx)("div",{className:"rounded-lg border",children:(0,D.jsxs)(ec,{children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{children:[(0,D.jsx)(ef,{className:"w-[60px]",children:"Index"}),(0,D.jsx)(ef,{className:"w-[100px]",children:"ID"}),(0,D.jsx)(ef,{className:"w-[80px]",children:"Items"}),(0,D.jsx)(ef,{children:"Status"})]})}),(0,D.jsx)(ed,{children:p.child_operations.map(e=>(0,D.jsxs)(eh,{children:[(0,D.jsx)(ep,{className:"text-sm",children:e.sub_batch_index}),(0,D.jsx)(ep,{className:"font-mono text-xs text-muted-foreground",children:e.operation_id.substring(0,8)}),(0,D.jsx)(ep,{className:"text-sm",children:e.items_count}),(0,D.jsxs)(ep,{children:["pending"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:[(0,D.jsx)(eo,{className:"w-3 h-3"}),"pending"]}),"failed"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400",title:e.error_message??void 0,children:[(0,D.jsx)(wC,{className:"w-3 h-3"}),"failed"]}),"completed"===e.status&&(0,D.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:[(0,D.jsx)(ea,{className:"w-3 h-3"}),"completed"]})]})]},e.operation_id))})]})})]})]})}):null]})})]}):null}var tu=tu;let wI=(0,F.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);var tu=tu;function wO({directiveId:e,onClose:t}){let n,{currentBank:r}=(0,I.useBank)(),[i,a]=(0,M.useState)(null),[o,s]=(0,M.useState)(!1),[l,c]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&r&&(async()=>{s(!0),c(null),a(null);try{let t=await K.client.getDirective(r,e);a(t)}catch(e){console.error("Error loading directive:",e),c(e.message)}finally{s(!1)}})()},[e,r]);let u=null!==e;return(0,D.jsx)(td.Dialog,{open:u,onOpenChange:e=>!e&&t(),children:(0,D.jsxs)(td.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,D.jsx)(h2,{children:(0,D.jsx)(td.DialogTitle,{children:"Directive Details"})}),o?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)(tu.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):l?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)("div",{className:"text-center text-destructive",children:(0,D.jsxs)("div",{className:"text-sm",children:["Error: ",l]})})}):i?(0,D.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,D.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:i.name}),!i.is_active&&(0,D.jsx)("span",{className:"px-2 py-0.5 rounded-full bg-red-500/10 text-red-600 dark:text-red-400 text-xs font-medium",children:"Inactive"})]}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:i.id})]}),(0,D.jsxs)("div",{className:"flex gap-8",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:(n=new Date(i.created_at),`${n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Priority"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:i.priority})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:i.content})})]}),i.tags&&i.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:i.tags.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:e},t))})]})]}):null]})})}function wB(){let{currentBank:e}=(0,I.useBank)(),[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)("dashboard"),[s,l]=(0,M.useState)(""),[c,u]=(0,M.useState)(1),[d,h]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),[g,v]=(0,M.useState)(!1),[x,y]=(0,M.useState)(null),[b,w]=(0,M.useState)(null),[N,j]=(0,M.useState)(!1),k=t.filter(e=>{if(!s)return!0;let t=s.toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.source_query.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),C=async()=>{if(e){i(!0);try{let t=await K.client.listMentalModels(e);n(t.items||[])}catch(e){console.error("Error loading mental models:",e)}finally{i(!1)}}},E=async()=>{if(e&&b){j(!0);try{await K.client.deleteMentalModel(e,b.id),n(e=>e.filter(e=>e.id!==b.id)),f?.id===b.id&&p(null),w(null)}catch(e){}finally{j(!1)}}};if((0,M.useEffect)(()=>{e&&C()},[e]),(0,M.useEffect)(()=>{let e=e=>{"Escape"===e.key&&p(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,M.useEffect)(()=>{u(1)},[s]),!e)return(0,D.jsx)(f4,{children:(0,D.jsx)(f8,{className:"p-10 text-center",children:(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to view mental models."})})});let T=Math.ceil(k.length/100),S=(c-1)*100,_=S+100,A=k.slice(S,_);return(0,D.jsxs)("div",{children:[r?(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(ei,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"mb-4",children:(0,D.jsx)(Q.Input,{type:"text",value:s,onChange:e=>l(e.target.value),placeholder:"Filter mental models by name, query, or content...",className:"max-w-md"})}),(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:s?`${k.length} of ${t.length} mental models`:`${t.length} mental model${1!==t.length?"s":""}`}),(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsxs)(Z.Button,{onClick:()=>h(!0),size:"sm",children:[(0,D.jsx)(y0.Plus,{className:"w-4 h-4 mr-2"}),"Add Mental Model"]}),(0,D.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,D.jsxs)("button",{onClick:()=>o("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,D.jsx)(wI,{className:"w-4 h-4"}),"Dashboard"]}),(0,D.jsxs)("button",{onClick:()=>o("table"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"table"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,D.jsx)(el,{className:"w-4 h-4"}),"Table"]})]})]})]}),k.length>0?(0,D.jsxs)(D.Fragment,{children:["dashboard"===a&&(0,D.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:A.map(e=>{let t=new Date(e.last_refreshed_at),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,D.jsx)(f4,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${f?.id===e.id?"border-primary shadow-md":""}`,onClick:()=>p(e),children:(0,D.jsxs)(f8,{className:"p-4",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:e.name}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:e.id}),(0,D.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${e.trigger?.refresh_after_consolidation?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-slate-500/10 text-slate-600 dark:text-slate-400"}`,children:e.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]})]}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 ml-2 text-muted-foreground hover:text-destructive flex-shrink-0",onClick:t=>{t.stopPropagation(),w({id:e.id,name:e.name})},children:(0,D.jsx)(hH,{className:"h-4 w-4"})})]}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:e.source_query}),(0,D.jsx)("div",{className:"text-sm text-foreground mb-3 border-t border-border pt-3",children:e.content.includes("|")||e.content.includes("```")||e.content.includes("\n\n")?(0,D.jsxs)("div",{className:"line-clamp-3 text-muted-foreground italic",children:[e.content.substring(0,150),"..."," ",(0,D.jsx)("span",{className:"text-primary",children:"Click to view full content"})]}):(0,D.jsx)("div",{className:"line-clamp-6 prose prose-sm dark:prose-invert max-w-none",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:e.content})})}),(0,D.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,D.jsx)("div",{className:"flex items-center gap-2",children:e.tags.length>0&&(0,D.jsxs)("div",{className:"flex gap-1",children:[e.tags.slice(0,2).map(e=>(0,D.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e)),e.tags.length>2&&(0,D.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",e.tags.length-2]})]})}),(0,D.jsxs)("div",{className:"text-muted-foreground",children:[n," ",r]})]})]})},e.id)})}),"table"===a&&(0,D.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,D.jsxs)(ec,{className:"table-fixed",children:[(0,D.jsx)(eu,{children:(0,D.jsxs)(eh,{className:"bg-muted/50",children:[(0,D.jsx)(ef,{className:"w-[20%]",children:"ID"}),(0,D.jsx)(ef,{className:"w-[20%]",children:"Name"}),(0,D.jsx)(ef,{className:"w-[35%]",children:"Source Query"}),(0,D.jsx)(ef,{className:"w-[15%]",children:"Last Refreshed"}),(0,D.jsx)(ef,{className:"w-[10%]"})]})}),(0,D.jsx)(ed,{children:A.map(e=>{let t=new Date(e.last_refreshed_at),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,D.jsxs)(eh,{className:`cursor-pointer hover:bg-muted/50 ${f?.id===e.id?"bg-primary/10":""}`,onClick:()=>p(e),children:[(0,D.jsx)(ep,{className:"py-2",children:(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate block",children:e.id})}),(0,D.jsx)(ep,{className:"py-2",children:(0,D.jsx)("div",{className:"font-medium text-foreground",children:e.name})}),(0,D.jsx)(ep,{className:"py-2",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground truncate",children:e.source_query})}),(0,D.jsxs)(ep,{className:"py-2 text-sm text-foreground",children:[(0,D.jsx)("div",{children:n}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:r})]}),(0,D.jsx)(ep,{className:"py-2",children:(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:t=>{t.stopPropagation(),w({id:e.id,name:e.name})},children:(0,D.jsx)(hH,{className:"h-4 w-4"})})})]},e.id)})})]})}),T>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[S+1,"-",Math.min(_,k.length)," of"," ",k.length]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>u(1),disabled:1===c,className:"h-7 w-7 p-0",children:(0,D.jsx)(en,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>u(e=>Math.max(1,e-1)),disabled:1===c,className:"h-7 w-7 p-0",children:(0,D.jsx)(G,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[c," / ",T]}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>u(e=>Math.min(T,e+1)),disabled:c===T,className:"h-7 w-7 p-0",children:(0,D.jsx)(Y,{className:"h-3 w-3"})}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",onClick:()=>u(T),disabled:c===T,className:"h-7 w-7 p-0",children:(0,D.jsx)(er,{className:"h-3 w-3"})})]})]})]}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,D.jsx)(z,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:s?"No mental models match your filter":"No mental models yet. Create a mental model to generate and save a summary from your memories."})]})]}),(0,D.jsx)(wF,{open:d,onClose:()=>h(!1),onCreated:()=>{h(!1),C()}}),(0,D.jsx)(hx,{open:!!b,onOpenChange:e=>!e&&w(null),children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Delete Mental Model"}),(0,D.jsxs)(hF,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',b?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hO,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hV,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hz,{onClick:E,disabled:N,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[N?(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),f&&(0,D.jsx)(wV,{mentalModel:f,onClose:()=>p(null),onDelete:()=>w({id:f.id,name:f.name}),onEdit:()=>{y(f),v(!0)},onRefreshed:e=>{n(t=>t.map(t=>t.id===e.id?e:t)),p(e)}}),x&&(0,D.jsx)(wz,{open:g,mentalModel:x,onClose:()=>{v(!1),y(null)},onUpdated:e=>{n(t=>t.map(t=>t.id===e.id?e:t)),p(e),v(!1),y(null)}})]})}function wF({open:e,onClose:t,onCreated:n}){let{currentBank:r}=(0,I.useBank)(),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),l=async()=>{if(r&&o.name.trim()&&o.sourceQuery.trim()){a(!0);try{let e=o.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=parseInt(o.maxTokens)||2048;await K.client.createMentalModel(r,{id:o.id.trim()||void 0,name:o.name.trim(),source_query:o.sourceQuery.trim(),tags:e.length>0?e:void 0,max_tokens:t,trigger:{refresh_after_consolidation:o.autoRefresh}}),s({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),n()}catch(e){}finally{a(!1)}}};return(0,D.jsx)(td.Dialog,{open:e,onOpenChange:e=>{e||(s({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),t())},children:(0,D.jsxs)(td.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Create Mental Model"}),(0,D.jsx)(td.DialogDescription,{children:"Create a mental model by running a query. The content will be auto-generated and can be refreshed later."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["ID ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(Q.Input,{value:o.id,onChange:e=>s({...o,id:e.target.value}),placeholder:"e.g., team-communication"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"Custom ID for the mental model. If not provided, a UUID will be generated."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(Q.Input,{value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,D.jsx)(Q.Input,{value:o.sourceQuery,onChange:e=>s({...o,sourceQuery:e.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,D.jsx)(Q.Input,{type:"number",value:o.maxTokens,onChange:e=>s({...o,maxTokens:e.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(Q.Input,{value:o.tags,onChange:e=>s({...o,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,D.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,D.jsx)(f3.Checkbox,{id:"auto-refresh",checked:o.autoRefresh,onCheckedChange:e=>s({...o,autoRefresh:!0===e})}),(0,D.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),(0,D.jsx)(Z.Button,{onClick:l,disabled:i||!o.name.trim()||!o.sourceQuery.trim(),children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}),"Generating..."]}):"Create"})]})]})})}function wz({open:e,mentalModel:t,onClose:n,onUpdated:r}){let{currentBank:i}=(0,I.useBank)(),[a,o]=(0,M.useState)(!1),[s,l]=(0,M.useState)({name:t.name,sourceQuery:t.source_query,maxTokens:String(t.max_tokens||2048),tags:t.tags.join(", "),autoRefresh:t.trigger?.refresh_after_consolidation||!1});(0,M.useEffect)(()=>{e&&l({name:t.name,sourceQuery:t.source_query,maxTokens:String(t.max_tokens||2048),tags:t.tags.join(", "),autoRefresh:t.trigger?.refresh_after_consolidation||!1})},[e,t]);let c=async()=>{if(i&&s.name.trim()&&s.sourceQuery.trim()){o(!0);try{let e=s.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),a=parseInt(s.maxTokens)||2048,o=await K.client.updateMentalModel(i,t.id,{name:s.name.trim(),source_query:s.sourceQuery.trim(),tags:e.length>0?e:void 0,max_tokens:a,trigger:{refresh_after_consolidation:s.autoRefresh}});r(o),n()}catch(e){}finally{o(!1)}}};return(0,D.jsx)(td.Dialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,D.jsxs)(td.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(td.DialogHeader,{children:[(0,D.jsx)(td.DialogTitle,{children:"Update Mental Model"}),(0,D.jsx)(td.DialogDescription,{children:"Update the mental model configuration. Changes will take effect immediately."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)(Q.Input,{value:t.id,disabled:!0,className:"bg-muted"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"ID cannot be changed after creation."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(Q.Input,{value:s.name,onChange:e=>l({...s,name:e.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,D.jsx)(Q.Input,{value:s.sourceQuery,onChange:e=>l({...s,sourceQuery:e.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,D.jsx)(Q.Input,{type:"number",value:s.maxTokens,onChange:e=>l({...s,maxTokens:e.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(Q.Input,{value:s.tags,onChange:e=>l({...s,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,D.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,D.jsx)(f3.Checkbox,{id:"update-auto-refresh",checked:s.autoRefresh,onCheckedChange:e=>l({...s,autoRefresh:!0===e})}),(0,D.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,D.jsxs)(td.DialogFooter,{children:[(0,D.jsx)(Z.Button,{variant:"outline",onClick:n,disabled:a,children:"Cancel"}),(0,D.jsx)(Z.Button,{onClick:c,disabled:a||!s.name.trim()||!s.sourceQuery.trim(),children:a?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}),"Updating..."]}):"Update"})]})]})})}function wV({mentalModel:e,onClose:t,onDelete:n,onEdit:r,onRefreshed:i}){let{currentBank:a}=(0,I.useBank)(),[o,s]=(0,M.useState)(!1),[l,c]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),h=async()=>{if(!a)return;s(!0);let t=e.last_refreshed_at;try{await K.client.refreshMentalModel(a,e.id);let n=0,r=async()=>{n++;try{let o=await K.client.getMentalModel(a,e.id);if(o.last_refreshed_at!==t){i(o),s(!1);return}if(n>=120){s(!1),R.toast.error("Refresh timeout",{description:"Refresh is taking longer than expected. Check the operations list for status."});return}setTimeout(r,1e3)}catch(e){console.error("Error polling mental model:",e),s(!1)}};setTimeout(r,1e3)}catch(e){s(!1)}},f=e=>{let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`},p=e.reflect_response?.based_on?Object.entries(e.reflect_response.based_on).filter(([e])=>"observation"!==e).flatMap(([e,t])=>t.map(t=>({...t,factType:e}))):[],g=e.reflect_response?.based_on?.observation||[];return(0,D.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex-1 mr-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:r,className:"h-7 w-7 p-0",children:(0,D.jsx)(y1,{className:"h-3.5 w-3.5"})})]}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e.source_query})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsxs)(Z.Button,{variant:"outline",size:"sm",onClick:h,disabled:o,className:"h-8",children:[o?(0,D.jsx)(tu.default,{className:"w-4 h-4 animate-spin mr-1"}):(0,D.jsx)(ei,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(0,D.jsx)(Z.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(tc.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"ID"}),(0,D.jsx)("div",{className:"text-sm text-foreground font-mono",children:e.id})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Name"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:e.name})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Source Query"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:e.source_query})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Max Tokens"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:e.max_tokens})]}),e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Auto-refresh"}),(0,D.jsx)("span",{className:`inline-block text-xs px-2 py-1 rounded-full font-medium ${e.trigger?.refresh_after_consolidation?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-slate-500/10 text-slate-600 dark:text-slate-400"}`,children:e.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]}),e.last_refreshed_at&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Last Refreshed"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:f(e.last_refreshed_at)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:f(e.created_at)})]})]}),(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xp,{remarkPlugins:[yY],children:e.content})})]}),p.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Based On (",p.length," ",1===p.length?"fact":"facts",")"]}),(0,D.jsx)("div",{className:"space-y-3",children:p.map((e,t)=>{let n="directives"===e.factType?{label:"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===e.factType?{label:"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===e.factType?{label:"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===e.factType?{label:"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:e.factType,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"};return(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${n.color}`,children:n.label}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>{"directives"===e.factType?d(e.id):c(e.id)},children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t)})})]}),g.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Observations Used (",g.length,")"]}),(0,D.jsx)("div",{className:"space-y-3",children:g.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:"observation"}),(0,D.jsx)(Z.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>c(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t))})]}),!e.reflect_response&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Based On"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:'No source data available. Click "Refresh" to regenerate with source tracking.'})]}),(0,D.jsx)("div",{className:"pt-4 border-t border-border",children:(0,D.jsxs)(Z.Button,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive hover:border-destructive",children:[(0,D.jsx)(hH,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]}),l&&a&&(0,D.jsx)(tm,{memoryId:l,onClose:()=>c(null)}),u&&a&&(0,D.jsx)(wO,{directiveId:u,onClose:()=>d(null)})]})}var tu=tu;function wH(){(0,P.useParams)();let e=(0,P.useRouter)(),t=(0,P.useSearchParams)(),{features:n}=(0,O.useFeatures)(),{currentBank:r,setCurrentBank:i,loadBanks:a}=(0,I.useBank)(),o=t.get("view")||"profile",s=t.get("subTab")||"world",l=t.get("bankConfigTab")||"general",c=n?.observations??!1,u=n?.bank_config_api??!1,[d,h]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),[g,v]=(0,M.useState)(!1),[x,y]=(0,M.useState)(!1),[b,w]=(0,M.useState)(!1),N=t=>{e.push(`/banks/${r}?view=data&subTab=${t}`)},j=t=>{e.push(`/banks/${r}?view=profile&bankConfigTab=${t}`)},k=async()=>{if(r){p(!0);try{await K.client.deleteBank(r),h(!1),i(null),await a(),e.push("/")}catch(e){}finally{p(!1)}}},C=async()=>{if(r){y(!0);try{let e=await K.client.clearObservations(r);v(!1),R.toast.success("Success",{description:e.message||"Observations cleared successfully"})}catch(e){}finally{y(!1)}}},E=async()=>{if(r){w(!0);try{await K.client.triggerConsolidation(r)}catch(e){}finally{w(!1)}}};return(0,D.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,D.jsx)(L.BankSelector,{}),(0,D.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,D.jsx)($,{currentTab:o,onTabChange:t=>{e.push(`/banks/${r}?view=${t}`)}}),(0,D.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,D.jsxs)("div",{className:"p-6",children:["profile"===o&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Bank Configuration"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Manage bank settings, profile, and operations."})]}),(0,D.jsxs)(ws,{children:[(0,D.jsx)(wc,{asChild:!0,children:(0,D.jsxs)(Z.Button,{variant:"outline",size:"sm",children:["Actions",(0,D.jsx)(wT,{className:"w-4 h-4 ml-2"})]})}),(0,D.jsxs)(wN,{align:"end",className:"w-48",children:[(0,D.jsxs)(wj,{onClick:E,disabled:b||!c,title:c?void 0:"Observations feature is not enabled",children:[b?(0,D.jsx)(tu.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,D.jsx)(pt,{className:"w-4 h-4 mr-2"}),b?"Consolidating...":"Run Consolidation",!c&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsxs)(wj,{onClick:()=>v(!0),disabled:!c,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:c?void 0:"Observations feature is not enabled",children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Clear Observations",!c&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsx)(wk,{}),(0,D.jsxs)(wj,{onClick:()=>h(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})]})]})]}),(0,D.jsx)("div",{className:"mb-6 border-b border-border",children:(0,D.jsxs)("div",{className:"flex gap-1",children:[(0,D.jsxs)("button",{onClick:()=>j("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===l?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["General","general"===l&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>j("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===l?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Configuration","configuration"===l&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,D.jsxs)("div",{children:["general"===l&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview statistics and background operations for this memory bank."}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(wR,{}),(0,D.jsx)(wL,{})]})]}),"configuration"===l&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-6",children:"Configure disposition traits, mission, directives, and behavioral settings for this bank."}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(y5,{}),u&&(0,D.jsx)(w_,{})]})]})]})]}),"recall"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Recall"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Analyze memory recall with detailed trace information and retrieval methods."}),(0,D.jsx)(yZ,{})]}),"reflect"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Reflect"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Run an agentic loop that autonomously gathers evidence and reasons through the lens of the bank's disposition to generate contextual responses."}),(0,D.jsx)(y$,{})]}),"data"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Memories"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and explore different types of memories stored in this memory bank."}),(0,D.jsx)("div",{className:"mb-6 border-b border-border",children:(0,D.jsxs)("div",{className:"flex gap-1",children:[(0,D.jsxs)("button",{onClick:()=>N("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===s?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["World Facts","world"===s&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>N("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===s?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Experience","experience"===s&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>N("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===s?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Observations",!c&&(0,D.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===s&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>N("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===s?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Mental Models","mental-models"===s&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,D.jsxs)("div",{children:["world"===s&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Objective facts about the world received from external sources."}),(0,D.jsx)(hu,{factType:"world"},"world")]}),"experience"===s&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"The bank's own actions, interactions, and first-person experiences."}),(0,D.jsx)(hu,{factType:"experience"},"experience")]}),"observations"===s&&(c?(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Consolidated knowledge synthesized from facts — patterns, preferences, and learnings that emerge from accumulated evidence."}),(0,D.jsx)(hu,{factType:"observation"},"observations")]}):(0,D.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,D.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Z"}),(0,D.jsx)("path",{d:"M12 8v4"}),(0,D.jsx)("path",{d:"M12 16h.01"})]})}),(0,D.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"Observations Not Enabled"}),(0,D.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md",children:["Observations consolidation is disabled on this server. Set"," ",(0,D.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})," ","to enable."]})]})),"mental-models"===s&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"User-curated summaries generated from queries — reusable knowledge snapshots that can be refreshed as memories evolve."}),(0,D.jsx)(wB,{},"mental-models")]})]})]}),"documents"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Documents"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Manage documents and retain new memories."}),(0,D.jsx)(hU,{})]}),"entities"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Entities"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Explore entities (people, organizations, places) mentioned in memories."}),(0,D.jsx)(hG,{})]})]})})]}),(0,D.jsx)(hx,{open:d,onOpenChange:h,children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Delete Memory Bank"}),(0,D.jsx)(hF,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:r}),"?"]}),(0,D.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."})]})})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{disabled:f,children:"Cancel"}),(0,D.jsx)(hz,{onClick:k,disabled:f,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:f?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,D.jsx)(hx,{open:g,onOpenChange:v,children:(0,D.jsxs)(hL,{children:[(0,D.jsxs)(hI,{children:[(0,D.jsx)(hB,{children:"Clear Observations"}),(0,D.jsx)(hF,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:r}),"?"]}),(0,D.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."})]})})]}),(0,D.jsxs)(hO,{children:[(0,D.jsx)(hV,{disabled:x,children:"Cancel"}),(0,D.jsx)(hz,{onClick:C,disabled:x,className:"bg-amber-500 text-white hover:bg-amber-600",children:x?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(tu.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hH,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})})]})}e.s(["default",()=>wH],37578)}]);