@pickaxeproject/react 6.23.0 → 6.23.2

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 (31) hide show
  1. package/dist/cjs/common/responseArtifactSnapshot.js +1 -1
  2. package/dist/cjs/common/responseArtifactWordImages.js +1 -1
  3. package/dist/cjs/common/responseDownloadDocx.js +1 -1
  4. package/dist/cjs/common/responseDownloadHtml.js +1 -1
  5. package/dist/cjs/common/responseDownloadImages.js +1 -0
  6. package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  7. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  8. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  9. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  10. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  11. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  12. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  13. package/dist/cjs/src/common/responseDownloadDocx.d.ts +2 -2
  14. package/dist/cjs/src/common/responseDownloadImages.d.ts +3 -0
  15. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +7 -0
  16. package/dist/esm/common/responseArtifactSnapshot.js +1 -1
  17. package/dist/esm/common/responseArtifactWordImages.js +1 -1
  18. package/dist/esm/common/responseDownloadDocx.js +1 -1
  19. package/dist/esm/common/responseDownloadHtml.js +1 -1
  20. package/dist/esm/common/responseDownloadImages.js +1 -0
  21. package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  22. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  23. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  24. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  25. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  26. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  27. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  28. package/dist/esm/src/common/responseDownloadDocx.d.ts +2 -2
  29. package/dist/esm/src/common/responseDownloadImages.d.ts +3 -0
  30. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +7 -0
  31. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),i=require("../../../../../_virtual/layout-base2.js");i.__module.exports,exports.__require=function(){return t||(t=1,r=i.__module,i.__module.exports,e.commonjsGlobal,n=function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=28)}([function(t,e,i){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,t.exports=r},function(t,e,i){var r=i(2),n=i(8),o=i(9);function s(t,e,i){r.call(this,i),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=i,this.bendpoints=[],this.source=t,this.target=e}for(var h in s.prototype=Object.create(r.prototype),r)s[h]=r[h];s.prototype.getSource=function(){return this.source},s.prototype.getTarget=function(){return this.target},s.prototype.isInterGraph=function(){return this.isInterGraph},s.prototype.getLength=function(){return this.length},s.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},s.prototype.getBendpoints=function(){return this.bendpoints},s.prototype.getLca=function(){return this.lca},s.prototype.getSourceInLca=function(){return this.sourceInLca},s.prototype.getTargetInLca=function(){return this.targetInLca},s.prototype.getOtherEnd=function(t){if(this.source===t)return this.target;if(this.target===t)return this.source;throw"Node is not incident with this edge"},s.prototype.getOtherEndInGraph=function(t,e){for(var i=this.getOtherEnd(t),r=e.getGraphManager().getRoot();;){if(i.getOwner()==e)return i;if(i.getOwner()==r)break;i=i.getOwner().getParent()}return null},s.prototype.updateLength=function(){var t=new Array(4);this.isOverlapingSourceAndTarget=n.getIntersection(this.target.getRect(),this.source.getRect(),t),this.isOverlapingSourceAndTarget||(this.lengthX=t[0]-t[2],this.lengthY=t[1]-t[3],Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},s.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},t.exports=s},function(t,e,i){t.exports=function(t){this.vGraphObject=t}},function(t,e,i){var r=i(2),n=i(10),o=i(13),s=i(0),h=i(16),a=i(5);function l(t,e,i,s){null==i&&null==s&&(s=e),r.call(this,s),null!=t.graphManager&&(t=t.graphManager),this.estimatedSize=n.MIN_VALUE,this.inclusionTreeDepth=n.MAX_VALUE,this.vGraphObject=s,this.edges=[],this.graphManager=t,this.rect=null!=i&&null!=e?new o(e.x,e.y,i.width,i.height):new o}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(t){this.rect.width=t},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(t){this.rect.height=t},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new a(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new a(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(t,e){this.rect.x=t.x,this.rect.y=t.y,this.rect.width=e.width,this.rect.height=e.height},l.prototype.setCenter=function(t,e){this.rect.x=t-this.rect.width/2,this.rect.y=e-this.rect.height/2},l.prototype.setLocation=function(t,e){this.rect.x=t,this.rect.y=e},l.prototype.moveBy=function(t,e){this.rect.x+=t,this.rect.y+=e},l.prototype.getEdgeListToNode=function(t){var e=[],i=this;return i.edges.forEach((function(r){if(r.target==t){if(r.source!=i)throw"Incorrect edge source!";e.push(r)}})),e},l.prototype.getEdgesBetween=function(t){var e=[],i=this;return i.edges.forEach((function(r){if(r.source!=i&&r.target!=i)throw"Incorrect edge source and/or target";r.target!=t&&r.source!=t||e.push(r)})),e},l.prototype.getNeighborsList=function(){var t=new Set,e=this;return e.edges.forEach((function(i){if(i.source==e)t.add(i.target);else{if(i.target!=e)throw"Incorrect incidency!";t.add(i.source)}})),t},l.prototype.withChildren=function(){var t=new Set;if(t.add(this),null!=this.child)for(var e=this.child.getNodes(),i=0;i<e.length;i++)e[i].withChildren().forEach((function(e){t.add(e)}));return t},l.prototype.getNoOfChildren=function(){var t=0;if(null==this.child)t=1;else for(var e=this.child.getNodes(),i=0;i<e.length;i++)t+=e[i].getNoOfChildren();return 0==t&&(t=1),t},l.prototype.getEstimatedSize=function(){if(this.estimatedSize==n.MIN_VALUE)throw"assert failed";return this.estimatedSize},l.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)},l.prototype.scatter=function(){var t,e,i=-s.INITIAL_WORLD_BOUNDARY,r=s.INITIAL_WORLD_BOUNDARY;t=s.WORLD_CENTER_X+h.nextDouble()*(r-i)+i;var n=-s.INITIAL_WORLD_BOUNDARY,o=s.INITIAL_WORLD_BOUNDARY;e=s.WORLD_CENTER_Y+h.nextDouble()*(o-n)+n,this.rect.x=t,this.rect.y=e},l.prototype.updateBounds=function(){if(null==this.getChild())throw"assert failed";if(0!=this.getChild().getNodes().length){var t=this.getChild();if(t.updateBounds(!0),this.rect.x=t.getLeft(),this.rect.y=t.getTop(),this.setWidth(t.getRight()-t.getLeft()),this.setHeight(t.getBottom()-t.getTop()),s.NODE_DIMENSIONS_INCLUDE_LABELS){var e=t.getRight()-t.getLeft(),i=t.getBottom()-t.getTop();this.labelWidth&&("left"==this.labelPosHorizontal?(this.rect.x-=this.labelWidth,this.setWidth(e+this.labelWidth)):"center"==this.labelPosHorizontal&&this.labelWidth>e?(this.rect.x-=(this.labelWidth-e)/2,this.setWidth(this.labelWidth)):"right"==this.labelPosHorizontal&&this.setWidth(e+this.labelWidth)),this.labelHeight&&("top"==this.labelPosVertical?(this.rect.y-=this.labelHeight,this.setHeight(i+this.labelHeight)):"center"==this.labelPosVertical&&this.labelHeight>i?(this.rect.y-=(this.labelHeight-i)/2,this.setHeight(this.labelHeight)):"bottom"==this.labelPosVertical&&this.setHeight(i+this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==n.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},l.prototype.transform=function(t){var e=this.rect.x;e>s.WORLD_BOUNDARY?e=s.WORLD_BOUNDARY:e<-s.WORLD_BOUNDARY&&(e=-s.WORLD_BOUNDARY);var i=this.rect.y;i>s.WORLD_BOUNDARY?i=s.WORLD_BOUNDARY:i<-s.WORLD_BOUNDARY&&(i=-s.WORLD_BOUNDARY);var r=new a(e,i),n=t.inverseTransformPoint(r);this.setLocation(n.x,n.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},t.exports=l},function(t,e,i){var r=i(0);function n(){}for(var o in r)n[o]=r[o];n.MAX_ITERATIONS=2500,n.DEFAULT_EDGE_LENGTH=50,n.DEFAULT_SPRING_STRENGTH=.45,n.DEFAULT_REPULSION_STRENGTH=4500,n.DEFAULT_GRAVITY_STRENGTH=.4,n.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,n.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,n.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,n.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,n.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,n.COOLING_ADAPTATION_FACTOR=.33,n.ADAPTATION_LOWER_NODE_LIMIT=1e3,n.ADAPTATION_UPPER_NODE_LIMIT=5e3,n.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,n.MAX_NODE_DISPLACEMENT=3*n.MAX_NODE_DISPLACEMENT_INCREMENTAL,n.MIN_REPULSION_DIST=n.DEFAULT_EDGE_LENGTH/10,n.CONVERGENCE_CHECK_PERIOD=100,n.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,n.MIN_EDGE_LENGTH=1,n.GRID_CALCULATION_CHECK_PERIOD=10,t.exports=n},function(t,e,i){function r(t,e){null==t&&null==e?(this.x=0,this.y=0):(this.x=t,this.y=e)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(t){this.x=t},r.prototype.setY=function(t){this.y=t},r.prototype.getDifference=function(t){return new DimensionD(this.x-t.x,this.y-t.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(t){return this.x+=t.width,this.y+=t.height,this},t.exports=r},function(t,e,i){var r=i(2),n=i(10),o=i(0),s=i(7),h=i(3),a=i(1),l=i(13),u=i(12),g=i(11);function c(t,e,i){r.call(this,i),this.estimatedSize=n.MIN_VALUE,this.margin=o.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=t,null!=e&&e instanceof s?this.graphManager=e:null!=e&&e instanceof Layout&&(this.graphManager=e.graphManager)}for(var p in c.prototype=Object.create(r.prototype),r)c[p]=r[p];c.prototype.getNodes=function(){return this.nodes},c.prototype.getEdges=function(){return this.edges},c.prototype.getGraphManager=function(){return this.graphManager},c.prototype.getParent=function(){return this.parent},c.prototype.getLeft=function(){return this.left},c.prototype.getRight=function(){return this.right},c.prototype.getTop=function(){return this.top},c.prototype.getBottom=function(){return this.bottom},c.prototype.isConnected=function(){return this.isConnected},c.prototype.add=function(t,e,i){if(null==e&&null==i){var r=t;if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(r)>-1)throw"Node already in graph!";return r.owner=this,this.getNodes().push(r),r}var n=t;if(!(this.getNodes().indexOf(e)>-1&&this.getNodes().indexOf(i)>-1))throw"Source or target not in graph!";if(e.owner!=i.owner||e.owner!=this)throw"Both owners must be this graph!";return e.owner!=i.owner?null:(n.source=e,n.target=i,n.isInterGraph=!1,this.getEdges().push(n),e.edges.push(n),i!=e&&i.edges.push(n),n)},c.prototype.remove=function(t){var e=t;if(t instanceof h){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 i=e.edges.slice(),r=i.length,n=0;n<r;n++)(o=i[n]).isInterGraph?this.graphManager.remove(o):o.source.owner.remove(o);if(-1==(s=this.nodes.indexOf(e)))throw"Node not in owner node list!";this.nodes.splice(s,1)}else if(t instanceof a){var o;if(null==(o=t))throw"Edge is null!";if(null==o.source||null==o.target)throw"Source and/or target is null!";if(null==o.source.owner||null==o.target.owner||o.source.owner!=this||o.target.owner!=this)throw"Source and/or target owner is invalid!";var s,l=o.source.edges.indexOf(o),u=o.target.edges.indexOf(o);if(!(l>-1&&u>-1))throw"Source and/or target doesn't know this edge!";if(o.source.edges.splice(l,1),o.target!=o.source&&o.target.edges.splice(u,1),-1==(s=o.source.owner.getEdges().indexOf(o)))throw"Not in owner's edge list!";o.source.owner.getEdges().splice(s,1)}},c.prototype.updateLeftTop=function(){for(var t,e,i,r=n.MAX_VALUE,o=n.MAX_VALUE,s=this.getNodes(),h=s.length,a=0;a<h;a++){var l=s[a];r>(t=l.getTop())&&(r=t),o>(e=l.getLeft())&&(o=e)}return r==n.MAX_VALUE?null:(i=null!=s[0].getParent().paddingLeft?s[0].getParent().paddingLeft:this.margin,this.left=o-i,this.top=r-i,new u(this.left,this.top))},c.prototype.updateBounds=function(t){for(var e,i,r,o,s,h=n.MAX_VALUE,a=-n.MAX_VALUE,u=n.MAX_VALUE,g=-n.MAX_VALUE,c=this.nodes,p=c.length,f=0;f<p;f++){var d=c[f];t&&null!=d.child&&d.updateBounds(),h>(e=d.getLeft())&&(h=e),a<(i=d.getRight())&&(a=i),u>(r=d.getTop())&&(u=r),g<(o=d.getBottom())&&(g=o)}var y=new l(h,u,a-h,g-u);h==n.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),s=null!=c[0].getParent().paddingLeft?c[0].getParent().paddingLeft:this.margin,this.left=y.x-s,this.right=y.x+y.width+s,this.top=y.y-s,this.bottom=y.y+y.height+s},c.calculateBounds=function(t){for(var e,i,r,o,s=n.MAX_VALUE,h=-n.MAX_VALUE,a=n.MAX_VALUE,u=-n.MAX_VALUE,g=t.length,c=0;c<g;c++){var p=t[c];s>(e=p.getLeft())&&(s=e),h<(i=p.getRight())&&(h=i),a>(r=p.getTop())&&(a=r),u<(o=p.getBottom())&&(u=o)}return new l(s,a,h-s,u-a)},c.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},c.prototype.getEstimatedSize=function(){if(this.estimatedSize==n.MIN_VALUE)throw"assert failed";return this.estimatedSize},c.prototype.calcEstimatedSize=function(){for(var t=0,e=this.nodes,i=e.length,r=0;r<i;r++)t+=e[r].calcEstimatedSize();return this.estimatedSize=0==t?o.EMPTY_COMPOUND_NODE_SIZE:t/Math.sqrt(this.nodes.length),this.estimatedSize},c.prototype.updateConnected=function(){var t=this;if(0!=this.nodes.length){var e,i,r=new g,n=new Set,o=this.nodes[0];for(o.withChildren().forEach((function(t){r.push(t),n.add(t)}));0!==r.length;)for(var s=(e=(o=r.shift()).getEdges()).length,h=0;h<s;h++)null==(i=e[h].getOtherEndInGraph(o,this))||n.has(i)||i.withChildren().forEach((function(t){r.push(t),n.add(t)}));if(this.isConnected=!1,n.size>=this.nodes.length){var a=0;n.forEach((function(e){e.owner==t&&a++})),a==this.nodes.length&&(this.isConnected=!0)}}else this.isConnected=!0},t.exports=c},function(t,e,i){var r,n=i(1);function o(t){r=i(6),this.layout=t,this.graphs=[],this.edges=[]}o.prototype.addRoot=function(){var t=this.layout.newGraph(),e=this.layout.newNode(null),i=this.add(t,e);return this.setRootGraph(i),this.rootGraph},o.prototype.add=function(t,e,i,r,n){if(null==i&&null==r&&null==n){if(null==t)throw"Graph is null!";if(null==e)throw"Parent node is null!";if(this.graphs.indexOf(t)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(t),null!=t.parent)throw"Already has a parent!";if(null!=e.child)throw"Already has a child!";return t.parent=e,e.child=t,t}n=i,i=t;var o=(r=e).getOwner(),s=n.getOwner();if(null==o||o.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==s||s.getGraphManager()!=this)throw"Target not in this graph mgr!";if(o==s)return i.isInterGraph=!1,o.add(i,r,n);if(i.isInterGraph=!0,i.source=r,i.target=n,this.edges.indexOf(i)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(i),null==i.source||null==i.target)throw"Edge source and/or target is null!";if(-1!=i.source.edges.indexOf(i)||-1!=i.target.edges.indexOf(i))throw"Edge already in source and/or target incidency list!";return i.source.edges.push(i),i.target.edges.push(i),i},o.prototype.remove=function(t){if(t instanceof r){var e=t;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 i,o=[],s=(o=o.concat(e.getEdges())).length,h=0;h<s;h++)i=o[h],e.remove(i);var a,l=[];for(s=(l=l.concat(e.getNodes())).length,h=0;h<s;h++)a=l[h],e.remove(a);e==this.rootGraph&&this.setRootGraph(null);var u=this.graphs.indexOf(e);this.graphs.splice(u,1),e.parent=null}else if(t instanceof n){if(null==(i=t))throw"Edge is null!";if(!i.isInterGraph)throw"Not an inter-graph edge!";if(null==i.source||null==i.target)throw"Source and/or target is null!";if(-1==i.source.edges.indexOf(i)||-1==i.target.edges.indexOf(i))throw"Source and/or target doesn't know this edge!";if(u=i.source.edges.indexOf(i),i.source.edges.splice(u,1),u=i.target.edges.indexOf(i),i.target.edges.splice(u,1),null==i.source.owner||null==i.source.owner.getGraphManager())throw"Edge owner graph or owner graph manager is null!";if(-1==i.source.owner.getGraphManager().edges.indexOf(i))throw"Not in owner graph manager's edge list!";u=i.source.owner.getGraphManager().edges.indexOf(i),i.source.owner.getGraphManager().edges.splice(u,1)}},o.prototype.updateBounds=function(){this.rootGraph.updateBounds(!0)},o.prototype.getGraphs=function(){return this.graphs},o.prototype.getAllNodes=function(){if(null==this.allNodes){for(var t=[],e=this.getGraphs(),i=e.length,r=0;r<i;r++)t=t.concat(e[r].getNodes());this.allNodes=t}return this.allNodes},o.prototype.resetAllNodes=function(){this.allNodes=null},o.prototype.resetAllEdges=function(){this.allEdges=null},o.prototype.resetAllNodesToApplyGravitation=function(){this.allNodesToApplyGravitation=null},o.prototype.getAllEdges=function(){if(null==this.allEdges){var t=[],e=this.getGraphs();e.length;for(var i=0;i<e.length;i++)t=t.concat(e[i].getEdges());t=t.concat(this.edges),this.allEdges=t}return this.allEdges},o.prototype.getAllNodesToApplyGravitation=function(){return this.allNodesToApplyGravitation},o.prototype.setAllNodesToApplyGravitation=function(t){if(null!=this.allNodesToApplyGravitation)throw"assert failed";this.allNodesToApplyGravitation=t},o.prototype.getRoot=function(){return this.rootGraph},o.prototype.setRootGraph=function(t){if(t.getGraphManager()!=this)throw"Root not in this graph mgr!";this.rootGraph=t,null==t.parent&&(t.parent=this.layout.newNode("Root node"))},o.prototype.getLayout=function(){return this.layout},o.prototype.isOneAncestorOfOther=function(t,e){if(null==t||null==e)throw"assert failed";if(t==e)return!0;for(var i,r=t.getOwner();null!=(i=r.getParent());){if(i==e)return!0;if(null==(r=i.getOwner()))break}for(r=e.getOwner();null!=(i=r.getParent());){if(i==t)return!0;if(null==(r=i.getOwner()))break}return!1},o.prototype.calcLowestCommonAncestors=function(){for(var t,e,i,r,n,o=this.getAllEdges(),s=o.length,h=0;h<s;h++)if(e=(t=o[h]).source,i=t.target,t.lca=null,t.sourceInLca=e,t.targetInLca=i,e!=i){for(r=e.getOwner();null==t.lca;){for(t.targetInLca=i,n=i.getOwner();null==t.lca;){if(n==r){t.lca=n;break}if(n==this.rootGraph)break;if(null!=t.lca)throw"assert failed";t.targetInLca=n.getParent(),n=t.targetInLca.getOwner()}if(r==this.rootGraph)break;null==t.lca&&(t.sourceInLca=r.getParent(),r=t.sourceInLca.getOwner())}if(null==t.lca)throw"assert failed"}else t.lca=e.getOwner()},o.prototype.calcLowestCommonAncestor=function(t,e){if(t==e)return t.getOwner();for(var i=t.getOwner();null!=i;){for(var r=e.getOwner();null!=r;){if(r==i)return r;r=r.getParent().getOwner()}i=i.getParent().getOwner()}return i},o.prototype.calcInclusionTreeDepths=function(t,e){var i;null==t&&null==e&&(t=this.rootGraph,e=1);for(var r=t.getNodes(),n=r.length,o=0;o<n;o++)(i=r[o]).inclusionTreeDepth=e,null!=i.child&&this.calcInclusionTreeDepths(i.child,e+1)},o.prototype.includesInvalidEdge=function(){for(var t,e=[],i=this.edges.length,r=0;r<i;r++)t=this.edges[r],this.isOneAncestorOfOther(t.source,t.target)&&e.push(t);for(r=0;r<e.length;r++)this.remove(e[r]);return!1},t.exports=o},function(t,e,i){var r=i(12);function n(){}n.calcSeparationAmount=function(t,e,i,r){if(!t.intersects(e))throw"assert failed";var n=new Array(2);this.decideDirectionsForOverlappingNodes(t,e,n),i[0]=Math.min(t.getRight(),e.getRight())-Math.max(t.x,e.x),i[1]=Math.min(t.getBottom(),e.getBottom())-Math.max(t.y,e.y),t.getX()<=e.getX()&&t.getRight()>=e.getRight()?i[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight()):e.getX()<=t.getX()&&e.getRight()>=t.getRight()&&(i[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight())),t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()?i[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()):e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()&&(i[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()));var o=Math.abs((e.getCenterY()-t.getCenterY())/(e.getCenterX()-t.getCenterX()));e.getCenterY()===t.getCenterY()&&e.getCenterX()===t.getCenterX()&&(o=1);var s=o*i[0],h=i[1]/o;i[0]<h?h=i[0]:s=i[1],i[0]=-1*n[0]*(h/2+r),i[1]=-1*n[1]*(s/2+r)},n.decideDirectionsForOverlappingNodes=function(t,e,i){t.getCenterX()<e.getCenterX()?i[0]=-1:i[0]=1,t.getCenterY()<e.getCenterY()?i[1]=-1:i[1]=1},n.getIntersection2=function(t,e,i){var r=t.getCenterX(),n=t.getCenterY(),o=e.getCenterX(),s=e.getCenterY();if(t.intersects(e))return i[0]=r,i[1]=n,i[2]=o,i[3]=s,!0;var h=t.getX(),a=t.getY(),l=t.getRight(),u=t.getX(),g=t.getBottom(),c=t.getRight(),p=t.getWidthHalf(),f=t.getHeightHalf(),d=e.getX(),y=e.getY(),v=e.getRight(),E=e.getX(),A=e.getBottom(),_=e.getRight(),O=e.getWidthHalf(),m=e.getHeightHalf(),N=!1,L=!1;if(r===o){if(n>s)return i[0]=r,i[1]=a,i[2]=o,i[3]=A,!1;if(n<s)return i[0]=r,i[1]=g,i[2]=o,i[3]=y,!1}else if(n===s){if(r>o)return i[0]=h,i[1]=n,i[2]=v,i[3]=s,!1;if(r<o)return i[0]=l,i[1]=n,i[2]=d,i[3]=s,!1}else{var I=t.height/t.width,T=e.height/e.width,D=(s-n)/(o-r),M=void 0,w=void 0,R=void 0,x=void 0,C=void 0,G=void 0;if(-I===D?r>o?(i[0]=u,i[1]=g,N=!0):(i[0]=l,i[1]=a,N=!0):I===D&&(r>o?(i[0]=h,i[1]=a,N=!0):(i[0]=c,i[1]=g,N=!0)),-T===D?o>r?(i[2]=E,i[3]=A,L=!0):(i[2]=v,i[3]=y,L=!0):T===D&&(o>r?(i[2]=d,i[3]=y,L=!0):(i[2]=_,i[3]=A,L=!0)),N&&L)return!1;if(r>o?n>s?(M=this.getCardinalDirection(I,D,4),w=this.getCardinalDirection(T,D,2)):(M=this.getCardinalDirection(-I,D,3),w=this.getCardinalDirection(-T,D,1)):n>s?(M=this.getCardinalDirection(-I,D,1),w=this.getCardinalDirection(-T,D,3)):(M=this.getCardinalDirection(I,D,2),w=this.getCardinalDirection(T,D,4)),!N)switch(M){case 1:x=a,R=r+-f/D,i[0]=R,i[1]=x;break;case 2:R=c,x=n+p*D,i[0]=R,i[1]=x;break;case 3:x=g,R=r+f/D,i[0]=R,i[1]=x;break;case 4:R=u,x=n+-p*D,i[0]=R,i[1]=x}if(!L)switch(w){case 1:G=y,C=o+-m/D,i[2]=C,i[3]=G;break;case 2:C=_,G=s+O*D,i[2]=C,i[3]=G;break;case 3:G=A,C=o+m/D,i[2]=C,i[3]=G;break;case 4:C=E,G=s+-O*D,i[2]=C,i[3]=G}}return!1},n.getCardinalDirection=function(t,e,i){return t>e?i:1+i%4},n.getIntersection=function(t,e,i,n){if(null==n)return this.getIntersection2(t,e,i);var o,s,h,a,l,u,g,c=t.x,p=t.y,f=e.x,d=e.y,y=i.x,v=i.y,E=n.x,A=n.y;return 0==(g=(o=d-p)*(a=y-E)-(s=A-v)*(h=c-f))?null:new r((h*(u=E*v-y*A)-a*(l=f*p-c*d))/g,(s*l-o*u)/g)},n.angleOfVector=function(t,e,i,r){var n=void 0;return t!==i?(n=Math.atan((r-e)/(i-t)),i<t?n+=Math.PI:r<e&&(n+=this.TWO_PI)):n=r<e?this.ONE_AND_HALF_PI:this.HALF_PI,n},n.doIntersect=function(t,e,i,r){var n=t.x,o=t.y,s=e.x,h=e.y,a=i.x,l=i.y,u=r.x,g=r.y,c=(s-n)*(g-l)-(u-a)*(h-o);if(0===c)return!1;var p=((g-l)*(u-n)+(a-u)*(g-o))/c,f=((o-h)*(u-n)+(s-n)*(g-o))/c;return 0<p&&p<1&&0<f&&f<1},n.findCircleLineIntersections=function(t,e,i,r,n,o,s){var h=(i-t)*(i-t)+(r-e)*(r-e),a=2*((t-n)*(i-t)+(e-o)*(r-e)),l=(t-n)*(t-n)+(e-o)*(e-o)-s*s;if(a*a-4*h*l>=0){var u=(-a+Math.sqrt(a*a-4*h*l))/(2*h),g=(-a-Math.sqrt(a*a-4*h*l))/(2*h);return u>=0&&u<=1?[u]:g>=0&&g<=1?[g]:null}return null},n.HALF_PI=.5*Math.PI,n.ONE_AND_HALF_PI=1.5*Math.PI,n.TWO_PI=2*Math.PI,n.THREE_PI=3*Math.PI,t.exports=n},function(t,e,i){function r(){}r.sign=function(t){return t>0?1:t<0?-1:0},r.floor=function(t){return t<0?Math.ceil(t):Math.floor(t)},r.ceil=function(t){return t<0?Math.floor(t):Math.ceil(t)},t.exports=r},function(t,e,i){function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=function(t){return{value:t,next:null,prev:null}},o=function(t,e,i,r){return null!==t?t.next=e:r.head=e,null!==i?i.prev=e:r.tail=e,e.prev=t,e.next=i,r.length++,e},s=function(t,e){var i=t.prev,r=t.next;return null!==i?i.next=r:e.head=r,null!==r?r.prev=i:e.tail=i,t.prev=t.next=null,e.length--,t},h=function(){function t(e){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.length=0,this.head=null,this.tail=null,null!=e&&e.forEach((function(t){return i.push(t)}))}return r(t,[{key:"size",value:function(){return this.length}},{key:"insertBefore",value:function(t,e){return o(e.prev,n(t),e,this)}},{key:"insertAfter",value:function(t,e){return o(e,n(t),e.next,this)}},{key:"insertNodeBefore",value:function(t,e){return o(e.prev,t,e,this)}},{key:"insertNodeAfter",value:function(t,e){return o(e,t,e.next,this)}},{key:"push",value:function(t){return o(this.tail,n(t),null,this)}},{key:"unshift",value:function(t){return o(null,n(t),this.head,this)}},{key:"remove",value:function(t){return s(t,this)}},{key:"pop",value:function(){return s(this.tail,this).value}},{key:"popNode",value:function(){return s(this.tail,this)}},{key:"shift",value:function(){return s(this.head,this).value}},{key:"shiftNode",value:function(){return s(this.head,this)}},{key:"get_object_at",value:function(t){if(t<=this.length()){for(var e=1,i=this.head;e<t;)i=i.next,e++;return i.value}}},{key:"set_object_at",value:function(t,e){if(t<=this.length()){for(var i=1,r=this.head;i<t;)r=r.next,i++;r.value=e}}}]),t}();t.exports=h},function(t,e,i){function r(t,e,i){this.x=null,this.y=null,null==t&&null==e&&null==i?(this.x=0,this.y=0):"number"==typeof t&&"number"==typeof e&&null==i?(this.x=t,this.y=e):"Point"==t.constructor.name&&null==e&&null==i&&(i=t,this.x=i.x,this.y=i.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(t,e,i){"Point"==t.constructor.name&&null==e&&null==i?(i=t,this.setLocation(i.x,i.y)):"number"==typeof t&&"number"==typeof e&&null==i&&(parseInt(t)==t&&parseInt(e)==e?this.move(t,e):(this.x=Math.floor(t+.5),this.y=Math.floor(e+.5)))},r.prototype.move=function(t,e){this.x=t,this.y=e},r.prototype.translate=function(t,e){this.x+=t,this.y+=e},r.prototype.equals=function(t){if("Point"==t.constructor.name){var e=t;return this.x==e.x&&this.y==e.y}return this==t},r.prototype.toString=function(){return(new r).constructor.name+"[x="+this.x+",y="+this.y+"]"},t.exports=r},function(t,e,i){function r(t,e,i,r){this.x=0,this.y=0,this.width=0,this.height=0,null!=t&&null!=e&&null!=i&&null!=r&&(this.x=t,this.y=e,this.width=i,this.height=r)}r.prototype.getX=function(){return this.x},r.prototype.setX=function(t){this.x=t},r.prototype.getY=function(){return this.y},r.prototype.setY=function(t){this.y=t},r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(t){this.width=t},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(t){this.height=t},r.prototype.getRight=function(){return this.x+this.width},r.prototype.getBottom=function(){return this.y+this.height},r.prototype.intersects=function(t){return!(this.getRight()<t.x||this.getBottom()<t.y||t.getRight()<this.x||t.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},t.exports=r},function(t,e,i){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function n(){}n.lastID=0,n.createID=function(t){return n.isPrimitive(t)?t:(null!=t.uniqueID||(t.uniqueID=n.getString(),n.lastID++),t.uniqueID)},n.getString=function(t){return null==t&&(t=n.lastID),"Object#"+t},n.isPrimitive=function(t){var e=void 0===t?"undefined":r(t);return null==t||"object"!=e&&"function"!=e},t.exports=n},function(t,e,i){function r(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var n=i(0),o=i(7),s=i(3),h=i(1),a=i(6),l=i(5),u=i(17),g=i(29);function c(t){g.call(this),this.layoutQuality=n.QUALITY,this.createBendsAsNeeded=n.DEFAULT_CREATE_BENDS_AS_NEEDED,this.incremental=n.DEFAULT_INCREMENTAL,this.animationOnLayout=n.DEFAULT_ANIMATION_ON_LAYOUT,this.animationDuringLayout=n.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=n.DEFAULT_ANIMATION_PERIOD,this.uniformLeafNodeSizes=n.DEFAULT_UNIFORM_LEAF_NODE_SIZES,this.edgeToDummyNodes=new Map,this.graphManager=new o(this),this.isLayoutFinished=!1,this.isSubLayout=!1,this.isRemoteUse=!1,null!=t&&(this.isRemoteUse=t)}c.RANDOM_SEED=1,c.prototype=Object.create(g.prototype),c.prototype.getGraphManager=function(){return this.graphManager},c.prototype.getAllNodes=function(){return this.graphManager.getAllNodes()},c.prototype.getAllEdges=function(){return this.graphManager.getAllEdges()},c.prototype.getAllNodesToApplyGravitation=function(){return this.graphManager.getAllNodesToApplyGravitation()},c.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},c.prototype.newGraph=function(t){return new a(null,this.graphManager,t)},c.prototype.newNode=function(t){return new s(this.graphManager,t)},c.prototype.newEdge=function(t){return new h(null,null,t)},c.prototype.checkLayoutSuccess=function(){return null==this.graphManager.getRoot()||0==this.graphManager.getRoot().getNodes().length||this.graphManager.includesInvalidEdge()},c.prototype.runLayout=function(){var t;return this.isLayoutFinished=!1,this.tilingPreLayout&&this.tilingPreLayout(),this.initParameters(),t=!this.checkLayoutSuccess()&&this.layout(),"during"!==n.ANIMATE&&(t&&(this.isSubLayout||this.doPostLayout()),this.tilingPostLayout&&this.tilingPostLayout(),this.isLayoutFinished=!0,t)},c.prototype.doPostLayout=function(){this.incremental||this.transform(),this.update()},c.prototype.update2=function(){if(this.createBendsAsNeeded&&(this.createBendpointsFromDummyNodes(),this.graphManager.resetAllEdges()),!this.isRemoteUse){for(var t=this.graphManager.getAllEdges(),e=0;e<t.length;e++)t[e];var i=this.graphManager.getRoot().getNodes();for(e=0;e<i.length;e++)i[e];this.update(this.graphManager.getRoot())}},c.prototype.update=function(t){if(null==t)this.update2();else if(t instanceof s){var e=t;if(null!=e.getChild())for(var i=e.getChild().getNodes(),r=0;r<i.length;r++)update(i[r]);null!=e.vGraphObject&&e.vGraphObject.update(e)}else if(t instanceof h){var n=t;null!=n.vGraphObject&&n.vGraphObject.update(n)}else if(t instanceof a){var o=t;null!=o.vGraphObject&&o.vGraphObject.update(o)}},c.prototype.initParameters=function(){this.isSubLayout||(this.layoutQuality=n.QUALITY,this.animationDuringLayout=n.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=n.DEFAULT_ANIMATION_PERIOD,this.animationOnLayout=n.DEFAULT_ANIMATION_ON_LAYOUT,this.incremental=n.DEFAULT_INCREMENTAL,this.createBendsAsNeeded=n.DEFAULT_CREATE_BENDS_AS_NEEDED,this.uniformLeafNodeSizes=n.DEFAULT_UNIFORM_LEAF_NODE_SIZES),this.animationDuringLayout&&(this.animationOnLayout=!1)},c.prototype.transform=function(t){if(null==t)this.transform(new l(0,0));else{var e=new u,i=this.graphManager.getRoot().updateLeftTop();if(null!=i){e.setWorldOrgX(t.x),e.setWorldOrgY(t.y),e.setDeviceOrgX(i.x),e.setDeviceOrgY(i.y);for(var r=this.getAllNodes(),n=0;n<r.length;n++)r[n].transform(e)}}},c.prototype.positionNodesRandomly=function(t){if(null==t)this.positionNodesRandomly(this.getGraphManager().getRoot()),this.getGraphManager().getRoot().updateBounds(!0);else for(var e,i,r=t.getNodes(),n=0;n<r.length;n++)null==(i=(e=r[n]).getChild())||0==i.getNodes().length?e.scatter():(this.positionNodesRandomly(i),e.updateBounds())},c.prototype.getFlatForest=function(){for(var t=[],e=!0,i=this.graphManager.getRoot().getNodes(),n=!0,o=0;o<i.length;o++)null!=i[o].getChild()&&(n=!1);if(!n)return t;var s=new Set,h=[],a=new Map,l=[];for(l=l.concat(i);l.length>0&&e;){for(h.push(l[0]);h.length>0&&e;){var u=h[0];h.splice(0,1),s.add(u);var g=u.getEdges();for(o=0;o<g.length;o++){var c=g[o].getOtherEnd(u);if(a.get(u)!=c){if(s.has(c)){e=!1;break}h.push(c),a.set(c,u)}}}if(e){var p=[].concat(r(s));for(t.push(p),o=0;o<p.length;o++){var f=p[o],d=l.indexOf(f);d>-1&&l.splice(d,1)}s=new Set,a=new Map}else t=[]}return t},c.prototype.createDummyNodesForBendpoints=function(t){for(var e=[],i=t.source,r=this.graphManager.calcLowestCommonAncestor(t.source,t.target),n=0;n<t.bendpoints.length;n++){var o=this.newNode(null);o.setRect(new Point(0,0),new Dimension(1,1)),r.add(o);var s=this.newEdge(null);this.graphManager.add(s,i,o),e.add(o),i=o}return s=this.newEdge(null),this.graphManager.add(s,i,t.target),this.edgeToDummyNodes.set(t,e),t.isInterGraph()?this.graphManager.remove(t):r.remove(t),e},c.prototype.createBendpointsFromDummyNodes=function(){var t=[];t=t.concat(this.graphManager.getAllEdges()),t=[].concat(r(this.edgeToDummyNodes.keys())).concat(t);for(var e=0;e<t.length;e++){var i=t[e];if(i.bendpoints.length>0){for(var n=this.edgeToDummyNodes.get(i),o=0;o<n.length;o++){var s=n[o],h=new l(s.getCenterX(),s.getCenterY()),a=i.bendpoints.get(o);a.x=h.x,a.y=h.y,s.getOwner().remove(s)}this.graphManager.add(i,i.source,i.target)}}},c.transform=function(t,e,i,r){if(null!=i&&null!=r){var n=e;return t<=50?n-=(e-e/i)/50*(50-t):n+=(e*r-e)/50*(t-50),n}var o,s;return t<=50?(o=9*e/500,s=e/10):(o=9*e/50,s=-8*e),o*t+s},c.findCenterOfTree=function(t){var e=[];e=e.concat(t);var i=[],r=new Map,n=!1,o=null;1!=e.length&&2!=e.length||(n=!0,o=e[0]);for(var s=0;s<e.length;s++){var h=(u=e[s]).getNeighborsList().size;r.set(u,u.getNeighborsList().size),1==h&&i.push(u)}var a=[];for(a=a.concat(i);!n;){var l=[];for(l=l.concat(a),a=[],s=0;s<e.length;s++){var u=e[s],g=e.indexOf(u);g>=0&&e.splice(g,1),u.getNeighborsList().forEach((function(t){if(i.indexOf(t)<0){var e=r.get(t)-1;1==e&&a.push(t),r.set(t,e)}}))}i=i.concat(a),1!=e.length&&2!=e.length||(n=!0,o=e[0])}return o},c.prototype.setGraphManager=function(t){this.graphManager=t},t.exports=c},function(t,e,i){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)},t.exports=r},function(t,e,i){var r=i(5);function n(t,e){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}n.prototype.getWorldOrgX=function(){return this.lworldOrgX},n.prototype.setWorldOrgX=function(t){this.lworldOrgX=t},n.prototype.getWorldOrgY=function(){return this.lworldOrgY},n.prototype.setWorldOrgY=function(t){this.lworldOrgY=t},n.prototype.getWorldExtX=function(){return this.lworldExtX},n.prototype.setWorldExtX=function(t){this.lworldExtX=t},n.prototype.getWorldExtY=function(){return this.lworldExtY},n.prototype.setWorldExtY=function(t){this.lworldExtY=t},n.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},n.prototype.setDeviceOrgX=function(t){this.ldeviceOrgX=t},n.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},n.prototype.setDeviceOrgY=function(t){this.ldeviceOrgY=t},n.prototype.getDeviceExtX=function(){return this.ldeviceExtX},n.prototype.setDeviceExtX=function(t){this.ldeviceExtX=t},n.prototype.getDeviceExtY=function(){return this.ldeviceExtY},n.prototype.setDeviceExtY=function(t){this.ldeviceExtY=t},n.prototype.transformX=function(t){var e=0,i=this.lworldExtX;return 0!=i&&(e=this.ldeviceOrgX+(t-this.lworldOrgX)*this.ldeviceExtX/i),e},n.prototype.transformY=function(t){var e=0,i=this.lworldExtY;return 0!=i&&(e=this.ldeviceOrgY+(t-this.lworldOrgY)*this.ldeviceExtY/i),e},n.prototype.inverseTransformX=function(t){var e=0,i=this.ldeviceExtX;return 0!=i&&(e=this.lworldOrgX+(t-this.ldeviceOrgX)*this.lworldExtX/i),e},n.prototype.inverseTransformY=function(t){var e=0,i=this.ldeviceExtY;return 0!=i&&(e=this.lworldOrgY+(t-this.ldeviceOrgY)*this.lworldExtY/i),e},n.prototype.inverseTransformPoint=function(t){return new r(this.inverseTransformX(t.x),this.inverseTransformY(t.y))},t.exports=n},function(t,e,i){var r=i(15),n=i(4),o=i(0),s=i(8),h=i(9);function a(){r.call(this),this.useSmartIdealEdgeLengthCalculation=n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=n.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=n.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=n.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=n.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*n.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=n.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=n.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=n.MAX_ITERATIONS}for(var l in a.prototype=Object.create(r.prototype),r)a[l]=r[l];a.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=n.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},a.prototype.calcIdealEdgeLengths=function(){for(var t,e,i,r,s,h,a,l=this.getGraphManager().getAllEdges(),u=0;u<l.length;u++)e=(t=l[u]).idealLength,t.isInterGraph&&(r=t.getSource(),s=t.getTarget(),h=t.getSourceInLca().getEstimatedSize(),a=t.getTargetInLca().getEstimatedSize(),this.useSmartIdealEdgeLengthCalculation&&(t.idealLength+=h+a-2*o.SIMPLE_NODE_SIZE),i=t.getLca().getInclusionTreeDepth(),t.idealLength+=e*n.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR*(r.getInclusionTreeDepth()+s.getInclusionTreeDepth()-2*i))},a.prototype.initSpringEmbedder=function(){var t=this.getAllNodes().length;this.incremental?(t>n.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*n.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(t-n.ADAPTATION_LOWER_NODE_LIMIT)/(n.ADAPTATION_UPPER_NODE_LIMIT-n.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-n.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=n.MAX_NODE_DISPLACEMENT_INCREMENTAL):(t>n.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(n.COOLING_ADAPTATION_FACTOR,1-(t-n.ADAPTATION_LOWER_NODE_LIMIT)/(n.ADAPTATION_UPPER_NODE_LIMIT-n.ADAPTATION_LOWER_NODE_LIMIT)*(1-n.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=n.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.displacementThresholdPerNode=3*n.DEFAULT_EDGE_LENGTH/100,this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},a.prototype.calcSpringForces=function(){for(var t,e=this.getAllEdges(),i=0;i<e.length;i++)t=e[i],this.calcSpringForce(t,t.idealLength)},a.prototype.calcRepulsionForces=function(){var t,e,i,r,o,s=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],h=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%n.GRID_CALCULATION_CHECK_PERIOD==1&&s&&this.updateGrid(),o=new Set,t=0;t<a.length;t++)i=a[t],this.calculateRepulsionForceOfANode(i,o,s,h),o.add(i);else for(t=0;t<a.length;t++)for(i=a[t],e=t+1;e<a.length;e++)r=a[e],i.getOwner()==r.getOwner()&&this.calcRepulsionForce(i,r)},a.prototype.calcGravitationalForces=function(){for(var t,e=this.getAllNodesToApplyGravitation(),i=0;i<e.length;i++)t=e[i],this.calcGravitationalForce(t)},a.prototype.moveNodes=function(){for(var t=this.getAllNodes(),e=0;e<t.length;e++)t[e].move()},a.prototype.calcSpringForce=function(t,e){var i,r,n,o,s=t.getSource(),h=t.getTarget();if(this.uniformLeafNodeSizes&&null==s.getChild()&&null==h.getChild())t.updateLengthSimple();else if(t.updateLength(),t.isOverlapingSourceAndTarget)return;0!=(i=t.getLength())&&(n=(r=t.edgeElasticity*(i-e))*(t.lengthX/i),o=r*(t.lengthY/i),s.springForceX+=n,s.springForceY+=o,h.springForceX-=n,h.springForceY-=o)},a.prototype.calcRepulsionForce=function(t,e){var i,r,o,a,l,u,g,c=t.getRect(),p=e.getRect(),f=new Array(2),d=new Array(4);if(c.intersects(p)){s.calcSeparationAmount(c,p,f,n.DEFAULT_EDGE_LENGTH/2),u=2*f[0],g=2*f[1];var y=t.noOfChildren*e.noOfChildren/(t.noOfChildren+e.noOfChildren);t.repulsionForceX-=y*u,t.repulsionForceY-=y*g,e.repulsionForceX+=y*u,e.repulsionForceY+=y*g}else this.uniformLeafNodeSizes&&null==t.getChild()&&null==e.getChild()?(i=p.getCenterX()-c.getCenterX(),r=p.getCenterY()-c.getCenterY()):(s.getIntersection(c,p,d),i=d[2]-d[0],r=d[3]-d[1]),Math.abs(i)<n.MIN_REPULSION_DIST&&(i=h.sign(i)*n.MIN_REPULSION_DIST),Math.abs(r)<n.MIN_REPULSION_DIST&&(r=h.sign(r)*n.MIN_REPULSION_DIST),o=i*i+r*r,a=Math.sqrt(o),u=(l=(t.nodeRepulsion/2+e.nodeRepulsion/2)*t.noOfChildren*e.noOfChildren/o)*i/a,g=l*r/a,t.repulsionForceX-=u,t.repulsionForceY-=g,e.repulsionForceX+=u,e.repulsionForceY+=g},a.prototype.calcGravitationalForce=function(t){var e,i,r,n,o,s,h,a;i=((e=t.getOwner()).getRight()+e.getLeft())/2,r=(e.getTop()+e.getBottom())/2,n=t.getCenterX()-i,o=t.getCenterY()-r,s=Math.abs(n)+t.getWidth()/2,h=Math.abs(o)+t.getHeight()/2,t.getOwner()==this.graphManager.getRoot()?(s>(a=e.getEstimatedSize()*this.gravityRangeFactor)||h>a)&&(t.gravitationForceX=-this.gravityConstant*n,t.gravitationForceY=-this.gravityConstant*o):(s>(a=e.getEstimatedSize()*this.compoundGravityRangeFactor)||h>a)&&(t.gravitationForceX=-this.gravityConstant*n*this.compoundGravityConstant,t.gravitationForceY=-this.gravityConstant*o*this.compoundGravityConstant)},a.prototype.isConverged=function(){var t,e=!1;return this.totalIterations>this.maxIterations/3&&(e=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),t=this.totalDisplacement<this.totalDisplacementThreshold,this.oldTotalDisplacement=this.totalDisplacement,t||e},a.prototype.animate=function(){this.animationDuringLayout&&!this.isSubLayout&&(this.notAnimatedIterations==this.animationPeriod?(this.update(),this.notAnimatedIterations=0):this.notAnimatedIterations++)},a.prototype.calcNoOfChildrenForAllNodes=function(){for(var t,e=this.graphManager.getAllNodes(),i=0;i<e.length;i++)(t=e[i]).noOfChildren=t.getNoOfChildren()},a.prototype.calcGrid=function(t){var e,i;e=parseInt(Math.ceil((t.getRight()-t.getLeft())/this.repulsionRange)),i=parseInt(Math.ceil((t.getBottom()-t.getTop())/this.repulsionRange));for(var r=new Array(e),n=0;n<e;n++)r[n]=new Array(i);for(n=0;n<e;n++)for(var o=0;o<i;o++)r[n][o]=new Array;return r},a.prototype.addNodeToGrid=function(t,e,i){var r,n,o,s;r=parseInt(Math.floor((t.getRect().x-e)/this.repulsionRange)),n=parseInt(Math.floor((t.getRect().width+t.getRect().x-e)/this.repulsionRange)),o=parseInt(Math.floor((t.getRect().y-i)/this.repulsionRange)),s=parseInt(Math.floor((t.getRect().height+t.getRect().y-i)/this.repulsionRange));for(var h=r;h<=n;h++)for(var a=o;a<=s;a++)this.grid[h][a].push(t),t.setGridCoordinates(r,n,o,s)},a.prototype.updateGrid=function(){var t,e,i=this.getAllNodes();for(this.grid=this.calcGrid(this.graphManager.getRoot()),t=0;t<i.length;t++)e=i[t],this.addNodeToGrid(e,this.graphManager.getRoot().getLeft(),this.graphManager.getRoot().getTop())},a.prototype.calculateRepulsionForceOfANode=function(t,e,i,r){if(this.totalIterations%n.GRID_CALCULATION_CHECK_PERIOD==1&&i||r){var o,s=new Set;t.surrounding=new Array;for(var h=this.grid,a=t.startX-1;a<t.finishX+2;a++)for(var l=t.startY-1;l<t.finishY+2;l++)if(!(a<0||l<0||a>=h.length||l>=h[0].length))for(var u=0;u<h[a][l].length;u++)if(o=h[a][l][u],t.getOwner()==o.getOwner()&&t!=o&&!e.has(o)&&!s.has(o)){var g=Math.abs(t.getCenterX()-o.getCenterX())-(t.getWidth()/2+o.getWidth()/2),c=Math.abs(t.getCenterY()-o.getCenterY())-(t.getHeight()/2+o.getHeight()/2);g<=this.repulsionRange&&c<=this.repulsionRange&&s.add(o)}t.surrounding=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(s))}for(a=0;a<t.surrounding.length;a++)this.calcRepulsionForce(t,t.surrounding[a])},a.prototype.calcRepulsionRange=function(){return 0},t.exports=a},function(t,e,i){var r=i(1),n=i(4);function o(t,e,i){r.call(this,t,e,i),this.idealLength=n.DEFAULT_EDGE_LENGTH,this.edgeElasticity=n.DEFAULT_SPRING_STRENGTH}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];t.exports=o},function(t,e,i){var r=i(3),n=i(4);function o(t,e,i,o){r.call(this,t,e,i,o),this.nodeRepulsion=n.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 s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.setGridCoordinates=function(t,e,i,r){this.startX=t,this.finishX=e,this.startY=i,this.finishY=r},t.exports=o},function(t,e,i){function r(t,e){this.width=0,this.height=0,null!==t&&null!==e&&(this.height=e,this.width=t)}r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(t){this.width=t},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(t){this.height=t},t.exports=r},function(t,e,i){var r=i(14);function n(){this.map={},this.keys=[]}n.prototype.put=function(t,e){var i=r.createID(t);this.contains(i)||(this.map[i]=e,this.keys.push(t))},n.prototype.contains=function(t){return r.createID(t),null!=this.map[t]},n.prototype.get=function(t){var e=r.createID(t);return this.map[e]},n.prototype.keySet=function(){return this.keys},t.exports=n},function(t,e,i){var r=i(14);function n(){this.set={}}n.prototype.add=function(t){var e=r.createID(t);this.contains(e)||(this.set[e]=t)},n.prototype.remove=function(t){delete this.set[r.createID(t)]},n.prototype.clear=function(){this.set={}},n.prototype.contains=function(t){return this.set[r.createID(t)]==t},n.prototype.isEmpty=function(){return 0===this.size()},n.prototype.size=function(){return Object.keys(this.set).length},n.prototype.addAllTo=function(t){for(var e=Object.keys(this.set),i=e.length,r=0;r<i;r++)t.push(this.set[e[r]])},n.prototype.size=function(){return Object.keys(this.set).length},n.prototype.addAll=function(t){for(var e=t.length,i=0;i<e;i++){var r=t[i];this.add(r)}},t.exports=n},function(t,e,i){function r(){}r.multMat=function(t,e){for(var i=[],r=0;r<t.length;r++){i[r]=[];for(var n=0;n<e[0].length;n++){i[r][n]=0;for(var o=0;o<t[0].length;o++)i[r][n]+=t[r][o]*e[o][n]}}return i},r.transpose=function(t){for(var e=[],i=0;i<t[0].length;i++){e[i]=[];for(var r=0;r<t.length;r++)e[i][r]=t[r][i]}return e},r.multCons=function(t,e){for(var i=[],r=0;r<t.length;r++)i[r]=t[r]*e;return i},r.minusOp=function(t,e){for(var i=[],r=0;r<t.length;r++)i[r]=t[r]-e[r];return i},r.dotProduct=function(t,e){for(var i=0,r=0;r<t.length;r++)i+=t[r]*e[r];return i},r.mag=function(t){return Math.sqrt(this.dotProduct(t,t))},r.normalize=function(t){for(var e=[],i=this.mag(t),r=0;r<t.length;r++)e[r]=t[r]/i;return e},r.multGamma=function(t){for(var e=[],i=0,r=0;r<t.length;r++)i+=t[r];i*=-1/t.length;for(var n=0;n<t.length;n++)e[n]=i+t[n];return e},r.multL=function(t,e,i){for(var r=[],n=[],o=[],s=0;s<e[0].length;s++){for(var h=0,a=0;a<e.length;a++)h+=-.5*e[a][s]*t[a];n[s]=h}for(var l=0;l<i.length;l++){for(var u=0,g=0;g<i.length;g++)u+=i[l][g]*n[g];o[l]=u}for(var c=0;c<e.length;c++){for(var p=0,f=0;f<e[0].length;f++)p+=e[c][f]*o[f];r[c]=p}return r},t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=i(11),o=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),null===i&&void 0===i||(this.compareFunction=this._defaultCompareFunction);var r=void 0;r=e instanceof n?e.size():e.length,this._quicksort(e,0,r-1)}return r(t,[{key:"_quicksort",value:function(t,e,i){if(e<i){var r=this._partition(t,e,i);this._quicksort(t,e,r),this._quicksort(t,r+1,i)}}},{key:"_partition",value:function(t,e,i){for(var r=this._get(t,e),n=e,o=i;;){for(;this.compareFunction(r,this._get(t,o));)o--;for(;this.compareFunction(this._get(t,n),r);)n++;if(!(n<o))return o;this._swap(t,n,o),n++,o--}}},{key:"_get",value:function(t,e){return t instanceof n?t.get_object_at(e):t[e]}},{key:"_set",value:function(t,e,i){t instanceof n?t.set_object_at(e,i):t[e]=i}},{key:"_swap",value:function(t,e,i){var r=this._get(t,e);this._set(t,e,this._get(t,i)),this._set(t,i,r)}},{key:"_defaultCompareFunction",value:function(t,e){return e>t}}]),t}();t.exports=o},function(t,e,i){function r(){}r.svd=function(t){this.U=null,this.V=null,this.s=null,this.m=0,this.n=0,this.m=t.length,this.n=t[0].length;var e=Math.min(this.m,this.n);this.s=function(t){for(var e=[];t-- >0;)e.push(0);return e}(Math.min(this.m+1,this.n)),this.U=function t(e){if(0==e.length)return 0;for(var i=[],r=0;r<e[0];r++)i.push(t(e.slice(1)));return i}([this.m,e]),this.V=function(t){return function t(e){if(0==e.length)return 0;for(var i=[],r=0;r<e[0];r++)i.push(t(e.slice(1)));return i}(t)}([this.n,this.n]);for(var i,n,o=function(t){for(var e=[];t-- >0;)e.push(0);return e}(this.n),s=function(t){for(var e=[];t-- >0;)e.push(0);return e}(this.m),h=Math.min(this.m-1,this.n),a=Math.max(0,Math.min(this.n-2,this.m)),l=0;l<Math.max(h,a);l++){if(l<h){this.s[l]=0;for(var u=l;u<this.m;u++)this.s[l]=r.hypot(this.s[l],t[u][l]);if(0!==this.s[l]){t[l][l]<0&&(this.s[l]=-this.s[l]);for(var g=l;g<this.m;g++)t[g][l]/=this.s[l];t[l][l]+=1}this.s[l]=-this.s[l]}for(var c=l+1;c<this.n;c++){if(i=l<h,n=0!==this.s[l],i&&n){for(var p=0,f=l;f<this.m;f++)p+=t[f][l]*t[f][c];p=-p/t[l][l];for(var d=l;d<this.m;d++)t[d][c]+=p*t[d][l]}o[c]=t[l][c]}if(function(t,e){return e}(0,l<h))for(var y=l;y<this.m;y++)this.U[y][l]=t[y][l];if(l<a){o[l]=0;for(var v=l+1;v<this.n;v++)o[l]=r.hypot(o[l],o[v]);if(0!==o[l]){o[l+1]<0&&(o[l]=-o[l]);for(var E=l+1;E<this.n;E++)o[E]/=o[l];o[l+1]+=1}if(o[l]=-o[l],function(t,e){return t&&e}(l+1<this.m,0!==o[l])){for(var A=l+1;A<this.m;A++)s[A]=0;for(var _=l+1;_<this.n;_++)for(var O=l+1;O<this.m;O++)s[O]+=o[_]*t[O][_];for(var m=l+1;m<this.n;m++)for(var N=-o[m]/o[l+1],L=l+1;L<this.m;L++)t[L][m]+=N*s[L]}for(var I=l+1;I<this.n;I++)this.V[I][l]=o[I]}}var T=Math.min(this.n,this.m+1);h<this.n&&(this.s[h]=t[h][h]),this.m<T&&(this.s[T-1]=0),a+1<T&&(o[a]=t[a][T-1]),o[T-1]=0;for(var D=h;D<e;D++){for(var M=0;M<this.m;M++)this.U[M][D]=0;this.U[D][D]=1}for(var w=h-1;w>=0;w--)if(0!==this.s[w]){for(var R=w+1;R<e;R++){for(var x=0,C=w;C<this.m;C++)x+=this.U[C][w]*this.U[C][R];x=-x/this.U[w][w];for(var G=w;G<this.m;G++)this.U[G][R]+=x*this.U[G][w]}for(var U=w;U<this.m;U++)this.U[U][w]=-this.U[U][w];this.U[w][w]=1+this.U[w][w];for(var b=0;b<w-1;b++)this.U[b][w]=0}else{for(var S=0;S<this.m;S++)this.U[S][w]=0;this.U[w][w]=1}for(var F=this.n-1;F>=0;F--){if(function(t,e){return t&&e}(F<a,0!==o[F]))for(var Y=F+1;Y<e;Y++){for(var P=0,X=F+1;X<this.n;X++)P+=this.V[X][F]*this.V[X][Y];P=-P/this.V[F+1][F];for(var k=F+1;k<this.n;k++)this.V[k][Y]+=P*this.V[k][F]}for(var H=0;H<this.n;H++)this.V[H][F]=0;this.V[F][F]=1}for(var V=T-1,B=Math.pow(2,-52),W=Math.pow(2,-966);T>0;){var q=void 0,j=void 0;for(q=T-2;q>=-1&&-1!==q;q--)if(Math.abs(o[q])<=W+B*(Math.abs(this.s[q])+Math.abs(this.s[q+1]))){o[q]=0;break}if(q===T-2)j=4;else{var z=void 0;for(z=T-1;z>=q&&z!==q;z--){var Z=(z!==T?Math.abs(o[z]):0)+(z!==q+1?Math.abs(o[z-1]):0);if(Math.abs(this.s[z])<=W+B*Z){this.s[z]=0;break}}z===q?j=3:z===T-1?j=1:(j=2,q=z)}switch(q++,j){case 1:var Q=o[T-2];o[T-2]=0;for(var K=T-2;K>=q;K--){var J=r.hypot(this.s[K],Q),$=this.s[K]/J,tt=Q/J;this.s[K]=J,K!==q&&(Q=-tt*o[K-1],o[K-1]=$*o[K-1]);for(var et=0;et<this.n;et++)J=$*this.V[et][K]+tt*this.V[et][T-1],this.V[et][T-1]=-tt*this.V[et][K]+$*this.V[et][T-1],this.V[et][K]=J}break;case 2:var it=o[q-1];o[q-1]=0;for(var rt=q;rt<T;rt++){var nt=r.hypot(this.s[rt],it),ot=this.s[rt]/nt,st=it/nt;this.s[rt]=nt,it=-st*o[rt],o[rt]=ot*o[rt];for(var ht=0;ht<this.m;ht++)nt=ot*this.U[ht][rt]+st*this.U[ht][q-1],this.U[ht][q-1]=-st*this.U[ht][rt]+ot*this.U[ht][q-1],this.U[ht][rt]=nt}break;case 3:var at=Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[T-1]),Math.abs(this.s[T-2])),Math.abs(o[T-2])),Math.abs(this.s[q])),Math.abs(o[q])),lt=this.s[T-1]/at,ut=this.s[T-2]/at,gt=o[T-2]/at,ct=this.s[q]/at,pt=o[q]/at,ft=((ut+lt)*(ut-lt)+gt*gt)/2,dt=lt*gt*(lt*gt),yt=0;(function(t,e){return t||e})(0!==ft,0!==dt)&&(yt=Math.sqrt(ft*ft+dt),ft<0&&(yt=-yt),yt=dt/(ft+yt));for(var vt=(ct+lt)*(ct-lt)+yt,Et=ct*pt,At=q;At<T-1;At++){var _t=r.hypot(vt,Et),Ot=vt/_t,mt=Et/_t;At!==q&&(o[At-1]=_t),vt=Ot*this.s[At]+mt*o[At],o[At]=Ot*o[At]-mt*this.s[At],Et=mt*this.s[At+1],this.s[At+1]=Ot*this.s[At+1];for(var Nt=0;Nt<this.n;Nt++)_t=Ot*this.V[Nt][At]+mt*this.V[Nt][At+1],this.V[Nt][At+1]=-mt*this.V[Nt][At]+Ot*this.V[Nt][At+1],this.V[Nt][At]=_t;if(Ot=vt/(_t=r.hypot(vt,Et)),mt=Et/_t,this.s[At]=_t,vt=Ot*o[At]+mt*this.s[At+1],this.s[At+1]=-mt*o[At]+Ot*this.s[At+1],Et=mt*o[At+1],o[At+1]=Ot*o[At+1],At<this.m-1)for(var Lt=0;Lt<this.m;Lt++)_t=Ot*this.U[Lt][At]+mt*this.U[Lt][At+1],this.U[Lt][At+1]=-mt*this.U[Lt][At]+Ot*this.U[Lt][At+1],this.U[Lt][At]=_t}o[T-2]=vt;break;case 4:if(this.s[q]<=0){this.s[q]=this.s[q]<0?-this.s[q]:0;for(var It=0;It<=V;It++)this.V[It][q]=-this.V[It][q]}for(;q<V&&!(this.s[q]>=this.s[q+1]);){var Tt=this.s[q];if(this.s[q]=this.s[q+1],this.s[q+1]=Tt,q<this.n-1)for(var Dt=0;Dt<this.n;Dt++)Tt=this.V[Dt][q+1],this.V[Dt][q+1]=this.V[Dt][q],this.V[Dt][q]=Tt;if(q<this.m-1)for(var Mt=0;Mt<this.m;Mt++)Tt=this.U[Mt][q+1],this.U[Mt][q+1]=this.U[Mt][q],this.U[Mt][q]=Tt;q++}T--}}return{U:this.U,V:this.V,S:this.s}},r.hypot=function(t,e){var i=void 0;return Math.abs(t)>Math.abs(e)?(i=e/t,i=Math.abs(t)*Math.sqrt(1+i*i)):0!=e?(i=t/e,i=Math.abs(e)*Math.sqrt(1+i*i)):i=0,i},t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=function(){function t(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sequence1=e,this.sequence2=i,this.match_score=r,this.mismatch_penalty=n,this.gap_penalty=o,this.iMax=e.length+1,this.jMax=i.length+1,this.grid=new Array(this.iMax);for(var s=0;s<this.iMax;s++){this.grid[s]=new Array(this.jMax);for(var h=0;h<this.jMax;h++)this.grid[s][h]=0}this.tracebackGrid=new Array(this.iMax);for(var a=0;a<this.iMax;a++){this.tracebackGrid[a]=new Array(this.jMax);for(var l=0;l<this.jMax;l++)this.tracebackGrid[a][l]=[null,null,null]}this.alignments=[],this.score=-1,this.computeGrids()}return r(t,[{key:"getScore",value:function(){return this.score}},{key:"getAlignments",value:function(){return this.alignments}},{key:"computeGrids",value:function(){for(var t=1;t<this.jMax;t++)this.grid[0][t]=this.grid[0][t-1]+this.gap_penalty,this.tracebackGrid[0][t]=[!1,!1,!0];for(var e=1;e<this.iMax;e++)this.grid[e][0]=this.grid[e-1][0]+this.gap_penalty,this.tracebackGrid[e][0]=[!1,!0,!1];for(var i=1;i<this.iMax;i++)for(var r=1;r<this.jMax;r++){var n=[this.sequence1[i-1]===this.sequence2[r-1]?this.grid[i-1][r-1]+this.match_score:this.grid[i-1][r-1]+this.mismatch_penalty,this.grid[i-1][r]+this.gap_penalty,this.grid[i][r-1]+this.gap_penalty],o=this.arrayAllMaxIndexes(n);this.grid[i][r]=n[o[0]],this.tracebackGrid[i][r]=[o.includes(0),o.includes(1),o.includes(2)]}this.score=this.grid[this.iMax-1][this.jMax-1]}},{key:"alignmentTraceback",value:function(){var t=[];for(t.push({pos:[this.sequence1.length,this.sequence2.length],seq1:"",seq2:""});t[0];){var e=t[0],i=this.tracebackGrid[e.pos[0]][e.pos[1]];i[0]&&t.push({pos:[e.pos[0]-1,e.pos[1]-1],seq1:this.sequence1[e.pos[0]-1]+e.seq1,seq2:this.sequence2[e.pos[1]-1]+e.seq2}),i[1]&&t.push({pos:[e.pos[0]-1,e.pos[1]],seq1:this.sequence1[e.pos[0]-1]+e.seq1,seq2:"-"+e.seq2}),i[2]&&t.push({pos:[e.pos[0],e.pos[1]-1],seq1:"-"+e.seq1,seq2:this.sequence2[e.pos[1]-1]+e.seq2}),0===e.pos[0]&&0===e.pos[1]&&this.alignments.push({sequence1:e.seq1,sequence2:e.seq2}),t.shift()}return this.alignments}},{key:"getAllIndexes",value:function(t,e){for(var i=[],r=-1;-1!==(r=t.indexOf(e,r+1));)i.push(r);return i}},{key:"arrayAllMaxIndexes",value:function(t){return this.getAllIndexes(t,Math.max.apply(null,t))}}]),t}();t.exports=n},function(t,e,i){var r=function(){};r.FDLayout=i(18),r.FDLayoutConstants=i(4),r.FDLayoutEdge=i(19),r.FDLayoutNode=i(20),r.DimensionD=i(21),r.HashMap=i(22),r.HashSet=i(23),r.IGeometry=i(8),r.IMath=i(9),r.Integer=i(10),r.Point=i(12),r.PointD=i(5),r.RandomSeed=i(16),r.RectangleD=i(13),r.Transform=i(17),r.UniqueIDGeneretor=i(14),r.Quicksort=i(25),r.LinkedList=i(11),r.LGraphObject=i(2),r.LGraph=i(6),r.LEdge=i(1),r.LGraphManager=i(7),r.LNode=i(3),r.Layout=i(15),r.LayoutConstants=i(0),r.NeedlemanWunsch=i(27),r.Matrix=i(24),r.SVD=i(26),t.exports=r},function(t,e,i){function r(){this.listeners=[]}var n=r.prototype;n.addListener=function(t,e){this.listeners.push({event:t,callback:e})},n.removeListener=function(t,e){for(var i=this.listeners.length;i>=0;i--){var r=this.listeners[i];r.event===t&&r.callback===e&&this.listeners.splice(i,1)}},n.emit=function(t,e){for(var i=0;i<this.listeners.length;i++){var r=this.listeners[i];t===r.event&&r.callback(e)}},t.exports=r}])},r.exports=n()),i.__module.exports;var r,n};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),i=require("../../../../../_virtual/layout-base.js");i.__module.exports,exports.__require=function(){return t||(t=1,r=i.__module,i.__module.exports,e.commonjsGlobal,n=function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=28)}([function(t,e,i){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,t.exports=r},function(t,e,i){var r=i(2),n=i(8),o=i(9);function s(t,e,i){r.call(this,i),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=i,this.bendpoints=[],this.source=t,this.target=e}for(var h in s.prototype=Object.create(r.prototype),r)s[h]=r[h];s.prototype.getSource=function(){return this.source},s.prototype.getTarget=function(){return this.target},s.prototype.isInterGraph=function(){return this.isInterGraph},s.prototype.getLength=function(){return this.length},s.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},s.prototype.getBendpoints=function(){return this.bendpoints},s.prototype.getLca=function(){return this.lca},s.prototype.getSourceInLca=function(){return this.sourceInLca},s.prototype.getTargetInLca=function(){return this.targetInLca},s.prototype.getOtherEnd=function(t){if(this.source===t)return this.target;if(this.target===t)return this.source;throw"Node is not incident with this edge"},s.prototype.getOtherEndInGraph=function(t,e){for(var i=this.getOtherEnd(t),r=e.getGraphManager().getRoot();;){if(i.getOwner()==e)return i;if(i.getOwner()==r)break;i=i.getOwner().getParent()}return null},s.prototype.updateLength=function(){var t=new Array(4);this.isOverlapingSourceAndTarget=n.getIntersection(this.target.getRect(),this.source.getRect(),t),this.isOverlapingSourceAndTarget||(this.lengthX=t[0]-t[2],this.lengthY=t[1]-t[3],Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},s.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=o.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=o.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},t.exports=s},function(t,e,i){t.exports=function(t){this.vGraphObject=t}},function(t,e,i){var r=i(2),n=i(10),o=i(13),s=i(0),h=i(16),a=i(5);function l(t,e,i,s){null==i&&null==s&&(s=e),r.call(this,s),null!=t.graphManager&&(t=t.graphManager),this.estimatedSize=n.MIN_VALUE,this.inclusionTreeDepth=n.MAX_VALUE,this.vGraphObject=s,this.edges=[],this.graphManager=t,this.rect=null!=i&&null!=e?new o(e.x,e.y,i.width,i.height):new o}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(t){this.rect.width=t},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(t){this.rect.height=t},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new a(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new a(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(t,e){this.rect.x=t.x,this.rect.y=t.y,this.rect.width=e.width,this.rect.height=e.height},l.prototype.setCenter=function(t,e){this.rect.x=t-this.rect.width/2,this.rect.y=e-this.rect.height/2},l.prototype.setLocation=function(t,e){this.rect.x=t,this.rect.y=e},l.prototype.moveBy=function(t,e){this.rect.x+=t,this.rect.y+=e},l.prototype.getEdgeListToNode=function(t){var e=[],i=this;return i.edges.forEach((function(r){if(r.target==t){if(r.source!=i)throw"Incorrect edge source!";e.push(r)}})),e},l.prototype.getEdgesBetween=function(t){var e=[],i=this;return i.edges.forEach((function(r){if(r.source!=i&&r.target!=i)throw"Incorrect edge source and/or target";r.target!=t&&r.source!=t||e.push(r)})),e},l.prototype.getNeighborsList=function(){var t=new Set,e=this;return e.edges.forEach((function(i){if(i.source==e)t.add(i.target);else{if(i.target!=e)throw"Incorrect incidency!";t.add(i.source)}})),t},l.prototype.withChildren=function(){var t=new Set;if(t.add(this),null!=this.child)for(var e=this.child.getNodes(),i=0;i<e.length;i++)e[i].withChildren().forEach((function(e){t.add(e)}));return t},l.prototype.getNoOfChildren=function(){var t=0;if(null==this.child)t=1;else for(var e=this.child.getNodes(),i=0;i<e.length;i++)t+=e[i].getNoOfChildren();return 0==t&&(t=1),t},l.prototype.getEstimatedSize=function(){if(this.estimatedSize==n.MIN_VALUE)throw"assert failed";return this.estimatedSize},l.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)},l.prototype.scatter=function(){var t,e,i=-s.INITIAL_WORLD_BOUNDARY,r=s.INITIAL_WORLD_BOUNDARY;t=s.WORLD_CENTER_X+h.nextDouble()*(r-i)+i;var n=-s.INITIAL_WORLD_BOUNDARY,o=s.INITIAL_WORLD_BOUNDARY;e=s.WORLD_CENTER_Y+h.nextDouble()*(o-n)+n,this.rect.x=t,this.rect.y=e},l.prototype.updateBounds=function(){if(null==this.getChild())throw"assert failed";if(0!=this.getChild().getNodes().length){var t=this.getChild();if(t.updateBounds(!0),this.rect.x=t.getLeft(),this.rect.y=t.getTop(),this.setWidth(t.getRight()-t.getLeft()),this.setHeight(t.getBottom()-t.getTop()),s.NODE_DIMENSIONS_INCLUDE_LABELS){var e=t.getRight()-t.getLeft(),i=t.getBottom()-t.getTop();this.labelWidth&&("left"==this.labelPosHorizontal?(this.rect.x-=this.labelWidth,this.setWidth(e+this.labelWidth)):"center"==this.labelPosHorizontal&&this.labelWidth>e?(this.rect.x-=(this.labelWidth-e)/2,this.setWidth(this.labelWidth)):"right"==this.labelPosHorizontal&&this.setWidth(e+this.labelWidth)),this.labelHeight&&("top"==this.labelPosVertical?(this.rect.y-=this.labelHeight,this.setHeight(i+this.labelHeight)):"center"==this.labelPosVertical&&this.labelHeight>i?(this.rect.y-=(this.labelHeight-i)/2,this.setHeight(this.labelHeight)):"bottom"==this.labelPosVertical&&this.setHeight(i+this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==n.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},l.prototype.transform=function(t){var e=this.rect.x;e>s.WORLD_BOUNDARY?e=s.WORLD_BOUNDARY:e<-s.WORLD_BOUNDARY&&(e=-s.WORLD_BOUNDARY);var i=this.rect.y;i>s.WORLD_BOUNDARY?i=s.WORLD_BOUNDARY:i<-s.WORLD_BOUNDARY&&(i=-s.WORLD_BOUNDARY);var r=new a(e,i),n=t.inverseTransformPoint(r);this.setLocation(n.x,n.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},t.exports=l},function(t,e,i){var r=i(0);function n(){}for(var o in r)n[o]=r[o];n.MAX_ITERATIONS=2500,n.DEFAULT_EDGE_LENGTH=50,n.DEFAULT_SPRING_STRENGTH=.45,n.DEFAULT_REPULSION_STRENGTH=4500,n.DEFAULT_GRAVITY_STRENGTH=.4,n.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,n.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,n.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,n.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,n.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,n.COOLING_ADAPTATION_FACTOR=.33,n.ADAPTATION_LOWER_NODE_LIMIT=1e3,n.ADAPTATION_UPPER_NODE_LIMIT=5e3,n.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,n.MAX_NODE_DISPLACEMENT=3*n.MAX_NODE_DISPLACEMENT_INCREMENTAL,n.MIN_REPULSION_DIST=n.DEFAULT_EDGE_LENGTH/10,n.CONVERGENCE_CHECK_PERIOD=100,n.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,n.MIN_EDGE_LENGTH=1,n.GRID_CALCULATION_CHECK_PERIOD=10,t.exports=n},function(t,e,i){function r(t,e){null==t&&null==e?(this.x=0,this.y=0):(this.x=t,this.y=e)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(t){this.x=t},r.prototype.setY=function(t){this.y=t},r.prototype.getDifference=function(t){return new DimensionD(this.x-t.x,this.y-t.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(t){return this.x+=t.width,this.y+=t.height,this},t.exports=r},function(t,e,i){var r=i(2),n=i(10),o=i(0),s=i(7),h=i(3),a=i(1),l=i(13),u=i(12),g=i(11);function c(t,e,i){r.call(this,i),this.estimatedSize=n.MIN_VALUE,this.margin=o.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=t,null!=e&&e instanceof s?this.graphManager=e:null!=e&&e instanceof Layout&&(this.graphManager=e.graphManager)}for(var p in c.prototype=Object.create(r.prototype),r)c[p]=r[p];c.prototype.getNodes=function(){return this.nodes},c.prototype.getEdges=function(){return this.edges},c.prototype.getGraphManager=function(){return this.graphManager},c.prototype.getParent=function(){return this.parent},c.prototype.getLeft=function(){return this.left},c.prototype.getRight=function(){return this.right},c.prototype.getTop=function(){return this.top},c.prototype.getBottom=function(){return this.bottom},c.prototype.isConnected=function(){return this.isConnected},c.prototype.add=function(t,e,i){if(null==e&&null==i){var r=t;if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(r)>-1)throw"Node already in graph!";return r.owner=this,this.getNodes().push(r),r}var n=t;if(!(this.getNodes().indexOf(e)>-1&&this.getNodes().indexOf(i)>-1))throw"Source or target not in graph!";if(e.owner!=i.owner||e.owner!=this)throw"Both owners must be this graph!";return e.owner!=i.owner?null:(n.source=e,n.target=i,n.isInterGraph=!1,this.getEdges().push(n),e.edges.push(n),i!=e&&i.edges.push(n),n)},c.prototype.remove=function(t){var e=t;if(t instanceof h){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 i=e.edges.slice(),r=i.length,n=0;n<r;n++)(o=i[n]).isInterGraph?this.graphManager.remove(o):o.source.owner.remove(o);if(-1==(s=this.nodes.indexOf(e)))throw"Node not in owner node list!";this.nodes.splice(s,1)}else if(t instanceof a){var o;if(null==(o=t))throw"Edge is null!";if(null==o.source||null==o.target)throw"Source and/or target is null!";if(null==o.source.owner||null==o.target.owner||o.source.owner!=this||o.target.owner!=this)throw"Source and/or target owner is invalid!";var s,l=o.source.edges.indexOf(o),u=o.target.edges.indexOf(o);if(!(l>-1&&u>-1))throw"Source and/or target doesn't know this edge!";if(o.source.edges.splice(l,1),o.target!=o.source&&o.target.edges.splice(u,1),-1==(s=o.source.owner.getEdges().indexOf(o)))throw"Not in owner's edge list!";o.source.owner.getEdges().splice(s,1)}},c.prototype.updateLeftTop=function(){for(var t,e,i,r=n.MAX_VALUE,o=n.MAX_VALUE,s=this.getNodes(),h=s.length,a=0;a<h;a++){var l=s[a];r>(t=l.getTop())&&(r=t),o>(e=l.getLeft())&&(o=e)}return r==n.MAX_VALUE?null:(i=null!=s[0].getParent().paddingLeft?s[0].getParent().paddingLeft:this.margin,this.left=o-i,this.top=r-i,new u(this.left,this.top))},c.prototype.updateBounds=function(t){for(var e,i,r,o,s,h=n.MAX_VALUE,a=-n.MAX_VALUE,u=n.MAX_VALUE,g=-n.MAX_VALUE,c=this.nodes,p=c.length,f=0;f<p;f++){var d=c[f];t&&null!=d.child&&d.updateBounds(),h>(e=d.getLeft())&&(h=e),a<(i=d.getRight())&&(a=i),u>(r=d.getTop())&&(u=r),g<(o=d.getBottom())&&(g=o)}var y=new l(h,u,a-h,g-u);h==n.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),s=null!=c[0].getParent().paddingLeft?c[0].getParent().paddingLeft:this.margin,this.left=y.x-s,this.right=y.x+y.width+s,this.top=y.y-s,this.bottom=y.y+y.height+s},c.calculateBounds=function(t){for(var e,i,r,o,s=n.MAX_VALUE,h=-n.MAX_VALUE,a=n.MAX_VALUE,u=-n.MAX_VALUE,g=t.length,c=0;c<g;c++){var p=t[c];s>(e=p.getLeft())&&(s=e),h<(i=p.getRight())&&(h=i),a>(r=p.getTop())&&(a=r),u<(o=p.getBottom())&&(u=o)}return new l(s,a,h-s,u-a)},c.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},c.prototype.getEstimatedSize=function(){if(this.estimatedSize==n.MIN_VALUE)throw"assert failed";return this.estimatedSize},c.prototype.calcEstimatedSize=function(){for(var t=0,e=this.nodes,i=e.length,r=0;r<i;r++)t+=e[r].calcEstimatedSize();return this.estimatedSize=0==t?o.EMPTY_COMPOUND_NODE_SIZE:t/Math.sqrt(this.nodes.length),this.estimatedSize},c.prototype.updateConnected=function(){var t=this;if(0!=this.nodes.length){var e,i,r=new g,n=new Set,o=this.nodes[0];for(o.withChildren().forEach((function(t){r.push(t),n.add(t)}));0!==r.length;)for(var s=(e=(o=r.shift()).getEdges()).length,h=0;h<s;h++)null==(i=e[h].getOtherEndInGraph(o,this))||n.has(i)||i.withChildren().forEach((function(t){r.push(t),n.add(t)}));if(this.isConnected=!1,n.size>=this.nodes.length){var a=0;n.forEach((function(e){e.owner==t&&a++})),a==this.nodes.length&&(this.isConnected=!0)}}else this.isConnected=!0},t.exports=c},function(t,e,i){var r,n=i(1);function o(t){r=i(6),this.layout=t,this.graphs=[],this.edges=[]}o.prototype.addRoot=function(){var t=this.layout.newGraph(),e=this.layout.newNode(null),i=this.add(t,e);return this.setRootGraph(i),this.rootGraph},o.prototype.add=function(t,e,i,r,n){if(null==i&&null==r&&null==n){if(null==t)throw"Graph is null!";if(null==e)throw"Parent node is null!";if(this.graphs.indexOf(t)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(t),null!=t.parent)throw"Already has a parent!";if(null!=e.child)throw"Already has a child!";return t.parent=e,e.child=t,t}n=i,i=t;var o=(r=e).getOwner(),s=n.getOwner();if(null==o||o.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==s||s.getGraphManager()!=this)throw"Target not in this graph mgr!";if(o==s)return i.isInterGraph=!1,o.add(i,r,n);if(i.isInterGraph=!0,i.source=r,i.target=n,this.edges.indexOf(i)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(i),null==i.source||null==i.target)throw"Edge source and/or target is null!";if(-1!=i.source.edges.indexOf(i)||-1!=i.target.edges.indexOf(i))throw"Edge already in source and/or target incidency list!";return i.source.edges.push(i),i.target.edges.push(i),i},o.prototype.remove=function(t){if(t instanceof r){var e=t;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 i,o=[],s=(o=o.concat(e.getEdges())).length,h=0;h<s;h++)i=o[h],e.remove(i);var a,l=[];for(s=(l=l.concat(e.getNodes())).length,h=0;h<s;h++)a=l[h],e.remove(a);e==this.rootGraph&&this.setRootGraph(null);var u=this.graphs.indexOf(e);this.graphs.splice(u,1),e.parent=null}else if(t instanceof n){if(null==(i=t))throw"Edge is null!";if(!i.isInterGraph)throw"Not an inter-graph edge!";if(null==i.source||null==i.target)throw"Source and/or target is null!";if(-1==i.source.edges.indexOf(i)||-1==i.target.edges.indexOf(i))throw"Source and/or target doesn't know this edge!";if(u=i.source.edges.indexOf(i),i.source.edges.splice(u,1),u=i.target.edges.indexOf(i),i.target.edges.splice(u,1),null==i.source.owner||null==i.source.owner.getGraphManager())throw"Edge owner graph or owner graph manager is null!";if(-1==i.source.owner.getGraphManager().edges.indexOf(i))throw"Not in owner graph manager's edge list!";u=i.source.owner.getGraphManager().edges.indexOf(i),i.source.owner.getGraphManager().edges.splice(u,1)}},o.prototype.updateBounds=function(){this.rootGraph.updateBounds(!0)},o.prototype.getGraphs=function(){return this.graphs},o.prototype.getAllNodes=function(){if(null==this.allNodes){for(var t=[],e=this.getGraphs(),i=e.length,r=0;r<i;r++)t=t.concat(e[r].getNodes());this.allNodes=t}return this.allNodes},o.prototype.resetAllNodes=function(){this.allNodes=null},o.prototype.resetAllEdges=function(){this.allEdges=null},o.prototype.resetAllNodesToApplyGravitation=function(){this.allNodesToApplyGravitation=null},o.prototype.getAllEdges=function(){if(null==this.allEdges){var t=[],e=this.getGraphs();e.length;for(var i=0;i<e.length;i++)t=t.concat(e[i].getEdges());t=t.concat(this.edges),this.allEdges=t}return this.allEdges},o.prototype.getAllNodesToApplyGravitation=function(){return this.allNodesToApplyGravitation},o.prototype.setAllNodesToApplyGravitation=function(t){if(null!=this.allNodesToApplyGravitation)throw"assert failed";this.allNodesToApplyGravitation=t},o.prototype.getRoot=function(){return this.rootGraph},o.prototype.setRootGraph=function(t){if(t.getGraphManager()!=this)throw"Root not in this graph mgr!";this.rootGraph=t,null==t.parent&&(t.parent=this.layout.newNode("Root node"))},o.prototype.getLayout=function(){return this.layout},o.prototype.isOneAncestorOfOther=function(t,e){if(null==t||null==e)throw"assert failed";if(t==e)return!0;for(var i,r=t.getOwner();null!=(i=r.getParent());){if(i==e)return!0;if(null==(r=i.getOwner()))break}for(r=e.getOwner();null!=(i=r.getParent());){if(i==t)return!0;if(null==(r=i.getOwner()))break}return!1},o.prototype.calcLowestCommonAncestors=function(){for(var t,e,i,r,n,o=this.getAllEdges(),s=o.length,h=0;h<s;h++)if(e=(t=o[h]).source,i=t.target,t.lca=null,t.sourceInLca=e,t.targetInLca=i,e!=i){for(r=e.getOwner();null==t.lca;){for(t.targetInLca=i,n=i.getOwner();null==t.lca;){if(n==r){t.lca=n;break}if(n==this.rootGraph)break;if(null!=t.lca)throw"assert failed";t.targetInLca=n.getParent(),n=t.targetInLca.getOwner()}if(r==this.rootGraph)break;null==t.lca&&(t.sourceInLca=r.getParent(),r=t.sourceInLca.getOwner())}if(null==t.lca)throw"assert failed"}else t.lca=e.getOwner()},o.prototype.calcLowestCommonAncestor=function(t,e){if(t==e)return t.getOwner();for(var i=t.getOwner();null!=i;){for(var r=e.getOwner();null!=r;){if(r==i)return r;r=r.getParent().getOwner()}i=i.getParent().getOwner()}return i},o.prototype.calcInclusionTreeDepths=function(t,e){var i;null==t&&null==e&&(t=this.rootGraph,e=1);for(var r=t.getNodes(),n=r.length,o=0;o<n;o++)(i=r[o]).inclusionTreeDepth=e,null!=i.child&&this.calcInclusionTreeDepths(i.child,e+1)},o.prototype.includesInvalidEdge=function(){for(var t,e=[],i=this.edges.length,r=0;r<i;r++)t=this.edges[r],this.isOneAncestorOfOther(t.source,t.target)&&e.push(t);for(r=0;r<e.length;r++)this.remove(e[r]);return!1},t.exports=o},function(t,e,i){var r=i(12);function n(){}n.calcSeparationAmount=function(t,e,i,r){if(!t.intersects(e))throw"assert failed";var n=new Array(2);this.decideDirectionsForOverlappingNodes(t,e,n),i[0]=Math.min(t.getRight(),e.getRight())-Math.max(t.x,e.x),i[1]=Math.min(t.getBottom(),e.getBottom())-Math.max(t.y,e.y),t.getX()<=e.getX()&&t.getRight()>=e.getRight()?i[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight()):e.getX()<=t.getX()&&e.getRight()>=t.getRight()&&(i[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight())),t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()?i[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()):e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()&&(i[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()));var o=Math.abs((e.getCenterY()-t.getCenterY())/(e.getCenterX()-t.getCenterX()));e.getCenterY()===t.getCenterY()&&e.getCenterX()===t.getCenterX()&&(o=1);var s=o*i[0],h=i[1]/o;i[0]<h?h=i[0]:s=i[1],i[0]=-1*n[0]*(h/2+r),i[1]=-1*n[1]*(s/2+r)},n.decideDirectionsForOverlappingNodes=function(t,e,i){t.getCenterX()<e.getCenterX()?i[0]=-1:i[0]=1,t.getCenterY()<e.getCenterY()?i[1]=-1:i[1]=1},n.getIntersection2=function(t,e,i){var r=t.getCenterX(),n=t.getCenterY(),o=e.getCenterX(),s=e.getCenterY();if(t.intersects(e))return i[0]=r,i[1]=n,i[2]=o,i[3]=s,!0;var h=t.getX(),a=t.getY(),l=t.getRight(),u=t.getX(),g=t.getBottom(),c=t.getRight(),p=t.getWidthHalf(),f=t.getHeightHalf(),d=e.getX(),y=e.getY(),v=e.getRight(),E=e.getX(),A=e.getBottom(),_=e.getRight(),O=e.getWidthHalf(),m=e.getHeightHalf(),N=!1,L=!1;if(r===o){if(n>s)return i[0]=r,i[1]=a,i[2]=o,i[3]=A,!1;if(n<s)return i[0]=r,i[1]=g,i[2]=o,i[3]=y,!1}else if(n===s){if(r>o)return i[0]=h,i[1]=n,i[2]=v,i[3]=s,!1;if(r<o)return i[0]=l,i[1]=n,i[2]=d,i[3]=s,!1}else{var I=t.height/t.width,T=e.height/e.width,D=(s-n)/(o-r),M=void 0,w=void 0,R=void 0,x=void 0,C=void 0,G=void 0;if(-I===D?r>o?(i[0]=u,i[1]=g,N=!0):(i[0]=l,i[1]=a,N=!0):I===D&&(r>o?(i[0]=h,i[1]=a,N=!0):(i[0]=c,i[1]=g,N=!0)),-T===D?o>r?(i[2]=E,i[3]=A,L=!0):(i[2]=v,i[3]=y,L=!0):T===D&&(o>r?(i[2]=d,i[3]=y,L=!0):(i[2]=_,i[3]=A,L=!0)),N&&L)return!1;if(r>o?n>s?(M=this.getCardinalDirection(I,D,4),w=this.getCardinalDirection(T,D,2)):(M=this.getCardinalDirection(-I,D,3),w=this.getCardinalDirection(-T,D,1)):n>s?(M=this.getCardinalDirection(-I,D,1),w=this.getCardinalDirection(-T,D,3)):(M=this.getCardinalDirection(I,D,2),w=this.getCardinalDirection(T,D,4)),!N)switch(M){case 1:x=a,R=r+-f/D,i[0]=R,i[1]=x;break;case 2:R=c,x=n+p*D,i[0]=R,i[1]=x;break;case 3:x=g,R=r+f/D,i[0]=R,i[1]=x;break;case 4:R=u,x=n+-p*D,i[0]=R,i[1]=x}if(!L)switch(w){case 1:G=y,C=o+-m/D,i[2]=C,i[3]=G;break;case 2:C=_,G=s+O*D,i[2]=C,i[3]=G;break;case 3:G=A,C=o+m/D,i[2]=C,i[3]=G;break;case 4:C=E,G=s+-O*D,i[2]=C,i[3]=G}}return!1},n.getCardinalDirection=function(t,e,i){return t>e?i:1+i%4},n.getIntersection=function(t,e,i,n){if(null==n)return this.getIntersection2(t,e,i);var o,s,h,a,l,u,g,c=t.x,p=t.y,f=e.x,d=e.y,y=i.x,v=i.y,E=n.x,A=n.y;return 0==(g=(o=d-p)*(a=y-E)-(s=A-v)*(h=c-f))?null:new r((h*(u=E*v-y*A)-a*(l=f*p-c*d))/g,(s*l-o*u)/g)},n.angleOfVector=function(t,e,i,r){var n=void 0;return t!==i?(n=Math.atan((r-e)/(i-t)),i<t?n+=Math.PI:r<e&&(n+=this.TWO_PI)):n=r<e?this.ONE_AND_HALF_PI:this.HALF_PI,n},n.doIntersect=function(t,e,i,r){var n=t.x,o=t.y,s=e.x,h=e.y,a=i.x,l=i.y,u=r.x,g=r.y,c=(s-n)*(g-l)-(u-a)*(h-o);if(0===c)return!1;var p=((g-l)*(u-n)+(a-u)*(g-o))/c,f=((o-h)*(u-n)+(s-n)*(g-o))/c;return 0<p&&p<1&&0<f&&f<1},n.findCircleLineIntersections=function(t,e,i,r,n,o,s){var h=(i-t)*(i-t)+(r-e)*(r-e),a=2*((t-n)*(i-t)+(e-o)*(r-e)),l=(t-n)*(t-n)+(e-o)*(e-o)-s*s;if(a*a-4*h*l>=0){var u=(-a+Math.sqrt(a*a-4*h*l))/(2*h),g=(-a-Math.sqrt(a*a-4*h*l))/(2*h);return u>=0&&u<=1?[u]:g>=0&&g<=1?[g]:null}return null},n.HALF_PI=.5*Math.PI,n.ONE_AND_HALF_PI=1.5*Math.PI,n.TWO_PI=2*Math.PI,n.THREE_PI=3*Math.PI,t.exports=n},function(t,e,i){function r(){}r.sign=function(t){return t>0?1:t<0?-1:0},r.floor=function(t){return t<0?Math.ceil(t):Math.floor(t)},r.ceil=function(t){return t<0?Math.floor(t):Math.ceil(t)},t.exports=r},function(t,e,i){function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=function(t){return{value:t,next:null,prev:null}},o=function(t,e,i,r){return null!==t?t.next=e:r.head=e,null!==i?i.prev=e:r.tail=e,e.prev=t,e.next=i,r.length++,e},s=function(t,e){var i=t.prev,r=t.next;return null!==i?i.next=r:e.head=r,null!==r?r.prev=i:e.tail=i,t.prev=t.next=null,e.length--,t},h=function(){function t(e){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.length=0,this.head=null,this.tail=null,null!=e&&e.forEach((function(t){return i.push(t)}))}return r(t,[{key:"size",value:function(){return this.length}},{key:"insertBefore",value:function(t,e){return o(e.prev,n(t),e,this)}},{key:"insertAfter",value:function(t,e){return o(e,n(t),e.next,this)}},{key:"insertNodeBefore",value:function(t,e){return o(e.prev,t,e,this)}},{key:"insertNodeAfter",value:function(t,e){return o(e,t,e.next,this)}},{key:"push",value:function(t){return o(this.tail,n(t),null,this)}},{key:"unshift",value:function(t){return o(null,n(t),this.head,this)}},{key:"remove",value:function(t){return s(t,this)}},{key:"pop",value:function(){return s(this.tail,this).value}},{key:"popNode",value:function(){return s(this.tail,this)}},{key:"shift",value:function(){return s(this.head,this).value}},{key:"shiftNode",value:function(){return s(this.head,this)}},{key:"get_object_at",value:function(t){if(t<=this.length()){for(var e=1,i=this.head;e<t;)i=i.next,e++;return i.value}}},{key:"set_object_at",value:function(t,e){if(t<=this.length()){for(var i=1,r=this.head;i<t;)r=r.next,i++;r.value=e}}}]),t}();t.exports=h},function(t,e,i){function r(t,e,i){this.x=null,this.y=null,null==t&&null==e&&null==i?(this.x=0,this.y=0):"number"==typeof t&&"number"==typeof e&&null==i?(this.x=t,this.y=e):"Point"==t.constructor.name&&null==e&&null==i&&(i=t,this.x=i.x,this.y=i.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(t,e,i){"Point"==t.constructor.name&&null==e&&null==i?(i=t,this.setLocation(i.x,i.y)):"number"==typeof t&&"number"==typeof e&&null==i&&(parseInt(t)==t&&parseInt(e)==e?this.move(t,e):(this.x=Math.floor(t+.5),this.y=Math.floor(e+.5)))},r.prototype.move=function(t,e){this.x=t,this.y=e},r.prototype.translate=function(t,e){this.x+=t,this.y+=e},r.prototype.equals=function(t){if("Point"==t.constructor.name){var e=t;return this.x==e.x&&this.y==e.y}return this==t},r.prototype.toString=function(){return(new r).constructor.name+"[x="+this.x+",y="+this.y+"]"},t.exports=r},function(t,e,i){function r(t,e,i,r){this.x=0,this.y=0,this.width=0,this.height=0,null!=t&&null!=e&&null!=i&&null!=r&&(this.x=t,this.y=e,this.width=i,this.height=r)}r.prototype.getX=function(){return this.x},r.prototype.setX=function(t){this.x=t},r.prototype.getY=function(){return this.y},r.prototype.setY=function(t){this.y=t},r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(t){this.width=t},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(t){this.height=t},r.prototype.getRight=function(){return this.x+this.width},r.prototype.getBottom=function(){return this.y+this.height},r.prototype.intersects=function(t){return!(this.getRight()<t.x||this.getBottom()<t.y||t.getRight()<this.x||t.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},t.exports=r},function(t,e,i){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function n(){}n.lastID=0,n.createID=function(t){return n.isPrimitive(t)?t:(null!=t.uniqueID||(t.uniqueID=n.getString(),n.lastID++),t.uniqueID)},n.getString=function(t){return null==t&&(t=n.lastID),"Object#"+t},n.isPrimitive=function(t){var e=void 0===t?"undefined":r(t);return null==t||"object"!=e&&"function"!=e},t.exports=n},function(t,e,i){function r(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var n=i(0),o=i(7),s=i(3),h=i(1),a=i(6),l=i(5),u=i(17),g=i(29);function c(t){g.call(this),this.layoutQuality=n.QUALITY,this.createBendsAsNeeded=n.DEFAULT_CREATE_BENDS_AS_NEEDED,this.incremental=n.DEFAULT_INCREMENTAL,this.animationOnLayout=n.DEFAULT_ANIMATION_ON_LAYOUT,this.animationDuringLayout=n.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=n.DEFAULT_ANIMATION_PERIOD,this.uniformLeafNodeSizes=n.DEFAULT_UNIFORM_LEAF_NODE_SIZES,this.edgeToDummyNodes=new Map,this.graphManager=new o(this),this.isLayoutFinished=!1,this.isSubLayout=!1,this.isRemoteUse=!1,null!=t&&(this.isRemoteUse=t)}c.RANDOM_SEED=1,c.prototype=Object.create(g.prototype),c.prototype.getGraphManager=function(){return this.graphManager},c.prototype.getAllNodes=function(){return this.graphManager.getAllNodes()},c.prototype.getAllEdges=function(){return this.graphManager.getAllEdges()},c.prototype.getAllNodesToApplyGravitation=function(){return this.graphManager.getAllNodesToApplyGravitation()},c.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},c.prototype.newGraph=function(t){return new a(null,this.graphManager,t)},c.prototype.newNode=function(t){return new s(this.graphManager,t)},c.prototype.newEdge=function(t){return new h(null,null,t)},c.prototype.checkLayoutSuccess=function(){return null==this.graphManager.getRoot()||0==this.graphManager.getRoot().getNodes().length||this.graphManager.includesInvalidEdge()},c.prototype.runLayout=function(){var t;return this.isLayoutFinished=!1,this.tilingPreLayout&&this.tilingPreLayout(),this.initParameters(),t=!this.checkLayoutSuccess()&&this.layout(),"during"!==n.ANIMATE&&(t&&(this.isSubLayout||this.doPostLayout()),this.tilingPostLayout&&this.tilingPostLayout(),this.isLayoutFinished=!0,t)},c.prototype.doPostLayout=function(){this.incremental||this.transform(),this.update()},c.prototype.update2=function(){if(this.createBendsAsNeeded&&(this.createBendpointsFromDummyNodes(),this.graphManager.resetAllEdges()),!this.isRemoteUse){for(var t=this.graphManager.getAllEdges(),e=0;e<t.length;e++)t[e];var i=this.graphManager.getRoot().getNodes();for(e=0;e<i.length;e++)i[e];this.update(this.graphManager.getRoot())}},c.prototype.update=function(t){if(null==t)this.update2();else if(t instanceof s){var e=t;if(null!=e.getChild())for(var i=e.getChild().getNodes(),r=0;r<i.length;r++)update(i[r]);null!=e.vGraphObject&&e.vGraphObject.update(e)}else if(t instanceof h){var n=t;null!=n.vGraphObject&&n.vGraphObject.update(n)}else if(t instanceof a){var o=t;null!=o.vGraphObject&&o.vGraphObject.update(o)}},c.prototype.initParameters=function(){this.isSubLayout||(this.layoutQuality=n.QUALITY,this.animationDuringLayout=n.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=n.DEFAULT_ANIMATION_PERIOD,this.animationOnLayout=n.DEFAULT_ANIMATION_ON_LAYOUT,this.incremental=n.DEFAULT_INCREMENTAL,this.createBendsAsNeeded=n.DEFAULT_CREATE_BENDS_AS_NEEDED,this.uniformLeafNodeSizes=n.DEFAULT_UNIFORM_LEAF_NODE_SIZES),this.animationDuringLayout&&(this.animationOnLayout=!1)},c.prototype.transform=function(t){if(null==t)this.transform(new l(0,0));else{var e=new u,i=this.graphManager.getRoot().updateLeftTop();if(null!=i){e.setWorldOrgX(t.x),e.setWorldOrgY(t.y),e.setDeviceOrgX(i.x),e.setDeviceOrgY(i.y);for(var r=this.getAllNodes(),n=0;n<r.length;n++)r[n].transform(e)}}},c.prototype.positionNodesRandomly=function(t){if(null==t)this.positionNodesRandomly(this.getGraphManager().getRoot()),this.getGraphManager().getRoot().updateBounds(!0);else for(var e,i,r=t.getNodes(),n=0;n<r.length;n++)null==(i=(e=r[n]).getChild())||0==i.getNodes().length?e.scatter():(this.positionNodesRandomly(i),e.updateBounds())},c.prototype.getFlatForest=function(){for(var t=[],e=!0,i=this.graphManager.getRoot().getNodes(),n=!0,o=0;o<i.length;o++)null!=i[o].getChild()&&(n=!1);if(!n)return t;var s=new Set,h=[],a=new Map,l=[];for(l=l.concat(i);l.length>0&&e;){for(h.push(l[0]);h.length>0&&e;){var u=h[0];h.splice(0,1),s.add(u);var g=u.getEdges();for(o=0;o<g.length;o++){var c=g[o].getOtherEnd(u);if(a.get(u)!=c){if(s.has(c)){e=!1;break}h.push(c),a.set(c,u)}}}if(e){var p=[].concat(r(s));for(t.push(p),o=0;o<p.length;o++){var f=p[o],d=l.indexOf(f);d>-1&&l.splice(d,1)}s=new Set,a=new Map}else t=[]}return t},c.prototype.createDummyNodesForBendpoints=function(t){for(var e=[],i=t.source,r=this.graphManager.calcLowestCommonAncestor(t.source,t.target),n=0;n<t.bendpoints.length;n++){var o=this.newNode(null);o.setRect(new Point(0,0),new Dimension(1,1)),r.add(o);var s=this.newEdge(null);this.graphManager.add(s,i,o),e.add(o),i=o}return s=this.newEdge(null),this.graphManager.add(s,i,t.target),this.edgeToDummyNodes.set(t,e),t.isInterGraph()?this.graphManager.remove(t):r.remove(t),e},c.prototype.createBendpointsFromDummyNodes=function(){var t=[];t=t.concat(this.graphManager.getAllEdges()),t=[].concat(r(this.edgeToDummyNodes.keys())).concat(t);for(var e=0;e<t.length;e++){var i=t[e];if(i.bendpoints.length>0){for(var n=this.edgeToDummyNodes.get(i),o=0;o<n.length;o++){var s=n[o],h=new l(s.getCenterX(),s.getCenterY()),a=i.bendpoints.get(o);a.x=h.x,a.y=h.y,s.getOwner().remove(s)}this.graphManager.add(i,i.source,i.target)}}},c.transform=function(t,e,i,r){if(null!=i&&null!=r){var n=e;return t<=50?n-=(e-e/i)/50*(50-t):n+=(e*r-e)/50*(t-50),n}var o,s;return t<=50?(o=9*e/500,s=e/10):(o=9*e/50,s=-8*e),o*t+s},c.findCenterOfTree=function(t){var e=[];e=e.concat(t);var i=[],r=new Map,n=!1,o=null;1!=e.length&&2!=e.length||(n=!0,o=e[0]);for(var s=0;s<e.length;s++){var h=(u=e[s]).getNeighborsList().size;r.set(u,u.getNeighborsList().size),1==h&&i.push(u)}var a=[];for(a=a.concat(i);!n;){var l=[];for(l=l.concat(a),a=[],s=0;s<e.length;s++){var u=e[s],g=e.indexOf(u);g>=0&&e.splice(g,1),u.getNeighborsList().forEach((function(t){if(i.indexOf(t)<0){var e=r.get(t)-1;1==e&&a.push(t),r.set(t,e)}}))}i=i.concat(a),1!=e.length&&2!=e.length||(n=!0,o=e[0])}return o},c.prototype.setGraphManager=function(t){this.graphManager=t},t.exports=c},function(t,e,i){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)},t.exports=r},function(t,e,i){var r=i(5);function n(t,e){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}n.prototype.getWorldOrgX=function(){return this.lworldOrgX},n.prototype.setWorldOrgX=function(t){this.lworldOrgX=t},n.prototype.getWorldOrgY=function(){return this.lworldOrgY},n.prototype.setWorldOrgY=function(t){this.lworldOrgY=t},n.prototype.getWorldExtX=function(){return this.lworldExtX},n.prototype.setWorldExtX=function(t){this.lworldExtX=t},n.prototype.getWorldExtY=function(){return this.lworldExtY},n.prototype.setWorldExtY=function(t){this.lworldExtY=t},n.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},n.prototype.setDeviceOrgX=function(t){this.ldeviceOrgX=t},n.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},n.prototype.setDeviceOrgY=function(t){this.ldeviceOrgY=t},n.prototype.getDeviceExtX=function(){return this.ldeviceExtX},n.prototype.setDeviceExtX=function(t){this.ldeviceExtX=t},n.prototype.getDeviceExtY=function(){return this.ldeviceExtY},n.prototype.setDeviceExtY=function(t){this.ldeviceExtY=t},n.prototype.transformX=function(t){var e=0,i=this.lworldExtX;return 0!=i&&(e=this.ldeviceOrgX+(t-this.lworldOrgX)*this.ldeviceExtX/i),e},n.prototype.transformY=function(t){var e=0,i=this.lworldExtY;return 0!=i&&(e=this.ldeviceOrgY+(t-this.lworldOrgY)*this.ldeviceExtY/i),e},n.prototype.inverseTransformX=function(t){var e=0,i=this.ldeviceExtX;return 0!=i&&(e=this.lworldOrgX+(t-this.ldeviceOrgX)*this.lworldExtX/i),e},n.prototype.inverseTransformY=function(t){var e=0,i=this.ldeviceExtY;return 0!=i&&(e=this.lworldOrgY+(t-this.ldeviceOrgY)*this.lworldExtY/i),e},n.prototype.inverseTransformPoint=function(t){return new r(this.inverseTransformX(t.x),this.inverseTransformY(t.y))},t.exports=n},function(t,e,i){var r=i(15),n=i(4),o=i(0),s=i(8),h=i(9);function a(){r.call(this),this.useSmartIdealEdgeLengthCalculation=n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=n.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=n.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=n.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=n.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*n.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=n.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=n.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=n.MAX_ITERATIONS}for(var l in a.prototype=Object.create(r.prototype),r)a[l]=r[l];a.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=n.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},a.prototype.calcIdealEdgeLengths=function(){for(var t,e,i,r,s,h,a,l=this.getGraphManager().getAllEdges(),u=0;u<l.length;u++)e=(t=l[u]).idealLength,t.isInterGraph&&(r=t.getSource(),s=t.getTarget(),h=t.getSourceInLca().getEstimatedSize(),a=t.getTargetInLca().getEstimatedSize(),this.useSmartIdealEdgeLengthCalculation&&(t.idealLength+=h+a-2*o.SIMPLE_NODE_SIZE),i=t.getLca().getInclusionTreeDepth(),t.idealLength+=e*n.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR*(r.getInclusionTreeDepth()+s.getInclusionTreeDepth()-2*i))},a.prototype.initSpringEmbedder=function(){var t=this.getAllNodes().length;this.incremental?(t>n.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*n.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(t-n.ADAPTATION_LOWER_NODE_LIMIT)/(n.ADAPTATION_UPPER_NODE_LIMIT-n.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-n.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=n.MAX_NODE_DISPLACEMENT_INCREMENTAL):(t>n.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(n.COOLING_ADAPTATION_FACTOR,1-(t-n.ADAPTATION_LOWER_NODE_LIMIT)/(n.ADAPTATION_UPPER_NODE_LIMIT-n.ADAPTATION_LOWER_NODE_LIMIT)*(1-n.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=n.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.displacementThresholdPerNode=3*n.DEFAULT_EDGE_LENGTH/100,this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},a.prototype.calcSpringForces=function(){for(var t,e=this.getAllEdges(),i=0;i<e.length;i++)t=e[i],this.calcSpringForce(t,t.idealLength)},a.prototype.calcRepulsionForces=function(){var t,e,i,r,o,s=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],h=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%n.GRID_CALCULATION_CHECK_PERIOD==1&&s&&this.updateGrid(),o=new Set,t=0;t<a.length;t++)i=a[t],this.calculateRepulsionForceOfANode(i,o,s,h),o.add(i);else for(t=0;t<a.length;t++)for(i=a[t],e=t+1;e<a.length;e++)r=a[e],i.getOwner()==r.getOwner()&&this.calcRepulsionForce(i,r)},a.prototype.calcGravitationalForces=function(){for(var t,e=this.getAllNodesToApplyGravitation(),i=0;i<e.length;i++)t=e[i],this.calcGravitationalForce(t)},a.prototype.moveNodes=function(){for(var t=this.getAllNodes(),e=0;e<t.length;e++)t[e].move()},a.prototype.calcSpringForce=function(t,e){var i,r,n,o,s=t.getSource(),h=t.getTarget();if(this.uniformLeafNodeSizes&&null==s.getChild()&&null==h.getChild())t.updateLengthSimple();else if(t.updateLength(),t.isOverlapingSourceAndTarget)return;0!=(i=t.getLength())&&(n=(r=t.edgeElasticity*(i-e))*(t.lengthX/i),o=r*(t.lengthY/i),s.springForceX+=n,s.springForceY+=o,h.springForceX-=n,h.springForceY-=o)},a.prototype.calcRepulsionForce=function(t,e){var i,r,o,a,l,u,g,c=t.getRect(),p=e.getRect(),f=new Array(2),d=new Array(4);if(c.intersects(p)){s.calcSeparationAmount(c,p,f,n.DEFAULT_EDGE_LENGTH/2),u=2*f[0],g=2*f[1];var y=t.noOfChildren*e.noOfChildren/(t.noOfChildren+e.noOfChildren);t.repulsionForceX-=y*u,t.repulsionForceY-=y*g,e.repulsionForceX+=y*u,e.repulsionForceY+=y*g}else this.uniformLeafNodeSizes&&null==t.getChild()&&null==e.getChild()?(i=p.getCenterX()-c.getCenterX(),r=p.getCenterY()-c.getCenterY()):(s.getIntersection(c,p,d),i=d[2]-d[0],r=d[3]-d[1]),Math.abs(i)<n.MIN_REPULSION_DIST&&(i=h.sign(i)*n.MIN_REPULSION_DIST),Math.abs(r)<n.MIN_REPULSION_DIST&&(r=h.sign(r)*n.MIN_REPULSION_DIST),o=i*i+r*r,a=Math.sqrt(o),u=(l=(t.nodeRepulsion/2+e.nodeRepulsion/2)*t.noOfChildren*e.noOfChildren/o)*i/a,g=l*r/a,t.repulsionForceX-=u,t.repulsionForceY-=g,e.repulsionForceX+=u,e.repulsionForceY+=g},a.prototype.calcGravitationalForce=function(t){var e,i,r,n,o,s,h,a;i=((e=t.getOwner()).getRight()+e.getLeft())/2,r=(e.getTop()+e.getBottom())/2,n=t.getCenterX()-i,o=t.getCenterY()-r,s=Math.abs(n)+t.getWidth()/2,h=Math.abs(o)+t.getHeight()/2,t.getOwner()==this.graphManager.getRoot()?(s>(a=e.getEstimatedSize()*this.gravityRangeFactor)||h>a)&&(t.gravitationForceX=-this.gravityConstant*n,t.gravitationForceY=-this.gravityConstant*o):(s>(a=e.getEstimatedSize()*this.compoundGravityRangeFactor)||h>a)&&(t.gravitationForceX=-this.gravityConstant*n*this.compoundGravityConstant,t.gravitationForceY=-this.gravityConstant*o*this.compoundGravityConstant)},a.prototype.isConverged=function(){var t,e=!1;return this.totalIterations>this.maxIterations/3&&(e=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),t=this.totalDisplacement<this.totalDisplacementThreshold,this.oldTotalDisplacement=this.totalDisplacement,t||e},a.prototype.animate=function(){this.animationDuringLayout&&!this.isSubLayout&&(this.notAnimatedIterations==this.animationPeriod?(this.update(),this.notAnimatedIterations=0):this.notAnimatedIterations++)},a.prototype.calcNoOfChildrenForAllNodes=function(){for(var t,e=this.graphManager.getAllNodes(),i=0;i<e.length;i++)(t=e[i]).noOfChildren=t.getNoOfChildren()},a.prototype.calcGrid=function(t){var e,i;e=parseInt(Math.ceil((t.getRight()-t.getLeft())/this.repulsionRange)),i=parseInt(Math.ceil((t.getBottom()-t.getTop())/this.repulsionRange));for(var r=new Array(e),n=0;n<e;n++)r[n]=new Array(i);for(n=0;n<e;n++)for(var o=0;o<i;o++)r[n][o]=new Array;return r},a.prototype.addNodeToGrid=function(t,e,i){var r,n,o,s;r=parseInt(Math.floor((t.getRect().x-e)/this.repulsionRange)),n=parseInt(Math.floor((t.getRect().width+t.getRect().x-e)/this.repulsionRange)),o=parseInt(Math.floor((t.getRect().y-i)/this.repulsionRange)),s=parseInt(Math.floor((t.getRect().height+t.getRect().y-i)/this.repulsionRange));for(var h=r;h<=n;h++)for(var a=o;a<=s;a++)this.grid[h][a].push(t),t.setGridCoordinates(r,n,o,s)},a.prototype.updateGrid=function(){var t,e,i=this.getAllNodes();for(this.grid=this.calcGrid(this.graphManager.getRoot()),t=0;t<i.length;t++)e=i[t],this.addNodeToGrid(e,this.graphManager.getRoot().getLeft(),this.graphManager.getRoot().getTop())},a.prototype.calculateRepulsionForceOfANode=function(t,e,i,r){if(this.totalIterations%n.GRID_CALCULATION_CHECK_PERIOD==1&&i||r){var o,s=new Set;t.surrounding=new Array;for(var h=this.grid,a=t.startX-1;a<t.finishX+2;a++)for(var l=t.startY-1;l<t.finishY+2;l++)if(!(a<0||l<0||a>=h.length||l>=h[0].length))for(var u=0;u<h[a][l].length;u++)if(o=h[a][l][u],t.getOwner()==o.getOwner()&&t!=o&&!e.has(o)&&!s.has(o)){var g=Math.abs(t.getCenterX()-o.getCenterX())-(t.getWidth()/2+o.getWidth()/2),c=Math.abs(t.getCenterY()-o.getCenterY())-(t.getHeight()/2+o.getHeight()/2);g<=this.repulsionRange&&c<=this.repulsionRange&&s.add(o)}t.surrounding=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(s))}for(a=0;a<t.surrounding.length;a++)this.calcRepulsionForce(t,t.surrounding[a])},a.prototype.calcRepulsionRange=function(){return 0},t.exports=a},function(t,e,i){var r=i(1),n=i(4);function o(t,e,i){r.call(this,t,e,i),this.idealLength=n.DEFAULT_EDGE_LENGTH,this.edgeElasticity=n.DEFAULT_SPRING_STRENGTH}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];t.exports=o},function(t,e,i){var r=i(3),n=i(4);function o(t,e,i,o){r.call(this,t,e,i,o),this.nodeRepulsion=n.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 s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.setGridCoordinates=function(t,e,i,r){this.startX=t,this.finishX=e,this.startY=i,this.finishY=r},t.exports=o},function(t,e,i){function r(t,e){this.width=0,this.height=0,null!==t&&null!==e&&(this.height=e,this.width=t)}r.prototype.getWidth=function(){return this.width},r.prototype.setWidth=function(t){this.width=t},r.prototype.getHeight=function(){return this.height},r.prototype.setHeight=function(t){this.height=t},t.exports=r},function(t,e,i){var r=i(14);function n(){this.map={},this.keys=[]}n.prototype.put=function(t,e){var i=r.createID(t);this.contains(i)||(this.map[i]=e,this.keys.push(t))},n.prototype.contains=function(t){return r.createID(t),null!=this.map[t]},n.prototype.get=function(t){var e=r.createID(t);return this.map[e]},n.prototype.keySet=function(){return this.keys},t.exports=n},function(t,e,i){var r=i(14);function n(){this.set={}}n.prototype.add=function(t){var e=r.createID(t);this.contains(e)||(this.set[e]=t)},n.prototype.remove=function(t){delete this.set[r.createID(t)]},n.prototype.clear=function(){this.set={}},n.prototype.contains=function(t){return this.set[r.createID(t)]==t},n.prototype.isEmpty=function(){return 0===this.size()},n.prototype.size=function(){return Object.keys(this.set).length},n.prototype.addAllTo=function(t){for(var e=Object.keys(this.set),i=e.length,r=0;r<i;r++)t.push(this.set[e[r]])},n.prototype.size=function(){return Object.keys(this.set).length},n.prototype.addAll=function(t){for(var e=t.length,i=0;i<e;i++){var r=t[i];this.add(r)}},t.exports=n},function(t,e,i){function r(){}r.multMat=function(t,e){for(var i=[],r=0;r<t.length;r++){i[r]=[];for(var n=0;n<e[0].length;n++){i[r][n]=0;for(var o=0;o<t[0].length;o++)i[r][n]+=t[r][o]*e[o][n]}}return i},r.transpose=function(t){for(var e=[],i=0;i<t[0].length;i++){e[i]=[];for(var r=0;r<t.length;r++)e[i][r]=t[r][i]}return e},r.multCons=function(t,e){for(var i=[],r=0;r<t.length;r++)i[r]=t[r]*e;return i},r.minusOp=function(t,e){for(var i=[],r=0;r<t.length;r++)i[r]=t[r]-e[r];return i},r.dotProduct=function(t,e){for(var i=0,r=0;r<t.length;r++)i+=t[r]*e[r];return i},r.mag=function(t){return Math.sqrt(this.dotProduct(t,t))},r.normalize=function(t){for(var e=[],i=this.mag(t),r=0;r<t.length;r++)e[r]=t[r]/i;return e},r.multGamma=function(t){for(var e=[],i=0,r=0;r<t.length;r++)i+=t[r];i*=-1/t.length;for(var n=0;n<t.length;n++)e[n]=i+t[n];return e},r.multL=function(t,e,i){for(var r=[],n=[],o=[],s=0;s<e[0].length;s++){for(var h=0,a=0;a<e.length;a++)h+=-.5*e[a][s]*t[a];n[s]=h}for(var l=0;l<i.length;l++){for(var u=0,g=0;g<i.length;g++)u+=i[l][g]*n[g];o[l]=u}for(var c=0;c<e.length;c++){for(var p=0,f=0;f<e[0].length;f++)p+=e[c][f]*o[f];r[c]=p}return r},t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=i(11),o=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),null===i&&void 0===i||(this.compareFunction=this._defaultCompareFunction);var r=void 0;r=e instanceof n?e.size():e.length,this._quicksort(e,0,r-1)}return r(t,[{key:"_quicksort",value:function(t,e,i){if(e<i){var r=this._partition(t,e,i);this._quicksort(t,e,r),this._quicksort(t,r+1,i)}}},{key:"_partition",value:function(t,e,i){for(var r=this._get(t,e),n=e,o=i;;){for(;this.compareFunction(r,this._get(t,o));)o--;for(;this.compareFunction(this._get(t,n),r);)n++;if(!(n<o))return o;this._swap(t,n,o),n++,o--}}},{key:"_get",value:function(t,e){return t instanceof n?t.get_object_at(e):t[e]}},{key:"_set",value:function(t,e,i){t instanceof n?t.set_object_at(e,i):t[e]=i}},{key:"_swap",value:function(t,e,i){var r=this._get(t,e);this._set(t,e,this._get(t,i)),this._set(t,i,r)}},{key:"_defaultCompareFunction",value:function(t,e){return e>t}}]),t}();t.exports=o},function(t,e,i){function r(){}r.svd=function(t){this.U=null,this.V=null,this.s=null,this.m=0,this.n=0,this.m=t.length,this.n=t[0].length;var e=Math.min(this.m,this.n);this.s=function(t){for(var e=[];t-- >0;)e.push(0);return e}(Math.min(this.m+1,this.n)),this.U=function t(e){if(0==e.length)return 0;for(var i=[],r=0;r<e[0];r++)i.push(t(e.slice(1)));return i}([this.m,e]),this.V=function(t){return function t(e){if(0==e.length)return 0;for(var i=[],r=0;r<e[0];r++)i.push(t(e.slice(1)));return i}(t)}([this.n,this.n]);for(var i,n,o=function(t){for(var e=[];t-- >0;)e.push(0);return e}(this.n),s=function(t){for(var e=[];t-- >0;)e.push(0);return e}(this.m),h=Math.min(this.m-1,this.n),a=Math.max(0,Math.min(this.n-2,this.m)),l=0;l<Math.max(h,a);l++){if(l<h){this.s[l]=0;for(var u=l;u<this.m;u++)this.s[l]=r.hypot(this.s[l],t[u][l]);if(0!==this.s[l]){t[l][l]<0&&(this.s[l]=-this.s[l]);for(var g=l;g<this.m;g++)t[g][l]/=this.s[l];t[l][l]+=1}this.s[l]=-this.s[l]}for(var c=l+1;c<this.n;c++){if(i=l<h,n=0!==this.s[l],i&&n){for(var p=0,f=l;f<this.m;f++)p+=t[f][l]*t[f][c];p=-p/t[l][l];for(var d=l;d<this.m;d++)t[d][c]+=p*t[d][l]}o[c]=t[l][c]}if(function(t,e){return e}(0,l<h))for(var y=l;y<this.m;y++)this.U[y][l]=t[y][l];if(l<a){o[l]=0;for(var v=l+1;v<this.n;v++)o[l]=r.hypot(o[l],o[v]);if(0!==o[l]){o[l+1]<0&&(o[l]=-o[l]);for(var E=l+1;E<this.n;E++)o[E]/=o[l];o[l+1]+=1}if(o[l]=-o[l],function(t,e){return t&&e}(l+1<this.m,0!==o[l])){for(var A=l+1;A<this.m;A++)s[A]=0;for(var _=l+1;_<this.n;_++)for(var O=l+1;O<this.m;O++)s[O]+=o[_]*t[O][_];for(var m=l+1;m<this.n;m++)for(var N=-o[m]/o[l+1],L=l+1;L<this.m;L++)t[L][m]+=N*s[L]}for(var I=l+1;I<this.n;I++)this.V[I][l]=o[I]}}var T=Math.min(this.n,this.m+1);h<this.n&&(this.s[h]=t[h][h]),this.m<T&&(this.s[T-1]=0),a+1<T&&(o[a]=t[a][T-1]),o[T-1]=0;for(var D=h;D<e;D++){for(var M=0;M<this.m;M++)this.U[M][D]=0;this.U[D][D]=1}for(var w=h-1;w>=0;w--)if(0!==this.s[w]){for(var R=w+1;R<e;R++){for(var x=0,C=w;C<this.m;C++)x+=this.U[C][w]*this.U[C][R];x=-x/this.U[w][w];for(var G=w;G<this.m;G++)this.U[G][R]+=x*this.U[G][w]}for(var U=w;U<this.m;U++)this.U[U][w]=-this.U[U][w];this.U[w][w]=1+this.U[w][w];for(var b=0;b<w-1;b++)this.U[b][w]=0}else{for(var S=0;S<this.m;S++)this.U[S][w]=0;this.U[w][w]=1}for(var F=this.n-1;F>=0;F--){if(function(t,e){return t&&e}(F<a,0!==o[F]))for(var Y=F+1;Y<e;Y++){for(var P=0,X=F+1;X<this.n;X++)P+=this.V[X][F]*this.V[X][Y];P=-P/this.V[F+1][F];for(var k=F+1;k<this.n;k++)this.V[k][Y]+=P*this.V[k][F]}for(var H=0;H<this.n;H++)this.V[H][F]=0;this.V[F][F]=1}for(var V=T-1,B=Math.pow(2,-52),W=Math.pow(2,-966);T>0;){var q=void 0,j=void 0;for(q=T-2;q>=-1&&-1!==q;q--)if(Math.abs(o[q])<=W+B*(Math.abs(this.s[q])+Math.abs(this.s[q+1]))){o[q]=0;break}if(q===T-2)j=4;else{var z=void 0;for(z=T-1;z>=q&&z!==q;z--){var Z=(z!==T?Math.abs(o[z]):0)+(z!==q+1?Math.abs(o[z-1]):0);if(Math.abs(this.s[z])<=W+B*Z){this.s[z]=0;break}}z===q?j=3:z===T-1?j=1:(j=2,q=z)}switch(q++,j){case 1:var Q=o[T-2];o[T-2]=0;for(var K=T-2;K>=q;K--){var J=r.hypot(this.s[K],Q),$=this.s[K]/J,tt=Q/J;this.s[K]=J,K!==q&&(Q=-tt*o[K-1],o[K-1]=$*o[K-1]);for(var et=0;et<this.n;et++)J=$*this.V[et][K]+tt*this.V[et][T-1],this.V[et][T-1]=-tt*this.V[et][K]+$*this.V[et][T-1],this.V[et][K]=J}break;case 2:var it=o[q-1];o[q-1]=0;for(var rt=q;rt<T;rt++){var nt=r.hypot(this.s[rt],it),ot=this.s[rt]/nt,st=it/nt;this.s[rt]=nt,it=-st*o[rt],o[rt]=ot*o[rt];for(var ht=0;ht<this.m;ht++)nt=ot*this.U[ht][rt]+st*this.U[ht][q-1],this.U[ht][q-1]=-st*this.U[ht][rt]+ot*this.U[ht][q-1],this.U[ht][rt]=nt}break;case 3:var at=Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[T-1]),Math.abs(this.s[T-2])),Math.abs(o[T-2])),Math.abs(this.s[q])),Math.abs(o[q])),lt=this.s[T-1]/at,ut=this.s[T-2]/at,gt=o[T-2]/at,ct=this.s[q]/at,pt=o[q]/at,ft=((ut+lt)*(ut-lt)+gt*gt)/2,dt=lt*gt*(lt*gt),yt=0;(function(t,e){return t||e})(0!==ft,0!==dt)&&(yt=Math.sqrt(ft*ft+dt),ft<0&&(yt=-yt),yt=dt/(ft+yt));for(var vt=(ct+lt)*(ct-lt)+yt,Et=ct*pt,At=q;At<T-1;At++){var _t=r.hypot(vt,Et),Ot=vt/_t,mt=Et/_t;At!==q&&(o[At-1]=_t),vt=Ot*this.s[At]+mt*o[At],o[At]=Ot*o[At]-mt*this.s[At],Et=mt*this.s[At+1],this.s[At+1]=Ot*this.s[At+1];for(var Nt=0;Nt<this.n;Nt++)_t=Ot*this.V[Nt][At]+mt*this.V[Nt][At+1],this.V[Nt][At+1]=-mt*this.V[Nt][At]+Ot*this.V[Nt][At+1],this.V[Nt][At]=_t;if(Ot=vt/(_t=r.hypot(vt,Et)),mt=Et/_t,this.s[At]=_t,vt=Ot*o[At]+mt*this.s[At+1],this.s[At+1]=-mt*o[At]+Ot*this.s[At+1],Et=mt*o[At+1],o[At+1]=Ot*o[At+1],At<this.m-1)for(var Lt=0;Lt<this.m;Lt++)_t=Ot*this.U[Lt][At]+mt*this.U[Lt][At+1],this.U[Lt][At+1]=-mt*this.U[Lt][At]+Ot*this.U[Lt][At+1],this.U[Lt][At]=_t}o[T-2]=vt;break;case 4:if(this.s[q]<=0){this.s[q]=this.s[q]<0?-this.s[q]:0;for(var It=0;It<=V;It++)this.V[It][q]=-this.V[It][q]}for(;q<V&&!(this.s[q]>=this.s[q+1]);){var Tt=this.s[q];if(this.s[q]=this.s[q+1],this.s[q+1]=Tt,q<this.n-1)for(var Dt=0;Dt<this.n;Dt++)Tt=this.V[Dt][q+1],this.V[Dt][q+1]=this.V[Dt][q],this.V[Dt][q]=Tt;if(q<this.m-1)for(var Mt=0;Mt<this.m;Mt++)Tt=this.U[Mt][q+1],this.U[Mt][q+1]=this.U[Mt][q],this.U[Mt][q]=Tt;q++}T--}}return{U:this.U,V:this.V,S:this.s}},r.hypot=function(t,e){var i=void 0;return Math.abs(t)>Math.abs(e)?(i=e/t,i=Math.abs(t)*Math.sqrt(1+i*i)):0!=e?(i=t/e,i=Math.abs(e)*Math.sqrt(1+i*i)):i=0,i},t.exports=r},function(t,e,i){var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),n=function(){function t(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sequence1=e,this.sequence2=i,this.match_score=r,this.mismatch_penalty=n,this.gap_penalty=o,this.iMax=e.length+1,this.jMax=i.length+1,this.grid=new Array(this.iMax);for(var s=0;s<this.iMax;s++){this.grid[s]=new Array(this.jMax);for(var h=0;h<this.jMax;h++)this.grid[s][h]=0}this.tracebackGrid=new Array(this.iMax);for(var a=0;a<this.iMax;a++){this.tracebackGrid[a]=new Array(this.jMax);for(var l=0;l<this.jMax;l++)this.tracebackGrid[a][l]=[null,null,null]}this.alignments=[],this.score=-1,this.computeGrids()}return r(t,[{key:"getScore",value:function(){return this.score}},{key:"getAlignments",value:function(){return this.alignments}},{key:"computeGrids",value:function(){for(var t=1;t<this.jMax;t++)this.grid[0][t]=this.grid[0][t-1]+this.gap_penalty,this.tracebackGrid[0][t]=[!1,!1,!0];for(var e=1;e<this.iMax;e++)this.grid[e][0]=this.grid[e-1][0]+this.gap_penalty,this.tracebackGrid[e][0]=[!1,!0,!1];for(var i=1;i<this.iMax;i++)for(var r=1;r<this.jMax;r++){var n=[this.sequence1[i-1]===this.sequence2[r-1]?this.grid[i-1][r-1]+this.match_score:this.grid[i-1][r-1]+this.mismatch_penalty,this.grid[i-1][r]+this.gap_penalty,this.grid[i][r-1]+this.gap_penalty],o=this.arrayAllMaxIndexes(n);this.grid[i][r]=n[o[0]],this.tracebackGrid[i][r]=[o.includes(0),o.includes(1),o.includes(2)]}this.score=this.grid[this.iMax-1][this.jMax-1]}},{key:"alignmentTraceback",value:function(){var t=[];for(t.push({pos:[this.sequence1.length,this.sequence2.length],seq1:"",seq2:""});t[0];){var e=t[0],i=this.tracebackGrid[e.pos[0]][e.pos[1]];i[0]&&t.push({pos:[e.pos[0]-1,e.pos[1]-1],seq1:this.sequence1[e.pos[0]-1]+e.seq1,seq2:this.sequence2[e.pos[1]-1]+e.seq2}),i[1]&&t.push({pos:[e.pos[0]-1,e.pos[1]],seq1:this.sequence1[e.pos[0]-1]+e.seq1,seq2:"-"+e.seq2}),i[2]&&t.push({pos:[e.pos[0],e.pos[1]-1],seq1:"-"+e.seq1,seq2:this.sequence2[e.pos[1]-1]+e.seq2}),0===e.pos[0]&&0===e.pos[1]&&this.alignments.push({sequence1:e.seq1,sequence2:e.seq2}),t.shift()}return this.alignments}},{key:"getAllIndexes",value:function(t,e){for(var i=[],r=-1;-1!==(r=t.indexOf(e,r+1));)i.push(r);return i}},{key:"arrayAllMaxIndexes",value:function(t){return this.getAllIndexes(t,Math.max.apply(null,t))}}]),t}();t.exports=n},function(t,e,i){var r=function(){};r.FDLayout=i(18),r.FDLayoutConstants=i(4),r.FDLayoutEdge=i(19),r.FDLayoutNode=i(20),r.DimensionD=i(21),r.HashMap=i(22),r.HashSet=i(23),r.IGeometry=i(8),r.IMath=i(9),r.Integer=i(10),r.Point=i(12),r.PointD=i(5),r.RandomSeed=i(16),r.RectangleD=i(13),r.Transform=i(17),r.UniqueIDGeneretor=i(14),r.Quicksort=i(25),r.LinkedList=i(11),r.LGraphObject=i(2),r.LGraph=i(6),r.LEdge=i(1),r.LGraphManager=i(7),r.LNode=i(3),r.Layout=i(15),r.LayoutConstants=i(0),r.NeedlemanWunsch=i(27),r.Matrix=i(24),r.SVD=i(26),t.exports=r},function(t,e,i){function r(){this.listeners=[]}var n=r.prototype;n.addListener=function(t,e){this.listeners.push({event:t,callback:e})},n.removeListener=function(t,e){for(var i=this.listeners.length;i>=0;i--){var r=this.listeners[i];r.event===t&&r.callback===e&&this.listeners.splice(i,1)}},n.emit=function(t,e){for(var i=0;i<this.listeners.length;i++){var r=this.listeners[i];t===r.event&&r.callback(e)}},t.exports=r}])},r.exports=n()),i.__module.exports;var r,n};
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Exports the same sanitized response used by HTML/PDF as editable Word content.
3
- * Parsing stays in an inert template. No response scripts, remote image fetches,
4
- * live chat DOM, or existing artifact-export code are used.
3
+ * Parsing stays in an inert template. Images are copied with bounded anonymous
4
+ * requests; response scripts and the live chat DOM are never used.
5
5
  */
