@canonry/canonry 7.51.4 → 7.51.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/assets/assets/AccessControls-B5TqDgeq.js +1 -0
  2. package/assets/assets/AuditHistoryPanel-DgxiizOW.js +1 -0
  3. package/assets/assets/BacklinksPage-Ay6pdphx.js +1 -0
  4. package/assets/assets/ChartPrimitives-DIEeZdrs.js +1 -0
  5. package/assets/assets/Hint-Cn4lh0Do.js +1 -0
  6. package/assets/assets/HistoryPage-B11eFH21.js +1 -0
  7. package/assets/assets/InfoTooltip-TIx9qM5h.js +1 -0
  8. package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +4 -0
  9. package/assets/assets/ProjectPage-DoY0hftd.js +8 -0
  10. package/assets/assets/RunsPage-BPBmuQAS.js +1 -0
  11. package/assets/assets/SettingsPage-ClKnP8xy.js +1 -0
  12. package/assets/assets/SiteHealthSection-PWjKMmEn.js +2 -0
  13. package/assets/assets/TrafficPage-DkfGiJXR.js +40 -0
  14. package/assets/assets/TrafficSourceDetailPage-DQu0YNt2.js +1 -0
  15. package/assets/assets/async-handler-Bj3TnIRw.js +1 -0
  16. package/assets/assets/card-DYMyvhB9.js +60 -0
  17. package/assets/assets/extract-error-message-BRM1I_3L.js +1 -0
  18. package/assets/assets/format-helpers-DrkFERj3.js +3 -0
  19. package/assets/assets/index-CG1Jox52.js +39 -0
  20. package/assets/assets/index-CsPsaUr7.css +1 -0
  21. package/assets/assets/query-client-gRFnU4VF.js +1 -0
  22. package/assets/assets/react-query-lH82FULK.js +1 -0
  23. package/assets/assets/react-sigma_core.esm.min-D09H4byP.js +3225 -0
  24. package/assets/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  25. package/assets/assets/service-Cx0HSnE9.js +1 -0
  26. package/assets/assets/vendor-lucide-BjvO55Hk.js +1 -0
  27. package/assets/assets/vendor-markdown-DWjffpgb.js +29 -0
  28. package/assets/assets/vendor-radix-BU76HM0G.js +41 -0
  29. package/assets/assets/vendor-recharts-CsHBXoK8.js +59 -0
  30. package/assets/assets/vendor-tanstack-QhOrDhIL.js +2 -0
  31. package/assets/assets/vendor-yaml-Y43rmNgW.js +105 -0
  32. package/assets/index.html +16 -8
  33. package/dist/{chunk-EQTVQIM2.js → chunk-4QQYYRHV.js} +9 -9
  34. package/dist/{chunk-6GNV6VF4.js → chunk-4YCGZGA3.js} +2 -2
  35. package/dist/{chunk-KUS7M65J.js → chunk-A3WSAAQS.js} +5 -3
  36. package/dist/{chunk-35QQMVO6.js → chunk-AZFPA7JV.js} +3 -3
  37. package/dist/{chunk-GZPJ7TSE.js → chunk-HAHXPJQ5.js} +2554 -5201
  38. package/dist/{chunk-P6D6P337.js → chunk-HLVEB5TB.js} +3 -3
  39. package/dist/{chunk-KU4TPVZV.js → chunk-JBZZEIM2.js} +1 -1
  40. package/dist/{chunk-RUWELF3K.js → chunk-KEATAHXH.js} +1 -1
  41. package/dist/{chunk-HHRM3H3L.js → chunk-PLYJX67A.js} +9 -9
  42. package/dist/{chunk-YOGHHIGE.js → chunk-SFMWHPMX.js} +28 -22
  43. package/dist/{cli-catalog-KTQ6BHEU.js → cli-catalog-MO6Z2CIZ.js} +3 -3
  44. package/dist/cli-commands-FOJR3HHU.js +15 -0
  45. package/dist/cli.js +10 -10
  46. package/dist/{demo-server-26UUDUM7.js → demo-server-GIWDJGJX.js} +4 -4
  47. package/dist/index.d.ts +182 -48
  48. package/dist/index.js +6 -6
  49. package/dist/{intelligence-service-ZGDBVFDE.js → intelligence-service-XQCNWAPL.js} +2 -2
  50. package/dist/mcp.js +4 -4
  51. package/package.json +30 -30
  52. package/assets/assets/AuditHistoryPanel-CtWNkC6F.js +0 -1
  53. package/assets/assets/BacklinksPage-Cs3_j55C.js +0 -1
  54. package/assets/assets/ChartPrimitives-B6ryduMN.js +0 -1
  55. package/assets/assets/Hint-DICI5Jq9.js +0 -1
  56. package/assets/assets/HistoryPage-_5Vwj01m.js +0 -1
  57. package/assets/assets/MeasurementPropertyPage-B2yBTUZd.js +0 -4
  58. package/assets/assets/ProjectPage-hs-9PcoS.js +0 -8
  59. package/assets/assets/RunsPage-B_mhz9vj.js +0 -1
  60. package/assets/assets/SettingsPage-D1Lzcw03.js +0 -1
  61. package/assets/assets/SiteHealthSection-CGlrPdrk.js +0 -4
  62. package/assets/assets/TrafficPage-C27a0rQp.js +0 -40
  63. package/assets/assets/TrafficSourceDetailPage-DOSoQySv.js +0 -1
  64. package/assets/assets/extract-error-message-itBoiivg.js +0 -1
  65. package/assets/assets/index-Br2WtEIO.css +0 -1
  66. package/assets/assets/index-CdAuyP-X.js +0 -86
  67. package/assets/assets/react-sigma_core.esm.min-CPYhSQFc.js +0 -312
  68. package/assets/assets/v2-overview-adapter-DQXWmK0B.js +0 -1
  69. package/assets/assets/vendor-lucide-Y6jANGfG.js +0 -1
  70. package/assets/assets/vendor-markdown-B4giJcws.js +0 -29
  71. package/assets/assets/vendor-radix-twS1M3FF.js +0 -45
  72. package/assets/assets/vendor-recharts-D_R6YxjS.js +0 -36
  73. package/assets/assets/vendor-tanstack-ZXXkndVj.js +0 -1
  74. package/assets/assets/vendor-yaml-GWJz5H2G.js +0 -131
  75. package/dist/cli-commands-5ZODWR4I.js +0 -15
