1
+ "use strict" ;
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
4
+
5
+ ( function e ( t , n , r ) {
6
+ function s ( o , u ) {
7
+ if ( ! n [ o ] ) {
8
+ if ( ! t [ o ] ) {
9
+ var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f ;
10
+ } var l = n [ o ] = { exports : { } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) {
11
+ var n = t [ o ] [ 1 ] [ e ] ; return s ( n ? n : e ) ;
12
+ } , l , l . exports , e , t , n , r ) ;
13
+ } return n [ o ] . exports ;
14
+ } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) {
15
+ s ( r [ o ] ) ;
16
+ } return s ;
17
+ } ) ( { 1 : [ function ( require , module , exports ) {
18
+ var Id = require ( "idy" ) ,
19
+ SetOrGet = require ( "set-or-get" ) ,
20
+ IterateObject = require ( "iterate-object" ) ,
21
+ Deffy = require ( "deffy" ) ; var _connections = { } ,
22
+ _betweenTwoBubbles = { } ,
23
+ container = null ,
24
+ markers = null ; function connectable ( options , elmTarget ) {
25
+ var con = { } ; if ( elmTarget === undefined ) {
26
+ elmTarget = options ; options = { } ;
27
+ } container = options . container || container ; var elmSource = this ; markers = options . markers || markers ; options . k = options . k || 100 ; options . kk = options . kk || 10 ; var marker = markers . marker ( 10 , 10 ) ,
28
+ markerId = "triangle-" + Id ( ) ,
29
+ line = container . path ( ) . attr ( "marker-end" , "url(#" + markerId + ")" ) . fill ( "none" ) ; marker . attr ( { id : markerId , viewBox : "0 0 10 10" , refX : "0" , refY : "5" , markerUnits : "strokeWidth" , markerWidth : "4" , markerHeight : "5" } ) ; marker . path ( ) . attr ( { d : "M 0 0 L 10 5 L 0 10 z" } ) ; var sPos = { } ,
30
+ tPos = { } ; con . source = elmSource ; con . target = elmTarget ; con . line = line ; con . marker = marker ; SetOrGet ( _connections , con . source . id ( ) , [ ] ) . push ( con ) ; SetOrGet ( _connections , con . target . id ( ) , [ ] ) . push ( con ) ; SetOrGet ( _betweenTwoBubbles , { toString : function toString ( ) {
31
+ var ids = [ con . source . id ( ) , con . target . id ( ) ] ,
32
+ id1 = ids . join ( "->" ) ,
33
+ id2 = ids . reverse ( ) . join ( "->" ) ; con . _ = con . id = id1 ; if ( _betweenTwoBubbles [ id2 ] ) {
34
+ con . _ = id2 ; return id2 ;
35
+ } con . id = id1 ; return id1 ;
36
+ } } , [ ] ) . push ( con ) ; con . computeLineCoordinates = function ( cons ) {
37
+ var output = [ ] ,
38
+ l = cons . length ; IterateObject ( cons , function ( con , i ) {
39
+ var sT = con . source . transform ( ) ,
40
+ tT = con . target . transform ( ) ,
41
+ sB = con . source . bbox ( ) ,
42
+ tB = con . target . bbox ( ) ,
43
+ x1 = sT . x + sB . width / 2 ,
44
+ y1 = sT . y + sB . height / 2 ,
45
+ x2 = tT . x + tB . width / 2 ,
46
+ y2 = tT . y + tB . height / 2 ,
47
+ cx = ( x1 + x2 ) / 2 ,
48
+ cy = ( y1 + y2 ) / 2 ,
49
+ dx = Math . abs ( ( x1 - x2 ) / 2 ) ,
50
+ dy = Math . abs ( ( y1 - y2 ) / 2 ) ,
51
+ dd = null ,
52
+ out = { x1 : x1 , y1 : y1 , x2 : x2 , y2 : y2 , ex : x1 , ey : y1 } ; if ( i !== ( l - 1 ) / 2 ) {
53
+ dd = Math . sqrt ( dx * dx + dy * dy ) ; out . ex = cx + dy / dd * options . k * ( i - ( l - 1 ) / 2 ) ; out . ey = cy - dx / dd * options . k * ( i - ( l - 1 ) / 2 ) ;
54
+ } output . push ( out ) ;
55
+ } ) ; return output ;
56
+ } ; if ( options . padEllipse ) {
57
+ con . computeLineCoordinates = function ( cons ) {
58
+ var output = [ ] ,
59
+ l = cons . length ; IterateObject ( cons , function ( con , i ) {
60
+ var elmS = con . source . node . querySelector ( "ellipse" ) || con . source . node . querySelector ( "circle" ) ,
61
+ elmT = con . target . node . querySelector ( "ellipse" ) || con . target . node . querySelector ( "circle" ) ,
62
+ xR1 ,
63
+ xR2 ,
64
+ yR1 ,
65
+ yR2 ,
66
+ sT = con . source . transform ( ) ,
67
+ tT = con . target . transform ( ) ,
68
+ sB = con . source . bbox ( ) ,
69
+ tB = con . target . bbox ( ) ; if ( elmS . tagName === "circle" ) {
70
+ xR1 = yR1 = parseFloat ( elmS . getAttribute ( "r" ) ) ; xR2 = yR2 = parseFloat ( elmT . getAttribute ( "r" ) ) ;
71
+ } else {
72
+ xR1 = parseFloat ( elmS . getAttribute ( "rx" ) ) ; yR1 = parseFloat ( elmS . getAttribute ( "ry" ) ) ; xR2 = parseFloat ( elmT . getAttribute ( "rx" ) ) ; yR2 = parseFloat ( elmT . getAttribute ( "ry" ) ) ;
73
+ } var sx = sT . x + xR1 / 2 ,
74
+ sy = sT . y + yR1 / 2 ,
75
+ tx = tT . x + xR2 / 2 ,
76
+ ty = tT . y + yR2 / 2 ,
77
+ dx = tx - sx ,
78
+ dy = ty - sy ,
79
+ d = Math . sqrt ( dx * dx + dy * dy ) ,
80
+ ux = dx / d ,
81
+ uy = dy / d ,
82
+ cx1 = sx + xR1 * ux ,
83
+ cy1 = sy + yR1 * uy ,
84
+ cx2 = sx + ( d - xR2 - 5 ) * ux ,
85
+ cy2 = sy + ( d - yR2 - 5 ) * uy ; var x1 = cx1 + xR1 / 2 ,
86
+ y1 = cy1 + yR1 / 2 ,
87
+ x2 = cx2 + xR2 / 2 ,
88
+ y2 = cy2 + yR2 / 2 ; var cx = ( x1 + x2 ) / 2 ,
89
+ cy = ( y1 + y2 ) / 2 ,
90
+ dd = null ,
91
+ out = { x1 : x1 , y1 : y1 , x2 : x2 , y2 : y2 , ex : x1 , ey : y1 } ; if ( isNaN ( out . x1 ) ) {
92
+ out . x1 = sT . x + xR1 * 2 ; out . y1 = sT . y + yR1 / 2 ; out . x2 = sT . x ; out . y2 = out . y1 ; out . ex = ( out . x1 + out . x2 ) / 2 ; out . ey = out . y1 - options . kk * ( i + 1 ) ;
93
+ } else {
94
+ dx = Math . abs ( ( x1 - x2 ) / 2 ) ; dy = Math . abs ( ( y1 - y2 ) / 2 ) ; if ( i !== ( l - 1 ) / 2 ) {
95
+ dd = Math . sqrt ( dx * dx + dy * dy ) ; out . ex = cx + dy / dd * options . k * ( i - ( l - 1 ) / 2 ) ; out . ey = cy - dx / dd * options . k * ( i - ( l - 1 ) / 2 ) ;
96
+ }
97
+ } output . push ( out ) ;
98
+ } ) ; return output ;
99
+ } ;
100
+ } elmSource . cons = elmSource . cons || [ ] ; elmSource . cons . push ( con ) ; con . update = function ( ) {
101
+ var cons = Deffy ( _betweenTwoBubbles [ con . _ ] , [ ] ) ,
102
+ results = con . computeLineCoordinates ( cons ) ; IterateObject ( results , function ( r , i ) {
103
+ cons [ i ] . line . plot ( "M" + r . x1 + " " + r . y1 + " Q" + r . ex + " " + r . ey + " " + r . x2 + " " + r . y2 ) ;
104
+ } ) ;
105
+ } ; con . update ( ) ; elmSource . on ( "dragmove" , con . update ) ; elmTarget . on ( "dragmove" , con . update ) ; con . setLineColor = function ( color , c ) {
106
+ c = c || this ; c . line . stroke ( color ) ; c . marker . fill ( color ) ;
107
+ } ; return con ;
108
+ } if ( typeof SVG === "function" ) {
109
+ SVG . extend ( SVG . Element , { connectable : connectable } ) ;
110
+ } else if ( ( typeof window === "undefined" ? "undefined" : _typeof ( window ) ) === "object" ) {
111
+ throw new Error ( "SVG.js is not loaded but it is required." ) ;
112
+ } module . exports = connectable ;
113
+ } , { deffy : 2 , idy : 4 , "iterate-object" : 5 , "set-or-get" : 6 } ] , 2 : [ function ( require , module , exports ) {
114
+ var Typpy = require ( "typpy" ) ; function Deffy ( input , def , options ) {
115
+ if ( typeof def === "function" ) {
116
+ return def ( input ) ;
117
+ } options = Typpy ( options ) === "boolean" ? { empty : options } : { empty : false } ; if ( options . empty ) {
118
+ return input || def ;
119
+ } if ( Typpy ( input ) === Typpy ( def ) ) {
120
+ return input ;
121
+ } return def ;
122
+ } module . exports = Deffy ;
123
+ } , { typpy : 3 } ] , 3 : [ function ( require , module , exports ) {
124
+ function Typpy ( input , target ) {
125
+ if ( arguments . length === 2 ) {
126
+ return Typpy . is ( input , target ) ;
127
+ } return Typpy . get ( input , true ) ;
128
+ } Typpy . is = function ( input , target ) {
129
+ return Typpy . get ( input , typeof target === "string" ) === target ;
130
+ } ; Typpy . get = function ( input , str ) {
131
+ if ( typeof input === "string" ) {
132
+ return str ? "string" : String ;
133
+ } if ( null === input ) {
134
+ return str ? "null" : null ;
135
+ } if ( undefined === input ) {
136
+ return str ? "undefined" : undefined ;
137
+ } if ( input !== input ) {
138
+ return str ? "nan" : NaN ;
139
+ } return str ? input . constructor . name . toLowerCase ( ) : input . constructor ;
140
+ } ; module . exports = Typpy ;
141
+ } , { } ] , 4 : [ function ( require , module , exports ) {
142
+ function Idy ( length ) {
143
+ length = length || 10 ; return Math . random ( ) . toString ( 35 ) . substr ( 2 , length ) ;
144
+ } module . exports = Idy ;
145
+ } , { } ] , 5 : [ function ( require , module , exports ) {
146
+ function IterateObject ( obj , fn ) {
147
+ var i = 0 ,
148
+ keys = [ ] ; if ( Array . isArray ( obj ) ) {
149
+ for ( ; i < obj . length ; ++ i ) {
150
+ if ( fn ( obj [ i ] , i , obj ) === false ) {
151
+ break ;
152
+ }
153
+ }
154
+ } else {
155
+ keys = Object . keys ( obj ) ; for ( ; i < keys . length ; ++ i ) {
156
+ if ( fn ( obj [ keys [ i ] ] , keys [ i ] , obj ) === false ) {
157
+ break ;
158
+ }
159
+ }
160
+ }
161
+ } module . exports = IterateObject ;
162
+ } , { } ] , 6 : [ function ( require , module , exports ) {
163
+ var Deffy = require ( "deffy" ) ; function SetOrGet ( input , field , def ) {
164
+ return input [ field ] = Deffy ( input [ field ] , def ) ;
165
+ } module . exports = SetOrGet ;
166
+ } , { deffy : 7 } ] , 7 : [ function ( require , module , exports ) {
167
+ arguments [ 4 ] [ 2 ] [ 0 ] . apply ( exports , arguments ) ;
168
+ } , { dup : 2 , typpy : 8 } ] , 8 : [ function ( require , module , exports ) {
169
+ arguments [ 4 ] [ 3 ] [ 0 ] . apply ( exports , arguments ) ;
170
+ } , { dup : 3 } ] } , { } , [ 1 ] ) ;
0 commit comments