6
6
  export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;
@@ -0,0 +1,3 @@
1
+ /** Only modifies an inert export copy. Never reads or changes live chat images. */
2
+ export declare const embedResponseDownloadImages: (root: ParentNode, format: "docx" | "html") => Promise<Set<Element>>;
3
+ export declare const embedResponseDownloadHtmlImages: (html: string) => Promise<string>;
@@ -4,6 +4,13 @@ type SmartQuotesNode = {
4
4
  children?: SmartQuotesNode[];
5
5
  };
6
6
  export declare const remarkSmartQuotes: () => (tree: SmartQuotesNode) => void;
7
+ /**
8
+ * Keep raw HTML backwards compatible, but render document-scoped CSS as code.
9
+ * Styled HTML that needs its own document belongs in the artifact iframe.
10
+ */
11
+ export declare const remarkDocumentCssAsCode: (options?: {
12
+ disableCss?: boolean;
13
+ }) => (tree: any) => void;
7
14
  export declare const rehypeSanitize: (options?: {
8
15
  disableJs?: boolean;
9
16
  disableCss?: boolean;
@@ -1 +1 @@
1
- import{v4 as e}from"uuid";import{artifactStyleProperties as t}from"./responseArtifactStyles.js";import{artifactSvgSnapshotScript as n}from"./responseArtifactSvg.js";const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', () => { failed = true; }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`,i=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),h=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},g=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),h(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(g(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(g(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):h())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;h(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(h(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));export{i as renderResponseArtifactHtml};
1
+ import{v4 as e}from"uuid";import{artifactStyleProperties as t}from"./responseArtifactStyles.js";import{artifactSvgSnapshotScript as n}from"./responseArtifactSvg.js";const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', event => {\n // Missing images use the export's image fallback, not a fatal capture error.\n // Script errors (including errors thrown by image handlers) still fail.\n if (event.target instanceof HTMLImageElement) return;\n failed = true;\n }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`,i=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),g=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},h=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),g(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(h(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(h(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):g())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;g(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(g(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));export{i as renderResponseArtifactHtml};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";const o=(o,r)=>t(void 0,void 0,void 0,(function*(){const t=e(`<div class="pxe-export-artifact">${o}</div>`,!0),n=(new DOMParser).parseFromString(t,"text/html");for(const t of n.querySelectorAll("img"))if(!/^data:image\/(png|jpeg|gif);base64,/i.test(t.getAttribute("src")||""))throw new Error("Word artifact pictures require self-contained images.");const i=document.createElement("iframe");i.setAttribute("sandbox","allow-same-origin"),i.setAttribute("aria-hidden","true"),i.tabIndex=-1,i.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((e,o)=>{const r=setTimeout((()=>o(new Error("Word snapshot timed out."))),5e3);i.onload=()=>{clearTimeout(r),e()},i.onerror=()=>{clearTimeout(r),o(new Error("Word snapshot failed."))},i.srcdoc=t,document.body.appendChild(i)}));const e=i.contentDocument,o=i.contentWindow,n=null==e?void 0:e.querySelector("main");if(!e||!o||!n)throw new Error("Word snapshot unavailable.");const a=e.createElement("style");a.textContent="main{width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",e.head.appendChild(a),e.querySelectorAll("details").forEach((t=>{t.open=!0}));const l=Math.ceil(Math.max(n.scrollWidth,n.getBoundingClientRect().width)),c=Math.ceil(n.getBoundingClientRect().height);if(l>1440||!c||c>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=n.cloneNode(!0),d=[n,...n.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((t,e)=>{const r=h[e],n=o.getComputedStyle(t);r.removeAttribute("style");for(const t of Array.from(n))r.style.setProperty(t,n.getPropertyValue(t))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const p=(new XMLSerializer).serializeToString(s);if(p.length>1e7)throw new Error("Word snapshot is too large.");const m=n.getBoundingClientRect().top,g=[],w=e.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(;w.nextNode();){const t=e.createRange();t.selectNodeContents(w.currentNode);for(const e of Array.from(t.getClientRects()))e.height&&g.push({top:e.top-m,bottom:e.bottom-m})}n.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&g.push({top:e.top-m,bottom:e.bottom-m})}));const f=[];let u=0;for(let t=0;t<c;){let o=Math.min(c,t+800);if(o<c)for(let e=0;e<g.length;e++){const e=g.find((t=>t.top+1<o&&t.bottom-1>o));if(!e||e.top<=t)break;o=Math.ceil(e.top)}if(o<=t)throw new Error("Unable to paginate artifact picture.");const n=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${o-t}" viewBox="0 ${t} ${l} ${o-t}"><foreignObject x="0" y="0" width="${l}" height="${c}">${p}</foreignObject></svg>`,i=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>r(!1)),5e3),r=r=>{clearTimeout(o),i.onload=i.onerror=null,r?t():e(new Error("Unable to draw Word artifact picture."))};i.onload=()=>r(!0),i.onerror=()=>r(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}));const a=document.createElement("canvas");a.width=2*l,a.height=2*(o-t);const s=a.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,a.width,a.height),s.drawImage(i,0,0,a.width,a.height);const d=a.toDataURL("image/png");if(u+=d.length,u>1e7)throw new Error("Word artifact pictures are too large.");const h=e.createElement("img");h.src=d,h.width=l,h.height=o-t,h.alt=r;const m=e.createElement("p");m.appendChild(h),f.push(m.outerHTML),a.width=a.height=0,i.removeAttribute("src"),t=o}return f.join("")}finally{i.remove()}}));export{o as createResponseArtifactWordImages};
1
+ import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as o}from"./responseDownloadImages.js";const r=(r,n)=>t(void 0,void 0,void 0,(function*(){var t;let i=e(`<div class="pxe-export-artifact">${r}</div>`,!0);const a=document.createElement("template");a.innerHTML=i;const l=yield o(a.content,"docx");for(const e of a.content.querySelectorAll("img")){if(l.has(e))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(t=e.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,e.replaceWith(o)}i=`<!doctype html>\n${a.innerHTML}`;const c=document.createElement("iframe");c.setAttribute("sandbox","allow-same-origin"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((t,e)=>{const o=setTimeout((()=>e(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),t()},c.onerror=()=>{clearTimeout(o),e(new Error("Word snapshot failed."))},c.srcdoc=i,document.body.appendChild(c)}));const t=c.contentDocument,e=c.contentWindow,o=null==t?void 0:t.querySelector("main");if(!t||!e||!o)throw new Error("Word snapshot unavailable.");const r=t.createElement("style");r.textContent="main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",t.head.appendChild(r),t.querySelectorAll("details").forEach((t=>{t.open=!0}));const a=Math.ceil(Math.max(o.scrollWidth,o.getBoundingClientRect().width)),l=Math.ceil(o.getBoundingClientRect().height);if(a>1440||!l||l>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=o.cloneNode(!0),d=[o,...o.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((t,o)=>{const r=h[o],n=e.getComputedStyle(t);r.removeAttribute("style");for(const t of Array.from(n))r.style.setProperty(t,n.getPropertyValue(t))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const m=(new XMLSerializer).serializeToString(s);if(m.length>1e7)throw new Error("Word snapshot is too large.");const p=o.getBoundingClientRect().top,w=[],g=t.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;g.nextNode();){const e=t.createRange();e.selectNodeContents(g.currentNode);for(const t of Array.from(e.getClientRects()))t.height&&w.push({top:t.top-p,bottom:t.bottom-p})}o.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&w.push({top:e.top-p,bottom:e.bottom-p})}));const u=[];let f=0;for(let e=0;e<l;){let o=Math.min(l,e+800);if(o<l)for(let t=0;t<w.length;t++){const t=w.find((t=>t.top+1<o&&t.bottom-1>o));if(!t||t.top<=e)break;o=Math.ceil(t.top)}if(o<=e)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o-e}" viewBox="0 ${e} ${a} ${o-e}"><foreignObject x="0" y="0" width="${a}" height="${l}">${m}</foreignObject></svg>`,i=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>n(!1)),5e3),n=r=>{clearTimeout(o),i.onload=i.onerror=null,r?t():e(new Error("Unable to draw Word artifact picture."))};i.onload=()=>n(!0),i.onerror=()=>n(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const c=document.createElement("canvas");c.width=2*a,c.height=2*(o-e);const s=c.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,c.width,c.height),s.drawImage(i,0,0,c.width,c.height);const d=c.toDataURL("image/png");if(f+=d.length,f>1e7)throw new Error("Word artifact pictures are too large.");const h=t.createElement("img");h.src=d,h.width=a,h.height=o-e,h.alt=n;const p=t.createElement("p");p.appendChild(h),u.push(p.outerHTML),c.width=c.height=0,i.removeAttribute("src"),e=o}return u.join("")}finally{c.remove()}}));export{r as createResponseArtifactWordImages};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as g,WidthType as m,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";const w=720,A=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),N=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},O=(e,t)=>{const r=Object.assign({},t);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:l.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r},E=(E,I)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=I?I:f(E);const y=e.content.querySelector("main");if(!y)throw new Error("Unable to prepare the response document.");const T=new Map;for(const e of y.querySelectorAll('.pxe-export-artifact img[src^="data:image/png;base64,"]')){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const i=n.getUint32(16),a=n.getUint32(20);if(!i||!a||i*a>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,r)=>{const n=new Image,s=t=>{clearTimeout(o),n.onload=n.onerror=null,n.removeAttribute("src"),t?e():r(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);n.onload=()=>s(n.naturalWidth===i&&n.naturalHeight===a),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/i):1;T.set(e,{data:r,width:i*o,height:a*o})}const j=[],v=(e,t,r)=>Array.from(e).flatMap((e=>{var n;if(3===e.nodeType){const r=e.textContent||"";return[new i(Object.assign(Object.assign({},t),{text:(null===(n=e.parentElement)||void 0===n?void 0:n.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const a=e,s=O(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=T.get(a);if(e){const t=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new c(Object.assign(Object.assign({type:"png",data:e.data},a.getAttribute("alt")?{altText:{name:a.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*t,height:e.height*t}}))]}const n=N(a.getAttribute("src")),s=a.getAttribute("alt")||n||"[…]",o=[new i(Object.assign(Object.assign({},t),{text:s}))];return n&&!a.closest("a")?[new d({link:n,children:o})]:o}const o="A"===a.tagName?N(a.getAttribute("href")):void 0,u=v(a.childNodes,o?Object.assign(Object.assign({},s),{color:"174EA6",underline:{type:l.SINGLE}}):s,r);return o?[new d({link:o,children:u})]:u})),S=(e,t,n={})=>{const i=t.marker&&!t.marker.used?t.marker:void 0;return i&&(i.used=!0),new r(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},t.indent?{indent:Object.assign({left:t.indent},i?{hanging:360}:{})}:{}),null==i?void 0:i.properties),n))},D=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${j.length}`,a=0===e,j.push({reference:i,levels:[{level:0,format:p.DECIMAL,text:a?"0.":"%1.",start:a?1:e,alignment:b.LEFT}]})},o=e.hasAttribute("reversed"),l=Array.from(e.children).filter((e=>"LI"===e.tagName)),c=Number.parseInt(e.getAttribute("start")||"",10);let d=Number.isFinite(c)?c:o?l.length:1;n&&s(d);const u=[];for(const l of Array.from(e.children)){if("LI"!==l.tagName){u.push(...k([l],t));continue}const e=Number.parseInt(l.getAttribute("value")||"",10);n&&Number.isFinite(e)&&(d=e),n&&(o||a||0===d||Number.isFinite(e))&&s(d),d+=o?-1:1;const c=Object.assign(Object.assign({},t),{indent:Math.min(t.indent+720,5760),marker:{used:!1,properties:n?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),g=k(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||g.unshift(S([],c)),u.push(...g)}return u},H=(e,t)=>{const n=[];let i=0;const a=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let r=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;n[r]>t;)r++;const a=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=a("colspan"),o=a("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return i=Math.max(i,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*t/i),o=Array.from({length:i},((e,t)=>s(t+1)-s(t))),l=a.flatMap((({row:e,cells:t})=>{var n;return t.length?[new u({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||t.every((({cell:e})=>"TH"===e.tagName)),children:t.map((({cell:e,start:t,columnSpan:n,rowSpan:i})=>{const a=s(t+n)-s(t),o=k(e.childNodes,{indent:0,width:Math.max(1,a-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof r||o.push(new r("")),new g(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:m.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...k(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:m.DXA},columnWidths:o})]:k(e.childNodes,{indent:0,width:t,run:{}})},k=(e,t)=>{const r=[];let n=[];const l=()=>{n.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(S(v(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!A.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>A.has(e.tagName)))?(l(),r.push(...k(c.childNodes,Object.assign(Object.assign({},t),{run:O(c,t.run)})))):n.push(c);continue}l();const e=c,d=e.tagName;if("UL"===d||"OL"===d)t.marker&&!t.marker.used&&r.push(S([],t)),r.push(...D(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(S([],t)),r.push(...H(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(S(n.map(((e,r)=>new i(Object.assign(Object.assign(Object.assign({},t.run),{children:e.split("\t").flatMap(((e,t)=>t?[new a,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),t,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(d)){const n=[s.HEADING_1,s.HEADING_2,s.HEADING_3,s.HEADING_4,s.HEADING_5,s.HEADING_6];r.push(S(v(e.childNodes,Object.assign(Object.assign({},t.run),{bold:!0,color:"202020"}),t.width-t.indent),t,{heading:n[Number(d[1])-1],keepNext:!0}))}else if("HR"===d)r.push(S([],t,{border:{bottom:{style:o.SINGLE,color:"CCCCCC",size:4}}}));else{const n="BLOCKQUOTE"===d?Object.assign(Object.assign({},t),{indent:t.indent+360}):t,i=k(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(S([],n))}}return l(),r},L=k(y.childNodes,{indent:0,width:10800,run:{}}),M=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:j},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:w,bottom:w,left:w,right:w}}},children:L.length?L:[new r("")]}]});return n.toBlob(M)}));export{E as createResponseDownloadDocx};
1
+ import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as m,WidthType as g,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as w}from"./responseDownloadImages.js";const A=720,N=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),O=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},E=(e,t)=>{const r=Object.assign({},t);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:l.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r},I=(I,j)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=j?j:f(I);const y=e.content.querySelector("main");if(!y)throw new Error("Unable to prepare the response document.");const T=yield w(y,"docx"),v=new Map;for(const e of T){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const i=n.getUint32(16),a=n.getUint32(20);if(!i||!a||i*a>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,r)=>{const n=new Image,s=t=>{clearTimeout(o),n.onload=n.onerror=null,n.removeAttribute("src"),t?e():r(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);n.onload=()=>s(n.naturalWidth===i&&n.naturalHeight===a),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/i):1;v.set(e,{data:r,width:i*o,height:a*o})}const D=[],S=(e,t,r)=>Array.from(e).flatMap((e=>{var n;if(3===e.nodeType){const r=e.textContent||"";return[new i(Object.assign(Object.assign({},t),{text:(null===(n=e.parentElement)||void 0===n?void 0:n.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const a=e,s=E(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=v.get(a);if(e){const t=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new c(Object.assign(Object.assign({type:"png",data:e.data},a.getAttribute("alt")?{altText:{name:a.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*t,height:e.height*t}}))]}const n=O(a.getAttribute("src")),s=a.getAttribute("alt")||n||"[…]",o=[new i(Object.assign(Object.assign({},t),{text:s}))];return n&&!a.closest("a")?[new d({link:n,children:o})]:o}const o="A"===a.tagName?O(a.getAttribute("href")):void 0,u=S(a.childNodes,o?Object.assign(Object.assign({},s),{color:"174EA6",underline:{type:l.SINGLE}}):s,r);return o?[new d({link:o,children:u})]:u})),H=(e,t,n={})=>{const i=t.marker&&!t.marker.used?t.marker:void 0;return i&&(i.used=!0),new r(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},t.indent?{indent:Object.assign({left:t.indent},i?{hanging:360}:{})}:{}),null==i?void 0:i.properties),n))},k=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${D.length}`,a=0===e,D.push({reference:i,levels:[{level:0,format:p.DECIMAL,text:a?"0.":"%1.",start:a?1:e,alignment:b.LEFT}]})},o=e.hasAttribute("reversed"),l=Array.from(e.children).filter((e=>"LI"===e.tagName)),c=Number.parseInt(e.getAttribute("start")||"",10);let d=Number.isFinite(c)?c:o?l.length:1;n&&s(d);const u=[];for(const l of Array.from(e.children)){if("LI"!==l.tagName){u.push(...M([l],t));continue}const e=Number.parseInt(l.getAttribute("value")||"",10);n&&Number.isFinite(e)&&(d=e),n&&(o||a||0===d||Number.isFinite(e))&&s(d),d+=o?-1:1;const c=Object.assign(Object.assign({},t),{indent:Math.min(t.indent+720,5760),marker:{used:!1,properties:n?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),m=M(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||m.unshift(H([],c)),u.push(...m)}return u},L=(e,t)=>{const n=[];let i=0;const a=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let r=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;n[r]>t;)r++;const a=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=a("colspan"),o=a("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return i=Math.max(i,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*t/i),o=Array.from({length:i},((e,t)=>s(t+1)-s(t))),l=a.flatMap((({row:e,cells:t})=>{var n;return t.length?[new u({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||t.every((({cell:e})=>"TH"===e.tagName)),children:t.map((({cell:e,start:t,columnSpan:n,rowSpan:i})=>{const a=s(t+n)-s(t),o=M(e.childNodes,{indent:0,width:Math.max(1,a-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof r||o.push(new r("")),new m(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:g.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...M(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:g.DXA},columnWidths:o})]:M(e.childNodes,{indent:0,width:t,run:{}})},M=(e,t)=>{const r=[];let n=[];const l=()=>{n.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(H(S(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!N.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>N.has(e.tagName)))?(l(),r.push(...M(c.childNodes,Object.assign(Object.assign({},t),{run:E(c,t.run)})))):n.push(c);continue}l();const e=c,d=e.tagName;if("UL"===d||"OL"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...k(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...L(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(H(n.map(((e,r)=>new i(Object.assign(Object.assign(Object.assign({},t.run),{children:e.split("\t").flatMap(((e,t)=>t?[new a,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),t,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(d)){const n=[s.HEADING_1,s.HEADING_2,s.HEADING_3,s.HEADING_4,s.HEADING_5,s.HEADING_6];r.push(H(S(e.childNodes,Object.assign(Object.assign({},t.run),{bold:!0,color:"202020"}),t.width-t.indent),t,{heading:n[Number(d[1])-1],keepNext:!0}))}else if("HR"===d)r.push(H([],t,{border:{bottom:{style:o.SINGLE,color:"CCCCCC",size:4}}}));else{const n="BLOCKQUOTE"===d?Object.assign(Object.assign({},t),{indent:t.indent+360}):t,i=M(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(H([],n))}}return l(),r},C=M(y.childNodes,{indent:0,width:10800,run:{}}),U=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:D},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:A,bottom:A,left:A,right:A}}},children:C.length?C:[new r("")]}]});return n.toBlob(U)}));export{I as createResponseDownloadDocx};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import o from"react-markdown";import n from"remark-gfm";import i from"rehype-raw";import a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";const p=e=>{const a=r(t(o,{remarkPlugins:[n],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},e));return d(a)},d=(e,t=!1)=>{let r=a.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},c=e=>s(p(e)),s=(t,r)=>e(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const o=r.createElement("style");if(o.media="print",o.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(o),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield h(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),h=(t,r)=>new Promise(((o,n)=>{const i=window.setTimeout((()=>p(new Error("Response print images did not finish loading."))),15e3),a=window.setInterval((()=>{t.closed&&p(new Error("The response print window was closed."))}),100);let l=!1;function p(e){l||(l=!0,window.clearTimeout(i),window.clearInterval(a),e?n(e):o())}Promise.all([...Array.from(r.images,(t=>e(void 0,void 0,void 0,(function*(){if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.")})))),r.fonts.ready]).then((()=>p()),(()=>p(new Error("Unable to load the response print resources."))))}));export{d as createResponseDownloadDocument,p as createResponseDownloadHtml,s as printResponseDownloadDocument,c as printResponseDownloadHtml};
1
+ import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import o from"react-markdown";import n from"remark-gfm";import i from"rehype-raw";import a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";const p=e=>{const a=r(t(o,{remarkPlugins:[n],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},e));return c(a)},c=(e,t=!1)=>{let r=a.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},d=e=>s(p(e)),s=(t,r)=>e(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const o=r.createElement("style");if(o.media="print",o.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(o),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield m(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),m=(t,r)=>new Promise(((o,n)=>{const i=new Set(Array.from(r.images)),a=e=>{if(c)return;i.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{i.forEach(a),d()}),15e3),p=window.setInterval((()=>{t.closed&&d(new Error("The response print window was closed."))}),100);let c=!1;function d(e){c||(c=!0,window.clearTimeout(l),window.clearInterval(p),e?n(e):o())}Promise.all([...Array.from(i,(t=>e(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");i.delete(t)}catch(e){a(t)}})))),r.fonts.ready]).then((()=>d()),(()=>d(new Error("Unable to load the response print resources."))))}));export{c as createResponseDownloadDocument,p as createResponseDownloadHtml,s as printResponseDownloadDocument,d as printResponseDownloadHtml};
@@ -0,0 +1 @@
1
+ import{__awaiter as e}from"../_virtual/_tslib.js";const t=75e5,r=25e6,n=e=>{if(/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e))return e.length<=105e5?e:void 0;try{const t=new URL(e);if(!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&t.origin===location.origin))return t.href}catch(e){}},o=(e,t)=>new Promise(((r,n)=>{const o=new Image,i=e=>{o.onload=o.onerror=null,t.removeEventListener("abort",l),e&&o.naturalWidth&&o.naturalHeight?r(o):(o.removeAttribute("src"),n(new Error("Image unavailable.")))},l=()=>i(!1);if(t.aborted)return l();t.addEventListener("abort",l,{once:!0}),o.referrerPolicy="no-referrer",o.onload=()=>i(!0),o.onerror=()=>i(!1),o.src=e})),i=(i,l)=>e(void 0,void 0,void 0,(function*(){const a=Array.from(i.querySelectorAll("img")),c=new Set,s=new AbortController,d=setTimeout((()=>s.abort()),15e3),u=new Map;let m=0,g=0;const h=n=>e(void 0,void 0,void 0,(function*(){let i,a;try{if(s.signal.aborted)return;const c=yield((r,n)=>e(void 0,void 0,void 0,(function*(){var e;const o=yield fetch(r,{signal:n,credentials:"omit",referrerPolicy:"no-referrer"});if(!o.ok||!o.body)throw new Error("Image unavailable.");const i=null===(e=o.headers.get("content-type"))||void 0===e?void 0:e.split(";")[0].trim();if(!i||!/^image\/(png|jpeg|gif|webp|svg\+xml)$/i.test(i)||Number(o.headers.get("content-length"))>t)throw yield o.body.cancel(),new Error("Unsupported image.");const l=o.body.getReader(),a=[];let c=0;try{for(;;){const{done:e,value:r}=yield l.read();if(e)break;if(c+=r.byteLength,c>t)throw new Error("Image too large.");a.push(r)}}finally{yield l.cancel()}return new Blob(a,{type:i})})))(n,s.signal);if(m+=c.size,m>r)return;if(i=URL.createObjectURL(c),a=yield o(i,s.signal),a.naturalWidth*a.naturalHeight>16e6)return;if("docx"===l||"image/svg+xml"===c.type){const e=document.createElement("canvas");try{e.width=a.naturalWidth,e.height=a.naturalHeight;const t=e.getContext("2d");if(!t)return;t.drawImage(a,0,0);const n=e.toDataURL("image/png");if(m+=n.length,n.length>1e7||m>r)return;return n}finally{e.width=e.height=0}}const d=new Uint8Array(yield c.arrayBuffer());let u="";for(let e=0;e<d.length;e+=8192)u+=String.fromCharCode(...d.subarray(e,e+8192));return`data:${c.type};base64,${btoa(u)}`}catch(e){return}finally{null==a||a.removeAttribute("src"),i&&URL.revokeObjectURL(i)}}));try{yield Promise.all(Array.from({length:Math.min(4,a.length)},(()=>e(void 0,void 0,void 0,(function*(){for(var e,t;g<a.length;){const r=a[g++],i=n(r.getAttribute("src")||"");let d;if(i&&(u.has(i)||u.size<50)&&(u.has(i)||u.set(i,h(i)),d=yield u.get(i)),d)c.add(r),r.setAttribute("src",d),r.removeAttribute("srcset");else if("html"===l&&(null==i?void 0:i.startsWith("https:")))try{(yield o(i,s.signal)).removeAttribute("src");continue}catch(t){const n=document.createElement("span");n.textContent=`⚠ ${(null===(e=r.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,r.replaceWith(n)}else if("html"===l){const e=document.createElement("span");e.textContent=`⚠ ${(null===(t=r.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,r.replaceWith(e)}}})))))}finally{clearTimeout(d),s.abort()}return c})),l=t=>e(void 0,void 0,void 0,(function*(){const e=(new DOMParser).parseFromString(t,"text/html");yield i(e,"html");for(const t of e.querySelectorAll("iframe[srcdoc]")){const e=t.getAttribute("srcdoc");if(e){const r=(new DOMParser).parseFromString(e,"text/html");yield i(r,"html"),t.setAttribute("srcdoc",`<!doctype html>\n${r.documentElement.outerHTML}`)}}return`<!doctype html>\n${e.documentElement.outerHTML}`}));export{l as embedResponseDownloadHtmlImages,i as embedResponseDownloadImages};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{printResponseDownloadDocument as c,printResponseDownloadHtml as u,createResponseDownloadHtml as m}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as p,prepareResponseArtifactDownload as f}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as x}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as h}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as b}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as w}from"../../../hooks/core/useOutsideAlerter.js";import g from"../../Icons/download.svg.js";import k from"../../Core/Menu/index.js";import j from"../../Core/Menu/List.js";const A=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:C,disabled:D=!1})=>{const{translations:O,colors:S,styles:P,isRtl:M,sender:N,senderType:I,pickaxe:$}=b(),{artifacts:B=[]}=x(),{token:E}=y(),F=h(),[L,_]=n(""),[H,K]=n(!1),[R,U]=n(),[X,W]=n(!1),q=r(!1),z=r(null),G=r(null),J=r([]),Q=r(0),V=(null==O?void 0:O.download)||"Download",Y=D||X||!C.trim();i((()=>{_(`response-download-${l()}`)}),[]),i((()=>{Y&&K(!1)}),[Y]),i((()=>{H&&z.current&&U(getComputedStyle(z.current).fontFamily)}),[H,P.font]),w({ref:[z,G],callback:()=>K(!1)});const Z=()=>{var e;K(!1),null===(e=z.current)||void 0===e||e.focus({preventScroll:!0})},ee=e=>{var o;if(!Y)if("Escape"===e.key&&H)e.preventDefault(),e.stopPropagation(),Z();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=J.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=A.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;Q.current=i,K(!0),null===(o=J.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&K(!1)},oe=e=>{e.relatedTarget===z.current||J.current.some((o=>o===e.relatedTarget))||K(!1)};return o(k,Object.assign({id:L,className:"h-4 w-4 shrink-0",isOpen:H&&!Y,onChange:K,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:z,id:L||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:T},title:V,"aria-label":V,"aria-haspopup":"menu","aria-busy":X,"aria-expanded":H&&!Y,"aria-controls":H&&!Y?`${L}-menu`:void 0,disabled:Y,onClick:e=>{e.stopPropagation(),Q.current=0,K((e=>!e))},onKeyDown:ee,onBlur:oe},{children:t(g,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),L&&!Y&&s(t("div",Object.assign({ref:G,style:{fontFamily:R},dir:M?"rtl":"ltr"},{children:t(j,Object.assign({id:`${L}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:S.primary,color:S.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=J.current[Q.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:A.map(((o,n)=>t("button",Object.assign({ref:e=>{J.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Y||q.current)return;let r;Z();try{const o=p(C);let i;if(o.length){if(q.current=!0,W(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==O?void 0:O.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield f(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=B.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:F.mutateAsync({artifactId:o.id,version:o.version,studioId:null==$?void 0:$.studioid,senderType:I,sender:N||void 0,studioSessionToken:E||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){q.current=!0,W(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return q.current=!0,W(!0),void(i?yield c(i,r):yield u(C));const s=null!=i?i:"html"===t.extension?m(C):C,l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==O?void 0:O["something-went-wrong"])||"Something went wrong.")}finally{q.current=!1,W(!1)}}))})(t,o)},onKeyDown:ee,onBlur:oe},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as x}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../Icons/download.svg.js";import j from"../../Core/Menu/index.js";import A from"../../Core/Menu/List.js";const D=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:C,disabled:O=!1})=>{const{translations:S,colors:P,styles:I,isRtl:M,sender:N,senderType:$,pickaxe:B}=w(),{artifacts:E=[]}=h(),{token:F}=b(),L=y(),[_,H]=n(""),[K,R]=n(!1),[U,X]=n(),[W,q]=n(!1),z=r(!1),G=r(null),J=r(null),Q=r([]),V=r(0),Y=(null==S?void 0:S.download)||"Download",Z=O||W||!C.trim();i((()=>{H(`response-download-${l()}`)}),[]),i((()=>{Z&&R(!1)}),[Z]),i((()=>{K&&G.current&&X(getComputedStyle(G.current).fontFamily)}),[K,I.font]),g({ref:[G,J],callback:()=>R(!1)});const ee=()=>{var e;R(!1),null===(e=G.current)||void 0===e||e.focus({preventScroll:!0})},oe=e=>{var o;if(!Z)if("Escape"===e.key&&K)e.preventDefault(),e.stopPropagation(),ee();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=Q.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;V.current=i,R(!0),null===(o=Q.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&R(!1)},te=e=>{e.relatedTarget===G.current||Q.current.some((o=>o===e.relatedTarget))||R(!1)};return o(j,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:K&&!Z,onChange:R,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:G,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:T},title:Y,"aria-label":Y,"aria-haspopup":"menu","aria-busy":W,"aria-expanded":K&&!Z,"aria-controls":K&&!Z?`${_}-menu`:void 0,disabled:Z,onClick:e=>{e.stopPropagation(),V.current=0,R((e=>!e))},onKeyDown:oe,onBlur:te},{children:t(k,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!Z&&s(t("div",Object.assign({ref:J,style:{fontFamily:U},dir:M?"rtl":"ltr"},{children:t(A,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:P.primary,color:P.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=Q.current[V.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{Q.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Z||z.current)return;let r;ee();try{const o=f(C);let i;if(o.length){if(z.current=!0,q(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==S?void 0:S.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield x(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=E.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:L.mutateAsync({artifactId:o.id,version:o.version,studioId:null==B?void 0:B.studioid,senderType:$,sender:N||void 0,studioSessionToken:F||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){z.current=!0,q(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return z.current=!0,q(!0),void(i?yield u(i,r):yield m(C));let s=null!=i?i:"html"===t.extension?p(C):C;"html"===t.extension&&(z.current=!0,q(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==S?void 0:S["something-went-wrong"])||"Something went wrong.")}finally{z.current=!1,q(!1)}}))})(t,o)},onKeyDown:oe,onBlur:te},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as r,jsxs as n}from"react/jsx-runtime";import{useState as t,useRef as s,useMemo as i,useEffect as o}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import{remarkSmartQuotes as a,rehypeCode as c,rehypeSanitize as p}from"./utils/custom-plugins.js";import m from"react-markdown";import d from"remark-gfm";import f from"remark-math";import h from"rehype-katex";import u from"rehype-raw";import{A as g}from"./Components/A/index.js";import x,{getFilePreviewInfo as w,shouldSuppressRichPreviewForUrl as b,shouldRenderFilePreview as j}from"./Components/A/FilePreview.js";import{P as v}from"./Components/P/index.js";import{Img as C}from"./Components/Img/index.js";import{Iframe as k}from"./Components/Iframe/index.js";import{Code as P}from"./Components/Code/index.js";import{H1 as R,H2 as $,H3 as y,H4 as O,H5 as S}from"./Components/Headings/index.js";import{Ol as U,Ul as N,Li as A}from"./Components/List/index.js";import{Table as E,Th as I,Tr as L,Td as M}from"./Components/Table/index.js";import{Hr as T,Br as H,Blockquote as _}from"./Components/Others/index.js";import{ActionCaption as B,ActionFinished as J,ActionError as W}from"./Components/Action/index.js";import{Artifact as q,ArtifactError as z}from"./Components/Artifact/index.js";import{Think as D}from"./Components/Others/Think.js";import F from"../../../../common/cn.js";const G=({className:G,style:K,children:Q,value:V,maxLines:X,maxChars:Y,multiLineBreaks:Z,onExpandClick:ee,filePreviewSeenRef:re,suppressedRichPreviewUrls:ne})=>{const{colors:te,rtl:se,disableHtml:ie,disableJs:oe,disableCss:le}=l(),[ae,ce]=t({width:0,height:0}),[pe,me]=t(null),de=s(null),fe=i((()=>{if(!V)return"";if(ie)return V;let e=V.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Z&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[V,Z,ie]);o((()=>{if(Y)return void me(fe.length>Y?fe.slice(0,Y)+'<span class="pxe-expand-btn">...</span>':null);if(!X)return void me(null);if(!de.current||!fe||pe)return;const e=de.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=X*r;if(!(ae.height>n))return;const t=Math.floor(ae.width/8),s=Math.floor(t*X);me(fe.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[fe,X,Y,ae,pe]);const he=s(new Set);re||(he.current=new Set);const ue=null!=re?re:he,ge=s({colors:te,onExpandClick:ee,filePreviewSeenRef:ue,suppressedRichPreviewUrls:ne});ge.current={colors:te,onExpandClick:ee,filePreviewSeenRef:ue,suppressedRichPreviewUrls:ne};const xe=i((()=>({h1:R,h2:$,h3:y,h4:O,h5:S,p:e=>r(v,Object.assign({},e,{suppressedRichPreviewUrls:ge.current.suppressedRichPreviewUrls})),a:e=>r(g,Object.assign({},e,{filePreviewSeenRef:ge.current.filePreviewSeenRef,suppressedRichPreviewUrls:ge.current.suppressedRichPreviewUrls})),img:e=>{const{colors:n,filePreviewSeenRef:t,suppressedRichPreviewUrls:s}=ge.current,i="string"==typeof e.src?e.src:"",o=w(i);return o&&!b(o.url,s)?j(o,t)?r(x,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:n.accent}},{children:e.alt||o.fileName})):r(C,Object.assign({},e))},iframe:k,code:P,ol:U,ul:N,li:A,table:E,th:I,tr:L,td:M,hr:T,br:H,blockquote:_,span:n=>{var{children:t}=n,s=e(n,["children"]);const{colors:i,onExpandClick:o}=ge.current;return"pxe-expand-btn"===s.className?r("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:i.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:t})):r("span",Object.assign({},s,{children:t}))},"action-caption":B,"action-finished":J,"action-error":W,artifact:q,"artifact-error":z,think:D})),[]);o((()=>{if(!de.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;ce({width:e,height:n})}}));return e.observe(de.current),()=>{e.disconnect()}}),[]);const we=pe||fe;return n("div",Object.assign({className:"pxe-markdown",ref:de,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},K)},se&&{dir:"rtl"},{children:[r(m,Object.assign({className:F("pxe-prose",G),components:xe,remarkPlugins:[d,[f,{singleDollarTextMath:!1}],a],rehypePlugins:[c,h,...ie?[]:[u],[p,{disableJs:oe,disableCss:le}]]},{children:we})),Q]}))};export{G as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as r,jsxs as n}from"react/jsx-runtime";import{useState as s,useRef as t,useMemo as i,useEffect as o}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import{remarkDocumentCssAsCode as a,remarkSmartQuotes as c,rehypeCode as p,rehypeSanitize as m}from"./utils/custom-plugins.js";import d from"react-markdown";import f from"remark-gfm";import h from"remark-math";import u from"rehype-katex";import g from"rehype-raw";import{A as x}from"./Components/A/index.js";import w,{getFilePreviewInfo as b,shouldSuppressRichPreviewForUrl as j,shouldRenderFilePreview as v}from"./Components/A/FilePreview.js";import{P as C}from"./Components/P/index.js";import{Img as k}from"./Components/Img/index.js";import{Iframe as P}from"./Components/Iframe/index.js";import{Code as R}from"./Components/Code/index.js";import{H1 as $,H2 as y,H3 as O,H4 as S,H5 as U}from"./Components/Headings/index.js";import{Ol as N,Ul as A,Li as E}from"./Components/List/index.js";import{Table as I,Th as L,Tr as M,Td as T}from"./Components/Table/index.js";import{Hr as H,Br as _,Blockquote as B}from"./Components/Others/index.js";import{ActionCaption as J,ActionFinished as W,ActionError as q}from"./Components/Action/index.js";import{Artifact as z,ArtifactError as D}from"./Components/Artifact/index.js";import{Think as F}from"./Components/Others/Think.js";import G from"../../../../common/cn.js";const K=({className:K,style:Q,children:V,value:X,maxLines:Y,maxChars:Z,multiLineBreaks:ee,onExpandClick:re,filePreviewSeenRef:ne,suppressedRichPreviewUrls:se})=>{const{colors:te,rtl:ie,disableHtml:oe,disableJs:le,disableCss:ae}=l(),[ce,pe]=s({width:0,height:0}),[me,de]=s(null),fe=t(null),he=i((()=>{if(!X)return"";if(oe)return X;let e=X.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),ee&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[X,ee,oe]);o((()=>{if(Z)return void de(he.length>Z?he.slice(0,Z)+'<span class="pxe-expand-btn">...</span>':null);if(!Y)return void de(null);if(!fe.current||!he||me)return;const e=fe.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=Y*r;if(!(ce.height>n))return;const s=Math.floor(ce.width/8),t=Math.floor(s*Y);de(he.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[he,Y,Z,ce,me]);const ue=t(new Set);ne||(ue.current=new Set);const ge=null!=ne?ne:ue,xe=t({colors:te,onExpandClick:re,filePreviewSeenRef:ge,suppressedRichPreviewUrls:se});xe.current={colors:te,onExpandClick:re,filePreviewSeenRef:ge,suppressedRichPreviewUrls:se};const we=i((()=>({h1:$,h2:y,h3:O,h4:S,h5:U,p:e=>r(C,Object.assign({},e,{suppressedRichPreviewUrls:xe.current.suppressedRichPreviewUrls})),a:e=>r(x,Object.assign({},e,{filePreviewSeenRef:xe.current.filePreviewSeenRef,suppressedRichPreviewUrls:xe.current.suppressedRichPreviewUrls})),img:e=>{const{colors:n,filePreviewSeenRef:s,suppressedRichPreviewUrls:t}=xe.current,i="string"==typeof e.src?e.src:"",o=b(i);return o&&!j(o.url,t)?v(o,s)?r(w,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:n.accent}},{children:e.alt||o.fileName})):r(k,Object.assign({},e))},iframe:P,code:R,ol:N,ul:A,li:E,table:I,th:L,tr:M,td:T,hr:H,br:_,blockquote:B,span:n=>{var{children:s}=n,t=e(n,["children"]);const{colors:i,onExpandClick:o}=xe.current;return"pxe-expand-btn"===t.className?r("span",Object.assign({},t,{style:Object.assign({display:"inline",fontWeight:500,color:i.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:s})):r("span",Object.assign({},t,{children:s}))},"action-caption":J,"action-finished":W,"action-error":q,artifact:z,"artifact-error":D,think:F})),[]);o((()=>{if(!fe.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;pe({width:e,height:n})}}));return e.observe(fe.current),()=>{e.disconnect()}}),[]);const be=me||he;return n("div",Object.assign({className:"pxe-markdown",ref:fe,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},Q)},ie&&{dir:"rtl"},{children:[r(d,Object.assign({className:G("pxe-prose",K),components:we,remarkPlugins:[f,[h,{singleDollarTextMath:!1}],[a,{disableCss:ae}],c],rehypePlugins:[p,u,...oe?[]:[g],[m,{disableJs:le,disableCss:ae}]]},{children:be})),V]}))};export{K as PickaxeMarkdownRenderer};