@@ -1,312 +0,0 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-CGlrPdrk.js";import"./index-CdAuyP-X.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D_R6YxjS.js";import"./vendor-lucide-Y6jANGfG.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-B6ryduMN.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
- `.concat(o,`
4
- `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE
5
- `,ai=c(c(c(c(c(c(c(c({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),St=(function(){function r(n,i,e){A(this,r),c(this,"array",new Float32Array),c(this,"constantArray",new Float32Array),c(this,"capacity",0),c(this,"verticesCount",0);var t=this.getDefinition();if(this.VERTICES=t.VERTICES,this.VERTEX_SHADER_SOURCE=t.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=t.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=t.UNIFORMS,this.ATTRIBUTES=t.ATTRIBUTES,this.METHOD=t.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in t?t.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in t?t.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in t,this.ATTRIBUTES_ITEMS_COUNT=ye(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=e,this.normalProgram=this.getProgramInfo("normal",n,t.VERTEX_SHADER_SOURCE,t.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=i?this.getProgramInfo("pick",n,qe+t.VERTEX_SHADER_SOURCE,qe+t.FRAGMENT_SHADER_SOURCE,i):null,this.isInstanced){var a=ye(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(a,")"));for(var l=0;l<s.length;l++)this.constantArray[o*a+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return L(r,[{key:"kill",value:function(){Ze(this.normalProgram),this.pickProgram&&(Ze(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(i,e,t,a,o){var s=this.getDefinition(),l=e.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var h=ii(e,t),u=ri(e,a),d=ni(e,[h,u]),f={};s.UNIFORMS.forEach(function(v){var p=e.getUniformLocation(d,v);p&&(f[v]=p)});var g={};s.ATTRIBUTES.forEach(function(v){g[v.name]=e.getAttribLocation(d,v.name)});var m;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(v){g[v.name]=e.getAttribLocation(d,v.name)}),m=e.createBuffer(),m===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:i,program:d,gl:e,frameBuffer:o,buffer:l,constantBuffer:m||{},uniformLocations:f,attributeLocations:g,isPicking:i==="pick",vertexShader:h,fragmentShader:u}}},{key:"bindProgram",value:function(i){var e=this,t=0,a=i.gl,o=i.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,i.constantBuffer),t=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return t+=e.bindAttribute(s,i,t,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,i.buffer),t=0,this.ATTRIBUTES.forEach(function(s){return t+=e.bindAttribute(s,i,t,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),t=0,this.ATTRIBUTES.forEach(function(s){return t+=e.bindAttribute(s,i,t)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(i){var e=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(t){return e.unbindAttribute(t,i,!1)}),this.ATTRIBUTES.forEach(function(t){return e.unbindAttribute(t,i,!0)})):this.ATTRIBUTES.forEach(function(t){return e.unbindAttribute(t,i)})}},{key:"bindAttribute",value:function(i,e,t,a){var o=ai[i.type];if(typeof o!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(i.type,'"'));var s=e.attributeLocations[i.name],l=e.gl;if(s!==-1){l.enableVertexAttribArray(s);var h=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:ye(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,i.size,i.type,i.normalized||!1,h,t),this.isInstanced&&a)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var u=l.getExtension("ANGLE_instanced_arrays");u&&u.vertexAttribDivisorANGLE(s,1)}}return i.size*o}},{key:"unbindAttribute",value:function(i,e,t){var a=e.attributeLocations[i.name],o=e.gl;if(a!==-1&&(o.disableVertexAttribArray(a),this.isInstanced&&t))if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,0);else{var s=o.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(a,0)}}},{key:"reallocate",value:function(i){i!==this.capacity&&(this.capacity=i,this.verticesCount=this.VERTICES*i,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(i,e){var t=e.gl,a=e.program;t.enable(t.BLEND),t.useProgram(a),this.setUniforms(i,e),this.drawWebGL(this.METHOD,e)}},{key:"render",value:function(i){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,i.width*i.pixelRatio/i.downSizingRatio,i.height*i.pixelRatio/i.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(b(b({},i),{},{pixelRatio:i.pixelRatio/i.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,i.width*i.pixelRatio,i.height*i.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(i,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(i,e){var t=e.gl,a=e.frameBuffer;if(t.bindFramebuffer(t.FRAMEBUFFER,a),!this.isInstanced)t.drawArrays(i,0,this.verticesCount);else if(t instanceof WebGL2RenderingContext)t.drawArraysInstanced(i,0,this.VERTICES,this.capacity);else{var o=t.getExtension("ANGLE_instanced_arrays");o&&o.drawArraysInstancedANGLE(i,0,this.VERTICES,this.capacity)}}}])})(),oi=(function(r){function n(){return A(this,n),I(this,n,arguments)}return G(n,r),L(n,[{key:"kill",value:function(){wt(n,"kill",this)([])}},{key:"process",value:function(e,t,a){var o=t*this.STRIDE;if(a.hidden){for(var s=o+this.STRIDE;o<s;o++)this.array[o]=0;return}return this.processVisibleItem(_t(e),o,a)}}])})(St),Ge=(function(r){function n(){var i;A(this,n);for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return i=I(this,n,[].concat(t)),c(i,"drawLabel",void 0),i}return G(n,r),L(n,[{key:"kill",value:function(){wt(n,"kill",this)([])}},{key:"process",value:function(e,t,a,o,s){var l=t*this.STRIDE;if(s.hidden||a.hidden||o.hidden){for(var h=l+this.STRIDE;l<h;l++)this.array[l]=0;return}return this.processVisibleItem(_t(e),l,a,o,s)}}])})(St);function si(r,n){return(function(){function i(e,t,a){A(this,i),c(this,"drawLabel",n),this.programs=r.map(function(o){return new o(e,t,a)})}return L(i,[{key:"reallocate",value:function(t){this.programs.forEach(function(a){return a.reallocate(t)})}},{key:"process",value:function(t,a,o,s,l){this.programs.forEach(function(h){return h.process(t,a,o,s,l)})}},{key:"render",value:function(t){this.programs.forEach(function(a){return a.render(t)})}},{key:"kill",value:function(){this.programs.forEach(function(t){return t.kill()})}}])})()}function li(r,n,i,e,t){var a=t.edgeLabelSize,o=t.edgeLabelFont,s=t.edgeLabelWeight,l=t.edgeLabelColor.attribute?n[t.edgeLabelColor.attribute]||t.edgeLabelColor.color||"#000":t.edgeLabelColor.color,h=n.label;if(h){r.fillStyle=l,r.font="".concat(s," ").concat(a,"px ").concat(o);var u=i.size,d=e.size,f=i.x,g=i.y,m=e.x,v=e.y,p=(f+m)/2,R=(g+v)/2,y=m-f,E=v-g,T=Math.sqrt(y*y+E*E);if(!(T<u+d)){f+=y*u/T,g+=E*u/T,m-=y*d/T,v-=E*d/T,p=(f+m)/2,R=(g+v)/2,y=m-f,E=v-g,T=Math.sqrt(y*y+E*E);var x=r.measureText(h).width;if(x>T){var w="…";for(h=h+w,x=r.measureText(h).width;x>T&&h.length>1;)h=h.slice(0,-2)+w,x=r.measureText(h).width;if(h.length<4)return}var _;y>0?E>0?_=Math.acos(y/T):_=Math.asin(E/T):E>0?_=Math.acos(y/T)+Math.PI:_=Math.asin(y/T)+Math.PI/2,r.save(),r.translate(p,R),r.rotate(_),r.fillText(h,-x/2,n.size/2+a),r.restore()}}}function At(r,n,i){if(n.label){var e=i.labelSize,t=i.labelFont,a=i.labelWeight,o=i.labelColor.attribute?n[i.labelColor.attribute]||i.labelColor.color||"#000":i.labelColor.color;r.fillStyle=o,r.font="".concat(a," ").concat(e,"px ").concat(t),r.fillText(n.label,n.x+n.size+3,n.y+e/3)}}function hi(r,n,i){var e=i.labelSize,t=i.labelFont,a=i.labelWeight;r.font="".concat(a," ").concat(e,"px ").concat(t),r.fillStyle="#FFF",r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=8,r.shadowColor="#000";var o=2;if(typeof n.label=="string"){var s=r.measureText(n.label).width,l=Math.round(s+5),h=Math.round(e+2*o),u=Math.max(n.size,e/2)+o,d=Math.asin(h/2/u),f=Math.sqrt(Math.abs(Math.pow(u,2)-Math.pow(h/2,2)));r.beginPath(),r.moveTo(n.x+f,n.y+h/2),r.lineTo(n.x+u+l,n.y+h/2),r.lineTo(n.x+u+l,n.y-h/2),r.lineTo(n.x+f,n.y-h/2),r.arc(n.x,n.y,u,d,-d),r.closePath(),r.fill()}else r.beginPath(),r.arc(n.x,n.y,n.size+o,0,Math.PI*2),r.closePath(),r.fill();r.shadowOffsetX=0,r.shadowOffsetY=0,r.shadowBlur=0,At(r,n,i)}var ui=`
6
- precision highp float;
7
-
8
- varying vec4 v_color;
9
- varying vec2 v_diffVector;
10
- varying float v_radius;
11
-
12
- uniform float u_correctionRatio;
13
-
14
- const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
15
-
16
- void main(void) {
17
- float border = u_correctionRatio * 2.0;
18
- float dist = length(v_diffVector) - v_radius + border;
19
-
20
- // No antialiasing for picking mode:
21
- #ifdef PICKING_MODE
22
- if (dist > border)
23
- gl_FragColor = transparent;
24
- else
25
- gl_FragColor = v_color;
26
-
27
- #else
28
- float t = 0.0;
29
- if (dist > border)
30
- t = 1.0;
31
- else if (dist > 0.0)
32
- t = dist / border;
33
-
34
- gl_FragColor = mix(v_color, transparent, t);
35
- #endif
36
- }
37
- `,di=ui,ci=`
38
- attribute vec4 a_id;
39
- attribute vec4 a_color;
40
- attribute vec2 a_position;
41
- attribute float a_size;
42
- attribute float a_angle;
43
-
44
- uniform mat3 u_matrix;
45
- uniform float u_sizeRatio;
46
- uniform float u_correctionRatio;
47
-
48
- varying vec4 v_color;
49
- varying vec2 v_diffVector;
50
- varying float v_radius;
51
- varying float v_border;
52
-
53
- const float bias = 255.0 / 254.0;
54
-
55
- void main() {
56
- float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
57
- vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
58
- vec2 position = a_position + diffVector;
59
- gl_Position = vec4(
60
- (u_matrix * vec3(position, 1)).xy,
61
- 0,
62
- 1
63
- );
64
-
65
- v_diffVector = diffVector;
66
- v_radius = size / 2.0;
67
-
68
- #ifdef PICKING_MODE
69
- // For picking mode, we use the ID as the color:
70
- v_color = a_id;
71
- #else
72
- // For normal mode, we use the color:
73
- v_color = a_color;
74
- #endif
75
-
76
- v_color.a *= bias;
77
- }
78
- `,fi=ci,Lt=WebGLRenderingContext,Ye=Lt.UNSIGNED_BYTE,Te=Lt.FLOAT,gi=["u_sizeRatio","u_correctionRatio","u_matrix"],fe=(function(r){function n(){return A(this,n),I(this,n,arguments)}return G(n,r),L(n,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:fi,FRAGMENT_SHADER_SOURCE:di,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:gi,ATTRIBUTES:[{name:"a_position",size:2,type:Te},{name:"a_size",size:1,type:Te},{name:"a_color",size:4,type:Ye,normalized:!0},{name:"a_id",size:4,type:Ye,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Te}],CONSTANT_DATA:[[n.ANGLE_1],[n.ANGLE_2],[n.ANGLE_3]]}}},{key:"processVisibleItem",value:function(e,t,a){var o=this.array,s=oe(a.color);o[t++]=a.x,o[t++]=a.y,o[t++]=a.size,o[t++]=s,o[t++]=e}},{key:"setUniforms",value:function(e,t){var a=t.gl,o=t.uniformLocations,s=o.u_sizeRatio,l=o.u_correctionRatio,h=o.u_matrix;a.uniform1f(l,e.correctionRatio),a.uniform1f(s,e.sizeRatio),a.uniformMatrix3fv(h,!1,e.matrix)}}])})(oi);c(fe,"ANGLE_1",0);c(fe,"ANGLE_2",2*Math.PI/3);c(fe,"ANGLE_3",4*Math.PI/3);var vi=`
79
- precision mediump float;
80
-
81
- varying vec4 v_color;
82
-
83
- void main(void) {
84
- gl_FragColor = v_color;
85
- }
86
- `,mi=vi,pi=`
87
- attribute vec2 a_position;
88
- attribute vec2 a_normal;
89
- attribute float a_radius;
90
- attribute vec3 a_barycentric;
91
-
92
- #ifdef PICKING_MODE
93
- attribute vec4 a_id;
94
- #else
95
- attribute vec4 a_color;
96
- #endif
97
-
98
- uniform mat3 u_matrix;
99
- uniform float u_sizeRatio;
100
- uniform float u_correctionRatio;
101
- uniform float u_minEdgeThickness;
102
- uniform float u_lengthToThicknessRatio;
103
- uniform float u_widenessToThicknessRatio;
104
-
105
- varying vec4 v_color;
106
-
107
- const float bias = 255.0 / 254.0;
108
-
109
- void main() {
110
- float minThickness = u_minEdgeThickness;
111
-
112
- float normalLength = length(a_normal);
113
- vec2 unitNormal = a_normal / normalLength;
114
-
115
- // These first computations are taken from edge.vert.glsl and
116
- // edge.clamped.vert.glsl. Please read it to get better comments on what's
117
- // happening:
118
- float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
119
- float webGLThickness = pixelsThickness * u_correctionRatio;
120
- float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
121
- float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
122
- float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
123
-
124
- float da = a_barycentric.x;
125
- float db = a_barycentric.y;
126
- float dc = a_barycentric.z;
127
-
128
- vec2 delta = vec2(
129
- da * (webGLNodeRadius * unitNormal.y)
130
- + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
131
- + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
132
-
133
- da * (-webGLNodeRadius * unitNormal.x)
134
- + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
135
- + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
136
- );
137
-
138
- vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
139
-
140
- gl_Position = vec4(position, 0, 1);
141
-
142
- #ifdef PICKING_MODE
143
- // For picking mode, we use the ID as the color:
144
- v_color = a_id;
145
- #else
146
- // For normal mode, we use the color:
147
- v_color = a_color;
148
- #endif
149
-
150
- v_color.a *= bias;
151
- }
152
- `,bi=pi,kt=WebGLRenderingContext,Xe=kt.UNSIGNED_BYTE,he=kt.FLOAT,Ei=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Ft={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Nt(r){var n=b(b({},Ft),{});return(function(i){function e(){return A(this,e),I(this,e,arguments)}return G(e,i),L(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:bi,FRAGMENT_SHADER_SOURCE:mi,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ei,ATTRIBUTES:[{name:"a_position",size:2,type:he},{name:"a_normal",size:2,type:he},{name:"a_radius",size:1,type:he},{name:"a_color",size:4,type:Xe,normalized:!0},{name:"a_id",size:4,type:Xe,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:he}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,h){if(n.extremity==="source"){var u=[l,s];s=u[0],l=u[1]}var d=h.size||1,f=l.size||1,g=s.x,m=s.y,v=l.x,p=l.y,R=oe(h.color),y=v-g,E=p-m,T=y*y+E*E,x=0,w=0;T&&(T=1/Math.sqrt(T),x=-E*T*d,w=y*T*d);var _=this.array;_[o++]=v,_[o++]=p,_[o++]=-x,_[o++]=-w,_[o++]=f,_[o++]=R,_[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,h=l.u_matrix,u=l.u_sizeRatio,d=l.u_correctionRatio,f=l.u_minEdgeThickness,g=l.u_lengthToThicknessRatio,m=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(u,a.sizeRatio),s.uniform1f(d,a.correctionRatio),s.uniform1f(f,a.minEdgeThickness),s.uniform1f(g,n.lengthToThicknessRatio),s.uniform1f(m,n.widenessToThicknessRatio)}}])})(Ge)}Nt();var yi=`
153
- precision mediump float;
154
-
155
- varying vec4 v_color;
156
- varying vec2 v_normal;
157
- varying float v_thickness;
158
- varying float v_feather;
159
-
160
- const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
161
-
162
- void main(void) {
163
- // We only handle antialiasing for normal mode:
164
- #ifdef PICKING_MODE
165
- gl_FragColor = v_color;
166
- #else
167
- float dist = length(v_normal) * v_thickness;
168
-
169
- float t = smoothstep(
170
- v_thickness - v_feather,
171
- v_thickness,
172
- dist
173
- );
174
-
175
- gl_FragColor = mix(v_color, transparent, t);
176
- #endif
177
- }
178
- `,Dt=yi,Ti=`
179
- attribute vec4 a_id;
180
- attribute vec4 a_color;
181
- attribute vec2 a_normal;
182
- attribute float a_normalCoef;
183
- attribute vec2 a_positionStart;
184
- attribute vec2 a_positionEnd;
185
- attribute float a_positionCoef;
186
- attribute float a_radius;
187
- attribute float a_radiusCoef;
188
-
189
- uniform mat3 u_matrix;
190
- uniform float u_zoomRatio;
191
- uniform float u_sizeRatio;
192
- uniform float u_pixelRatio;
193
- uniform float u_correctionRatio;
194
- uniform float u_minEdgeThickness;
195
- uniform float u_lengthToThicknessRatio;
196
- uniform float u_feather;
197
-
198
- varying vec4 v_color;
199
- varying vec2 v_normal;
200
- varying float v_thickness;
201
- varying float v_feather;
202
-
203
- const float bias = 255.0 / 254.0;
204
-
205
- void main() {
206
- float minThickness = u_minEdgeThickness;
207
-
208
- float radius = a_radius * a_radiusCoef;
209
- vec2 normal = a_normal * a_normalCoef;
210
- vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
211
-
212
- float normalLength = length(normal);
213
- vec2 unitNormal = normal / normalLength;
214
-
215
- // These first computations are taken from edge.vert.glsl. Please read it to
216
- // get better comments on what's happening:
217
- float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
218
- float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
219
-
220
- // Here, we move the point to leave space for the arrow head:
221
- float direction = sign(radius);
222
- float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
223
- float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
224
-
225
- vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
226
-
227
- // Here is the proper position of the vertex
228
- gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
229
-
230
- v_thickness = webGLThickness / u_zoomRatio;
231
-
232
- v_normal = unitNormal;
233
-
234
- v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
235
-
236
- #ifdef PICKING_MODE
237
- // For picking mode, we use the ID as the color:
238
- v_color = a_id;
239
- #else
240
- // For normal mode, we use the color:
241
- v_color = a_color;
242
- #endif
243
-
244
- v_color.a *= bias;
245
- }
246
- `,Ci=Ti,Pt=WebGLRenderingContext,$e=Pt.UNSIGNED_BYTE,$=Pt.FLOAT,Ri=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],_i={lengthToThicknessRatio:Ft.lengthToThicknessRatio};function It(r){var n=b(b({},_i),{});return(function(i){function e(){return A(this,e),I(this,e,arguments)}return G(e,i),L(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ci,FRAGMENT_SHADER_SOURCE:Dt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ri,ATTRIBUTES:[{name:"a_positionStart",size:2,type:$},{name:"a_positionEnd",size:2,type:$},{name:"a_normal",size:2,type:$},{name:"a_color",size:4,type:$e,normalized:!0},{name:"a_id",size:4,type:$e,normalized:!0},{name:"a_radius",size:1,type:$}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:$},{name:"a_normalCoef",size:1,type:$},{name:"a_radiusCoef",size:1,type:$}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,h){var u=h.size||1,d=s.x,f=s.y,g=l.x,m=l.y,v=oe(h.color),p=g-d,R=m-f,y=l.size||1,E=p*p+R*R,T=0,x=0;E&&(E=1/Math.sqrt(E),T=-R*E*u,x=p*E*u);var w=this.array;w[o++]=d,w[o++]=f,w[o++]=g,w[o++]=m,w[o++]=T,w[o++]=x,w[o++]=v,w[o++]=a,w[o++]=y}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,h=l.u_matrix,u=l.u_zoomRatio,d=l.u_feather,f=l.u_pixelRatio,g=l.u_correctionRatio,m=l.u_sizeRatio,v=l.u_minEdgeThickness,p=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,a.matrix),s.uniform1f(u,a.zoomRatio),s.uniform1f(m,a.sizeRatio),s.uniform1f(g,a.correctionRatio),s.uniform1f(f,a.pixelRatio),s.uniform1f(d,a.antiAliasingFeather),s.uniform1f(v,a.minEdgeThickness),s.uniform1f(p,n.lengthToThicknessRatio)}}])})(Ge)}It();function wi(r){return si([It(),Nt()])}var xi=wi(),Si=xi,Ai=`
247
- attribute vec4 a_id;
248
- attribute vec4 a_color;
249
- attribute vec2 a_normal;
250
- attribute float a_normalCoef;
251
- attribute vec2 a_positionStart;
252
- attribute vec2 a_positionEnd;
253
- attribute float a_positionCoef;
254
-
255
- uniform mat3 u_matrix;
256
- uniform float u_sizeRatio;
257
- uniform float u_zoomRatio;
258
- uniform float u_pixelRatio;
259
- uniform float u_correctionRatio;
260
- uniform float u_minEdgeThickness;
261
- uniform float u_feather;
262
-
263
- varying vec4 v_color;
264
- varying vec2 v_normal;
265
- varying float v_thickness;
266
- varying float v_feather;
267
-
268
- const float bias = 255.0 / 254.0;
269
-
270
- void main() {
271
- float minThickness = u_minEdgeThickness;
272
-
273
- vec2 normal = a_normal * a_normalCoef;
274
- vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
275
-
276
- float normalLength = length(normal);
277
- vec2 unitNormal = normal / normalLength;
278
-
279
- // We require edges to be at least "minThickness" pixels thick *on screen*
280
- // (so we need to compensate the size ratio):
281
- float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
282
-
283
- // Then, we need to retrieve the normalized thickness of the edge in the WebGL
284
- // referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
285
- // ratio:
286
- float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
287
-
288
- // Here is the proper position of the vertex
289
- gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
290
-
291
- // For the fragment shader though, we need a thickness that takes the "magic"
292
- // correction ratio into account (as in webGLThickness), but so that the
293
- // antialiasing effect does not depend on the zoom level. So here's yet
294
- // another thickness version:
295
- v_thickness = webGLThickness / u_zoomRatio;
296
-
297
- v_normal = unitNormal;
298
-
299
- v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
300
-
301
- #ifdef PICKING_MODE
302
- // For picking mode, we use the ID as the color:
303
- v_color = a_id;
304
- #else
305
- // For normal mode, we use the color:
306
- v_color = a_color;
307
- #endif
308
-
309
- v_color.a *= bias;
310
- }
311
- `,Li=Ai,Gt=WebGLRenderingContext,Ke=Gt.UNSIGNED_BYTE,te=Gt.FLOAT,ki=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Fi=(function(r){function n(){return A(this,n),I(this,n,arguments)}return G(n,r),L(n,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Li,FRAGMENT_SHADER_SOURCE:Dt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ki,ATTRIBUTES:[{name:"a_positionStart",size:2,type:te},{name:"a_positionEnd",size:2,type:te},{name:"a_normal",size:2,type:te},{name:"a_color",size:4,type:Ke,normalized:!0},{name:"a_id",size:4,type:Ke,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:te},{name:"a_normalCoef",size:1,type:te}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(e,t,a,o,s){var l=s.size||1,h=a.x,u=a.y,d=o.x,f=o.y,g=oe(s.color),m=d-h,v=f-u,p=m*m+v*v,R=0,y=0;p&&(p=1/Math.sqrt(p),R=-v*p*l,y=m*p*l);var E=this.array;E[t++]=h,E[t++]=u,E[t++]=d,E[t++]=f,E[t++]=R,E[t++]=y,E[t++]=g,E[t++]=e}},{key:"setUniforms",value:function(e,t){var a=t.gl,o=t.uniformLocations,s=o.u_matrix,l=o.u_zoomRatio,h=o.u_feather,u=o.u_pixelRatio,d=o.u_correctionRatio,f=o.u_sizeRatio,g=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,e.matrix),a.uniform1f(l,e.zoomRatio),a.uniform1f(f,e.sizeRatio),a.uniform1f(d,e.correctionRatio),a.uniform1f(u,e.pixelRatio),a.uniform1f(h,e.antiAliasingFeather),a.uniform1f(g,e.minEdgeThickness)}}])})(Ge),Oe=(function(r){function n(){var i;return A(this,n),i=I(this,n),i.rawEmitter=i,i}return G(n,r),L(n)})(Ht.EventEmitter),Ce,Je;function Ni(){return Je||(Je=1,Ce=function(n){return n!==null&&typeof n=="object"&&typeof n.addUndirectedEdgeWithKey=="function"&&typeof n.dropNode=="function"&&typeof n.multi=="boolean"}),Ce}var Di=Ni();const Pi=Bt(Di);var Ii=function(n){return n},Gi=function(n){return n*n},Oi=function(n){return n*(2-n)},Mi=function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)},zi=function(n){return n*n*n},Ui=function(n){return--n*n*n+1},Bi=function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)},Hi={linear:Ii,quadraticIn:Gi,quadraticOut:Oi,quadraticInOut:Mi,cubicIn:zi,cubicOut:Ui,cubicInOut:Bi},Wi={easing:"quadraticInOut",duration:150};function z(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function ue(r,n,i){return r[0]=n,r[4]=typeof i=="number"?i:n,r}function Qe(r,n){var i=Math.sin(n),e=Math.cos(n);return r[0]=e,r[1]=i,r[3]=-i,r[4]=e,r}function et(r,n,i){return r[6]=n,r[7]=i,r}function q(r,n){var i=r[0],e=r[1],t=r[2],a=r[3],o=r[4],s=r[5],l=r[6],h=r[7],u=r[8],d=n[0],f=n[1],g=n[2],m=n[3],v=n[4],p=n[5],R=n[6],y=n[7],E=n[8];return r[0]=d*i+f*a+g*l,r[1]=d*e+f*o+g*h,r[2]=d*t+f*s+g*u,r[3]=m*i+v*a+p*l,r[4]=m*e+v*o+p*h,r[5]=m*t+v*s+p*u,r[6]=R*i+y*a+E*l,r[7]=R*e+y*o+E*h,r[8]=R*t+y*s+E*u,r}function Le(r,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=r[0],t=r[1],a=r[3],o=r[4],s=r[6],l=r[7],h=n.x,u=n.y;return{x:h*e+u*a+s*i,y:h*t+u*o+l*i}}function Vi(r,n){var i=r.height/r.width,e=n.height/n.width;return i<1&&e>1||i>1&&e<1?1:Math.min(Math.max(e,1/e),Math.max(1/i,i))}function ie(r,n,i,e,t){var a=r.angle,o=r.ratio,s=r.x,l=r.y,h=n.width,u=n.height,d=z(),f=Math.min(h,u)-2*e,g=Vi(n,i);return t?(q(d,et(z(),s,l)),q(d,ue(z(),o)),q(d,Qe(z(),a)),q(d,ue(z(),h/f/2/g,u/f/2/g))):(q(d,ue(z(),2*(f/h)*g,2*(f/u)*g)),q(d,Qe(z(),-a)),q(d,ue(z(),1/o)),q(d,et(z(),-s,-l))),d}function ji(r,n,i){var e=Le(r,{x:Math.cos(n.angle),y:Math.sin(n.angle)},0),t=e.x,a=e.y;return 1/Math.sqrt(Math.pow(t,2)+Math.pow(a,2))/i.width}function Zi(r){if(!r.order)return{x:[0,1],y:[0,1]};var n=1/0,i=-1/0,e=1/0,t=-1/0;return r.forEachNode(function(a,o){var s=o.x,l=o.y;s<n&&(n=s),s>i&&(i=s),l<e&&(e=l),l>t&&(t=l)}),{x:[n,i],y:[e,t]}}function qi(r){if(!Pi(r))throw new Error("Sigma: invalid graph instance.");r.forEachNode(function(n,i){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))throw new Error("Sigma: Coordinates of node ".concat(n," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Yi(r,n,i){var e=document.createElement(r);if(n)for(var t in n)e.style[t]=n[t];if(i)for(var a in i)e.setAttribute(a,i[a]);return e}function tt(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function it(r,n,i){return i.sort(function(e,t){var a=n(e)||0,o=n(t)||0;return a<o?-1:a>o?1:0})}function rt(r){var n=ee(r.x,2),i=n[0],e=n[1],t=ee(r.y,2),a=t[0],o=t[1],s=Math.max(e-i,o-a),l=(e+i)/2,h=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(h)&&(h=0);var u=function(f){return{x:.5+(f.x-l)/s,y:.5+(f.y-h)/s}};return u.applyTo=function(d){d.x=.5+(d.x-l)/s,d.y=.5+(d.y-h)/s},u.inverse=function(d){return{x:l+s*(d.x-.5),y:h+s*(d.y-.5)}},u.ratio=s,u}function ke(r){"@babel/helpers - typeof";return ke=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ke(r)}function nt(r,n){var i=n.size;if(i!==0){var e=r.length;r.length+=i;var t=0;n.forEach(function(a){r[e+t]=a,t++})}}function Re(r){r=r||{};for(var n=0,i=arguments.length<=1?0:arguments.length-1;n<i;n++){var e=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];e&&Object.assign(r,e)}return r}var Me={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:li,defaultDrawNodeLabel:At,defaultDrawNodeHover:hi,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Xi={circle:fe},$i={arrow:Si,line:Fi};function _e(r){if(typeof r.labelDensity!="number"||r.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var n=r.minCameraRatio,i=r.maxCameraRatio;if(typeof n=="number"&&typeof i=="number"&&i<n)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Ki(r){var n=Re({},Me,r);return n.nodeProgramClasses=Re({},Xi,n.nodeProgramClasses),n.edgeProgramClasses=Re({},$i,n.edgeProgramClasses),n}var de=1.5,at=(function(r){function n(){var i;return A(this,n),i=I(this,n),c(i,"x",.5),c(i,"y",.5),c(i,"angle",0),c(i,"ratio",1),c(i,"minRatio",null),c(i,"maxRatio",null),c(i,"enabledZooming",!0),c(i,"enabledPanning",!0),c(i,"enabledRotation",!0),c(i,"clean",null),c(i,"nextFrame",null),c(i,"previousState",null),c(i,"enabled",!0),i.previousState=i.getState(),i}return G(n,r),L(n,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:"getPreviousState",value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:"getBoundedRatio",value:function(e){var t=e;return typeof this.minRatio=="number"&&(t=Math.max(t,this.minRatio)),typeof this.maxRatio=="number"&&(t=Math.min(t,this.maxRatio)),t}},{key:"validateState",value:function(e){var t={};return this.enabledPanning&&typeof e.x=="number"&&(t.x=e.x),this.enabledPanning&&typeof e.y=="number"&&(t.y=e.y),this.enabledZooming&&typeof e.ratio=="number"&&(t.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle=="number"&&(t.angle=e.angle),this.clean?this.clean(b(b({},this.getState()),t)):t}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var t=this.validateState(e);return typeof t.x=="number"&&(this.x=t.x),typeof t.y=="number"&&(this.y=t.y),typeof t.ratio=="number"&&(this.ratio=t.ratio),typeof t.angle=="number"&&(this.angle=t.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(e){return this.setState(e(this.getState())),this}},{key:"animate",value:function(e){var t=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(!o)return new Promise(function(g){return t.animate(e,a,g)});if(this.enabled){var s=b(b({},Wi),a),l=this.validateState(e),h=typeof s.easing=="function"?s.easing:Hi[s.easing],u=Date.now(),d=this.getState(),f=function(){var m=(Date.now()-u)/s.duration;if(m>=1){t.nextFrame=null,t.setState(l),t.animationCallback&&(t.animationCallback.call(null),t.animationCallback=void 0);return}var v=h(m),p={};typeof l.x=="number"&&(p.x=d.x+(l.x-d.x)*v),typeof l.y=="number"&&(p.y=d.y+(l.y-d.y)*v),t.enabledRotation&&typeof l.angle=="number"&&(p.angle=d.angle+(l.angle-d.angle)*v),typeof l.ratio=="number"&&(p.ratio=d.ratio+(l.ratio-d.ratio)*v),t.setState(p),t.nextFrame=requestAnimationFrame(f)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(f)):f(),this.animationCallback=o}}},{key:"animatedZoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||de)},e):this.animate({ratio:this.ratio/de})}},{key:"animatedUnzoom",value:function(e){return e?typeof e=="number"?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||de)},e):this.animate({ratio:this.ratio*de})}},{key:"animatedReset",value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:"copy",value:function(){return n.from(this.getState())}}],[{key:"from",value:function(e){var t=new n;return t.setState(e)}}])})(Oe);function U(r,n){var i=n.getBoundingClientRect();return{x:r.clientX-i.left,y:r.clientY-i.top}}function H(r,n){var i=b(b({},U(r,n)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){i.sigmaDefaultPrevented=!0},original:r});return i}function re(r){var n="x"in r?r:b(b({},r.touches[0]||r.previousTouches[0]),{},{original:r.original,sigmaDefaultPrevented:r.sigmaDefaultPrevented,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0,n.sigmaDefaultPrevented=!0}});return n}function Ji(r,n){return b(b({},H(r,n)),{},{delta:Ot(r)})}var Qi=2;function ce(r){for(var n=[],i=0,e=Math.min(r.length,Qi);i<e;i++)n.push(r[i]);return n}function ne(r,n,i){var e={touches:ce(r.touches).map(function(t){return U(t,i)}),previousTouches:n.map(function(t){return U(t,i)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:r};return e}function Ot(r){if(typeof r.deltaY<"u")return r.deltaY*-3/360;if(typeof r.detail<"u")return r.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Mt=(function(r){function n(i,e){var t;return A(this,n),t=I(this,n),t.container=i,t.renderer=e,t}return G(n,r),L(n)})(Oe),er=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],tr=er.reduce(function(r,n){return b(b({},r),{},c({},n,Me[n]))},{}),ir=(function(r){function n(i,e){var t;return A(this,n),t=I(this,n,[i,e]),c(t,"enabled",!0),c(t,"draggedEvents",0),c(t,"downStartTime",null),c(t,"lastMouseX",null),c(t,"lastMouseY",null),c(t,"isMouseDown",!1),c(t,"isMoving",!1),c(t,"movingTimeout",null),c(t,"startCameraState",null),c(t,"clicks",0),c(t,"doubleClickTimeout",null),c(t,"currentWheelDirection",0),c(t,"settings",tr),t.handleClick=t.handleClick.bind(t),t.handleRightClick=t.handleRightClick.bind(t),t.handleDown=t.handleDown.bind(t),t.handleUp=t.handleUp.bind(t),t.handleMove=t.handleMove.bind(t),t.handleWheel=t.handleWheel.bind(t),t.handleLeave=t.handleLeave.bind(t),t.handleEnter=t.handleEnter.bind(t),i.addEventListener("click",t.handleClick,{capture:!1}),i.addEventListener("contextmenu",t.handleRightClick,{capture:!1}),i.addEventListener("mousedown",t.handleDown,{capture:!1}),i.addEventListener("wheel",t.handleWheel,{capture:!1}),i.addEventListener("mouseleave",t.handleLeave,{capture:!1}),i.addEventListener("mouseenter",t.handleEnter,{capture:!1}),document.addEventListener("mousemove",t.handleMove,{capture:!1}),document.addEventListener("mouseup",t.handleUp,{capture:!1}),t}return G(n,r),L(n,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("contextmenu",this.handleRightClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("wheel",this.handleWheel),e.removeEventListener("mouseleave",this.handleLeave),e.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var t=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(function(){t.clicks=0,t.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",H(e,this.container))}}},{key:"handleRightClick",value:function(e){this.enabled&&this.emit("rightClick",H(e,this.container))}},{key:"handleDoubleClick",value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var t=H(e,this.container);if(this.emit("doubleClick",t),!t.sigmaDefaultPrevented){var a=this.renderer.getCamera(),o=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(U(e,this.container),o),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var t=U(e,this.container),a=t.x,o=t.y;this.lastMouseX=a,this.lastMouseY=o,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",H(e,this.container))}}},{key:"handleUp",value:function(e){var t=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var o=U(e,this.container),s=o.x,l=o.y,h=a.getState(),u=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:h.x+this.settings.inertiaRatio*(h.x-u.x),y:h.y+this.settings.inertiaRatio*(h.y-u.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&a.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var d=t.draggedEvents>0;t.draggedEvents=0,d&&t.renderer.getSetting("hideEdgesOnMove")&&t.renderer.refresh()},0),this.emit("mouseup",H(e,this.container))}}},{key:"handleMove",value:function(e){var t=this;if(this.enabled){var a=H(e,this.container);if(this.emit("mousemovebody",a),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.movingTimeout=null,t.isMoving=!1},this.settings.dragTimeout);var o=this.renderer.getCamera(),s=U(e,this.container),l=s.x,h=s.y,u=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:l,y:h}),f=u.x-d.x,g=u.y-d.y,m=o.getState(),v=m.x+f,p=m.y+g;o.setState({x:v,y:p}),this.lastMouseX=l,this.lastMouseY=h,e.preventDefault(),e.stopPropagation()}}}},{key:"handleLeave",value:function(e){this.emit("mouseleave",H(e,this.container))}},{key:"handleEnter",value:function(e){this.emit("mouseenter",H(e,this.container))}},{key:"handleWheel",value:function(e){var t=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=Ot(e);if(o){var s=Ji(e,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){e.preventDefault(),e.stopPropagation();return}var l=a.getState().ratio,h=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,u=a.getBoundedRatio(l*h),d=o>0?1:-1,f=Date.now();l!==u&&(e.preventDefault(),e.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&f-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(U(e,this.container),u),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){t.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=f))}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(Mt),rr=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],nr=rr.reduce(function(r,n){return b(b({},r),{},c({},n,Me[n]))},{}),ar=(function(r){function n(i,e){var t;return A(this,n),t=I(this,n,[i,e]),c(t,"enabled",!0),c(t,"isMoving",!1),c(t,"hasMoved",!1),c(t,"touchMode",0),c(t,"startTouchesPositions",[]),c(t,"lastTouches",[]),c(t,"lastTap",null),c(t,"settings",nr),t.handleStart=t.handleStart.bind(t),t.handleLeave=t.handleLeave.bind(t),t.handleMove=t.handleMove.bind(t),i.addEventListener("touchstart",t.handleStart,{capture:!1}),i.addEventListener("touchcancel",t.handleLeave,{capture:!1}),document.addEventListener("touchend",t.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",t.handleMove,{capture:!1,passive:!1}),t}return G(n,r),L(n,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("touchstart",this.handleStart),e.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(e){var t=this;if(this.enabled){e.preventDefault();var a=ce(e.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(g){return U(g,t.container)}),this.touchMode===2){var o=ee(this.startTouchesPositions,2),s=o[0],l=s.x,h=s.y,u=o[1],d=u.x,f=u.y;this.startTouchesAngle=Math.atan2(f-h,d-l),this.startTouchesDistance=Math.sqrt(Math.pow(d-l,2)+Math.pow(f-h,2))}this.emit("touchdown",ne(e,this.lastTouches,this.container)),this.lastTouches=a,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(e){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var t=this.renderer.getCamera(),a=t.getState(),o=t.getPreviousState()||{x:0,y:0};t.animate({x:a.x+this.settings.inertiaRatio*(a.x-o.x),y:a.y+this.settings.inertiaRatio*(a.y-o.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",ne(e,this.lastTouches,this.container)),!e.touches.length){var s=U(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],h=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!e.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var u=ne(e,this.lastTouches,this.container);if(this.emit("doubletap",u),this.lastTap=null,!u.sigmaDefaultPrevented){var d=this.renderer.getCamera(),f=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,f),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var g=ne(e,this.lastTouches,this.container);this.emit("tap",g),this.lastTap={time:Date.now(),position:g.touches[0]||g.previousTouches[0]}}}this.lastTouches=ce(e.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(e){var t=this;if(!(!this.enabled||!this.startTouchesPositions.length)){e.preventDefault();var a=ce(e.touches),o=a.map(function(Z){return U(Z,t.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var l=ne(e,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(Z,ve){var B=t.startTouchesPositions[ve];return B&&(Z.x!==B.x||Z.y!==B.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),u=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var f=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),g=f.x,m=f.y,v=this.renderer.viewportToFramedGraph(o[0]),p=v.x,R=v.y;h.setState({x:u.x+g-p,y:u.y+m-R});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},E=o[0],T=E.x,x=E.y,w=o[1],_=w.x,O=w.y,D=Math.atan2(O-x,_-T)-this.startTouchesAngle,k=Math.hypot(O-x,_-T)/this.startTouchesDistance,P=h.getBoundedRatio(u.ratio/k);y.ratio=P,y.angle=u.angle+D;var F=this.getDimensions(),Y=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),N=Math.min(F.width,F.height)-2*d,M=N/F.width,V=N/F.height,se=P/N,K=T-N/2/M,X=x-N/2/V,j=[K*Math.cos(-y.angle)-X*Math.sin(-y.angle),X*Math.cos(-y.angle)+K*Math.sin(-y.angle)];K=j[0],X=j[1],y.x=Y.x-K*se,y.y=Y.y+X*se,h.setState(y);break}}}}}},{key:"setSettings",value:function(e){this.settings=e}}])})(Mt);function or(r){if(Array.isArray(r))return Se(r)}function sr(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function lr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
312
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ot(r){return or(r)||sr(r)||Tt(r)||lr()}function hr(r,n){if(r==null)return{};var i={};for(var e in r)if({}.hasOwnProperty.call(r,e)){if(n.indexOf(e)!==-1)continue;i[e]=r[e]}return i}function we(r,n){if(r==null)return{};var i,e,t=hr(r,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(e=0;e<a.length;e++)i=a[e],n.indexOf(i)===-1&&{}.propertyIsEnumerable.call(r,i)&&(t[i]=r[i])}return t}var st=(function(){function r(n,i){A(this,r),this.key=n,this.size=i}return L(r,null,[{key:"compare",value:function(i,e){return i.size>e.size?-1:i.size<e.size||i.key>e.key?1:-1}}])})(),lt=(function(){function r(){A(this,r),c(this,"width",0),c(this,"height",0),c(this,"cellSize",0),c(this,"columns",0),c(this,"rows",0),c(this,"cells",{})}return L(r,[{key:"resizeAndClear",value:function(i,e){this.width=i.width,this.height=i.height,this.cellSize=e,this.columns=Math.ceil(i.width/e),this.rows=Math.ceil(i.height/e),this.cells={}}},{key:"getIndex",value:function(i){var e=Math.floor(i.x/this.cellSize),t=Math.floor(i.y/this.cellSize);return t*this.columns+e}},{key:"add",value:function(i,e,t){var a=new st(i,e),o=this.getIndex(t),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var i in this.cells){var e=this.cells[i];e.sort(st.compare)}}},{key:"getLabelsToDisplay",value:function(i,e){var t=this.cellSize*this.cellSize,a=t/i/i,o=a*e/t,s=Math.ceil(o),l=[];for(var h in this.cells)for(var u=this.cells[h],d=0;d<Math.min(s,u.length);d++)l.push(u[d].key);return l}}])})();function ur(r){var n=r.graph,i=r.hoveredNode,e=r.highlightedNodes,t=r.displayedNodeLabels,a=[];return n.forEachEdge(function(o,s,l,h){(l===i||h===i||e.has(l)||e.has(h)||t.has(l)&&t.has(h))&&a.push(o)}),a}var ht=150,ut=50,W=Object.prototype.hasOwnProperty;function dr(r,n,i){if(!W.call(i,"x")||!W.call(i,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(n,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return i.color||(i.color=r.defaultNodeColor),!i.label&&i.label!==""&&(i.label=null),i.label!==void 0&&i.label!==null?i.label=""+i.label:i.label=null,i.size||(i.size=2),W.call(i,"hidden")||(i.hidden=!1),W.call(i,"highlighted")||(i.highlighted=!1),W.call(i,"forceLabel")||(i.forceLabel=!1),(!i.type||i.type==="")&&(i.type=r.defaultNodeType),i.zIndex||(i.zIndex=0),i}function cr(r,n,i){return i.color||(i.color=r.defaultEdgeColor),i.label||(i.label=""),i.size||(i.size=.5),W.call(i,"hidden")||(i.hidden=!1),W.call(i,"forceLabel")||(i.forceLabel=!1),(!i.type||i.type==="")&&(i.type=r.defaultEdgeType),i.zIndex||(i.zIndex=0),i}var fr=(function(r){function n(i,e){var t,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(A(this,n),t=I(this,n),c(t,"elements",{}),c(t,"canvasContexts",{}),c(t,"webGLContexts",{}),c(t,"pickingLayers",new Set),c(t,"textures",{}),c(t,"frameBuffers",{}),c(t,"activeListeners",{}),c(t,"labelGrid",new lt),c(t,"nodeDataCache",{}),c(t,"edgeDataCache",{}),c(t,"nodeProgramIndex",{}),c(t,"edgeProgramIndex",{}),c(t,"nodesWithForcedLabels",new Set),c(t,"edgesWithForcedLabels",new Set),c(t,"nodeExtent",{x:[0,1],y:[0,1]}),c(t,"nodeZExtent",[1/0,-1/0]),c(t,"edgeZExtent",[1/0,-1/0]),c(t,"matrix",z()),c(t,"invMatrix",z()),c(t,"correctionRatio",1),c(t,"customBBox",null),c(t,"normalizationFunction",rt({x:[0,1],y:[0,1]})),c(t,"graphToViewportRatio",1),c(t,"itemIDsIndex",{}),c(t,"nodeIndices",{}),c(t,"edgeIndices",{}),c(t,"width",0),c(t,"height",0),c(t,"pixelRatio",tt()),c(t,"pickingDownSizingRatio",2*t.pixelRatio),c(t,"displayedNodeLabels",new Set),c(t,"displayedEdgeLabels",new Set),c(t,"highlightedNodes",new Set),c(t,"hoveredNode",null),c(t,"hoveredEdge",null),c(t,"renderFrame",null),c(t,"renderHighlightedNodesFrame",null),c(t,"needToProcess",!1),c(t,"checkEdgesEventsFrame",null),c(t,"nodePrograms",{}),c(t,"nodeHoverPrograms",{}),c(t,"edgePrograms",{}),t.settings=Ki(a),_e(t.settings),qi(i),!(e instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");t.graph=i,t.container=e,t.createWebGLContext("edges",{picking:a.enableEdgeEvents}),t.createCanvasContext("edgeLabels"),t.createWebGLContext("nodes",{picking:!0}),t.createCanvasContext("labels"),t.createCanvasContext("hovers"),t.createWebGLContext("hoverNodes"),t.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),t.resize();for(var o in t.settings.nodeProgramClasses)t.registerNodeProgram(o,t.settings.nodeProgramClasses[o],t.settings.nodeHoverProgramClasses[o]);for(var s in t.settings.edgeProgramClasses)t.registerEdgeProgram(s,t.settings.edgeProgramClasses[s]);return t.camera=new at,t.bindCameraHandlers(),t.mouseCaptor=new ir(t.elements.mouse,t),t.mouseCaptor.setSettings(t.settings),t.touchCaptor=new ar(t.elements.mouse,t),t.touchCaptor.setSettings(t.settings),t.bindEventHandlers(),t.bindGraphHandlers(),t.handleSettingsUpdate(),t.refresh(),t}return G(n,r),L(n,[{key:"registerNodeProgram",value:function(e,t,a){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new t(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(a||t)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(e,t){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new t(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(e){if(this.nodePrograms[e]){var t=this.nodePrograms,a=t[e],o=we(t,[e].map(ae));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[e]){var s=this.nodeHoverPrograms,l=s[e],h=we(s,[e].map(ae));l.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(e){if(this.edgePrograms[e]){var t=this.edgePrograms,a=t[e],o=we(t,[e].map(ae));a.kill(),this.edgePrograms=o}return this}},{key:"resetWebGLTexture",value:function(e){var t=this.webGLContexts[e],a=this.frameBuffers[e],o=this.textures[e];o&&t.deleteTexture(o);var s=t.createTexture();return t.bindFramebuffer(t.FRAMEBUFFER,a),t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),this.textures[e]=s,this}},{key:"bindCameraHandlers",value:function(){var e=this;return this.activeListeners.camera=function(){e.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(e){var t=e.x,a=e.y,o=Ve(this.webGLContexts.nodes,this.frameBuffers.nodes,t,a,this.pixelRatio,this.pickingDownSizingRatio),s=We.apply(void 0,ot(o)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var o=re(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}},l=e.getNodeAtPosition(o);if(l&&e.hoveredNode!==l&&!e.nodeDataCache[l].hidden){e.hoveredNode&&e.emit("leaveNode",b(b({},s),{},{node:e.hoveredNode})),e.hoveredNode=l,e.emit("enterNode",b(b({},s),{},{node:l})),e.scheduleHighlightedNodesRender();return}if(e.hoveredNode&&e.getNodeAtPosition(o)!==e.hoveredNode){var h=e.hoveredNode;e.hoveredNode=null,e.emit("leaveNode",b(b({},s),{},{node:h})),e.scheduleHighlightedNodesRender();return}if(e.settings.enableEdgeEvents){var u=e.hoveredNode?null:e.getEdgeAtPoint(s.event.x,s.event.y);u!==e.hoveredEdge&&(e.hoveredEdge&&e.emit("leaveEdge",b(b({},s),{},{edge:e.hoveredEdge})),u&&e.emit("enterEdge",b(b({},s),{},{edge:u})),e.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(a){var o=re(a);e.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=re(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};e.hoveredNode&&(e.emit("leaveNode",b(b({},s),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit("leaveEdge",b(b({},s),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit("leaveStage",b({},s))},this.activeListeners.handleEnter=function(a){var o=re(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};e.emit("enterStage",b({},s))};var t=function(o){return function(s){var l=re(s),h={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=e.getNodeAtPosition(l);if(u)return e.emit("".concat(o,"Node"),b(b({},h),{},{node:u}));if(e.settings.enableEdgeEvents){var d=e.getEdgeAtPoint(l.x,l.y);if(d)return e.emit("".concat(o,"Edge"),b(b({},h),{},{edge:d}))}return e.emit("".concat(o,"Stage"),h)}};return this.activeListeners.handleClick=t("click"),this.activeListeners.handleRightClick=t("rightClick"),this.activeListeners.handleDoubleClick=t("doubleClick"),this.activeListeners.handleWheel=t("wheel"),this.activeListeners.handleDown=t("down"),this.activeListeners.handleUp=t("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var e=this,t=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachNode(function(u){return e.updateNode(u)});var h=!l||l.some(function(u){return a.has(u)});e.refresh({partialGraph:{nodes:t.nodes()},skipIndexation:!h,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;e.graph.forEachEdge(function(u){return e.updateEdge(u)});var h=l&&["zIndex","type"].some(function(u){return l?.includes(u)});e.refresh({partialGraph:{edges:t.edges()},skipIndexation:!h,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(o){var s=o.key;e.addNode(s),e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(o){var s=o.key;e.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(o){var s=o.key;e.removeNode(s),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(o){var s=o.key;e.addEdge(s),e.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(o){var s=o.key;e.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(o){var s=o.key;e.removeEdge(s),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},t.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),t.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),t.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),t.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),t.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),t.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),t.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),t.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var e=this.graph;e.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),e.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),e.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),e.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),e.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),e.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),e.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),e.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(e,t){var a=Ve(this.webGLContexts.edges,this.frameBuffers.edges,e,t,this.pixelRatio,this.pickingDownSizingRatio),o=We.apply(void 0,ot(a)),s=this.itemIDsIndex[o];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var e=this;this.emit("beforeProcess");var t=this.graph,a=this.settings,o=this.getDimensions();if(this.nodeExtent=Zi(this.graph),!this.settings.autoRescale){var s=o.width,l=o.height,h=this.nodeExtent,u=h.x,d=h.y;this.nodeExtent={x:[(u[0]+u[1])/2-s/2,(u[0]+u[1])/2+s/2],y:[(d[0]+d[1])/2-l/2,(d[0]+d[1])/2+l/2]}}this.normalizationFunction=rt(this.customBBox||this.nodeExtent);var f=new at,g=ie(f.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var m={},v={},p={},R={},y=1,E=t.nodes(),T=0,x=E.length;T<x;T++){var w=E[T],_=this.nodeDataCache[w],O=t.getNodeAttributes(w);_.x=O.x,_.y=O.y,this.normalizationFunction.applyTo(_),typeof _.label=="string"&&!_.hidden&&this.labelGrid.add(w,_.size,this.framedGraphToViewport(_,{matrix:g})),m[_.type]=(m[_.type]||0)+1}this.labelGrid.organize();for(var D in this.nodePrograms){if(!W.call(this.nodePrograms,D))throw new Error('Sigma: could not find a suitable program for node type "'.concat(D,'"!'));this.nodePrograms[D].reallocate(m[D]||0),m[D]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(E=it(this.nodeZExtent,function(me){return e.nodeDataCache[me].zIndex},E));for(var k=0,P=E.length;k<P;k++){var F=E[k];v[F]=y,R[v[F]]={type:"node",id:F},y++;var Y=this.nodeDataCache[F];this.addNodeToProgram(F,v[F],m[Y.type]++)}for(var N={},M=t.edges(),V=0,se=M.length;V<se;V++){var K=M[V],X=this.edgeDataCache[K];N[X.type]=(N[X.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(M=it(this.edgeZExtent,function(me){return e.edgeDataCache[me].zIndex},M));for(var j in this.edgePrograms){if(!W.call(this.edgePrograms,j))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(j,'"!'));this.edgePrograms[j].reallocate(N[j]||0),N[j]=0}for(var Z=0,ve=M.length;Z<ve;Z++){var B=M[Z];p[B]=y,R[p[B]]={type:"edge",id:B},y++;var Ut=this.edgeDataCache[B];this.addEdgeToProgram(B,p[B],N[Ut.type]++)}return this.itemIDsIndex=R,this.nodeIndices=v,this.edgeIndices=p,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(e){var t=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(u){return t.cleanCameraState(u,a.cameraPanBoundaries&&ke(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==a.edgeProgramClasses){for(var o in a.edgeProgramClasses)a.edgeProgramClasses[o]!==e.edgeProgramClasses[o]&&this.registerEdgeProgram(o,a.edgeProgramClasses[o]);for(var s in e.edgeProgramClasses)a.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(e.nodeProgramClasses!==a.nodeProgramClasses||e.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var l in a.nodeProgramClasses)(a.nodeProgramClasses[l]!==e.nodeProgramClasses[l]||a.nodeHoverProgramClasses[l]!==e.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,a.nodeProgramClasses[l],a.nodeHoverProgramClasses[l]);for(var h in e.nodeProgramClasses)a.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.tolerance,o=a===void 0?0:a,s=t.boundaries,l=b({},e),h=s||this.nodeExtent,u=ee(h.x,2),d=u[0],f=u[1],g=ee(h.y,2),m=g[0],v=g[1],p=[this.graphToViewport({x:d,y:m},{cameraState:e}),this.graphToViewport({x:f,y:m},{cameraState:e}),this.graphToViewport({x:d,y:v},{cameraState:e}),this.graphToViewport({x:f,y:v},{cameraState:e})],R=1/0,y=-1/0,E=1/0,T=-1/0;p.forEach(function(N){var M=N.x,V=N.y;R=Math.min(R,M),y=Math.max(y,M),E=Math.min(E,V),T=Math.max(T,V)});var x=y-R,w=T-E,_=this.getDimensions(),O=_.width,D=_.height,k=0,P=0;if(x>=O?y<O-o?k=y-(O-o):R>o&&(k=R-o):y>O+o?k=y-(O+o):R<-o&&(k=R+o),w>=D?T<D-o?P=T-(D-o):E>o&&(P=E-o):T>D+o?P=T-(D+o):E<-o&&(P=E+o),k||P){var F=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),Y=this.viewportToFramedGraph({x:k,y:P},{cameraState:e});k=Y.x-F.x,P=Y.y-F.y,l.x+=k,l.y+=P}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),t=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);nt(t,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,o=0,s=t.length;o<s;o++){var l=t[o],h=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!h.hidden){var u=this.framedGraphToViewport(h),d=u.x,f=u.y,g=this.scaleSize(h.size);if(!(!h.forceLabel&&g<this.settings.labelRenderedSizeThreshold)&&!(d<-ht||d>this.width+ht||f<-ut||f>this.height+ut)){this.displayedNodeLabels.add(l);var m=this.settings.defaultDrawNodeLabel,v=this.nodePrograms[h.type],p=v?.drawLabel||m;p(a,b(b({key:l},h),{},{size:g,x:d,y:f}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var t=ur({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});nt(t,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=t.length;o<s;o++){var l=t[o],h=this.graph.extremities(l),u=this.nodeDataCache[h[0]],d=this.nodeDataCache[h[1]],f=this.edgeDataCache[l];if(!a.has(l)&&!(f.hidden||u.hidden||d.hidden)){var g=this.settings.defaultDrawEdgeLabel,m=this.edgePrograms[f.type],v=m?.drawLabel||g;v(e,b(b({key:l},f),{},{size:this.scaleSize(f.size)}),b(b(b({key:h[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),b(b(b({key:h[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),a.add(l)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var e=this,t=this.canvasContexts.hovers;t.clearRect(0,0,this.width,this.height);var a=function(g){var m=e.nodeDataCache[g],v=e.framedGraphToViewport(m),p=v.x,R=v.y,y=e.scaleSize(m.size),E=e.settings.defaultDrawNodeHover,T=e.nodePrograms[m.type],x=T?.drawHover||E;x(t,b(b({key:g},m),{},{size:y,x:p,y:R}),e.settings)},o=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&o.push(this.hoveredNode),this.highlightedNodes.forEach(function(f){f!==e.hoveredNode&&o.push(f)}),o.forEach(function(f){return a(f)});var s={};o.forEach(function(f){var g=e.nodeDataCache[f].type;s[g]=(s[g]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;o.forEach(function(f){var g=e.nodeDataCache[f];e.nodeHoverPrograms[g.type].process(0,s[g.type]++,g)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var h=this.getRenderParams();for(var u in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[u];d.render(h)}}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:"render",value:function(){var e=this;this.emit("beforeRender");var t=function(){return e.emit("afterRender"),e};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(p){return e.resetWebGLTexture(p)}),!this.graph.order)return t();var a=this.mouseCaptor,o=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),h=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=ie(s,l,h,u),this.invMatrix=ie(s,l,h,u,!0),this.correctionRatio=ji(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var f in this.nodePrograms){var g=this.nodePrograms[f];g.render(d)}if(!this.settings.hideEdgesOnMove||!o)for(var m in this.edgePrograms){var v=this.edgePrograms[m];v.render(d)}return this.settings.hideLabelsOnMove&&o||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),t()}},{key:"addNode",value:function(e){var t=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(t=this.settings.nodeReducer(e,t));var a=dr(this.settings,e,t);this.nodeDataCache[e]=a,this.nodesWithForcedLabels.delete(e),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),a.highlighted&&!a.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(e){this.addNode(e);var t=this.nodeDataCache[e];this.normalizationFunction.applyTo(t)}},{key:"removeNode",value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:"addEdge",value:function(e){var t=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(t=this.settings.edgeReducer(e,t));var a=cr(this.settings,e,t);this.edgeDataCache[e]=a,this.edgesWithForcedLabels.delete(e),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(e){this.addEdge(e)}},{key:"removeEdge",value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new lt,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(e,t,a){var o=this.nodeDataCache[e],s=this.nodePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(o.type,'"!'));s.process(t,a,o),this.nodeProgramIndex[e]=a}},{key:"addEdgeToProgram",value:function(e,t,a){var o=this.edgeDataCache[e],s=this.edgePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(o.type,'"!'));var l=this.graph.extremities(e),h=this.nodeDataCache[l[0]],u=this.nodeDataCache[l[1]];s.process(t,a,h,u,o),this.edgeProgramIndex[e]=a}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var e=this.settings,t=e.stagePadding,a=e.autoRescale;return a&&t||0}},{key:"createLayer",value:function(e,t){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw new Error('Sigma: a layer named "'.concat(e,'" already exists'));var o=Yi(t,{position:"absolute"},{class:"sigma-".concat(e)});return a.style&&Object.assign(o.style,a.style),this.elements[e]=o,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(o):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(o):this.container.appendChild(o),o}},{key:"createCanvas",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,"canvas",t)}},{key:"createCanvasContext",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(e,t),o={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=a.getContext("2d",o),this}},{key:"createWebGLContext",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t?.canvas||this.createCanvas(e,t);t.hidden&&a.remove();var o=b({preserveDrawingBuffer:!1,antialias:!1},t),s;s=a.getContext("webgl2",o),s||(s=a.getContext("webgl",o)),s||(s=a.getContext("experimental-webgl",o));var l=s;if(this.webGLContexts[e]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),t.picking){this.pickingLayers.add(e);var h=l.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));this.frameBuffers[e]=h}return l}},{key:"killLayer",value:function(e){var t=this.elements[e];if(!t)throw new Error("Sigma: cannot kill layer ".concat(e,", which does not exist"));if(this.webGLContexts[e]){var a,o=this.webGLContexts[e];(a=o.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return t.remove(),delete this.elements[e],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:"getNodeDisplayData",value:function(e){var t=this.nodeDataCache[e];return t?Object.assign({},t):void 0}},{key:"getEdgeDisplayData",value:function(e){var t=this.edgeDataCache[e];return t?Object.assign({},t):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return b({},this.settings)}},{key:"getSetting",value:function(e){return this.settings[e]}},{key:"setSetting",value:function(e,t){var a=b({},this.settings);return this.settings[e]=t,_e(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(e,t){return this.setSetting(e,t(this.settings[e])),this}},{key:"setSettings",value:function(e){var t=b({},this.settings);return this.settings=b(b({},this.settings),e),_e(this.settings),this.handleSettingsUpdate(t),this.scheduleRefresh(),this}},{key:"resize",value:function(e){var t=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=tt(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!e&&t===this.width&&a===this.height)return this;for(var o in this.elements){var s=this.elements[o];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var h in this.webGLContexts){this.elements[h].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[h].setAttribute("height",this.height*this.pixelRatio+"px");var u=this.webGLContexts[h];if(u.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(h)){var d=this.textures[h];d&&u.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(e){var t=this,a=e?.skipIndexation!==void 0?e?.skipIndexation:!1,o=e?.schedule!==void 0?e.schedule:!1,s=!e||!e.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(T){return t.addNode(T)}),this.graph.forEachEdge(function(T){return t.addEdge(T)});else{for(var l,h,u=((l=e.partialGraph)===null||l===void 0?void 0:l.nodes)||[],d=0,f=u?.length||0;d<f;d++){var g=u[d];if(this.updateNode(g),a){var m=this.nodeProgramIndex[g];if(m===void 0)throw new Error('Sigma: node "'.concat(g,`" can't be repaint`));this.addNodeToProgram(g,this.nodeIndices[g],m)}}for(var v=(e==null||(h=e.partialGraph)===null||h===void 0?void 0:h.edges)||[],p=0,R=v.length;p<R;p++){var y=v[p];if(this.updateEdge(y),a){var E=this.edgeProgramIndex[y];if(E===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],E)}}}return(s||!a)&&(this.needToProcess=!0),o?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var e=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){e.render()})),this}},{key:"scheduleRefresh",value:function(e){return this.refresh(b(b({},e),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(e,t){var a=this.camera.getState(),o=a.ratio,s=a.angle,l=a.x,h=a.y,u=this.settings,d=u.minCameraRatio,f=u.maxCameraRatio;typeof f=="number"&&(t=Math.min(t,f)),typeof d=="number"&&(t=Math.max(t,d));var g=t/o,m={x:this.width/2,y:this.height/2},v=this.viewportToFramedGraph(e),p=this.viewportToFramedGraph(m);return{angle:s,x:(v.x-p.x)*(1-g)+l,y:(v.y-p.y)*(1-g)+h,ratio:t}}},{key:"viewRectangle",value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),t=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:t.x,y2:t.y,height:t.y-a.y}}},{key:"framedGraphToViewport",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!t.cameraState||!!t.viewportDimensions||!!t.graphDimensions,o=t.matrix?t.matrix:a?ie(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding()):this.matrix,s=Le(o,e);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!t.cameraState||!!t.viewportDimensions||!t.graphDimensions,o=t.matrix?t.matrix:a?ie(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding(),!0):this.invMatrix,s=Le(o,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,t))}},{key:"graphToViewport",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),t)}},{key:"getGraphToViewportRatio",value:function(){var e={x:0,y:0},t={x:1,y:1},a=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),o=this.graphToViewport(e),s=this.graphToViewport(t),l=Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));return l/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(e){return this.customBBox=e,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var t in this.nodePrograms)this.nodePrograms[t].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var o in this.edgePrograms)this.edgePrograms[o].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(t)*(this.getSetting("itemSizesReference")==="positions"?t*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var e={};for(var t in this.elements)this.elements[t]instanceof HTMLCanvasElement&&(e[t]=this.elements[t]);return e}}])})(Oe);const zt=C.createContext(null),gr=zt.Provider;function ze(){const r=C.useContext(zt);if(r==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return r}function Ue(){return ze().sigma}function vr(){const{sigma:r}=ze();return C.useCallback((n=>{r&&Object.keys(n).forEach((i=>{r.setSetting(i,n[i])}))}),[r])}function ge(r){return new Set(Object.keys(r))}const dt=ge({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),ct=ge({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),ft=ge({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),gt=ge({updated:!0});function Nr(){const r=Ue(),n=vr(),[i,e]=C.useState({});return C.useEffect((()=>{if(!r||!i)return;const t=i,a=Object.keys(t);return a.forEach((o=>{const s=t[o];dt.has(o)&&r.on(o,s),ct.has(o)&&r.getMouseCaptor().on(o,s),ft.has(o)&&r.getTouchCaptor().on(o,s),gt.has(o)&&r.getCamera().on(o,s)})),()=>{r&&a.forEach((o=>{const s=t[o];dt.has(o)&&r.off(o,s),ct.has(o)&&r.getMouseCaptor().off(o,s),ft.has(o)&&r.getTouchCaptor().off(o,s),gt.has(o)&&r.getCamera().off(o,s)}))}}),[r,i,n]),e}function Dr(){const r=Ue();return C.useCallback(((n,i=!0)=>{r&&n&&(i&&r.getGraph().order>0&&r.getGraph().clear(),r.getGraph().import(n),r.refresh())}),[r])}function Be(r,n){if(r===n)return!0;if(typeof r=="object"&&r!=null&&typeof n=="object"&&n!=null){if(Object.keys(r).length!=Object.keys(n).length)return!1;for(const i in r)if(!Object.hasOwn(n,i)||!Be(r[i],n[i]))return!1;return!0}return!1}function Pr(r,n){let i;return e=>new Promise((t=>{i&&clearTimeout(i),i=setTimeout((()=>{t(r(e))}),n)}))}function mr(r){const n=Ue(),[i,e]=C.useState(r||{});C.useEffect((()=>{e((h=>Be(h,r||{})?h:r||{}))}),[r]);const t=C.useCallback((h=>{n.getCamera().animatedZoom(Object.assign(Object.assign({},i),h))}),[n,i]),a=C.useCallback((h=>{n.getCamera().animatedUnzoom(Object.assign(Object.assign({},i),h))}),[n,i]),o=C.useCallback((h=>{n.getCamera().animatedReset(Object.assign(Object.assign({},i),h))}),[n,i]),s=C.useCallback(((h,u)=>{n.getCamera().animate(h,Object.assign(Object.assign({},i),u))}),[n,i]),l=C.useCallback(((h,u)=>{const d=n.getNodeDisplayData(h);d?n.getCamera().animate(d,Object.assign(Object.assign({},i),u)):console.warn(`Node ${h} not found`)}),[n,i]);return{zoomIn:t,zoomOut:a,reset:o,goto:s,gotoNode:l}}function pr(r){const n=ze(),[i,e]=C.useState(!1),[t,a]=C.useState(r||n.container),o=C.useCallback((()=>e((s=>!s))),[]);return C.useEffect((()=>(document.addEventListener("fullscreenchange",o),()=>document.removeEventListener("fullscreenchange",o))),[o]),C.useEffect((()=>{a(r||n.container)}),[r,n.container]),{toggle:C.useCallback((()=>{var s;s=t,document.fullscreenElement!==s?s.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()}),[t]),isFullScreen:i}}const Ir=C.forwardRef((({graph:r,id:n,className:i,style:e,settings:t={},children:a},o)=>{const s=C.useRef(null),l=C.useRef(null),h={className:`react-sigma ${i||""}`,id:n,style:e},[u,d]=C.useState(null),[f,g]=C.useState(t);C.useEffect((()=>{g((p=>Be(p,t)?p:t))}),[t]),C.useEffect((()=>{let p=null;if(l.current!==null){let R=new Wt;r&&(R=typeof r=="function"?new r:r),p=new fr(R,l.current,f),d((y=>{let E=null;return y&&(E=y.getCamera().getState()),E&&p.getCamera().setState(E),p}))}return()=>{p&&p.kill()}}),[l,r,f]),C.useImperativeHandle(o,(()=>u),[u]);const m=C.useMemo((()=>u&&s.current?{sigma:u,container:s.current}:null),[u,s]),v=m!==null?S.createElement(gr,{value:m},a):null;return S.createElement("div",Object.assign({},h,{ref:s}),S.createElement("div",{className:"sigma-container",ref:l}),v)})),Gr=({id:r,className:n,style:i,children:e,position:t="bottom-left"})=>{const a={className:`react-sigma-controls ${n||""} ${t}`,id:r,style:i};return S.createElement("div",Object.assign({},a),e)};var vt;function Fe(){return Fe=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)({}).hasOwnProperty.call(i,e)&&(r[e]=i[e])}return r},Fe.apply(null,arguments)}var mt,br=function(r){return C.createElement("svg",Fe({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16","data-icon":"dot-circle","data-prefix":"far",viewBox:"0 0 512 512",width:"1em",height:"1em"},r),vt||(vt=C.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8m0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80"})))};function Ne(){return Ne=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)({}).hasOwnProperty.call(i,e)&&(r[e]=i[e])}return r},Ne.apply(null,arguments)}var pt,Er=function(r){return C.createElement("svg",Ne({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14","data-icon":"minus","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),mt||(mt=C.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})))};function De(){return De=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)({}).hasOwnProperty.call(i,e)&&(r[e]=i[e])}return r},De.apply(null,arguments)}var yr=function(r){return C.createElement("svg",De({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14","data-icon":"plus","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),pt||(pt=C.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})))};const Or=({className:r,style:n,animationDuration:i=200,children:e,labels:t={}})=>{const{zoomIn:a,zoomOut:o,reset:s}=mr({duration:i,factor:1.5}),l={style:n,className:`react-sigma-control ${r||""}`};return S.createElement(S.Fragment,null,S.createElement("div",Object.assign({},l),S.createElement("button",{onClick:()=>a(),title:t.zoomIn||"Zoom In"},e?e[0]:S.createElement(yr,{style:{width:"1em"}}))),S.createElement("div",Object.assign({},l),S.createElement("button",{onClick:()=>o(),title:t.zoomOut||"Zoom Out"},e?e[1]:S.createElement(Er,{style:{width:"1em"}}))),S.createElement("div",Object.assign({},l),S.createElement("button",{onClick:()=>s(),title:t.reset||"See whole graph"},e?e[2]:S.createElement(br,{style:{width:"1em"}}))))};var bt;function Pe(){return Pe=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)({}).hasOwnProperty.call(i,e)&&(r[e]=i[e])}return r},Pe.apply(null,arguments)}var Et,Tr=function(r){return C.createElement("svg",Pe({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14","data-icon":"compress","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),bt||(bt=C.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12m-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24m0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12m192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12"})))};function Ie(){return Ie=Object.assign?Object.assign.bind():function(r){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)({}).hasOwnProperty.call(i,e)&&(r[e]=i[e])}return r},Ie.apply(null,arguments)}var Cr=function(r){return C.createElement("svg",Ie({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14","data-icon":"expand","data-prefix":"fas",viewBox:"0 0 448 512",width:"1em",height:"1em"},r),Et||(Et=C.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12M288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12m148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12M160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12"})))};const Mr=({id:r,className:n,style:i,container:e,children:t,labels:a={}})=>{const{isFullScreen:o,toggle:s}=pr(e?.current),l={className:`react-sigma-control ${n||""}`,id:r,style:i};return document.fullscreenEnabled?S.createElement("div",Object.assign({},l),S.createElement("button",{onClick:s,title:o?a.exit||"Exit fullscreen":a.enter||"Enter fullscreen"},t&&!o&&t[0],t&&o&&t[1],!t&&!o&&S.createElement(Cr,{style:{width:"1em"}}),!t&&o&&S.createElement(Tr,{style:{width:"1em"}}))):null};export{Gr as ControlsContainer,Mr as FullScreenControl,Ir as SigmaContainer,zt as SigmaContext,gr as SigmaProvider,Or as ZoomControl,Pr as debounce,Be as isEqual,mr as useCamera,pr as useFullScreen,Dr as useLoadGraph,Nr as useRegisterEvents,vr as useSetSettings,Ue as useSigma,ze as useSigmaContext};
@@ -1 +0,0 @@
1
- import{r as C,j as i}from"./vendor-tanstack-ZXXkndVj.js";import{_ as de,ea as pe,B as me,aL as W,eb as m,ec as fe,ed as ge,ee as he,ef as ye,eg as be,eh as xe,ei as ke,ej as Ae,ek as Pe,el as je,em as Ne,en as Ce,eo as ve,ep as Me,eq as Ie,er as Be,es as $e,et as Se,eu as De,ev as we,ew as Ke,ex as Ee,x as f,b6 as Ve}from"./index-CdAuyP-X.js";import{M as Re}from"./vendor-markdown-B4giJcws.js";import{C as Te,$ as qe,g as ne}from"./vendor-lucide-Y6jANGfG.js";const tt="Sources",_={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function _e({previewLength:e,highlight:t}){return r=>{if(e!==void 0&&Number.isFinite(e)){let l=Math.max(0,Math.floor(e));const d={field:"value",omitted:!1},p=s=>{if(s.type==="definition")return!0;if(s.children)return s.children=s.children.filter(p),s.children.length>0;const a=s.type==="image"||s.type==="imageReference"?"alt":"value",h=s[a];if(h===void 0)return l>0;const k=Array.from(h);if(k.length===0)return l>0;if(l===0)return d.omitted=!0,!1;const v=k.length>l,j=k.slice(0,l);if(v&&!/\s/.test(k[l])){let y=j.length-1;for(;y>=0&&!/\s/.test(j[y]);)y--;y>=0&&y>l-40&&(j.length=y)}return d.omitted||=v,s[a]=j.join(""),l=v?0:l-j.length,j.length===0?!1:(d.lastNode=s,d.field=a,!0)};p(r),d.omitted&&(d.lastNode?d.lastNode[d.field]=`${d.lastNode[d.field].trimEnd()}…`:r.children?.push({type:"paragraph",children:[{type:"text",value:"…"}]}))}if(t){const l=d=>{["link","linkReference","code","inlineCode"].includes(d.type)||(d.type==="text"&&(d.data={...d.data,hName:"span"}),d.children?.forEach(l))};l(r)}}}function Ge({headingLevel:e}){return t=>{const r=[],l=p=>{p.type==="heading"&&p.depth&&r.push(p),p.children?.forEach(l)};l(t);const d=r.reduce((p,s)=>Math.min(p,s.depth),6);for(const p of r){const s=p.depth-d;p.depth=Math.min(6,e+s),p.data={...p.data,hProperties:{...p.data?.hProperties,"data-answer-heading-level":s+1}}}}}function Oe({answer:e}){const[t,r]=C.useState("idle"),l=C.useRef(!1),d=async()=>{if(!l.current){l.current=!0,r("copying");try{await navigator.clipboard.writeText(e),r("copied")}catch{r("failed")}finally{l.current=!1}}};return i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[i.jsx(me,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":t==="copying","aria-busy":t==="copying",onClick:()=>{d()},children:t==="copying"?_.copying:_.copy}),i.jsx("span",{role:"status",className:"text-sm text-secondary",children:t==="copied"?_.copied:t==="failed"?_.failed:""})]})}const nt=C.memo(function({children:t,headingLevel:r=4,copyable:l=!1,highlightGroups:d,previewLength:p}){return i.jsxs("div",{className:"answer-markdown",children:[i.jsx(Re,{remarkPlugins:[[Ge,{headingLevel:r}],[_e,{previewLength:p,highlight:!!d?.length}]],components:{p:({children:s})=>i.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:s}),ul:({children:s})=>i.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:s}),ol:({children:s,start:a})=>i.jsx("ol",{start:a,className:"mb-3 ml-5 list-decimal space-y-1",children:s}),pre:({children:s})=>i.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:s}),span:({children:s})=>i.jsx("span",{children:typeof s=="string"&&d?s.split(/(https?:\/\/[^\s<>]+)/i).map((a,h)=>h%2?a:i.jsx(C.Fragment,{children:pe(a,d)},h)):s}),a:({children:s,href:a})=>{const h=de(a);return h?i.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:s}):i.jsx("span",{children:s})},img:({alt:s})=>i.jsx("span",{children:s})},children:t}),l&&t.trim()?i.jsx(Oe,{answer:t},t):null]})}),re="min-h-11 w-full rounded-md border border-default bg-surface px-3 py-2 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",H="flex min-h-11 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm text-primary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",K=e=>e.kind==="project"?"Whole site":e.label,E={allMarkets:"All markets",browse:e=>`Browse ${e}`,select:e=>`Select ${e}`,browseAll:"Browse all properties"},Le=e=>e?.kind==="group"&&e.marketKeys?.length===1?e.marketKeys[0]:void 0,se=e=>`${e} ${e===1?"property":"properties"}`;function rt({options:e,selected:t,onSelect:r,marketKey:l,label:d="Measurement scope",labelVisibility:p="visible",allowGroupSelect:s=!0}){const a=[...e].sort((n,u)=>n.label.localeCompare(u.label,void 0,{numeric:!0})||n.id.localeCompare(u.id)),[h,k]=C.useState(""),[v,j]=C.useState([]),[y,I]=C.useState(!1),N=C.useRef(null),B=C.useRef(null),o=C.useId(),x=a.filter(n=>n.kind==="group"),b=new Map(x.map(n=>[n.id,n])),c=b.get(v.at(-1)??""),Y=b.get(v.at(-2)??""),P=h.trim().toLocaleLowerCase(),le=x.filter(n=>!n.parentGroupIds?.some(u=>b.has(u))),G=a.filter(n=>n.kind==="property"),O=n=>(n.parentGroupIds??[]).map(u=>b.get(u)?.label).filter(Boolean).join(" · "),V=n=>`${K(n)} ${O(n)}`.toLocaleLowerCase().includes(P),z=n=>{const u=[...n.parentGroupIds??[]],g=new Set;for(;u.length;){const M=u.pop();if(M===c?.id)return!0;g.has(M)||(g.add(M),u.push(...b.get(M)?.parentGroupIds??[]))}return!1},S=(y?[]:c?x.filter(n=>P?z(n):n.parentGroupIds?.includes(c.id)):P?x:le).filter(V),D=a.find(n=>n.kind==="market"&&n.id===(l??(t.kind==="market"?t.id:void 0))),Q=c&&D&&(c.marketKeys?.includes(D.id)||D.parentGroupIds?.includes(c.id))?D.id:void 0,L=s?Q??Le(c):void 0,U=(c?G.filter(n=>n.parentGroupIds?.includes(c.id)&&(!L||n.marketKeys?.includes(L))):P||y||x.length===0?G:[]).filter(V),Z=a.filter(n=>n.kind!=="market"||y||!s&&!c&&!P&&x.length>0||s&&c?.marketKeys?.length===1&&!P?!1:(c?P?z(n):n.parentGroupIds?.includes(c.id):P||!n.parentGroupIds?.some(g=>b.has(g)))&&V(n)),J=c||y?[]:a.filter(n=>n.kind==="project"&&V(n));C.useEffect(()=>{const n=u=>{N.current?.open&&u.target instanceof Node&&!N.current.contains(u.target)&&(N.current.open=!1)};return document.addEventListener("pointerdown",n),()=>document.removeEventListener("pointerdown",n)},[]);const ce=n=>{N.current&&(N.current.open=!1,N.current.querySelector("summary")?.focus());const u=s?n.kind==="property"?L:n.kind==="group"&&n.id===c?.id?Q:void 0:void 0;u?r(n,u):r(n)},R=n=>{const u=[];let g=b.get(n.parentGroupIds?.[0]??"");for(;g&&!u.includes(g.id)&&g.id!==n.id;)u.unshift(g.id),g=b.get(g.parentGroupIds?.[0]??"");return[...u,n.id]},ue=()=>{const n=t.kind==="group"?b.get(t.id):void 0,u=b.get(D?.parentGroupIds?.[0]??""),g=(t.parentGroupIds??[]).flatMap(w=>{const q=b.get(w);return q?[R(q)]:[]}),M=g.find(w=>w.at(-1)===c?.id)??g.sort((w,q)=>q.length-w.length)[0]??[],te=u?R(u):t.marketKeys?.length?[]:M;j(n?R(n):te),I(t.kind==="property"&&te.length===0&&x.length>0),k("")},X=n=>{j(R(n)),I(!1),k(""),B.current?.focus()},T=(n,u=K(n))=>i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",className:H,"aria-label":n.kind==="group"&&!s?E.browse(K(n)):E.select(K(n)),"aria-current":t.kind===n.kind&&t.id===n.id?"true":void 0,onClick:()=>n.kind==="group"&&!s?X(n):ce(n),children:[i.jsxs("span",{className:"min-w-0 break-words",children:[u,P&&O(n)?i.jsx("span",{className:"block text-[13px] text-secondary",children:O(n)}):null]}),i.jsx("span",{className:"shrink-0 text-right text-[13px] text-secondary",children:n.kind==="market"?s?"Query context":"Market":n.kind==="property"?"Property":se(n.targetCount)})]}),s&&n.kind==="group"&&n.id!==c?.id&&a.some(g=>g.parentGroupIds?.includes(n.id))?i.jsx("button",{type:"button","aria-label":E.browse(n.label),title:`Browse ${n.label}`,className:"flex min-h-11 min-w-11 items-center justify-center rounded text-secondary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onClick:()=>X(n),children:i.jsx(ne,{size:18,"aria-hidden":"true"})}):null]},`${n.kind}:${n.id}`),F=(n,u)=>u.length>0?i.jsxs("section",{"aria-label":n,className:"mt-2",children:[i.jsx("h3",{className:"px-2 py-2 text-[13px] font-medium text-secondary",children:n}),u.map(g=>T(g))]}):null,ee=(n,u,g)=>u.length>0?i.jsxs("details",{open:g,className:"mt-2 border-y border-default",children:[i.jsxs("summary",{className:"min-h-11 cursor-pointer px-2 py-3 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[n," (",u.length,")"]}),u.map(M=>T(M))]},`${c?.id??"root"}:${n}`):null;return i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{id:`${o}-label`,className:p==="sr-only"?"sr-only":"mb-1 block text-sm font-medium text-heading",children:d}),i.jsxs("details",{ref:N,className:"relative",onToggle:n=>{n.target===n.currentTarget&&n.currentTarget.open&&B.current?.focus()},onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),n.currentTarget.open=!1,n.currentTarget.querySelector("summary")?.focus())},children:[i.jsxs("summary",{id:`${o}-value`,"aria-labelledby":`${o}-label ${o}-value`,className:`${re} visibility-scope-trigger`,onClick:()=>{N.current?.open||ue()},children:[`${K(t)}${t.kind==="group"?` · ${se(t.targetCount)}`:t.kind==="property"?` · ${a.find(n=>n.kind==="market"&&n.id===l)?.label??(t.marketKeys?.length?E.allMarkets:"Property")}`:t.kind==="market"?" · Market":""}`,i.jsx(Te,{size:16,"aria-hidden":"true",className:"shrink-0 text-secondary"})]}),i.jsxs("div",{className:"visibility-scope-menu",children:[c||y?i.jsxs("div",{className:"mb-2 border-b border-default pb-2",children:[i.jsx("button",{type:"button",className:H,"aria-label":`Back to ${Y?.label??"all groups"}`,onClick:()=>{j(v.slice(0,-1)),I(!1),k(""),B.current?.focus()},children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(qe,{size:16,"aria-hidden":"true"}),Y?.label??"All groups"]})}),i.jsx("p",{className:"px-2 py-1 text-sm font-medium text-heading","aria-live":"polite",children:c?.label??"All properties"})]}):null,i.jsx("input",{ref:B,type:"search","aria-label":"Search scopes",className:re,placeholder:c?"Search within this group":y?"Search properties":"Search groups or properties",value:h,onChange:n=>k(n.target.value)}),i.jsxs("div",{className:"mt-2 max-h-80 overflow-y-auto",children:[s&&c&&!P?T(c,"All properties in this group"):null,J.map(n=>T(n)),c&&!P?ee("Subgroups",S,!0):F(c?"Subgroups":"Groups",S),P?F("Properties",U):ee(c&&S.length>0?"All properties":"Properties",U,!c||S.length===0),F("Markets",Z),!c&&!y&&!P&&x.length>0&&G.length>0?i.jsxs("button",{type:"button",className:`${H} mt-2 border-t border-default`,"aria-label":E.browseAll,onClick:()=>{I(!0),B.current?.focus()},children:[i.jsx("span",{children:"All properties"}),i.jsx(ne,{size:18,"aria-hidden":"true"})]}):null,P&&S.length+U.length+Z.length+J.length===0?i.jsx("p",{className:"py-3 text-sm text-secondary",children:"No matching scopes."}):null]})]})]})]})}function oe(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`web-${Date.now()}-${Math.random().toString(36).slice(2)}`}function A(e){return{"If-Match":e,"Idempotency-Key":oe()}}function st(e){return e instanceof W&&(e.statusCode===404||e.statusCode===409||e.statusCode===412)}function at(e,t){return e instanceof W?t:(e instanceof Error?e.message.trim():"")||t}function it(e){const t="Could not calculate assignment impact.";if(!(e instanceof W)||e.code!=="VALIDATION_ERROR")return t;const r=e.message.trim();return e.details?.displayToOperator===!0&&r?r:t}const ot={loadSetup:e=>m(()=>Ee({client:f,path:{name:e}})),loadDraft:e=>m(()=>Ke({client:f,path:{name:e}})),createDraft:(e,t)=>m(()=>we({client:f,path:{name:e},headers:{"Idempotency-Key":oe()},body:{expectedActiveRevision:t}})),importSitemap:(e,t,r)=>m(()=>De({client:f,path:{name:e},headers:A(t),body:r})),applySitemapSelection:(e,t,r,l)=>m(()=>Se({client:f,path:{name:e},headers:A(t),body:{selections:r,selectedTargetKeys:l}})),previewAssignments:(e,t)=>m(()=>$e({client:f,path:{name:e},body:t})),applyAssignments:(e,t,r)=>m(()=>Be({client:f,path:{name:e},headers:A(t),body:r})),replaceAssignments:(e,t,r)=>m(()=>Ie({client:f,path:{name:e},headers:A(t),body:r})),applyPairedAssignments:(e,t,r)=>m(()=>Me({client:f,path:{name:e},headers:A(t),body:{pairs:r}})),removeAssignment:(e,t,r,l)=>m(()=>ve({client:f,path:{name:e},headers:A(t),body:{targetKeys:r,queryId:l}})),excludeTarget:(e,t,r)=>m(()=>Ce({client:f,path:{name:e},headers:A(t),body:{targetKey:r,cleanup:"assignments-and-group-memberships"}})),upsertTarget:(e,t,r)=>m(()=>Ne({client:f,path:{name:e},headers:A(t),body:{target:r}})),upsertGroup:(e,t,r)=>m(()=>je({client:f,path:{name:e},headers:A(t),body:{group:r}})),removeGroup:(e,t,r)=>m(()=>Pe({client:f,path:{name:e},headers:A(t),body:{groupKey:r}})),upsertCompetitor:(e,t,r)=>m(()=>Ae({client:f,path:{name:e},headers:A(t),body:r})),removeCompetitor:(e,t,r,l)=>m(()=>ke({client:f,path:{name:e},headers:A(t),body:{groupKey:r,competitorKey:l}})),previewGroupMembership:(e,t)=>m(()=>xe({client:f,path:{name:e},body:t})),applyGroupMembership:(e,t,r)=>m(()=>be({client:f,path:{name:e},headers:A(t),body:r})),compilePreview:e=>m(()=>ye({client:f,path:{name:e}})),diffPreview:e=>m(()=>he({client:f,path:{name:e}})),publish:(e,t,r)=>m(()=>ge({client:f,path:{name:e},headers:A(t),body:r})),discard:(e,t)=>m(()=>fe({client:f,path:{name:e},headers:A(t)}))};function lt(e){const t=e[0];return t?e.every(r=>r.mode===t.mode&&r.scope.kind===t.scope.kind&&r.scope.key===t.scope.key&&r.queryClass===t.queryClass&&r.measurement.displayedRunId===t.measurement.displayedRunId):!0}function $(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator,...e.unattributed===void 0?{}:{unattributed:e.unattributed},...e.unchecked===void 0?{}:{unchecked:e.unchecked}}}function Ue(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix==="/"?"":e.pathPrefix}/*`:`https://${e.host}/*`}function Fe(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function He(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function ae(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function We(e,t,r){const l=new Map;if(!t)return l;const d=new Map(e.usageEdges.map(a=>[ae(a),a.targetKey])),p=new Map(e.assignments.map(a=>[`${a.targetKey}:${a.queryId}`,a.queryClass])),s=new Map(e.usageEdges.map(a=>[ae(a),p.get(`${a.targetKey}:${a.queryId}`)]));for(const a of t.evidence){if(r&&s.get(a.usageEdgeId)!==r)continue;const h=d.get(a.usageEdgeId);if(!h)continue;const k=l.get(h)??[];k.push({id:`${a.observationId}:${a.expectedSlotId}:${a.usageEdgeId}:${a.sourceUrl}`,kind:Fe(a.classification),query:a.queryText,provider:a.provider,location:a.location,url:a.sourceUrl,tone:He(a.classification),historical:a.historical||a.bridged}),l.set(h,k)}return l}function Ye(e){if(e.flags>0)return{label:"Review",tone:"caution"};const t=[e.mentionCoverage,e.citationCoverage].filter(r=>r.state==="unavailable").map(r=>r.reason);return t.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:t.includes("plan_v1")?{label:"Update setup",tone:"caution"}:t.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:t.includes("identity_ambiguous")?{label:Ve.ambiguous,tone:"caution"}:t.includes("no_population")?{label:"No queries",tone:"neutral"}:t.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function ze(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function Qe(e){if(!e)return"";const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function ie(e){const t=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${t} flagged ${t===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function ct({overview:e,activePlan:t,report:r,reportState:l=r?"ready":"loading",sort:d}){if(t.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const p=t.plan,s=new Map(p.targets.map(o=>[o.stableKey,o])),a=new Map(p.querySnapshots.map(o=>[o.queryId,o.queryText])),h=new Map;for(const o of p.assignments){if(e.queryClass!=="all"&&o.queryClass!==e.queryClass)continue;const x=a.get(o.queryId);if(!x)continue;const b=h.get(o.targetKey)??new Set;b.add(x),h.set(o.targetKey,b)}const k=r?.revision===t.revision&&r.run?.id===e.measurement.displayedRunId?r:null,v=e.measurement.displayedRunId===void 0||k?"ready":l==="error"||r!=null?"error":"loading",j=We(p,k,e.queryClass==="all"?void 0:e.queryClass),y=new Map;for(const o of p.groups)for(const x of o.targetKeys)y.has(x)||y.set(x,o.label);const I=e.properties.items.map(o=>{const x=s.get(o.targetKey),b=j.get(o.targetKey)??[];return{id:o.targetKey,name:o.label,mentionCoverage:$(o.mentionCoverage),citationCoverage:$(o.citationCoverage),status:Ye(o),providers:o.providers?.map(c=>({provider:c.provider,mentionCoverage:$(c.mentionCoverage),citationCoverage:$(c.citationCoverage)})),market:y.get(o.targetKey),assignedQueries:[...h.get(o.targetKey)??[]],urls:x?.urlMatchers.map(Ue)??[],evidence:b,evidenceState:v,historical:b.some(c=>c.historical)}}),N=e.namedShareOfVoice?.entries.map(o=>({name:o.label,coverage:{numerator:o.credits,denominator:e.namedShareOfVoice.denominator}})),B=e.properties.items.flatMap(o=>o.flags>0?[{id:`property:${o.targetKey}`,property:o.label,summary:`${o.flags} ${o.flags===1?"result needs":"results need"} review.`,tone:"caution",count:o.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:ze(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:Qe(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:$(e.metrics.propertiesMentioned),mentionCoverage:$(e.metrics.mentionCoverage),citationCoverage:$(e.metrics.citationCoverage)},properties:I,...N?{shareOfVoice:N}:{}},propertyTotal:e.properties.totalEstimate??I.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...d?{sort:d}:{}},availableGroups:p.groups.map(o=>({id:o.stableKey,label:o.label})),...ie(e)?{nextActionText:ie(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:B}}export{nt as A,E as M,rt as V,tt as a,ot as b,it as c,lt as d,ct as e,st as i,Ue as m,at as s};