├── .gitignore
├── Procfile
├── requirements.txt
├── static
├── images
│ └── blank.png
├── css
│ └── neoviva.css
├── index.html
└── js
│ ├── neoviva.js
│ ├── vivagraph.min.js
│ └── jquery.min.js
├── app.py
├── load_graph.py
├── Readme.adoc
└── import.py
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | venv
3 | *.pyc
4 |
5 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: python app.py $PORT
2 | #worker: python import.py
3 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | neo4j-driver==1.0.2
2 | requests==2.20.0
3 | web.py==0.37
4 | wsgiref==0.1.2
5 |
--------------------------------------------------------------------------------
/static/images/blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4j-examples/twitter-graph-viz/HEAD/static/images/blank.png
--------------------------------------------------------------------------------
/static/css/neoviva.css:
--------------------------------------------------------------------------------
1 | .node {
2 | background-color: #00a2e8;
3 | width: 10px;
4 | height: 10px;
5 | position: absolute;
6 | }
7 | .link {
8 | background-color: #dddddd;
9 | position: absolute;
10 | }
11 |
12 | #graph1 {
13 | position: absolute;
14 | width: 100%;
15 | height: 100%;
16 | }
17 |
18 | #graph1 > svg {
19 | width: 100%;
20 | height: 100%;
21 | }
22 |
23 | #search {
24 | top: 5px;
25 | margin-left: auto;
26 | margin-right: auto;
27 | }
28 | #hoveredName {position: absolute; top: 40px; left: 10px; padding: 7px; background-color: #EFEFEF; text-align: center; display: none; max-width: 20em; font-family: "Helvetica";}
29 | #hoveredName > img { margin-top: 6px;}
30 | #hoveredName > div { font-size: smaller; text-align: left; margin-bottom: 5px; border-bottom: 1px solid black;}
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | import web
2 | from load_graph import load_graph
3 | import requests
4 |
5 | urls = (
6 | '/', 'index',
7 | '/twitter/(.*)','twitter_img',
8 | '/text/(.*)','text_img',
9 | '/graph','graph'
10 | )
11 |
12 | class index:
13 | def GET(self):
14 | raise web.seeother('/static/index.html')
15 |
16 | class twitter_img:
17 | def GET(self,name):
18 | img = requests.get('http://pbs.twimg.com/profile_images/'+name)
19 | return img.content
20 |
21 | class text_img:
22 | def GET(self,name):
23 | img = requests.get('http://ansrv.com/png?s='+name+'&c=74d0f4&b=231d40&size=5')
24 | return img.content
25 |
26 | class graph:
27 | def GET(self):
28 | return load_graph()
29 |
30 |
31 | if __name__ == "__main__":
32 | app = web.application(urls, globals())
33 | app.run()
--------------------------------------------------------------------------------
/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Neo4j Twitter Graph Visualization
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/load_graph.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 | import os
4 |
5 | url = os.environ.get('NEO4J_URL',"http://localhost:7474/db/data")
6 |
7 | def load_graph():
8 | query = """
9 | MATCH (t:Tweet)
10 | WITH t ORDER BY t.id DESC LIMIT 2000
11 | MATCH (user:User)-[:POSTS]->(t)<-[:TAGS]-(tag:Hashtag)
12 | MATCH (t)-[:MENTIONS]->(user2:User)
13 | UNWIND [tag,user2] as other WITH distinct user,other
14 | WHERE lower(other.name) <> 'oscon'
15 | RETURN { from: {id:id(user),label: head(labels(user)), data: user},
16 | rel: 'CONNECTS',
17 | to: {id: id(other), label: head(labels(other)), data: other}} as tuple
18 | LIMIT 1000
19 | """
20 | statements = {'statements':[{'statement':query}]}
21 | headers = {'content-type':'application/json'}
22 | res = requests.post(url + '/transaction/commit', data = json.dumps(statements), headers = headers)
23 | print res.status_code
24 | rows = res.json()['results'][0]['data']
25 | rows = map(lambda a: a['row'][0], rows)
26 | return json.dumps(rows)
27 |
28 | if __name__ == "__main__":
29 | print load_graph()
30 |
--------------------------------------------------------------------------------
/Readme.adoc:
--------------------------------------------------------------------------------
1 | == (OSCON) Twitter Graph
2 |
3 | Small Python sample app to load tweets for a certain twitter search continuously into a Neo4j instance
4 | and a webapp to render them with vivagraph.js (webgl)
5 |
6 | You can read the http://neo4j.com/blog/oscon-twitter-graph/[blog post for details].
7 |
8 | There is also a http://www.neo4j.org/graphgist?12b6cd13f1f1120f6099[GraphGist] explaining the model and some use-case queries in detail.
9 |
10 | image::http://dev.assets.neo4j.com.s3.amazonaws.com/wp-content/uploads/2014/07/image04.png?_ga=1.207666834.149316633.1397859613[width=400]
11 |
12 | The application uses the official https://github.com/neo4j/neo4j-python-driver[Neo4j-Python-Driver] which supports the binary *bolt* protocol.
13 | So it only works with Neo4j 3.x and later.
14 |
15 | == Usage
16 |
17 | === Import
18 |
19 | Start your neo4j server or provision a hosted server, e.g. at graphenedb.com or addons.heroku.com/graphenedb
20 |
21 | ----
22 | export NEO4J_URL=http://localhost:7474/db/data
23 | export TWITTER_BEARER=TWITTER_BEARER_TOKEN
24 |
25 | python import.py
26 | ----
27 |
28 | You can create a https://dev.twitter.com/docs/auth/application-only-auth[bearer token] for yourself by sending this request to twitter:
29 |
30 | ----
31 | curl -XPOST -u customer_id:customer_secret 'https://api.twitter.com/oauth2/token?grant_type=client_credentials'
32 | ----
33 |
34 | This will yield:
35 | ----
36 | {"token_type":"bearer","access_token":"....bearer token...."}
37 | ----
38 |
39 | === Webapp
40 |
41 | ----
42 | python app.py 8080
43 |
44 | open http://localhost:8080
45 | ----
46 |
47 | === Push to Heroku
48 |
49 | The application already contains a +Procfile+ for Heroku to run with the port provided.
50 |
51 | ----
52 | git init
53 | heroku apps:create my-twitter-graph
54 | heroku config:set NEO4J_URL=http://.....
55 | git push heroku master
56 | ----
57 |
58 | You can use a Neo4j instance on http://graphenedb.com[GrapheneDB] for your experiment or create an ec2 instance yourself using the http://neo4j.org/develop/cloud[cloud formation template].
59 |
60 | The import is not started automatically you can enable the worker in the Procfile to run the import automatically and continously.
61 |
--------------------------------------------------------------------------------
/import.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import os
3 | import time
4 | import urllib
5 | from neo4j.v1 import GraphDatabase, basic_auth
6 |
7 | neo4jUrl = os.environ.get('NEO4J_URL',"bolt://localhost")
8 | neo4jUser = os.environ.get('NEO4J_USER',"neo4j")
9 | neo4jPass = os.environ.get('NEO4J_PASSWORD',"test")
10 | driver = GraphDatabase.driver(neo4jUrl, auth=basic_auth(neo4jUser, neo4jPass))
11 |
12 | session = driver.session()
13 |
14 | # Add uniqueness constraints.
15 | session.run( "CREATE CONSTRAINT ON (t:Tweet) ASSERT t.id IS UNIQUE;")
16 | session.run( "CREATE CONSTRAINT ON (u:User) ASSERT u.screen_name IS UNIQUE;")
17 | session.run( "CREATE CONSTRAINT ON (h:Hashtag) ASSERT h.name IS UNIQUE;")
18 | session.run( "CREATE CONSTRAINT ON (l:Link) ASSERT l.url IS UNIQUE;")
19 | session.run( "CREATE CONSTRAINT ON (s:Source) ASSERT s.name IS UNIQUE;")
20 |
21 | # Get Twitter bearer to pass to header.
22 | TWITTER_BEARER = os.environ["TWITTER_BEARER"]
23 |
24 | # URL parameters.
25 | q = urllib.quote_plus(os.environ.get("TWITTER_SEARCH","oscon OR neo4j OR #oscon OR @neo4j"))
26 |
27 | count = 100
28 | result_type = "recent"
29 | lang = "en"
30 | since_id = -1
31 |
32 | while True:
33 | try:
34 | print(q)
35 | # Build URL.
36 | url = "https://api.twitter.com/1.1/search/tweets.json?q=%s&count=%s&result_type=%s&lang=%s&since_id=%s" % (q, count, result_type, lang, since_id)
37 | # Send GET request.
38 | r = requests.get(url, headers = {"accept":"application/json","Authorization":"Bearer " + TWITTER_BEARER})
39 |
40 | # Keep status objects.
41 | tweets = r.json()["statuses"]
42 |
43 | if tweets:
44 | plural = "s." if len(tweets) > 1 else "."
45 | print("Found " + str(len(tweets)) + " tweet" + plural)
46 | else:
47 | print("No tweets found.\n")
48 | time.sleep(65)
49 | continue
50 |
51 | since_id = tweets[0].get('id')
52 |
53 | # Pass dict to Cypher and build query.
54 | query = """
55 | UNWIND {tweets} AS t
56 |
57 | WITH t
58 | ORDER BY t.id
59 |
60 | WITH t,
61 | t.entities AS e,
62 | t.user AS u,
63 | t.retweeted_status AS retweet
64 |
65 | MERGE (tweet:Tweet {id:t.id})
66 | SET tweet.text = t.text,
67 | tweet.created_at = t.created_at,
68 | tweet.favorites = t.favorite_count
69 |
70 | MERGE (user:User {screen_name:u.screen_name})
71 | SET user.name = u.name,
72 | user.location = u.location,
73 | user.followers = u.followers_count,
74 | user.following = u.friends_count,
75 | user.statuses = u.statusus_count,
76 | user.profile_image_url = u.profile_image_url
77 |
78 | MERGE (user)-[:POSTS]->(tweet)
79 |
80 | MERGE (source:Source {name:t.source})
81 | MERGE (tweet)-[:USING]->(source)
82 |
83 | FOREACH (h IN e.hashtags |
84 | MERGE (tag:Hashtag {name:LOWER(h.text)})
85 | MERGE (tag)-[:TAGS]->(tweet)
86 | )
87 |
88 | FOREACH (u IN e.urls |
89 | MERGE (url:Link {url:u.expanded_url})
90 | MERGE (tweet)-[:CONTAINS]->(url)
91 | )
92 |
93 | FOREACH (m IN e.user_mentions |
94 | MERGE (mentioned:User {screen_name:m.screen_name})
95 | ON CREATE SET mentioned.name = m.name
96 | MERGE (tweet)-[:MENTIONS]->(mentioned)
97 | )
98 |
99 | FOREACH (r IN [r IN [t.in_reply_to_status_id] WHERE r IS NOT NULL] |
100 | MERGE (reply_tweet:Tweet {id:r})
101 | MERGE (tweet)-[:REPLY_TO]->(reply_tweet)
102 | )
103 |
104 | FOREACH (retweet_id IN [x IN [retweet.id] WHERE x IS NOT NULL] |
105 | MERGE (retweet_tweet:Tweet {id:retweet_id})
106 | MERGE (tweet)-[:RETWEETS]->(retweet_tweet)
107 | )
108 | """
109 |
110 | # Send Cypher query.
111 | session.run(query,{'tweets':tweets})
112 | print("Tweets added to graph!\n")
113 | time.sleep(65)
114 |
115 | except Exception as e:
116 | print(e)
117 | time.sleep(65)
118 | continue
119 |
--------------------------------------------------------------------------------
/static/js/neoviva.js:
--------------------------------------------------------------------------------
1 | var colors = [
2 | 0x1f77b4ff, 0xaec7e8ff,
3 | 0xff7f0eff, 0xffbb78ff,
4 | 0x2ca02cff, 0x98df8aff,
5 | 0xd62728ff, 0xff9896ff,
6 | 0x9467bdff, 0xc5b0d5ff,
7 | 0x8c564bff, 0xc49c94ff,
8 | 0xe377c2ff, 0xf7b6d2ff,
9 | 0x7f7f7fff, 0xc7c7c7ff,
10 | 0xbcbd22ff, 0xdbdb8dff,
11 | 0x17becfff, 0x9edae5ff];
12 |
13 | function addNeo(graph, data) {
14 | function addNode(id,data) {
15 | if (!id || typeof id == "undefined") return null;
16 | var node = graph.getNode(id);
17 | if (!node) node = graph.addNode(id, data);
18 | return node;
19 | }
20 | for (var i=0;i
';
100 | t.empty().text("@" + id).append(n).show()
101 | }
102 | $.ajax("/tweets/" + node['id'], {
103 | type:"GET",
104 | dataType:"json",
105 | success:function (res) {
106 | console.log("tweets", res);
107 | for (var n=0;n" + res[n].text + "").appendTo(t)
109 | }
110 | }});
111 | };
112 | var onMouseLeave = function () {
113 | // $("#hoveredName").hide().empty()
114 | clearTimeout(timeout);
115 | };
116 |
117 | var onClick = function (node) {
118 | console.log("click", node);
119 | if (!node || !node.position) return;
120 | showBox(node);
121 | graphics.graphCenterChanged(node.position.x,node.position.y);
122 | renderer.rerender();
123 | loadData(graph,node.id);
124 | };
125 | var onDblClick = function (node) {
126 | console.log("double-click", node)
127 | };
128 |
129 | var unHighlightLinks = function (node, color) {
130 | if (node && node.id) {
131 | node.ui.size=12;
132 | graph.forEachLinkedNode(node.id, function (aNode, link) {
133 | link.ui.color = color || link.ui.oldColor
134 | })
135 | }
136 | };
137 | var highlightNode = function (node, color) {
138 | if (!(node && node.id && node.ui)) return;
139 | node.ui.size = 36;
140 | graph.forEachLinkedNode(node.id, function (aNode, link) {
141 | link.ui.color = color || 4278190335;
142 | graphics.bringLinkToFront(link.ui)
143 | })
144 | };
145 |
146 | inputs.mouseEnter(function (node) {
147 | onMouseEnter(node);
148 | unHighlightLinks(lastNode);
149 | lastNode = node;
150 | highlightNode(node);
151 | renderer.rerender()
152 | }).mouseLeave(function (node) {
153 | onMouseLeave();
154 | unHighlightLinks(lastNode);
155 | lastNode = null;
156 | unHighlightLinks(node);
157 | renderer.rerender()
158 | }).dblClick(function (node) {
159 | onDblClick(node)
160 | }).click(function (node) {
161 | onClick(node)
162 | });
163 |
164 |
165 | renderer.run();
166 | loadData(graph);
167 | l = layout;
168 | }
--------------------------------------------------------------------------------
/static/js/vivagraph.min.js:
--------------------------------------------------------------------------------
1 | var Viva=Viva||{};Viva.Graph=Viva.Graph||{},"undefined"!=typeof module&&module.exports&&(module.exports=Viva),Viva.Graph.version="0.5.6",Viva.lazyExtend=function(e,t){var n;if(e||(e={}),t)for(n in t)if(t.hasOwnProperty(n)){var r=e.hasOwnProperty(n),i=typeof t[n],o=!r||typeof e[n]!==i;o?e[n]=t[n]:"object"===i&&(e[n]=Viva.lazyExtend(e[n],t[n]))}return e},Viva.random=function(){var e,t=arguments[0];e="number"==typeof t?t:"string"==typeof t?t.length:+new Date;var n=function(){return e=4294967295&e+2127912214+(e<<12),e=4294967295&(3345072700^e^e>>>19),e=4294967295&e+374761393+(e<<5),e=4294967295&(e+3550635116^e<<9),e=4294967295&e+4251993797+(e<<3),e=4294967295&(3042594569^e^e>>>16),(268435455&e)/268435456};return{next:function(e){return Math.floor(n()*e)},nextDouble:function(){return n()}}},Viva.randomIterator=function(e,t){return t=t||Viva.random(),{forEach:function(n){var r,i,o;for(r=e.length-1;r>0;--r)i=t.next(r+1),o=e[i],e[i]=e[r],e[r]=o,n(o);e.length&&n(e[0])},shuffle:function(){var n,r,i;for(n=e.length-1;n>0;--n)r=t.next(n+1),i=e[r],e[r]=e[n],e[n]=i;return e}}},Viva.BrowserInfo=function(){if("undefined"==typeof window||!window.hasOwnProperty("navigator"))return{browser:"",version:"0"};var e=window.navigator.userAgent.toLowerCase(),t=/(webkit)[ \/]([\w.]+)/,n=/(opera)(?:.*version)?[ \/]([\w.]+)/,r=/(msie) ([\w.]+)/,i=/(mozilla)(?:.*? rv:([\w.]+))?/,o=t.exec(e)||n.exec(e)||r.exec(e)||0>e.indexOf("compatible")&&i.exec(e)||[];return{browser:o[1]||"",version:o[2]||"0"}}(),Viva.Graph.Utils=Viva.Graph.Utils||{},Viva.Graph.Utils.indexOfElementInArray=function(e,t){if(t.indexOf)return t.indexOf(e);var n,r=t.length;for(n=0;r>n;n+=1)if(t.hasOwnProperty(n)&&t[n]===e)return n;return-1},Viva.Graph.Utils=Viva.Graph.Utils||{},Viva.Graph.Utils.getDimension=function(e){if(!e)throw{message:"Cannot get dimensions of undefined container"};var t=e.clientWidth,n=e.clientHeight;return{left:0,top:0,width:t,height:n}},Viva.Graph.Utils.findElementPosition=function(e){var t=0,n=0;if(e.offsetParent)do t+=e.offsetLeft,n+=e.offsetTop;while(null!==(e=e.offsetParent));return[t,n]},Viva.Graph.Utils=Viva.Graph.Utils||{},Viva.Graph.Utils.events=function(e){var t=function(e){var t={};return e.fire=function(e,n){var r,i,o,a;if("string"!=typeof e)throw"Only strings can be used as even type";if(t.hasOwnProperty(e))for(r=t[e],a=0;r.length>a;++a)o=r[a],i=o.method,i(n);return this},e.addEventListener=function(e,n){if("function"!=typeof n)throw"Only functions allowed to be callbacks";var r={method:n};return t.hasOwnProperty(e)?t[e].push(r):t[e]=[r],this},e.removeEventListener=function(e,n){if("function"!=typeof n)throw"Only functions allowed to be callbacks";if(t.hasOwnProperty(e)){var r,i=t[e];for(r=0;i.length>r;++r)if(i[r].callback===n){i.splice(r);break}}return this},e.removeAllListeners=function(){var e;for(e in t)t.hasOwnProperty(e)&&delete t[e]},e};return{on:function(t,n){return e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n),this},stop:function(t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)},extend:function(){return t(e)}}},Viva.Graph.Utils=Viva.Graph.Utils||{},Viva.Graph.Utils.dragndrop=function(e){var t,n,r,i,o,a,u,s=Viva.Graph.Utils.events(window.document),f=Viva.Graph.Utils.events(e),c=Viva.Graph.Utils.findElementPosition,d=0,l=0,h=!1,v=0,p=function(e){var t=0,n=0;return e=e||window.event,e.pageX||e.pageY?(t=e.pageX,n=e.pageY):(e.clientX||e.clientY)&&(t=e.clientX+window.document.body.scrollLeft+window.document.documentElement.scrollLeft,n=e.clientY+window.document.body.scrollTop+window.document.documentElement.scrollTop),[t,n]},m=function(e,t,r){n&&n(e,{x:t-d,y:r-l}),d=t,l=r},g=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},y=function(e){e.preventDefault&&e.preventDefault()},x=function(e){return g(e),!1},w=function(e){e=e||window.event,m(e,e.clientX,e.clientY)},V=function(e){if(e=e||window.event,h)return g(e),!1;var n=1===e.button&&null!==window.event||0===e.button;return n?(d=e.clientX,l=e.clientY,u=e.target||e.srcElement,t&&t(e,{x:d,y:l}),s.on("mousemove",w),s.on("mouseup",b),g(e),o=window.document.onselectstart,a=window.document.ondragstart,window.document.onselectstart=x,u.ondragstart=x,!1):void 0},b=function(e){e=e||window.event,s.stop("mousemove",w),s.stop("mouseup",b),window.document.onselectstart=o,u.ondragstart=a,u=null,r&&r(e)},N=function(t){if("function"==typeof i){t=t||window.event,t.preventDefault&&t.preventDefault(),t.returnValue=!1;var n,r=p(t),o=c(e),a={x:r[0]-o[0],y:r[1]-o[1]};n=t.wheelDelta?t.wheelDelta/360:t.detail/-9,i(t,n,a)}},P=function(t){!i&&t?"webkit"===Viva.BrowserInfo.browser?e.addEventListener("mousewheel",N,!1):e.addEventListener("DOMMouseScroll",N,!1):i&&!t&&("webkit"===Viva.BrowserInfo.browser?e.removeEventListener("mousewheel",N,!1):e.removeEventListener("DOMMouseScroll",N,!1)),i=t},E=function(e,t){return(e.clientX-t.clientX)*(e.clientX-t.clientX)+(e.clientY-t.clientY)*(e.clientY-t.clientY)},G=function(e){if(1===e.touches.length){g(e);var t=e.touches[0];m(e,t.clientX,t.clientY)}else if(2===e.touches.length){var n=E(e.touches[0],e.touches[1]),r=0;v>n?r=-1:n>v&&(r=1),i(e,r,{x:e.touches[0].clientX,y:e.touches[0].clientY}),v=n,g(e),y(e)}},L=function(e){h=!1,s.stop("touchmove",G),s.stop("touchend",L),s.stop("touchcancel",L),u=null,r&&r(e)},_=function(e,n){g(e),y(e),d=n.clientX,l=n.clientY,u=e.target||e.srcElement,t&&t(e,{x:d,y:l}),h||(h=!0,s.on("touchmove",G),s.on("touchend",L),s.on("touchcancel",L))},A=function(t){return console.log("Touch start for ",e),1===t.touches.length?_(t,t.touches[0]):(2===t.touches.length&&(g(t),y(t),v=E(t.touches[0],t.touches[1])),void 0)};return f.on("mousedown",V),f.on("touchstart",A),{onStart:function(e){return t=e,this},onDrag:function(e){return n=e,this},onStop:function(e){return r=e,this},onScroll:function(e){return P(e),this},release:function(){s.stop("mousemove",w),s.stop("mousedown",V),s.stop("mouseup",b),s.stop("touchmove",G),s.stop("touchend",L),s.stop("touchcancel",L),P(null)}}},Viva.Input=Viva.Input||{},Viva.Input.domInputManager=function(e,t){var n={};return{bindDragNDrop:function(e,r){var i;if(r){var o=t.getNodeUI(e.id);i=Viva.Graph.Utils.dragndrop(o),"function"==typeof r.onStart&&i.onStart(r.onStart),"function"==typeof r.onDrag&&i.onDrag(r.onDrag),"function"==typeof r.onStop&&i.onStop(r.onStop),n[e.id]=i}else(i=n[e.id])&&(i.release(),delete n[e.id])}}},Viva.Graph.Utils=Viva.Graph.Utils||{},function(){var e,t,n=0,r=["ms","moz","webkit","o"];for(t="undefined"!=typeof window?window:"undefined"!=typeof global?global:{setTimeout:function(){},clearTimeout:function(){}},e=0;r.length>e&&!t.requestAnimationFrame;++e){var i=r[e];t.requestAnimationFrame=t[i+"RequestAnimationFrame"],t.cancelAnimationFrame=t[i+"CancelAnimationFrame"]||t[i+"CancelRequestAnimationFrame"]}t.requestAnimationFrame||(t.requestAnimationFrame=function(e){var r=(new Date).getTime(),i=Math.max(0,16-(r-n)),o=t.setTimeout(function(){e(r+i)},i);return n=r+i,o}),t.cancelAnimationFrame||(t.cancelAnimationFrame=function(e){t.clearTimeout(e)}),Viva.Graph.Utils.timer=function(e){var n,r=function(){t.cancelAnimationFrame(n),n=0},i=function(){n=t.requestAnimationFrame(i),e()||r()};return i(),{stop:r,restart:function(){n||i()}}}}(),Viva.Graph.geom=function(){return{intersect:function(e,t,n,r,i,o,a,u){var s,f,c,d,l,h,v,p,m,g,y,x,w,V={x:0,y:0};return s=r-t,c=e-n,l=n*t-e*r,m=s*i+c*o+l,g=s*a+c*u+l,0!==m&&0!==g&&m>=0==g>=4?null:(f=u-o,d=i-a,h=a*o-i*u,v=f*e+d*t+h,p=f*n+d*r+h,0!==v&&0!==p&&v>=0==p>=0?null:(y=s*d-f*c,0===y?null:(x=0>y?-y/2:y/2,x=0,w=c*h-d*l,V.x=(0>w?w-x:w+x)/y,w=f*l-s*h,V.y=(0>w?w-x:w+x)/y,V)))},intersectRect:function(e,t,n,r,i,o,a,u){return this.intersect(e,t,e,r,i,o,a,u)||this.intersect(e,r,n,r,i,o,a,u)||this.intersect(n,r,n,t,i,o,a,u)||this.intersect(n,t,e,t,i,o,a,u)},convexHull:function(e){var t=function(e,t){var n,r,i=function(t){var n=t.x-e.x,r=t.y-e.y,i=n>0?1:-1;return i*n*n/(n*n+r*r)},o=t.sort(function(e,t){return i(t)-i(e)}),a=o[0],u=i(a),s=a.x-e.x,f=a.y-e.y,c=s*s+f*f;for(r=1;o.length>r;++r){a=o[r];var d=i(a);d===u?(s=a.x-e.x,f=a.y-e.y,n=s*s+f*f,c>n?o.splice(r,1):o.splice(r-1,1)):u=d}return o},n=function(e,t,n){return 0>(n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x)};if(3>e.length)return e;var r,i=0;for(r=0;e.length>r;++r)e[r].ya.length)return a;var u=[];u.push(o),u.push(a[0]),u.push(a[1]);var s=u.length;for(r=2;a.length>r;++r){for(;!n(u[s-2],u[s-1],a[r]);)u.pop(),s-=1;u.push(a[r]),s+=1}return u}}},Viva.Graph.Rect=function(e,t,n,r){this.x1=e||0,this.y1=t||0,this.x2=n||0,this.y2=r||0},Viva.Graph.Point2d=function(e,t){this.x=e||0,this.y=t||0},Viva.Graph.Node=function(e){this.id=e,this.links=[],this.data=null},Viva.Graph.Link=function(e,t,n,r){this.fromId=e,this.toId=t,this.data=n,this.id=r},Viva.Graph.graph=function(){var e="function"==typeof Object.create?Object.create(null):{},t=[],n={},r=0,i=0,o=[],a=function(e){e.fire("changed",o)},u=function(){i+=1},s=function(e){i-=1,0===i&&o.length>0&&(a(e),o.length=0)},f=function(e,t){o.push({node:e,changeType:t})},c=function(e,t){o.push({link:e,changeType:t})},d={addNode:function(t,n){if(t===void 0)throw{message:"Invalid node identifier"};u();var i=this.getNode(t);return i?f(i,"update"):(i=new Viva.Graph.Node(t),r++,f(i,"add")),i.data=n,e[t]=i,s(this),i},addLink:function(e,r,i){u();var o=this.getNode(e)||this.addNode(e),a=this.getNode(r)||this.addNode(r),f=""+e+"👉 "+(""+r),d=n.hasOwnProperty(f);(d||this.hasLink(e,r))&&(d||(n[f]=0),f+="@"+ ++n[f]);var l=new Viva.Graph.Link(e,r,i,f);return t.push(l),o.links.push(l),a.links.push(l),c(l,"add"),s(this),l},removeLink:function(e){if(!e)return!1;var n=Viva.Graph.Utils.indexOfElementInArray(e,t);if(0>n)return!1;u(),t.splice(n,1);var r=this.getNode(e.fromId),i=this.getNode(e.toId);return r&&(n=Viva.Graph.Utils.indexOfElementInArray(e,r.links),n>=0&&r.links.splice(n,1)),i&&(n=Viva.Graph.Utils.indexOfElementInArray(e,i.links),n>=0&&i.links.splice(n,1)),c(e,"remove"),s(this),!0},removeNode:function(t){var n=this.getNode(t);if(!n)return!1;for(u();n.links.length;){var i=n.links[0];this.removeLink(i)}e[t]=null,delete e[t],r--,f(n,"remove"),s(this)},getNode:function(t){return e[t]},getNodesCount:function(){return r},getLinksCount:function(){return t.length},getLinks:function(e){var t=this.getNode(e);return t?t.links:null},forEachNode:function(t){if("function"==typeof t){var n;for(n in e)if(t(e[n]))return}},forEachLinkedNode:function(t,n,r){var i,o,a,u=this.getNode(t);if(u&&u.links&&"function"==typeof n)if(r)for(i=0;u.links.length>i;++i)o=u.links[i],o.fromId===t&&n(e[o.toId],o);else for(i=0;u.links.length>i;++i)o=u.links[i],a=o.fromId===t?o.toId:o.fromId,n(e[a],o)},forEachLink:function(e){var n,r;if("function"==typeof e)for(n=0,r=t.length;r>n;++n)e(t[n])},beginUpdate:function(){u()},endUpdate:function(){s(this)},clear:function(){var e=this;e.beginUpdate(),e.forEachNode(function(t){e.removeNode(t.id)}),e.endUpdate()},hasLink:function(e,t){var n,r=this.getNode(e);if(!r)return null;for(n=0;r.links.length>n;++n){var i=r.links[n];if(i.fromId===e&&i.toId===t)return i}return null}};return Viva.Graph.Utils.events(d).extend(),d},Viva.Graph.operations=function(){return{density:function(e,t){var n=e.getNodesCount();return 0===n?0/0:t?e.getLinksCount()/(n*(n-1)):2*e.getLinksCount()/(n*(n-1))}}},Viva.Graph.Physics=Viva.Graph.Physics||{},Viva.Graph.Physics.Vector=function(e,t){this.x=e||0,this.y=t||0},Viva.Graph.Physics.Vector.prototype={multiply:function(e){return new Viva.Graph.Physics.Vector(this.x*e,this.y*e)}},Viva.Graph.Physics.Point=function(e,t){this.x=e||0,this.y=t||0},Viva.Graph.Physics.Point.prototype={add:function(e){return new Viva.Graph.Physics.Point(this.x+e.x,this.y+e.y)}},Viva.Graph.Physics.Body=function(){this.mass=1,this.force=new Viva.Graph.Physics.Vector,this.velocity=new Viva.Graph.Physics.Vector,this.location=new Viva.Graph.Physics.Point,this.prevLocation=new Viva.Graph.Physics.Point},Viva.Graph.Physics.Body.prototype={loc:function(e){return e?(this.location.x=e.x,this.location.y=e.y,this):this.location},vel:function(e){return e?(this.velocity.x=e.x,this.velocity.y=e.y,this):this.velocity}},Viva.Graph.Physics.Spring=function(e,t,n,r,i){this.body1=e,this.body2=t,this.length=n,this.coeff=r,this.weight=i},Viva.Graph.Physics.QuadTreeNode=function(){this.centerOfMass=new Viva.Graph.Physics.Point,this.children=[],this.body=null,this.hasChildren=!1,this.x1=0,this.y1=0,this.x2=0,this.y2=0},Viva.Graph.Physics=Viva.Graph.Physics||{},Viva.Graph.Physics.eulerIntegrator=function(){return{integrate:function(e,t){var n,r=e.speedLimit,i=0,o=0,a=e.bodies.length;for(n=0;a>n;++n){var u=e.bodies[n],s=t/u.mass;u.velocity.x+=s*u.force.x,u.velocity.y+=s*u.force.y;var f=u.velocity.x,c=u.velocity.y,d=Math.sqrt(f*f+c*c);d>r&&(u.velocity.x=r*f/d,u.velocity.y=r*c/d),i=t*u.velocity.x,o=t*u.velocity.y,u.location.x+=i,u.location.y+=o}return i*i+o*o}}},Viva.Graph.Physics.nbodyForce=function(e){function t(e,t){this.node=e,this.body=t}function n(){this.stack=[],this.popIdx=0}e=Viva.lazyExtend(e||{gravity:-1,theta:.8}),n.prototype={isEmpty:function(){return 0===this.popIdx},push:function(e,n){var r=this.stack[this.popIdx];r?(r.node=e,r.body=n):this.stack[this.popIdx]=new t(e,n),++this.popIdx},pop:function(){return this.popIdx>0?this.stack[--this.popIdx]:void 0},reset:function(){this.popIdx=0}};var r=e.gravity,i=[],o=new n,a=e.theta,u=Viva.random("5f4dcc3b5aa765d61d8327deb882cf99",75,20,63,108,65,76,65,72),s=function(){this.body=null,this.quads=[],this.mass=0,this.massX=0,this.massY=0,this.left=0,this.top=0,this.bottom=0,this.right=0,this.isInternal=!1},f=[],c=0,d=function(){var e;return f[c]?(e=f[c],e.quads[0]=null,e.quads[1]=null,e.quads[2]=null,e.quads[3]=null,e.body=null,e.mass=e.massX=e.massY=0,e.left=e.right=e.top=e.bottom=0,e.isInternal=!1):(e=new s,f[c]=e),++c,e},l=d(),h=function(e,t){var n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return 1e-8>n&&1e-8>r},v=function(e){for(o.reset(),o.push(l,e);!o.isEmpty();){var t=o.pop(),n=t.node,r=t.body;if(n.isInternal){var i=r.location.x,a=r.location.y;n.mass=n.mass+r.mass,n.massX=n.massX+r.mass*i,n.massY=n.massY+r.mass*a;var s=0,f=n.left,c=(n.right+f)/2,v=n.top,p=(n.bottom+v)/2;if(i>c){s+=1;var m=f;f=c,c+=c-m}if(a>p){s+=2;var g=v;v=p,p+=p-g}var y=n.quads[s];y||(y=d(),y.left=f,y.top=v,y.right=c,y.bottom=p,n.quads[s]=y),o.push(y,r)}else if(n.body){var x=n.body;if(n.body=null,n.isInternal=!0,h(x.location,r.location)){if(1e-8>n.right-n.left)return;do{var w=u.nextDouble(),V=(n.right-n.left)*w,b=(n.bottom-n.top)*w;x.location.x=n.left+V,x.location.y=n.top+b}while(h(x.location,r.location))}o.push(n,x),o.push(n,r)}else n.body=r}},p=function(e){var t,n,o,s,f=i,c=1,d=0,h=1;for(f[0]=l;c;){var v=f[d],p=v.body;c-=1,d+=1,p&&p!==e?(n=p.location.x-e.location.x,o=p.location.y-e.location.y,s=Math.sqrt(n*n+o*o),0===s&&(n=(u.nextDouble()-.5)/50,o=(u.nextDouble()-.5)/50,s=Math.sqrt(n*n+o*o)),t=r*p.mass*e.mass/(s*s*s),e.force.x=e.force.x+t*n,e.force.y=e.force.y+t*o):(n=v.massX/v.mass-e.location.x,o=v.massY/v.mass-e.location.y,s=Math.sqrt(n*n+o*o),0===s&&(n=(u.nextDouble()-.5)/50,o=(u.nextDouble()-.5)/50,s=Math.sqrt(n*n+o*o)),a>(v.right-v.left)/s?(t=r*v.mass*e.mass/(s*s*s),e.force.x=e.force.x+t*n,e.force.y=e.force.y+t*o):(v.quads[0]&&(f[h]=v.quads[0],c+=1,h+=1),v.quads[1]&&(f[h]=v.quads[1],c+=1,h+=1),v.quads[2]&&(f[h]=v.quads[2],c+=1,h+=1),v.quads[3]&&(f[h]=v.quads[3],c+=1,h+=1)))}},m=function(e){var t,n=Number.MAX_VALUE,r=Number.MAX_VALUE,i=Number.MIN_VALUE,o=Number.MIN_VALUE,a=e.bodies,u=a.length;for(t=u;t--;){var s=a[t].location.x,f=a[t].location.y;n>s&&(n=s),s>i&&(i=s),r>f&&(r=f),f>o&&(o=f)}var h=i-n,p=o-r;for(h>p?o=r+h:i=n+p,c=0,l=d(),l.left=n,l.right=i,l.top=r,l.bottom=o,t=u;t--;)v(a[t],l)};return{insert:v,init:m,update:p,options:function(e){return e?("number"==typeof e.gravity&&(r=e.gravity),"number"==typeof e.theta&&(a=e.theta),this):{gravity:r,theta:a}}}},Viva.Graph.Physics.dragForce=function(e){e||(e={});var t={coeff:e.coeff||.01};return{update:function(e){e.force.x-=t.coeff*e.velocity.x,e.force.y-=t.coeff*e.velocity.y},options:function(e){return e?("number"==typeof e.coeff&&(t.coeff=e.coeff),this):t}}},Viva.Graph.Physics.springForce=function(e){e=Viva.lazyExtend(e,{length:50,coeff:22e-5});var t=Viva.random("Random number 4.","Chosen by fair dice roll");return{update:function(n){var r=n.body1,i=n.body2,o=0>n.length?e.length:n.length,a=i.location.x-r.location.x,u=i.location.y-r.location.y,s=Math.sqrt(a*a+u*u);0===s&&(a=(t.nextDouble()-.5)/50,u=(t.nextDouble()-.5)/50,s=Math.sqrt(a*a+u*u));var f=s-o,c=(!n.coeff||0>n.coeff?e.coeff:n.coeff)*f/s*n.weight;r.force.x+=c*a,r.force.y+=c*u,i.force.x+=-c*a,i.force.y+=-c*u},options:function(t){return t?("number"==typeof t.length&&(e.length=t.length),"number"==typeof t.coeff&&(e.coeff=t.coeff),this):e}}},Viva.Graph.Physics=Viva.Graph.Physics||{},Viva.Graph.Physics.forceSimulator=function(e){var t,n,r,i=e,o=[],a=[];return{speedLimit:1,bodies:o,accumulate:function(){var e,i;for(n.init(this),e=o.length;e--;)i=o[e],i.force.x=0,i.force.y=0,n.update(i),r.update(i);for(e=a.length;e--;)t.update(a[e])},run:function(e){return this.accumulate(),i.integrate(this,e)},addBody:function(e){if(!e)throw{message:"Cannot add null body to force simulator"};return o.push(e),e},removeBody:function(e){if(!e)return!1;var t=Viva.Graph.Utils.indexOfElementInArray(e,o);return 0>t?!1:o.splice(t,1)},addSpring:function(e,t,n,r,i){if(!e||!t)throw{message:"Cannot add null spring to force simulator"};if("number"!=typeof n)throw{message:"Spring length should be a number"};r="number"==typeof r?r:1;var o=new Viva.Graph.Physics.Spring(e,t,n,i>=0?i:-1,r);return a.push(o),o},removeSpring:function(e){if(!e)return!1;var t=Viva.Graph.Utils.indexOfElementInArray(e,a);return 0>t?!1:a.splice(t,1)},setNbodyForce:function(e){if(!e)throw{message:"Cannot add mighty (unknown) force to the simulator"};n=e},setDragForce:function(e){if(!e)throw{message:"Cannot add mighty (unknown) force to the simulator"};r=e},setSpringForce:function(e){if(!e)throw{message:"Cannot add unknown force to the simulator"};t=e}}},Viva.Graph.Layout=Viva.Graph.Layout||{},Viva.Graph.Layout.forceDirected=function(e,t){if(!e)throw{message:"Graph structure cannot be undefined"};t=Viva.lazyExtend(t,{springLength:80,springCoeff:2e-4,gravity:-1.2,theta:.8,dragCoeff:.02,springTransform:function(){},timeStep:20,stableThreshold:.001});var n=Viva.Graph.Physics.forceSimulator(Viva.Graph.Physics.eulerIntegrator()),r=Viva.Graph.Physics.nbodyForce({gravity:t.gravity,theta:t.theta}),i=Viva.Graph.Physics.springForce({length:t.springLength,coeff:t.springCoeff}),o=Viva.Graph.Physics.dragForce({coeff:t.dragCoeff}),a=new Viva.Graph.Rect,u=Viva.random("ted.com",103,114,101,97,116),s={},f=function(e){if(e.position)return e.position;var n=(a.x1+a.x2)/2,r=(a.y1+a.y2)/2,i=t.springLength;if(e.links&&e.links.length>0){var o=e.links[0],f=o.fromId!==e.id?s[o.fromId]:s[o.toId];f&&f.location&&(n=f.location.x,r=f.location.y)}return{x:n+u.next(i)-i/2,y:r+u.next(i)-i/2}},c=function(e){return s[e]},d=function(e){s[e]=null,delete s[e]},l={},h=function(t){var n=c(t);n.mass=1+e.getLinks(t).length/3},v=function(e){return e&&(e.isPinned||e.data&&e.data.isPinned)},p=function(e){return e.isPinned},m=function(t){var r=c(t);if(!r){var i=e.getNode(t);if(!i)return;r=new Viva.Graph.Physics.Body,s[t]=r;var o=f(i);r.loc(o),h(t),v(i)&&(r.isPinned=!0),n.addBody(r)}},g=function(e){m(e.id)},y=function(t){var r=c(t.id);r&&(d(t.id),n.removeBody(r),0===e.getNodesCount()&&(a.x1=a.y1=0,a.x2=a.y2=0))},x=function(e){h(e.fromId),h(e.toId);var r=c(e.fromId),i=c(e.toId),o=n.addSpring(r,i,-1,e.weight);t.springTransform(e,o),l[e.id]=o},w=function(t){var r=l[t.id];if(r){var i=e.getNode(t.fromId),o=e.getNode(t.toId);i&&h(i.id),o&&h(o.id),delete l[t.id],n.removeSpring(r)}},V=function(e){for(var t=0;e.length>t;++t){var n=e[t];"add"===n.changeType?(n.node&&m(n.node.id),n.link&&x(n.link)):"remove"===n.changeType&&(n.node&&y(n.node),n.link&&w(n.link))}},b=function(){e.forEachNode(g),e.forEachLink(x),e.addEventListener("changed",V)},N=function(){var t=Number.MAX_VALUE,n=Number.MAX_VALUE,r=Number.MIN_VALUE,i=Number.MIN_VALUE;if(0!==e.getNodesCount()){for(var o in s)if(s.hasOwnProperty(o)){var u=s[o];p(u)?(u.location.x=u.prevLocation.x,u.location.y=u.prevLocation.y):(u.prevLocation.x=u.location.x,u.prevLocation.y=u.location.y),t>u.location.x&&(t=u.location.x),u.location.x>r&&(r=u.location.x),n>u.location.y&&(n=u.location.y),u.location.y>i&&(i=u.location.y)}a.x1=t,a.x2=r,a.y1=n,a.y2=i}};return n.setSpringForce(i),n.setNbodyForce(r),n.setDragForce(o),b(),{run:function(e){var t;for(e=e||50,t=0;e>t;++t)this.step()},step:function(){var e=n.run(t.timeStep);return N(),t.stableThreshold>e},isNodePinned:function(e){var t=c(e.id);return t?p(t):void 0},pinNode:function(e,t){var n=c(e.id);n.isPinned=!!t},getNodePosition:function(e){var t=c(e);return t||(m(e),t=c(e)),t&&t.location},getLinkPosition:function(e){var t=this.getNodePosition(e.fromId),n=this.getNodePosition(e.toId);return{from:t,to:n}},setNodePosition:function(e,t,n){var r=c(e.id);r&&(r.prevLocation.x=r.location.x=t,r.prevLocation.y=r.location.y=n)},getGraphRect:function(){return a},dispose:function(){e.removeEventListener("change",V)},springLength:function(e){return 1===arguments.length?(i.options({length:e}),this):i.options().length},springCoeff:function(e){return 1===arguments.length?(i.options({coeff:e}),this):i.options().coeff},gravity:function(e){return 1===arguments.length?(r.options({gravity:e}),this):r.options().gravity},theta:function(e){return 1===arguments.length?(r.options({theta:e}),this):r.options().theta},drag:function(e){return 1===arguments.length?(o.options({coeff:e}),this):o.options().coeff}}},Viva.Graph.Layout=Viva.Graph.Layout||{},Viva.Graph.Layout.constant=function(e,t){t=Viva.lazyExtend(t,{maxX:1024,maxY:1024,seed:"Deterministic randomness made me do this"});var n=Viva.random(t.seed),r=new Viva.Graph.Rect(Number.MAX_VALUE,Number.MAX_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),i=function(){return new Viva.Graph.Point2d(n.next(t.maxX),n.next(t.maxY))},o=function(e,t){e.xt.x2&&(t.x2=e.x),e.yt.y2&&(t.y2=e.y)},a="function"==typeof Object.create?Object.create(null):{},u=function(e){e&&(a[e.id]=i(e),o(a[e.id],r))},s=function(){0!==e.getNodesCount()&&(r.x1=Number.MAX_VALUE,r.y1=Number.MAX_VALUE,r.x2=Number.MIN_VALUE,r.y2=Number.MIN_VALUE,e.forEachNode(u))},f=function(e){for(var t=0;e.length>t;++t){var n=e[t];n.node&&("add"===n.changeType?u(n.node):delete a[n.node.id])}};return e.addEventListener("changed",f),{run:function(){this.step()},step:function(){return s(),!0},getGraphRect:function(){return r},dispose:function(){e.removeEventListener("change",f)},isNodePinned:function(){return!0},pinNode:function(){},getNodePosition:function(t){var n=a[t];return n||u(e.getNode(t)),n},getLinkPosition:function(e){var t=this.getNodePosition(e.fromId),n=this.getNodePosition(e.toId);return{from:t,to:n}},setNodePosition:function(e,t,n){var r=a[e.id];r&&(r.x=t,r.y=n)},placeNode:function(e){return"function"==typeof e?(i=e,s(),this):i(e)}}},Viva.Graph.View=Viva.Graph.View||{},Viva.Graph.View.renderer=function(e,t){var n=30;t=t||{};var r,i,o,a,u=t.layout,s=t.graphics,f=t.container,c=!1,d=!0,l=0,h=0,v=!1,p=!1,m={x:0,y:0},g={offsetX:0,offsetY:0,scale:1},y=function(){f=f||window.document.body,u=u||Viva.Graph.Layout.forceDirected(e),s=s||Viva.Graph.View.svgGraphics(e,{container:f}),t.hasOwnProperty("renderLinks")||(t.renderLinks=!0),t.prerender=t.prerender||0,r=(s.inputManager||Viva.Input.domInputManager)(e,s)},x=Viva.Graph.Utils.events(window),w=Viva.Graph.Utils.events({}).extend(),V=function(){s.beginRender(),t.renderLinks&&s.renderLinks(),s.renderNodes(),s.endRender()},b=function(){return v=u.step()&&!p,V(),!v},N=function(e){return i?(h+=e,void 0):(e?(h+=e,i=Viva.Graph.Utils.timer(function(){return b()},n)):(l=0,h=0,i=Viva.Graph.Utils.timer(b,n)),void 0)},P=function(){v=!1,i.restart()},E=function(){var e;if("number"==typeof t.prerender&&t.prerender>0)for(e=0;t.prerender>e;e+=1)u.step()},G=function(){var e=u.getGraphRect(),t=Viva.Graph.Utils.getDimension(f);m.x=m.y=0,g.offsetX=t.width/2-(e.x2+e.x1)/2,g.offsetY=t.height/2-(e.y2+e.y1)/2,s.graphCenterChanged(g.offsetX,g.offsetY),d=!1},L=function(e){var t=u.getNodePosition(e.id);s.addNode(e,t)},_=function(e){s.releaseNode(e)},A=function(e){var t=u.getLinkPosition(e);s.addLink(e,t)},I=function(e){s.releaseLink(e)},k=function(e){var t=!1;r.bindDragNDrop(e,{onStart:function(){t=u.isNodePinned(e),u.pinNode(e,!0),p=!0,P()},onDrag:function(t,n){var r=u.getNodePosition(e.id);u.setNodePosition(e,r.x+n.x/g.scale,r.y+n.y/g.scale),p=!0,V()},onStop:function(){u.pinNode(e,t),p=!1}})},T=function(e){r.bindDragNDrop(e,null)},C=function(){s.init(f),e.forEachNode(L),t.renderLinks&&e.forEachLink(A)},S=function(){s.release(f)},M=function(t){var n=t.node;"add"===t.changeType?(L(n),k(n),d&&G()):"remove"===t.changeType?(T(n),_(n),0===e.getNodesCount()&&(d=!0)):"update"===t.changeType&&(T(n),_(n),L(n),k(n))},U=function(e){var n=e.link;if("add"===e.changeType)t.renderLinks&&A(n);else if("remove"===e.changeType)t.renderLinks&&I(n);else if("update"===e.changeType)throw"Update type is not implemented. TODO: Implement me!"},D=function(e){var t,n;for(t=0;e.length>t;t+=1)n=e[t],n.node?M(n):n.link&&U(n);P()},R=function(){G(),b()},F=function(){a&&(a.release(),a=null)},O=function(){o&&(o.stop("changed",D),o=null)},z=function(e,t){if(!t){var n=Viva.Graph.Utils.getDimension(f);t={x:n.width/2,y:n.height/2}}var r=Math.pow(1.4,e?-.2:.2);g.scale=s.scale(r,t),V(),w.fire("scale",g.scale)},B=function(){x.on("resize",R),F(),a=Viva.Graph.Utils.dragndrop(f),a.onDrag(function(e,t){m.x+=t.x,m.y+=t.y,s.translateRel(t.x,t.y),V()}),a.onScroll(function(e,t,n){z(0>t,n)}),e.forEachNode(k),O(),o=Viva.Graph.Utils.events(e),o.on("changed",D)},Y=function(){c=!1,O(),F(),x.stop("resize",R),w.removeAllListeners(),i.stop(),e.forEachLink(function(e){t.renderLinks&&I(e)}),e.forEachNode(function(e){T(e),_(e)}),u.dispose(),S()};return{run:function(e){return c||(y(),E(),G(),C(),B(),c=!0),N(e),this},reset:function(){s.resetScale(),G(),g.scale=1},pause:function(){i.stop()},resume:function(){i.restart()},rerender:function(){return V(),this},zoomOut:function(){z(!0)},zoomIn:function(){z(!1)},moveTo:function(e,t){s.graphCenterChanged(g.offsetX-e*g.scale,g.offsetY-t*g.scale),V()},getGraphics:function(){return s},dispose:function(){Y()},on:function(e,t){return w.addEventListener(e,t),this},off:function(e,t){return w.removeEventListener(e,t),this}}},Viva.Graph.serializer=function(){var e=function(){if("undefined"==typeof JSON||!JSON.stringify||!JSON.parse)throw"JSON serializer is not defined."},t=function(e){return{id:e.id,data:e.data}},n=function(e){return{fromId:e.fromId,toId:e.toId,data:e.data}},r=function(e){return e},i=function(e){return e};return{storeToJSON:function(r,i,o){if(!r)throw"Graph is not defined";e(),i=i||t,o=o||n;var a={nodes:[],links:[]};return r.forEachNode(function(e){a.nodes.push(i(e))}),r.forEachLink(function(e){a.links.push(o(e))}),JSON.stringify(a)},loadFromJSON:function(t,n,o){if("string"!=typeof t)throw"String expected in loadFromJSON() method";e(),n=n||r,o=o||i;var a,u=JSON.parse(t),s=Viva.Graph.graph();if(!u||!u.nodes||!u.links)throw"Passed json string does not represent valid graph";for(a=0;u.nodes.length>a;++a){var f=n(u.nodes[a]);if(!f.hasOwnProperty("id"))throw"Graph node format is invalid. Node.id is missing";s.addNode(f.id,f.data)}for(a=0;u.links.length>a;++a){var c=o(u.links[a]);if(!c.hasOwnProperty("fromId")||!c.hasOwnProperty("toId"))throw"Graph link format is invalid. Both fromId and toId are required";s.addLink(c.fromId,c.toId,c.data)}return s}}},Viva.Graph.centrality=function(){var e=function(e,t,n){var r,i,o,a={},u=[],s={},f={},c=[t.id],d=function(e){f.hasOwnProperty(e.id)||(c.push(e.id),f[e.id]=i+1),f[e.id]===i+1&&(s[e.id]+=o,a[e.id].push(r))};for(e.forEachNode(function(e){a[e.id]=[],s[e.id]=0}),f[t.id]=0,s[t.id]=1;c.length;)r=c.shift(),i=f[r],o=s[r],u.push(r),e.forEachLinkedNode(r,d,n);return{S:u,P:a,sigma:s}},t=function(e,t,n){var r,i,o,a,u,s={},f=t.S;for(r=0;f.length>r;r+=1)s[f[r]]=0;for(;f.length;){for(i=f.pop(),o=(1+s[i])/t.sigma[i],a=t.P[i],r=0;a.length>r;r+=1)u=a[r],s[u]+=t.sigma[u]*o;i!==n&&(e[i]+=s[i])}},n=function(e){var t,n=[];for(t in e)e.hasOwnProperty(t)&&n.push({key:t,value:e[t]});return n.sort(function(e,t){return t.value-e.value})};return{betweennessCentrality:function(r){var i,o={};return r.forEachNode(function(e){o[e.id]=0}),r.forEachNode(function(n){i=e(r,n),t(o,i,n)}),n(o)},degreeCentrality:function(e,t){var n,r,i=[],o=[];if(t=(t||"both").toLowerCase(),"in"===t)n=function(e,t){var n,r=0;for(n=0;e.length>n;n+=1)r+=e[n].toId===t?1:0;return r};else if("out"===t)n=function(e,t){var n,r=0;for(n=0;e.length>n;n+=1)r+=e[n].fromId===t?1:0;return r};else{if("both"!==t)throw"Expected centrality degree kind is: in, out or both";n=function(e){return e.length}}e.forEachNode(function(t){var r=e.getLinks(t.id),o=n(r,t.id);i.hasOwnProperty(o)?i[o].push(t.id):i[o]=[t.id]});for(r in i)if(i.hasOwnProperty(r)){var a,u=i[r];if(u)for(a=0;u.length>a;++a)o.unshift({key:u[a],value:parseInt(r,10)})}return o}}},Viva.Graph.community=function(){return{slpa:function(e,t,n){var r=Viva.Graph._community.slpaAlgorithm(e,t,n);return r.run()}}},Viva.Graph._community={},Viva.Graph._community.slpaAlgorithm=function(e,t,n){t=t||100,n=n||.3;var r=Viva.random(1331782216905),i=Viva.random("Greeting goes to you, ","dear reader"),o=function(e,n){var r=[];return e.forEachUniqueWord(function(e,i){return i>n?(r.push({name:e,probability:i/t}),void 0):!0}),r},a=function(e){var t=[];return e.forEachNode(function(e){var n=Viva.Graph._community.occuranceMap(r);n.add(e.id),e.slpa={memory:n},t.push(e.id)}),t},u=function(e,n){var o,a=Viva.randomIterator(n,i),u=function(t){var n=e.getNode(t),i=Viva.Graph._community.occuranceMap(r);e.forEachLinkedNode(t,function(e){var t=e.slpa.memory.getRandomWord();i.add(t)});var o=i.getMostPopularFair();n.slpa.memory.add(o)};for(o=0;t-1>o;++o)a.forEach(u)},s=function(e){var r={};return e.forEachNode(function(e){var i,a=o(e.slpa.memory,n*t);for(i=0;a.length>i;++i){var u=a[i].name;r.hasOwnProperty(u)?r[u].push(e.id):r[u]=[e.id]}e.communities=a,e.slpa=null,delete e.slpa}),r};return{run:function(){var t=a(e);return u(e,t),s(e)}}},Viva.Graph._community.occuranceMap=function(e){e=e||Viva.random();var t={},n=[],r=!1,i=[],o=function(){var e;i.length=0;for(e in t)t.hasOwnProperty(e)&&i.push(e);i.sort(function(e,n){var r=t[n]-t[e];return r?r:n>e?-1:e>n?1:0})},a=function(){r&&(o(),r=!1)};return{add:function(e){e+="",t.hasOwnProperty(e)?t[e]+=1:t[e]=1,n.push(e),r=!0},getWordCount:function(e){return t[e]||0},getMostPopularFair:function(){if(1===n.length)return n[0];a();var r,o=0;for(r=1;i.length>r&&t[i[r-1]]===t[i[r]];++r)o+=1;return o+=1,i[e.next(o)]},getRandomWord:function(){if(0===n.length)throw"The occurance map is empty. Cannot get empty word";return n[e.next(n.length)]},forEachUniqueWord:function(e){if("function"!=typeof e)throw"Function callback is expected to enumerate all words";var n;for(a(),n=0;i.length>n;++n){var r=i[n],o=t[r],u=e(r,o);if(u)break}}}},Viva.Graph.generator=function(){return{complete:function(e){if(!e||1>e)throw{message:"At least two nodes expected for complete graph"};var t,n,r=Viva.Graph.graph();for(r.Name="Complete K"+e,t=0;e>t;++t)for(n=t+1;e>n;++n)t!==n&&r.addLink(t,n);return r},completeBipartite:function(e,t){if(!e||!t||0>e||0>t)throw{message:"Graph dimensions are invalid. Number of nodes in each partition should be greate than 0"};var n,r,i=Viva.Graph.graph();for(i.Name="Complete K "+e+","+t,n=0;e>n;++n)for(r=e;e+t>r;++r)i.addLink(n,r);return i},ladder:function(e){if(!e||0>e)throw{message:"Invalid number of nodes"};var t,n=Viva.Graph.graph();for(n.Name="Ladder graph "+e,t=0;e-1>t;++t)n.addLink(t,t+1),n.addLink(e+t,e+t+1),n.addLink(t,e+t);return n.addLink(e-1,2*e-1),n},circularLadder:function(e){if(!e||0>e)throw{message:"Invalid number of nodes"};
2 | var t=this.ladder(e);return t.Name="Circular ladder graph "+e,t.addLink(0,e-1),t.addLink(e,2*e-1),t},grid:function(e,t){var n,r,i=Viva.Graph.graph();for(i.Name="Grid graph "+e+"x"+t,n=0;e>n;++n)for(r=0;t>r;++r){var o=n+r*e;n>0&&i.addLink(o,n-1+r*e),r>0&&i.addLink(o,n+(r-1)*e)}return i},path:function(e){if(!e||0>e)throw{message:"Invalid number of nodes"};var t,n=Viva.Graph.graph();for(n.Name="Path graph "+e,n.addNode(0),t=1;e>t;++t)n.addLink(t-1,t);return n},lollipop:function(e,t){if(!t||0>t||!e||0>e)throw{message:"Invalid number of nodes"};var n,r=this.complete(e);for(r.Name="Lollipop graph. Head x Path "+e+"x"+t,n=0;t>n;++n)r.addLink(e+n-1,e+n);return r},balancedBinTree:function(e){var t,n=Viva.Graph.graph(),r=Math.pow(2,e);for(n.Name="Balanced bin tree graph "+e,t=1;r>t;++t){var i=t,o=2*i,a=2*i+1;n.addLink(i,o),n.addLink(i,a)}return n},randomNoLinks:function(e){if(!e||0>e)throw{message:"Invalid number of nodes"};var t,n=Viva.Graph.graph();for(n.Name="Random graph, no Links: "+e,t=0;e>t;++t)n.addNode(t);return n}}},Viva.Graph.View=Viva.Graph.View||{},Viva.Graph.View.cssGraphics=function(){var e,t,n,r="OLD_IE",i=1,o=1,a=function(){var e,t,n=Viva.BrowserInfo.browser;switch(n){case"mozilla":e="Moz";break;case"webkit":e="webkit";break;case"opera":e="O";break;case"msie":if(t=Viva.BrowserInfo.version.split(".")[0],!(t>8))return r;e="ms"}return e?e+"Transform":null}(),u=function(){return a===r?function(e,t,n,r){var i=Math.cos(r),o=Math.sin(r);0>r&&(r=2*Math.PI+r),Math.PI/2>r?(e.style.left=t+"px",e.style.top=n+"px"):Math.PI>r?(e.style.left=t-e.clientWidth*Math.cos(Math.PI-r),e.style.top=n):Math.PI+Math.PI/2>r?(e.style.left=t-e.clientWidth*Math.cos(Math.PI-r),e.style.top=n+e.clientWidth*Math.sin(Math.PI-r)):(e.style.left=t,e.style.top=n+e.clientWidth*Math.sin(Math.PI-r)),e.style.filter='progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand",M11='+i+", M12="+-o+","+"M21="+o+", M22="+i+");"}:a?function(e,t,n,r){e.style.left=t+"px",e.style.top=n+"px",e.style[a]="rotate("+r+"rad)",e.style[a+"Origin"]="left"}:function(){}}(),s=function(){var e=window.document.createElement("div");return e.setAttribute("class","node"),e},f=function(e,t){e.style.left=t.x-5+"px",e.style.top=t.y-5+"px"},c=function(e,t,n){var r=t.x-n.x,i=t.y-n.y,o=Math.sqrt(r*r+i*i);e.style.height="1px",e.style.width=o+"px",u(e,n.x,n.y,Math.atan2(i,r))},d=function(){var e=window.document.createElement("div");return e.setAttribute("class","link"),e},l=function(){if(e){if(!a||a===r)throw"Not implemented. TODO: Implement OLD_IE Filter based transform";var u="matrix("+i+", 0, 0,"+o+","+t+","+n+")";e.style[a]=u}};return{node:function(e){return e&&"function"!=typeof e?s(e):(s=e,this)},link:function(e){return e&&"function"!=typeof e?d(e):(d=e,this)},inputManager:Viva.Input.domInputManager,graphCenterChanged:function(e,r){t=e,n=r,l()},translateRel:function(e,r){t+=e,n+=r,l()},scale:function(){return 1},resetScale:function(){return this},beginRender:function(){},endRender:function(){},placeNode:function(e){return f=e,this},placeLink:function(e){return c=e,this},init:function(t){e=t,l()},initLink:function(t){e.childElementCount>0?e.insertBefore(t,e.firstChild):e.appendChild(t)},releaseLink:function(t){e.removeChild(t)},initNode:function(t){e.appendChild(t)},releaseNode:function(t){e.removeChild(t)},updateNodePosition:function(e,t){f(e,t)},updateLinkPosition:function(e,t,n){c(e,t,n)}}},Viva.Graph.svg=function(e){var t="http://www.w3.org/2000/svg",n="http://www.w3.org/1999/xlink",r=e;return"string"==typeof e&&(r=window.document.createElementNS(t,e)),r.vivagraphAugmented?r:(r.vivagraphAugmented=!0,r.attr=function(e,t){return 2===arguments.length?(null!==t?r.setAttributeNS(null,e,t):r.removeAttributeNS(null,e),r):r.getAttributeNS(null,e)},r.append=function(e){var t=Viva.Graph.svg(e);return r.appendChild(t),t},r.text=function(e){return e!==void 0?(r.textContent=e,r):r.textContent},r.link=function(e){return arguments.length?(r.setAttributeNS(n,"xlink:href",e),r):r.getAttributeNS(n,"xlink:href")},r.children=function(e){var t,n,i=[],o=r.childNodes.length;if(void 0===e&&r.hasChildNodes())for(t=0;o>t;t++)i.push(Viva.Graph.svg(r.childNodes[t]));else if("string"==typeof e){var a="."===e[0],u="#"===e[0],s=!a&&!u;for(t=0;o>t;t++){var f=r.childNodes[t];if(1===f.nodeType){var c=f.attr("class"),d=f.attr("id"),l=f.nodeName;if(a&&c){for(c=c.replace(/\s+/g," ").split(" "),n=0;c.length>n;n++)if(a&&c[n]===e.substr(1)){i.push(Viva.Graph.svg(f));break}}else{if(u&&d===e.substr(1)){i.push(Viva.Graph.svg(f));break}s&&l===e&&i.push(Viva.Graph.svg(f))}i=i.concat(Viva.Graph.svg(f).children(e))}}if(u&&1===i.length)return i[0]}return i},r)},Viva.Graph.View=Viva.Graph.View||{},Viva.Graph.View.svgGraphics=function(){var e,t,n,r,i,o=1,a={},u={},s=function(){return Viva.Graph.svg("rect").attr("width",10).attr("height",10).attr("fill","#00a2e8")},f=function(e,t){e.attr("x",t.x-5).attr("y",t.y-5)},c=function(){return Viva.Graph.svg("line").attr("stroke","#999")},d=function(e,t,n){e.attr("x1",t.x).attr("y1",t.y).attr("x2",n.x).attr("y2",n.y)},l=function(e){e.fire("rescaled")},h={x:0,y:0},v={x:0,y:0},p={x:0,y:0},m=function(){if(e){var t="matrix("+o+", 0, 0,"+o+","+n+","+r+")";e.attr("transform",t)}},g={getNodeUI:function(e){return a[e]},getLinkUI:function(e){return u[e]},node:function(e){return"function"==typeof e?(s=e,this):void 0},link:function(e){return"function"==typeof e?(c=e,this):void 0},placeNode:function(e){return f=e,this},placeLink:function(e){return d=e,this},beginRender:function(){},endRender:function(){},graphCenterChanged:function(e,t){n=e,r=t,m()},inputManager:Viva.Input.domInputManager,translateRel:function(n,r){var i=t.createSVGPoint(),o=e.getCTM(),a=t.createSVGPoint().matrixTransform(o.inverse());i.x=n,i.y=r,i=i.matrixTransform(o.inverse()),i.x=(i.x-a.x)*o.a,i.y=(i.y-a.y)*o.d,o.e+=i.x,o.f+=i.y;var u="matrix("+o.a+", 0, 0,"+o.d+","+o.e+","+o.f+")";e.attr("transform",u)},scale:function(i,a){var u=t.createSVGPoint();u.x=a.x,u.y=a.y,u=u.matrixTransform(e.getCTM().inverse());var s=t.createSVGMatrix().translate(u.x,u.y).scale(i).translate(-u.x,-u.y),f=e.getCTM().multiply(s);o=f.a,n=f.e,r=f.f;var c="matrix("+f.a+", 0, 0,"+f.d+","+f.e+","+f.f+")";return e.attr("transform",c),l(this),o},resetScale:function(){o=1;var t="matrix(1, 0, 0, 1, 0, 0)";return e.attr("transform",t),l(this),this},init:function(n){t=Viva.Graph.svg("svg"),e=Viva.Graph.svg("g").attr("buffered-rendering","dynamic"),t.appendChild(e),n.appendChild(t),m(),"function"==typeof i&&i(t)},release:function(e){t&&e&&e.removeChild(t)},addLink:function(t,n){var r=c(t);if(r)return r.position=n,r.link=t,u[t.id]=r,e.childElementCount>0?e.insertBefore(r,e.firstChild):e.appendChild(r),r},releaseLink:function(t){var n=u[t.id];n&&(e.removeChild(n),delete u[t.id])},addNode:function(t,n){var r=s(t);if(r)return r.position=n,r.node=t,a[t.id]=r,e.appendChild(r),r},releaseNode:function(t){var n=a[t.id];n&&(e.removeChild(n),delete a[t.id])},renderNodes:function(){for(var e in a)if(a.hasOwnProperty(e)){var t=a[e];h.x=t.position.x,h.y=t.position.y,f(t,h,t.node)}},renderLinks:function(){for(var e in u)if(u.hasOwnProperty(e)){var t=u[e];v.x=t.position.from.x,v.y=t.position.from.y,p.x=t.position.to.x,p.y=t.position.to.y,d(t,v,p,t.link)}},getGraphicsRoot:function(e){return"function"==typeof e&&(t?e(t):i=e),t},getSvgRoot:function(){return t}};return Viva.Graph.Utils.events(g).extend(),g},Viva.Graph.View.svgNodeFactory=function(e){var t="#999",n=Viva.Graph.geom(),r=function(e){e.size={w:10,h:10},e.append("rect").attr("width",e.size.w).attr("height",e.size.h).attr("stroke","orange").attr("fill","orange")},i=function(e){return e.size};return{node:function(e){var t=Viva.Graph.svg("g");return r(t,e),t.nodeId=e.id,t},link:function(n){var r=e.getNode(n.fromId),i=r&&r.ui;if(i&&!i.linksContainer){var o=Viva.Graph.svg("path").attr("stroke",t);return i.linksContainer=o,o}return null},customContent:function(e,t){if("function"!=typeof e||"function"!=typeof t)throw"Two functions expected: contentCreator(nodeUI, node) and size(nodeUI)";r=e,i=t},placeNode:function(t,r){var o="",a=i(t);e.forEachLinkedNode(t.nodeId,function(e,u){if(e.position&&e.ui&&e.ui!==t&&u.fromId===t.nodeId){var s=i(e.ui),f=e.position,c=n.intersectRect(r.x-a.w/2,r.y-a.h/2,r.x+a.w/2,r.y+a.h/2,r.x,r.y,f.x,f.y)||r,d=n.intersectRect(f.x-s.w/2,f.y-s.h/2,f.x+s.w/2,f.y+s.h/2,f.x,f.y,r.x,r.y)||f;o+="M"+Math.round(c.x)+" "+Math.round(c.y)+"L"+Math.round(d.x)+" "+Math.round(d.y)}}),t.attr("transform","translate("+(r.x-a.w/2)+", "+(r.y-a.h/2)+")"),""!==o&&t.linksContainer&&t.linksContainer.attr("d",o)}}},Viva.Graph.webgl=function(e){var t=function(t,n){var r=e.createShader(n);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){var i=e.getShaderInfoLog(r);throw window.alert(i),i}return r};return{createProgram:function(n,r){var i=e.createProgram(),o=t(n,e.VERTEX_SHADER),a=t(r,e.FRAGMENT_SHADER);if(e.attachShader(i,o),e.attachShader(i,a),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){var u=e.getShaderInfoLog(i);throw window.alert(u),u}return i},extendArray:function(e,t,n){if((t+1)*n>e.length){var r=new Float32Array(2*e.length*n);return r.set(e),r}return e},copyArrayPart:function(e,t,n,r){var i;for(i=0;r>i;++i)e[t+i]=e[n+i]},swapArrayPart:function(e,t,n,r){var i;for(i=0;r>i;++i){var o=e[t+i];e[t+i]=e[n+i],e[n+i]=o}},getLocations:function(t,n){var r,i={};for(r=0;n.length>r;++r){var o=n[r],a=-1;if(0===o.indexOf("a_")){if(a=e.getAttribLocation(t,o),-1===a)throw"Program doesn't have required attribute: "+o;i[o.slice(2)]=a}else{if(0!==o.indexOf("u_"))throw"Couldn't figure out your intent. All uniforms should start with 'u_' prefix, and attributes with 'a_'";if(a=e.getUniformLocation(t,o),null===a)throw"Program doesn't have required uniform: "+o;i[o.slice(2)]=a}}return i},context:e}},Viva.Graph.View.WebglUtils=function(){},Viva.Graph.View.WebglUtils.prototype.parseColor=function(e){var t=10414335;if("string"==typeof e&&e)if(4===e.length&&(e=e.replace(/([^#])/g,"$1$1")),9===e.length)t=parseInt(e.substr(1),16);else{if(7!==e.length)throw'Color expected in hex format with preceding "#". E.g. #00ff00. Got value: '+e;t=255|parseInt(e.substr(1),16)<<8}else"number"==typeof e&&(t=e);return t},Viva.Graph.View._webglUtil=new Viva.Graph.View.WebglUtils,Viva.Graph.View.webglLine=function(e){return{color:Viva.Graph.View._webglUtil.parseColor(e)}},Viva.Graph.View.webglSquare=function(e,t){return{size:"number"==typeof e?e:10,color:Viva.Graph.View._webglUtil.parseColor(t)}},Viva.Graph.View.webglImage=function(e,t){return{_texture:0,_offset:0,size:"number"==typeof e?e:32,src:t}},Viva.Graph.View.webglNodeProgram=function(){var e,t,n,r,i,o,a,u,s,f=4,c=3*Float32Array.BYTES_PER_ELEMENT+Uint32Array.BYTES_PER_ELEMENT,d=["precision mediump float;","varying vec4 color;","void main(void) {"," gl_FragColor = color;","}"].join("\n"),l=["attribute vec3 a_vertexPos;","attribute vec4 a_color;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","varying vec4 color;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos.xy/u_screenSize, 0, 1);"," gl_PointSize = a_vertexPos.z * u_transform[0][0];"," color = a_color.abgr;","}"].join("\n"),h=new ArrayBuffer(16*c),v=new Float32Array(h),p=new Uint32Array(h),m=0,g=function(){if((m+1)*c>=h.byteLength){var e=new ArrayBuffer(2*h.byteLength),t=new Float32Array(e),n=new Uint32Array(e);n.set(p),v=t,p=n,h=e}};return{load:function(o){t=o,i=Viva.Graph.webgl(o),e=i.createProgram(l,d),t.useProgram(e),r=i.getLocations(e,["a_vertexPos","a_color","u_screenSize","u_transform"]),t.enableVertexAttribArray(r.vertexPos),t.enableVertexAttribArray(r.color),n=t.createBuffer()},position:function(e,t){var n=e.id;v[n*f]=t.x,v[n*f+1]=t.y,v[n*f+2]=e.size,p[n*f+3]=e.color},updateTransform:function(e){s=!0,u=e},updateSize:function(e,t){o=e,a=t,s=!0},removeNode:function(e){m>0&&(m-=1),m>e.id&&m>0&&i.copyArrayPart(p,e.id*f,m*f,f)},createNode:function(){g(),m+=1},replaceProperties:function(){},render:function(){t.useProgram(e),t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,h,t.DYNAMIC_DRAW),s&&(s=!1,t.uniformMatrix4fv(r.transform,!1,u),t.uniform2f(r.screenSize,o,a)),t.vertexAttribPointer(r.vertexPos,3,t.FLOAT,!1,f*Float32Array.BYTES_PER_ELEMENT,0),t.vertexAttribPointer(r.color,4,t.UNSIGNED_BYTE,!0,f*Float32Array.BYTES_PER_ELEMENT,12),t.drawArrays(t.POINTS,0,m)}}},Viva.Graph.View.webglLinkProgram=function(){var e,t,n,r,i,o,a,u,s,f,c=6,d=2*(2*Float32Array.BYTES_PER_ELEMENT+Uint32Array.BYTES_PER_ELEMENT),l=["precision mediump float;","varying vec4 color;","void main(void) {"," gl_FragColor = color;","}"].join("\n"),h=["attribute vec2 a_vertexPos;","attribute vec4 a_color;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","varying vec4 color;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos/u_screenSize, 0.0, 1.0);"," color = a_color.abgr;","}"].join("\n"),v=0,p=new ArrayBuffer(16*d),m=new Float32Array(p),g=new Uint32Array(p),y=function(){if((v+1)*d>p.byteLength){var e=new ArrayBuffer(2*p.byteLength),t=new Float32Array(e),n=new Uint32Array(e);n.set(g),m=t,g=n,p=e}};return{load:function(o){t=o,r=Viva.Graph.webgl(o),e=r.createProgram(h,l),t.useProgram(e),i=r.getLocations(e,["a_vertexPos","a_color","u_screenSize","u_transform"]),t.enableVertexAttribArray(i.vertexPos),t.enableVertexAttribArray(i.color),n=t.createBuffer()},position:function(e,t,n){var r=e.id,i=r*c;m[i]=t.x,m[i+1]=t.y,g[i+2]=e.color,m[i+3]=n.x,m[i+4]=n.y,g[i+5]=e.color},createLink:function(e){y(),v+=1,o=e.id},removeLink:function(e){v>0&&(v-=1),v>e.id&&v>0&&r.copyArrayPart(g,e.id*c,v*c,c)},updateTransform:function(e){f=!0,s=e},updateSize:function(e,t){a=e,u=t,f=!0},render:function(){t.useProgram(e),t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,p,t.DYNAMIC_DRAW),f&&(f=!1,t.uniformMatrix4fv(i.transform,!1,s),t.uniform2f(i.screenSize,a,u)),t.vertexAttribPointer(i.vertexPos,2,t.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,0),t.vertexAttribPointer(i.color,4,t.UNSIGNED_BYTE,!0,3*Float32Array.BYTES_PER_ELEMENT,8),t.drawArrays(t.LINES,0,2*v),o=v-1},bringToFront:function(e){o>e.id&&r.swapArrayPart(m,e.id*c,o*c,c),o>0&&(o-=1)},getFrontLinkId:function(){return o}}},Viva.Graph.View.Texture=function(e){this.canvas=window.document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.isDirty=!1,this.canvas.width=this.canvas.height=e},Viva.Graph.View.webglAtlas=function(e){var t,n,r=Math.sqrt(e||1024)<<0,i=r,o=1,a={},u=0,s=[],f=[],c=function(e){return 0===(e&e-1)},d=function(){var e=new Viva.Graph.View.Texture(r*i);s.push(e)},l=function(t){var n=t/e<<0,i=t%e,o=i/r<<0,a=i%r;return{textureNumber:n,row:o,col:a}},h=function(){n.isDirty=!0,u=0,t=null},v=function(){t&&(window.clearTimeout(t),u+=1,t=null),u>10?h():t=window.setTimeout(h,400)},p=function(e,t){var n=s[e.textureNumber].canvas,r=s[t.textureNumber].ctx,o=t.col*i,a=t.row*i;r.drawImage(n,e.col*i,e.row*i,i,i,o,a,i,i),s[e.textureNumber].isDirty=!0,s[t.textureNumber].isDirty=!0},m=function(e,t,n){var r=l(e),o={offset:e};r.textureNumber>=s.length&&d();var u=s[r.textureNumber];u.ctx.drawImage(t,r.col*i,r.row*i,i,i),f[e]=t.src,a[t.src]=o,u.isDirty=!0,n(o)};if(!c(e))throw"Tiles per texture should be power of two.";return n={isDirty:!1,clearDirty:function(){var e;for(this.isDirty=!1,e=0;s.length>e;++e)s[e].isDirty=!1},remove:function(e){var t=a[e];if(!t)return!1;if(delete a[e],o-=1,o===t.offset)return!0;var n=l(t.offset),r=l(o);p(r,n);var i=a[f[o]];return i.offset=t.offset,f[t.offset]=f[o],v(),!0},getTextures:function(){return s},getCoordinates:function(e){return a[e]},load:function(e,t){if(a.hasOwnProperty(e))t(a[e]);else{var n=new window.Image,r=o;o+=1,n.crossOrigin="anonymous",n.onload=function(){v(),m(r,n,t)},n.src=e}}}},Viva.Graph.View.webglImageNodeProgram=function(){var e,t,n,r,i,o,a,u,s,f,c=18,d=["precision mediump float;","varying vec4 color;","varying vec3 vTextureCoord;","uniform sampler2D u_sampler0;","uniform sampler2D u_sampler1;","uniform sampler2D u_sampler2;","uniform sampler2D u_sampler3;","void main(void) {"," if (vTextureCoord.z == 0.) {"," gl_FragColor = texture2D(u_sampler0, vTextureCoord.xy);"," } else if (vTextureCoord.z == 1.) {"," gl_FragColor = texture2D(u_sampler1, vTextureCoord.xy);"," } else if (vTextureCoord.z == 2.) {"," gl_FragColor = texture2D(u_sampler2, vTextureCoord.xy);"," } else if (vTextureCoord.z == 3.) {"," gl_FragColor = texture2D(u_sampler3, vTextureCoord.xy);"," } else { gl_FragColor = vec4(0, 1, 0, 1); }","}"].join("\n"),l=["attribute vec2 a_vertexPos;","attribute float a_customAttributes;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","uniform float u_tilesPerTexture;","varying vec3 vTextureCoord;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos/u_screenSize, 0, 1);","float corner = mod(a_customAttributes, 4.);","float tileIndex = mod(floor(a_customAttributes / 4.), u_tilesPerTexture);","float tilesPerRow = sqrt(u_tilesPerTexture);","float tileSize = 1./tilesPerRow;","float tileColumn = mod(tileIndex, tilesPerRow);","float tileRow = floor(tileIndex/tilesPerRow);","if(corner == 0.0) {"," vTextureCoord.xy = vec2(0, 1);","} else if(corner == 1.0) {"," vTextureCoord.xy = vec2(1, 1);","} else if(corner == 2.0) {"," vTextureCoord.xy = vec2(0, 0);","} else {"," vTextureCoord.xy = vec2(1, 0);","}","vTextureCoord *= tileSize;","vTextureCoord.x += tileColumn * tileSize;","vTextureCoord.y += tileRow * tileSize;","vTextureCoord.z = floor(floor(a_customAttributes / 4.)/u_tilesPerTexture);","}"].join("\n"),h=1024,v=0,p=new Float32Array(64),m=function(e,t){e.nativeObject&&n.deleteTexture(e.nativeObject);var r=n.createTexture();n.activeTexture(n["TEXTURE"+t]),n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.canvas),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR_MIPMAP_NEAREST),n.generateMipmap(n.TEXTURE_2D),n.uniform1i(o["sampler"+t],t),e.nativeObject=r},g=function(){if(e.isDirty){var t,n=e.getTextures();for(t=0;n.length>t;++t)(n[t].isDirty||!n[t].nativeObject)&&m(n[t],t);e.clearDirty()}};return{load:function(a){n=a,i=Viva.Graph.webgl(a),e=new Viva.Graph.View.webglAtlas(h),t=i.createProgram(l,d),n.useProgram(t),o=i.getLocations(t,["a_vertexPos","a_customAttributes","u_screenSize","u_transform","u_sampler0","u_sampler1","u_sampler2","u_sampler3","u_tilesPerTexture"]),n.uniform1f(o.tilesPerTexture,h),n.enableVertexAttribArray(o.vertexPos),n.enableVertexAttribArray(o.customAttributes),r=n.createBuffer()},position:function(e,t){var n=e.id*c;p[n]=t.x-e.size,p[n+1]=t.y-e.size,p[n+2]=4*e._offset,p[n+3]=t.x+e.size,p[n+4]=t.y-e.size,p[n+5]=4*e._offset+1,p[n+6]=t.x-e.size,p[n+7]=t.y+e.size,p[n+8]=4*e._offset+2,p[n+9]=t.x-e.size,p[n+10]=t.y+e.size,p[n+11]=4*e._offset+2,p[n+12]=t.x+e.size,p[n+13]=t.y-e.size,p[n+14]=4*e._offset+1,p[n+15]=t.x+e.size,p[n+16]=t.y+e.size,p[n+17]=4*e._offset+3},createNode:function(t){p=i.extendArray(p,v,c),v+=1;var n=e.getCoordinates(t.src);n?t._offset=n.offset:(t._offset=0,e.load(t.src,function(e){t._offset=e.offset}))},removeNode:function(t){v>0&&(v-=1),v>t.id&&v>0&&(t.src&&e.remove(t.src),i.copyArrayPart(p,t.id*c,v*c,c))},replaceProperties:function(e,t){t._offset=e._offset},updateTransform:function(e){f=!0,s=e},updateSize:function(e,t){a=e,u=t,f=!0},render:function(){n.useProgram(t),n.bindBuffer(n.ARRAY_BUFFER,r),n.bufferData(n.ARRAY_BUFFER,p,n.DYNAMIC_DRAW),f&&(f=!1,n.uniformMatrix4fv(o.transform,!1,s),n.uniform2f(o.screenSize,a,u)),n.vertexAttribPointer(o.vertexPos,2,n.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,0),n.vertexAttribPointer(o.customAttributes,1,n.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,8),g(),n.drawArrays(n.TRIANGLES,0,6*v)}}},Viva.Graph.View=Viva.Graph.View||{},Viva.Graph.View.webglGraphics=function(e){e=Viva.lazyExtend(e,{enableBlending:!0,preserveDrawingBuffer:!1,clearColor:!1,clearColorValue:{r:1,g:1,b:1,a:1}});var t,n,r,i,o,a,u,s,f=0,c=0,d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],l=[],h=[],v={},p={},m=Viva.Graph.View.webglLinkProgram(),g=Viva.Graph.View.webglNodeProgram(),y=function(){return Viva.Graph.View.webglSquare()},x=function(){return Viva.Graph.View.webglLine(3014898687)},w=function(){m.updateTransform(d),g.updateTransform(d)},V=function(){d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},b=function(){t&&n&&(i=n.width=Math.max(t.offsetWidth,1),o=n.height=Math.max(t.offsetHeight,1),r&&r.viewport(0,0,i,o),m&&m.updateSize(i/2,o/2),g&&g.updateSize(i/2,o/2))},N=function(e){e.fire("rescaled")},P={getLinkUI:function(e){return p[e]},getNodeUI:function(e){return v[e]},node:function(e){return"function"==typeof e?(y=e,this):void 0},link:function(e){return"function"==typeof e?(x=e,this):void 0},placeNode:function(e){return a=e,this},placeLink:function(e){return u=e,this},inputManager:Viva.Input.webglInputManager,beginRender:function(){},endRender:function(){c>0&&m.render(),f>0&&g.render()},bringLinkToFront:function(e){var t,n,r=m.getFrontLinkId();m.bringToFront(e),r>e.id&&(t=e.id,n=h[r],h[r]=h[t],h[r].id=r,h[t]=n,h[t].id=t)},graphCenterChanged:function(e,t){d[12]=2*e/i-1,d[13]=1-2*t/o,w()},addLink:function(e,t){var n=c++,r=x(e);return r.id=n,r.pos=t,m.createLink(r),h[n]=r,p[e.id]=r,r},addNode:function(e,t){var n=f++,r=y(e);return r.id=n,r.position=t,r.node=e,g.createNode(r),l[n]=r,v[e.id]=r,r},translateRel:function(e,t){d[12]+=2*d[0]*e/i/d[0],d[13]-=2*d[5]*t/o/d[5],w()},scale:function(e,t){var n=2*t.x/i-1,r=1-2*t.y/o;return n-=d[12],r-=d[13],d[12]+=n*(1-e),d[13]+=r*(1-e),d[0]*=e,d[5]*=e,w(),N(this),d[0]},resetScale:function(){return V(),r&&(b(),w()),this},init:function(a){var u={};if(e.preserveDrawingBuffer&&(u.preserveDrawingBuffer=!0),t=a,n=window.document.createElement("canvas"),b(),V(),t.appendChild(n),r=n.getContext("experimental-webgl",u),!r){var f="Could not initialize WebGL. Seems like the browser doesn't support it.";throw window.alert(f),f}if(e.enableBlending&&(r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.BLEND)),e.clearColor){var c=e.clearColorValue;r.clearColor(c.r,c.g,c.b,c.a),this.beginRender=function(){r.clear(r.COLOR_BUFFER_BIT)}}m.load(r),m.updateSize(i/2,o/2),g.load(r),g.updateSize(i/2,o/2),w(),"function"==typeof s&&s(n)},release:function(e){n&&e&&e.removeChild(n)},isSupported:function(){var e=window.document.createElement("canvas"),t=e&&e.getContext&&e.getContext("experimental-webgl");return t},releaseLink:function(e){c>0&&(c-=1);var t=p[e.id];delete p[e.id],m.removeLink(t);var n=t.id;if(c>n){if(0===c||c===n)return;var r=h[c];h[n]=r,r.id=n}},releaseNode:function(e){f>0&&(f-=1);var t=v[e.id];delete v[e.id],g.removeNode(t);var n=t.id;if(f>n){if(0===f||f===n)return;var r=l[f];l[n]=r,r.id=n,g.replaceProperties(t,r)}},renderNodes:function(){for(var e={x:0,y:0},t=0;f>t;++t){var n=l[t];e.x=n.position.x,e.y=-n.position.y,a&&a(n,e),g.position(n,e)}},renderLinks:function(){if(!this.omitLinksRendering)for(var e={x:0,y:0},t={x:0,y:0},n=0;c>n;++n){var r=h[n],i=r.pos.from;t.x=i.x,t.y=-i.y,i=r.pos.to,e.x=i.x,e.y=-i.y,u&&u(r,t,e),m.position(r,t,e)}},getGraphicsRoot:function(e){return"function"==typeof e&&(n?e(n):s=e),n},setNodeProgram:function(e){if(!r&&e)g=e;else if(e)throw"Not implemented. Cannot swap shader on the fly... yet."},setLinkProgram:function(e){if(!r&&e)m=e;else if(e)throw"Not implemented. Cannot swap shader on the fly... yet."},transformClientToGraphCoordinates:function(e){return e.x=2*e.x/i-1,e.y=1-2*e.y/o,e.x=(e.x-d[12])/d[0],e.y=(e.y-d[13])/d[5],e.x*=i/2,e.y*=-o/2,e},getNodeAtClientPos:function(e,t){if("function"!=typeof t)return null;this.transformClientToGraphCoordinates(e);for(var n=0;f>n;++n)if(t(l[n],e.x,e.y))return l[n].node;return null}};return Viva.Graph.Utils.events(P).extend(),P},Viva.Graph.webglInputEvents=function(e){if(e.webglInputEvents)return e.webglInputEvents;var t,n,r=function(e,t,n){if(e&&e.size){var r=e.position,i=e.size;return t>r.x-i&&r.x+i>t&&n>r.y-i&&r.y+i>n}return!0},i=function(t){return e.getNodeAtClientPos(t,r)},o=null,a=[],u=[],s=[],f=[],c=[],d=[],l=[],h=Viva.Graph.Utils.events(window.document),v=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},p=function(e){return v(e),!1},m=function(e,t){var n,r;for(n=0;e.length>n;n+=1)if(r=e[n].apply(void 0,t))return!0},g=function(e){var r={x:0,y:0},g=null,y=+new Date,x=function(e){m(c,[g,e]),r.x=e.clientX,r.y=e.clientY},w=function(){h.stop("mousemove",x),h.stop("mouseup",w)},V=function(){n=e.getBoundingClientRect()};window.addEventListener("resize",V),V(),e.addEventListener("mousemove",function(e){if(!o){var t,s=!1;r.x=e.clientX-n.left,r.y=e.clientY-n.top,t=i(r),t&&g!==t?(g=t,s=s||m(a,[g])):null===t&&g!==t&&(s=s||m(u,[g]),g=null),s&&v(e)}}),e.addEventListener("mousedown",function(e){var o,a=!1;r.x=e.clientX-n.left,r.y=e.clientY-n.top,o=[i(r),e],o[0]?(a=m(s,o),h.on("mousemove",x),h.on("mouseup",w),t=window.document.onselectstart,window.document.onselectstart=p,g=o[0]):g=null,a&&v(e)}),e.addEventListener("mouseup",function(e){var o,a=+new Date;r.x=e.clientX-n.left,r.y=e.clientY-n.top,o=[i(r),e],o[0]&&(window.document.onselectstart=t,400>a-y&&o[0]===g?m(l,o):m(d,o),y=a,m(f,o)&&v(e))})};return e.getGraphicsRoot(g),e.webglInputEvents={mouseEnter:function(e){return"function"==typeof e&&a.push(e),this},mouseLeave:function(e){return"function"==typeof e&&u.push(e),this},mouseDown:function(e){return"function"==typeof e&&s.push(e),this},mouseUp:function(e){return"function"==typeof e&&f.push(e),this},mouseMove:function(e){return"function"==typeof e&&c.push(e),this},click:function(e){return"function"==typeof e&&d.push(e),this},dblClick:function(e){return"function"==typeof e&&l.push(e),this},mouseCapture:function(e){o=e},releaseMouseCapture:function(){o=null}},e.webglInputEvents},Viva.Input=Viva.Input||{},Viva.Input.webglInputManager=function(e,t){var n=Viva.Graph.webglInputEvents(t),r=null,i={},o={x:0,y:0};return n.mouseDown(function(e,t){r=e,o.x=t.clientX,o.y=t.clientY,n.mouseCapture(r);var a=i[e.id];return a&&a.onStart&&a.onStart(t,o),!0}).mouseUp(function(e){n.releaseMouseCapture(r),r=null;var t=i[e.id];return t&&t.onStop&&t.onStop(),!0}).mouseMove(function(e,t){if(r){var n=i[r.id];return n&&n.onDrag&&n.onDrag(t,{x:t.clientX-o.x,y:t.clientY-o.y}),o.x=t.clientX,o.y=t.clientY,!0}}),{bindDragNDrop:function(e,t){i[e.id]=t,t||delete i[e.id]}}};
--------------------------------------------------------------------------------
/static/js/jquery.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
2 | !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)
3 | },_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
4 | },removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=l.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,n.ajaxSettings),b):tc(n.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=n.ajaxSettings.xhr();a.ActiveXObject&&n(a).on("unload",function(){for(var a in Dc)Dc[a]()}),k.cors=!!Fc&&"withCredentials"in Fc,k.ajax=Fc=!!Fc,n.ajaxTransport(function(a){var b;return k.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("