cc-viewer 1.7.7 → 1.7.9

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 (88) hide show
  1. package/README.md +3 -1
  2. package/dist/assets/App-Bs6-c4Ov.css +1 -0
  3. package/dist/assets/App-CYvr5YQv.js +2 -0
  4. package/dist/assets/{MdxEditorPanel-BAE_5ssH.js → MdxEditorPanel-D1MOJabL.js} +1 -1
  5. package/dist/assets/Mobile-B7GXxkfK.js +1 -0
  6. package/dist/assets/ProxyStatsModal-BqH9cIks.js +1 -0
  7. package/dist/assets/ProxyStatsModal-Dz5GuoUa.css +1 -0
  8. package/dist/assets/{_baseUniq-BkQkqbX3.js → _baseUniq-aTokVjQN.js} +1 -1
  9. package/dist/assets/{arc-BKY9CS7c.js → arc-mxp8gSRQ.js} +1 -1
  10. package/dist/assets/{architectureDiagram-Q4EWVU46-f8VVp6F9.js → architectureDiagram-Q4EWVU46-msh8IODx.js} +1 -1
  11. package/dist/assets/{blockDiagram-DXYQGD6D-3h2PkZUH.js → blockDiagram-DXYQGD6D-BUatNJTI.js} +1 -1
  12. package/dist/assets/{c4Diagram-AHTNJAMY-DigIDzhn.js → c4Diagram-AHTNJAMY-CJ92TNZe.js} +1 -1
  13. package/dist/assets/{channel-5ajs7xDK.js → channel-CTM7CJrB.js} +1 -1
  14. package/dist/assets/{chunk-4BX2VUAB-BvwhA1RA.js → chunk-4BX2VUAB-Bdv98T9c.js} +1 -1
  15. package/dist/assets/{chunk-4TB4RGXK-GHcSNG2k.js → chunk-4TB4RGXK-DaIEuSP0.js} +1 -1
  16. package/dist/assets/{chunk-55IACEB6-DWO0TwNe.js → chunk-55IACEB6-Bi9130Nu.js} +1 -1
  17. package/dist/assets/{chunk-EDXVE4YY-0ycrM2oE.js → chunk-EDXVE4YY-CZw-Vwwn.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-DmdCml-0.js → chunk-FMBD7UC4-BBI7swjg.js} +1 -1
  19. package/dist/assets/{chunk-OYMX7WX6-fg2n9B_W.js → chunk-OYMX7WX6-CHKotm_J.js} +1 -1
  20. package/dist/assets/{chunk-QZHKN3VN-Bg3VPGcJ.js → chunk-QZHKN3VN-ECW0McUe.js} +1 -1
  21. package/dist/assets/{chunk-YZCP3GAM-BV1RGRqK.js → chunk-YZCP3GAM-DLdAqU2z.js} +1 -1
  22. package/dist/assets/classDiagram-6PBFFD2Q-CkmfHfqf.js +1 -0
  23. package/dist/assets/classDiagram-v2-HSJHXN6E-CkmfHfqf.js +1 -0
  24. package/dist/assets/clone-pjnYCaC4.js +1 -0
  25. package/dist/assets/{cose-bilkent-S5V4N54A-CjAVlyw6.js → cose-bilkent-S5V4N54A-CfMuBnZy.js} +1 -1
  26. package/dist/assets/{dagre-KV5264BT-DZV42aOy.js → dagre-KV5264BT-xxdATAWV.js} +1 -1
  27. package/dist/assets/{diagram-5BDNPKRD-DpDA9ZeE.js → diagram-5BDNPKRD-s8izYXws.js} +1 -1
  28. package/dist/assets/{diagram-G4DWMVQ6-86vmHGG_.js → diagram-G4DWMVQ6-BaZWrq-d.js} +1 -1
  29. package/dist/assets/{diagram-MMDJMWI5-CzLVfy9C.js → diagram-MMDJMWI5-DlzU0RKB.js} +1 -1
  30. package/dist/assets/{diagram-TYMM5635-C1n6QVNv.js → diagram-TYMM5635-Fej8ir1x.js} +1 -1
  31. package/dist/assets/{erDiagram-SMLLAGMA-BWST8PqT.js → erDiagram-SMLLAGMA-Bwg0_DNs.js} +1 -1
  32. package/dist/assets/{flowDiagram-DWJPFMVM-zfku-qzI.js → flowDiagram-DWJPFMVM-pJ8Bv6wt.js} +1 -1
  33. package/dist/assets/{ganttDiagram-T4ZO3ILL-BIxQMxEL.js → ganttDiagram-T4ZO3ILL-DvgJ4Q6n.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-UUTBAWPF-E7gXMGl0.js → gitGraphDiagram-UUTBAWPF-Du8KitZ0.js} +1 -1
  35. package/dist/assets/{graph-Chi_Do3A.js → graph-57Q-0mNG.js} +1 -1
  36. package/dist/assets/{index-BsRFLaCT.js → index-BOryMxum.js} +1 -1
  37. package/dist/assets/{index-CyMcZjWq.js → index-Bt7QsK9T.js} +1 -1
  38. package/dist/assets/{index-BbuqKcgW.js → index-CVh-Zo2A.js} +1 -1
  39. package/dist/assets/{index-BVkdlwjO.js → index-Cf77lzSr.js} +1 -1
  40. package/dist/assets/{index-Batfx707.js → index-Cn0akK9k.js} +1 -1
  41. package/dist/assets/{index-CaTBBfzw.js → index-EFFRo37G.js} +1 -1
  42. package/dist/assets/{index-Bp83Qa3f.js → index-mpHzrAV9.js} +2 -2
  43. package/dist/assets/{index-BrmFDbRb.js → index-zljZK-NO.js} +1 -1
  44. package/dist/assets/{infoDiagram-42DDH7IO-CJSIzH2A.js → infoDiagram-42DDH7IO-DZz6OAQe.js} +1 -1
  45. package/dist/assets/{ishikawaDiagram-UXIWVN3A-B631W1wW.js → ishikawaDiagram-UXIWVN3A-Chrlpw73.js} +1 -1
  46. package/dist/assets/{journeyDiagram-VCZTEJTY-ChtGieBW.js → journeyDiagram-VCZTEJTY-D-fCEwg9.js} +1 -1
  47. package/dist/assets/{jszip.min-MLKd3flP.js → jszip.min-mU_-As7x.js} +1 -1
  48. package/dist/assets/{kanban-definition-6JOO6SKY-hLAy-WRt.js → kanban-definition-6JOO6SKY-DFdrm5t-.js} +1 -1
  49. package/dist/assets/{layout-cxTukSs_.js → layout-Dh-E01gA.js} +1 -1
  50. package/dist/assets/{linear-lKN6YVn3.js → linear-BjXnK-6T.js} +1 -1
  51. package/dist/assets/{mermaid.core-BYpzUgET.js → mermaid.core-Cbqxn86C.js} +2 -2
  52. package/dist/assets/{min-BvhzyJ7G.js → min-B4n9eIGL.js} +1 -1
  53. package/dist/assets/{mindmap-definition-QFDTVHPH-DLmLjuqG.js → mindmap-definition-QFDTVHPH-Bw49x4oU.js} +1 -1
  54. package/dist/assets/{pieDiagram-DEJITSTG-CpQId_ss.js → pieDiagram-DEJITSTG-D-iq9rKK.js} +1 -1
  55. package/dist/assets/{quadrantDiagram-34T5L4WZ-B2xWOHsh.js → quadrantDiagram-34T5L4WZ-QtFjo8i4.js} +1 -1
  56. package/dist/assets/{requirementDiagram-MS252O5E-CfCJaJBw.js → requirementDiagram-MS252O5E-BwmEZf4F.js} +1 -1
  57. package/dist/assets/{sankeyDiagram-XADWPNL6-CSClMzTh.js → sankeyDiagram-XADWPNL6-CTtXN32x.js} +1 -1
  58. package/dist/assets/seqResourceLoaders-DMyPYdA-.js +2 -0
  59. package/dist/assets/{sequenceDiagram-FGHM5R23-D5WoARR1.js → sequenceDiagram-FGHM5R23-DC00gRqs.js} +1 -1
  60. package/dist/assets/{stateDiagram-FHFEXIEX-DC1_JCl1.js → stateDiagram-FHFEXIEX-CT963BWJ.js} +1 -1
  61. package/dist/assets/{stateDiagram-v2-QKLJ7IA2-BOndcGRp.js → stateDiagram-v2-QKLJ7IA2-1T7yDlvQ.js} +1 -1
  62. package/dist/assets/{timeline-definition-GMOUNBTQ-Bm3Lk96s.js → timeline-definition-GMOUNBTQ-CDu66c9j.js} +1 -1
  63. package/dist/assets/vendor-antd-DADYo_zg.js +17 -0
  64. package/dist/assets/{vendor-codemirror-BD02EJx5.js → vendor-codemirror-tF6HNoR6.js} +1 -1
  65. package/dist/assets/vendor-mdxeditor-CFAmRN3Y.js +2 -0
  66. package/dist/assets/vendor-qrcode-DYKmbePy.js +6 -0
  67. package/dist/assets/vendor-virtuoso-TxPxvPjL.js +1 -0
  68. package/dist/assets/{vennDiagram-DHZGUBPP-CA8MWsbD.js → vennDiagram-DHZGUBPP-DSm6yR_C.js} +1 -1
  69. package/dist/assets/{wardley-RL74JXVD-Dw7GlJWj.js → wardley-RL74JXVD-kFdCN4XL.js} +1 -1
  70. package/dist/assets/{wardleyDiagram-NUSXRM2D-woq7iHEC.js → wardleyDiagram-NUSXRM2D-BY1GQbCO.js} +1 -1
  71. package/dist/assets/{xychartDiagram-5P7HB3ND-B4JCiFF4.js → xychartDiagram-5P7HB3ND-ONnFdWbS.js} +1 -1
  72. package/dist/index.html +4 -4
  73. package/findcc.js +103 -6
  74. package/package.json +1 -1
  75. package/server/lib/proxy-stats.js +75 -32
  76. package/dist/assets/App-BfzeNwOB.css +0 -1
  77. package/dist/assets/App-Bqz6Y5h4.js +0 -2
  78. package/dist/assets/Mobile-2LDWfaUe.js +0 -1
  79. package/dist/assets/UnifiedProxyRetryPage-CFz4vOH5.css +0 -1
  80. package/dist/assets/UnifiedProxyRetryPage-DFyS9doh.js +0 -1
  81. package/dist/assets/classDiagram-6PBFFD2Q-CnUCTEpg.js +0 -1
  82. package/dist/assets/classDiagram-v2-HSJHXN6E-CnUCTEpg.js +0 -1
  83. package/dist/assets/clone-D0NlqTo0.js +0 -1
  84. package/dist/assets/seqResourceLoaders-DIUJh1ym.js +0 -2
  85. package/dist/assets/vendor-antd-CyudKxuD.js +0 -17
  86. package/dist/assets/vendor-mdxeditor-C3Q4i3LX.js +0 -2
  87. package/dist/assets/vendor-qrcode-DK9W5Ghb.js +0 -6
  88. package/dist/assets/vendor-virtuoso-C82iSAZx.js +0 -1
@@ -0,0 +1,6 @@
1
+ import{R as React}from"./vendor-antd-DADYo_zg.js";var qrcodegen,qrcodegen2,__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value:value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__objRest=(source,exclude)=>{var target={};for(var prop in source)__hasOwnProp.call(source,prop)&&exclude.indexOf(prop)<0&&(target[prop]=source[prop]);if(null!=source&&__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(source))exclude.indexOf(prop)<0&&__propIsEnum.call(source,prop)&&(target[prop]=source[prop]);return target};(qrcodegen2=>{const _QrCode=class _QrCode2{constructor(version,errorCorrectionLevel,dataCodewords,msk){if(this.version=version,this.errorCorrectionLevel=errorCorrectionLevel,this.modules=[],this.isFunction=[],version<_QrCode2.MIN_VERSION||version>_QrCode2.MAX_VERSION)throw new RangeError("Version value out of range");if(msk<-1||msk>7)throw new RangeError("Mask value out of range");this.size=4*version+17;let row=[];for(let i=0;i<this.size;i++)row.push(!1);for(let i=0;i<this.size;i++)this.modules.push(row.slice()),this.isFunction.push(row.slice());this.drawFunctionPatterns();const allCodewords=this.addEccAndInterleave(dataCodewords);if(this.drawCodewords(allCodewords),-1==msk){let minPenalty=1e9;for(let i=0;i<8;i++){this.applyMask(i),this.drawFormatBits(i);const penalty=this.getPenaltyScore();penalty<minPenalty&&(msk=i,minPenalty=penalty),this.applyMask(i)}}assert(0<=msk&&msk<=7),this.mask=msk,this.applyMask(msk),this.drawFormatBits(msk),this.isFunction=[]}static encodeText(text,ecl){const segs=qrcodegen2.QrSegment.makeSegments(text);return _QrCode2.encodeSegments(segs,ecl)}static encodeBinary(data,ecl){const seg=qrcodegen2.QrSegment.makeBytes(data);return _QrCode2.encodeSegments([seg],ecl)}static encodeSegments(segs,ecl,minVersion=1,maxVersion=40,mask=-1,boostEcl=!0){if(!(_QrCode2.MIN_VERSION<=minVersion&&minVersion<=maxVersion&&maxVersion<=_QrCode2.MAX_VERSION)||mask<-1||mask>7)throw new RangeError("Invalid value");let version,dataUsedBits;for(version=minVersion;;version++){const dataCapacityBits2=8*_QrCode2.getNumDataCodewords(version,ecl),usedBits=QrSegment.getTotalBits(segs,version);if(usedBits<=dataCapacityBits2){dataUsedBits=usedBits;break}if(version>=maxVersion)throw new RangeError("Data too long")}for(const newEcl of[_QrCode2.Ecc.MEDIUM,_QrCode2.Ecc.QUARTILE,_QrCode2.Ecc.HIGH])boostEcl&&dataUsedBits<=8*_QrCode2.getNumDataCodewords(version,newEcl)&&(ecl=newEcl);let bb=[];for(const seg of segs){appendBits(seg.mode.modeBits,4,bb),appendBits(seg.numChars,seg.mode.numCharCountBits(version),bb);for(const b of seg.getData())bb.push(b)}assert(bb.length==dataUsedBits);const dataCapacityBits=8*_QrCode2.getNumDataCodewords(version,ecl);assert(bb.length<=dataCapacityBits),appendBits(0,Math.min(4,dataCapacityBits-bb.length),bb),appendBits(0,(8-bb.length%8)%8,bb),assert(bb.length%8==0);for(let padByte=236;bb.length<dataCapacityBits;padByte^=253)appendBits(padByte,8,bb);let dataCodewords=[];for(;8*dataCodewords.length<bb.length;)dataCodewords.push(0);return bb.forEach((b,i)=>dataCodewords[i>>>3]|=b<<7-(7&i)),new _QrCode2(version,ecl,dataCodewords,mask)}getModule(x,y){return 0<=x&&x<this.size&&0<=y&&y<this.size&&this.modules[y][x]}getModules(){return this.modules}drawFunctionPatterns(){for(let i=0;i<this.size;i++)this.setFunctionModule(6,i,i%2==0),this.setFunctionModule(i,6,i%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const alignPatPos=this.getAlignmentPatternPositions(),numAlign=alignPatPos.length;for(let i=0;i<numAlign;i++)for(let j=0;j<numAlign;j++)0==i&&0==j||0==i&&j==numAlign-1||i==numAlign-1&&0==j||this.drawAlignmentPattern(alignPatPos[i],alignPatPos[j]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(mask){const data=this.errorCorrectionLevel.formatBits<<3|mask;let rem=data;for(let i=0;i<10;i++)rem=rem<<1^1335*(rem>>>9);const bits=21522^(data<<10|rem);assert(bits>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,getBit(bits,i));this.setFunctionModule(8,7,getBit(bits,6)),this.setFunctionModule(8,8,getBit(bits,7)),this.setFunctionModule(7,8,getBit(bits,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,getBit(bits,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,getBit(bits,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,getBit(bits,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let rem=this.version;for(let i=0;i<12;i++)rem=rem<<1^7973*(rem>>>11);const bits=this.version<<12|rem;assert(bits>>>18==0);for(let i=0;i<18;i++){const color=getBit(bits,i),a=this.size-11+i%3,b=Math.floor(i/3);this.setFunctionModule(a,b,color),this.setFunctionModule(b,a,color)}}drawFinderPattern(x,y){for(let dy=-4;dy<=4;dy++)for(let dx=-4;dx<=4;dx++){const dist=Math.max(Math.abs(dx),Math.abs(dy)),xx=x+dx,yy=y+dy;0<=xx&&xx<this.size&&0<=yy&&yy<this.size&&this.setFunctionModule(xx,yy,2!=dist&&4!=dist)}}drawAlignmentPattern(x,y){for(let dy=-2;dy<=2;dy++)for(let dx=-2;dx<=2;dx++)this.setFunctionModule(x+dx,y+dy,1!=Math.max(Math.abs(dx),Math.abs(dy)))}setFunctionModule(x,y,isDark){this.modules[y][x]=isDark,this.isFunction[y][x]=!0}addEccAndInterleave(data){const ver=this.version,ecl=this.errorCorrectionLevel;if(data.length!=_QrCode2.getNumDataCodewords(ver,ecl))throw new RangeError("Invalid argument");const numBlocks=_QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver],blockEccLen=_QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver],rawCodewords=Math.floor(_QrCode2.getNumRawDataModules(ver)/8),numShortBlocks=numBlocks-rawCodewords%numBlocks,shortBlockLen=Math.floor(rawCodewords/numBlocks);let blocks=[];const rsDiv=_QrCode2.reedSolomonComputeDivisor(blockEccLen);for(let i=0,k=0;i<numBlocks;i++){let dat=data.slice(k,k+shortBlockLen-blockEccLen+(i<numShortBlocks?0:1));k+=dat.length;const ecc=_QrCode2.reedSolomonComputeRemainder(dat,rsDiv);i<numShortBlocks&&dat.push(0),blocks.push(dat.concat(ecc))}let result=[];for(let i=0;i<blocks[0].length;i++)blocks.forEach((block,j)=>{(i!=shortBlockLen-blockEccLen||j>=numShortBlocks)&&result.push(block[i])});return assert(result.length==rawCodewords),result}drawCodewords(data){if(data.length!=Math.floor(_QrCode2.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let i=0;for(let right=this.size-1;right>=1;right-=2){6==right&&(right=5);for(let vert=0;vert<this.size;vert++)for(let j=0;j<2;j++){const x=right-j,y=!(right+1&2)?this.size-1-vert:vert;!this.isFunction[y][x]&&i<8*data.length&&(this.modules[y][x]=getBit(data[i>>>3],7-(7&i)),i++)}}assert(i==8*data.length)}applyMask(mask){if(mask<0||mask>7)throw new RangeError("Mask value out of range");for(let y=0;y<this.size;y++)for(let x=0;x<this.size;x++){let invert;switch(mask){case 0:invert=(x+y)%2==0;break;case 1:invert=y%2==0;break;case 2:invert=x%3==0;break;case 3:invert=(x+y)%3==0;break;case 4:invert=(Math.floor(x/3)+Math.floor(y/2))%2==0;break;case 5:invert=x*y%2+x*y%3==0;break;case 6:invert=(x*y%2+x*y%3)%2==0;break;case 7:invert=((x+y)%2+x*y%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[y][x]&&invert&&(this.modules[y][x]=!this.modules[y][x])}}getPenaltyScore(){let result=0;for(let y=0;y<this.size;y++){let runColor=!1,runX=0,runHistory=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[y][x]==runColor?(runX++,5==runX?result+=_QrCode2.PENALTY_N1:runX>5&&result++):(this.finderPenaltyAddHistory(runX,runHistory),runColor||(result+=this.finderPenaltyCountPatterns(runHistory)*_QrCode2.PENALTY_N3),runColor=this.modules[y][x],runX=1);result+=this.finderPenaltyTerminateAndCount(runColor,runX,runHistory)*_QrCode2.PENALTY_N3}for(let x=0;x<this.size;x++){let runColor=!1,runY=0,runHistory=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[y][x]==runColor?(runY++,5==runY?result+=_QrCode2.PENALTY_N1:runY>5&&result++):(this.finderPenaltyAddHistory(runY,runHistory),runColor||(result+=this.finderPenaltyCountPatterns(runHistory)*_QrCode2.PENALTY_N3),runColor=this.modules[y][x],runY=1);result+=this.finderPenaltyTerminateAndCount(runColor,runY,runHistory)*_QrCode2.PENALTY_N3}for(let y=0;y<this.size-1;y++)for(let x=0;x<this.size-1;x++){const color=this.modules[y][x];color==this.modules[y][x+1]&&color==this.modules[y+1][x]&&color==this.modules[y+1][x+1]&&(result+=_QrCode2.PENALTY_N2)}let dark=0;for(const row of this.modules)dark=row.reduce((sum,color)=>sum+(color?1:0),dark);const total=this.size*this.size,k=Math.ceil(Math.abs(20*dark-10*total)/total)-1;return assert(0<=k&&k<=9),result+=k*_QrCode2.PENALTY_N4,assert(0<=result&&result<=2568888),result}getAlignmentPatternPositions(){if(1==this.version)return[];{const numAlign=Math.floor(this.version/7)+2,step=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*numAlign-2));let result=[6];for(let pos=this.size-7;result.length<numAlign;pos-=step)result.splice(1,0,pos);return result}}static getNumRawDataModules(ver){if(ver<_QrCode2.MIN_VERSION||ver>_QrCode2.MAX_VERSION)throw new RangeError("Version number out of range");let result=(16*ver+128)*ver+64;if(ver>=2){const numAlign=Math.floor(ver/7)+2;result-=(25*numAlign-10)*numAlign-55,ver>=7&&(result-=36)}return assert(208<=result&&result<=29648),result}static getNumDataCodewords(ver,ecl){return Math.floor(_QrCode2.getNumRawDataModules(ver)/8)-_QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver]*_QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]}static reedSolomonComputeDivisor(degree){if(degree<1||degree>255)throw new RangeError("Degree out of range");let result=[];for(let i=0;i<degree-1;i++)result.push(0);result.push(1);let root=1;for(let i=0;i<degree;i++){for(let j=0;j<result.length;j++)result[j]=_QrCode2.reedSolomonMultiply(result[j],root),j+1<result.length&&(result[j]^=result[j+1]);root=_QrCode2.reedSolomonMultiply(root,2)}return result}static reedSolomonComputeRemainder(data,divisor){let result=divisor.map(_=>0);for(const b of data){const factor=b^result.shift();result.push(0),divisor.forEach((coef,i)=>result[i]^=_QrCode2.reedSolomonMultiply(coef,factor))}return result}static reedSolomonMultiply(x,y){if(x>>>8!=0||y>>>8!=0)throw new RangeError("Byte out of range");let z=0;for(let i=7;i>=0;i--)z=z<<1^285*(z>>>7),z^=(y>>>i&1)*x;return assert(z>>>8==0),z}finderPenaltyCountPatterns(runHistory){const n=runHistory[1];assert(n<=3*this.size);const core=n>0&&runHistory[2]==n&&runHistory[3]==3*n&&runHistory[4]==n&&runHistory[5]==n;return(core&&runHistory[0]>=4*n&&runHistory[6]>=n?1:0)+(core&&runHistory[6]>=4*n&&runHistory[0]>=n?1:0)}finderPenaltyTerminateAndCount(currentRunColor,currentRunLength,runHistory){return currentRunColor&&(this.finderPenaltyAddHistory(currentRunLength,runHistory),currentRunLength=0),currentRunLength+=this.size,this.finderPenaltyAddHistory(currentRunLength,runHistory),this.finderPenaltyCountPatterns(runHistory)}finderPenaltyAddHistory(currentRunLength,runHistory){0==runHistory[0]&&(currentRunLength+=this.size),runHistory.pop(),runHistory.unshift(currentRunLength)}};function appendBits(val,len,bb){if(len<0||len>31||val>>>len!=0)throw new RangeError("Value out of range");for(let i=len-1;i>=0;i--)bb.push(val>>>i&1)}function getBit(x,i){return!!(x>>>i&1)}function assert(cond){if(!cond)throw new Error("Assertion error")}_QrCode.MIN_VERSION=1,_QrCode.MAX_VERSION=40,_QrCode.PENALTY_N1=3,_QrCode.PENALTY_N2=3,_QrCode.PENALTY_N3=40,_QrCode.PENALTY_N4=10,_QrCode.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],_QrCode.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],qrcodegen2.QrCode=_QrCode;const _QrSegment=class _QrSegment2{constructor(mode,numChars,bitData){if(this.mode=mode,this.numChars=numChars,this.bitData=bitData,numChars<0)throw new RangeError("Invalid argument");this.bitData=bitData.slice()}static makeBytes(data){let bb=[];for(const b of data)appendBits(b,8,bb);return new _QrSegment2(_QrSegment2.Mode.BYTE,data.length,bb)}static makeNumeric(digits){if(!_QrSegment2.isNumeric(digits))throw new RangeError("String contains non-numeric characters");let bb=[];for(let i=0;i<digits.length;){const n=Math.min(digits.length-i,3);appendBits(parseInt(digits.substring(i,i+n),10),3*n+1,bb),i+=n}return new _QrSegment2(_QrSegment2.Mode.NUMERIC,digits.length,bb)}static makeAlphanumeric(text){if(!_QrSegment2.isAlphanumeric(text))throw new RangeError("String contains unencodable characters in alphanumeric mode");let i,bb=[];for(i=0;i+2<=text.length;i+=2){let temp=45*_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i));temp+=_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i+1)),appendBits(temp,11,bb)}return i<text.length&&appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)),6,bb),new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC,text.length,bb)}static makeSegments(text){return""==text?[]:_QrSegment2.isNumeric(text)?[_QrSegment2.makeNumeric(text)]:_QrSegment2.isAlphanumeric(text)?[_QrSegment2.makeAlphanumeric(text)]:[_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))]}static makeEci(assignVal){let bb=[];if(assignVal<0)throw new RangeError("ECI assignment value out of range");if(assignVal<128)appendBits(assignVal,8,bb);else if(assignVal<16384)appendBits(2,2,bb),appendBits(assignVal,14,bb);else{if(!(assignVal<1e6))throw new RangeError("ECI assignment value out of range");appendBits(6,3,bb),appendBits(assignVal,21,bb)}return new _QrSegment2(_QrSegment2.Mode.ECI,0,bb)}static isNumeric(text){return _QrSegment2.NUMERIC_REGEX.test(text)}static isAlphanumeric(text){return _QrSegment2.ALPHANUMERIC_REGEX.test(text)}getData(){return this.bitData.slice()}static getTotalBits(segs,version){let result=0;for(const seg of segs){const ccbits=seg.mode.numCharCountBits(version);if(seg.numChars>=1<<ccbits)return 1/0;result+=4+ccbits+seg.bitData.length}return result}static toUtf8ByteArray(str){str=encodeURI(str);let result=[];for(let i=0;i<str.length;i++)"%"!=str.charAt(i)?result.push(str.charCodeAt(i)):(result.push(parseInt(str.substring(i+1,i+3),16)),i+=2);return result}};_QrSegment.NUMERIC_REGEX=/^[0-9]*$/,_QrSegment.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,_QrSegment.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let QrSegment=_QrSegment;qrcodegen2.QrSegment=_QrSegment})(qrcodegen||(qrcodegen={})),(QrCode2=>{const _Ecc=class{constructor(ordinal,formatBits){this.ordinal=ordinal,this.formatBits=formatBits}};_Ecc.LOW=new _Ecc(0,1),_Ecc.MEDIUM=new _Ecc(1,0),_Ecc.QUARTILE=new _Ecc(2,3),_Ecc.HIGH=new _Ecc(3,2),QrCode2.Ecc=_Ecc})((qrcodegen2=qrcodegen||(qrcodegen={})).QrCode||(qrcodegen2.QrCode={})),(qrcodegen2=>{(QrSegment2=>{const _Mode=class{constructor(modeBits,numBitsCharCount){this.modeBits=modeBits,this.numBitsCharCount=numBitsCharCount}numCharCountBits(ver){return this.numBitsCharCount[Math.floor((ver+7)/17)]}};_Mode.NUMERIC=new _Mode(1,[10,12,14]),_Mode.ALPHANUMERIC=new _Mode(2,[9,11,13]),_Mode.BYTE=new _Mode(4,[8,16,16]),_Mode.KANJI=new _Mode(8,[8,10,12]),_Mode.ECI=new _Mode(7,[0,0,0]),QrSegment2.Mode=_Mode})(qrcodegen2.QrSegment||(qrcodegen2.QrSegment={}))})(qrcodegen||(qrcodegen={}));var qrcodegen_default=qrcodegen,ERROR_LEVEL_MAP={L:qrcodegen_default.QrCode.Ecc.LOW,M:qrcodegen_default.QrCode.Ecc.MEDIUM,Q:qrcodegen_default.QrCode.Ecc.QUARTILE,H:qrcodegen_default.QrCode.Ecc.HIGH},DEFAULT_SIZE=128,DEFAULT_LEVEL="L",DEFAULT_BGCOLOR="#FFFFFF",DEFAULT_FGCOLOR="#000000",DEFAULT_INCLUDEMARGIN=!1,DEFAULT_MINVERSION=1;
2
+ /**
3
+ * @license qrcode.react
4
+ * Copyright (c) Paul O'Shannessy
5
+ * SPDX-License-Identifier: ISC
6
+ */function generatePath(modules,margin=0){const ops=[];return modules.forEach(function(row,y){let start=null;row.forEach(function(cell,x){if(!cell&&null!==start)return ops.push(`M${start+margin} ${y+margin}h${x-start}v1H${start+margin}z`),void(start=null);if(x!==row.length-1)cell&&null===start&&(start=x);else{if(!cell)return;null===start?ops.push(`M${x+margin},${y+margin} h1v1H${x+margin}z`):ops.push(`M${start+margin},${y+margin} h${x+1-start}v1H${start+margin}z`)}})}),ops.join("")}function excavateModules(modules,excavation){return modules.slice().map((row,y)=>y<excavation.y||y>=excavation.y+excavation.h?row:row.map((cell,x)=>(x<excavation.x||x>=excavation.x+excavation.w)&&cell))}function useQRCode({value:value,level:level,minVersion:minVersion,includeMargin:includeMargin,marginSize:marginSize,imageSettings:imageSettings,size:size,boostLevel:boostLevel}){let qrcode=React.useMemo(()=>{const segments=(Array.isArray(value)?value:[value]).reduce((accum,v)=>(accum.push(...qrcodegen_default.QrSegment.makeSegments(v)),accum),[]);return qrcodegen_default.QrCode.encodeSegments(segments,ERROR_LEVEL_MAP[level],minVersion,void 0,void 0,boostLevel)},[value,level,minVersion,boostLevel]);const{cells:cells,margin:margin,numCells:numCells,calculatedImageSettings:calculatedImageSettings}=React.useMemo(()=>{let cells2=qrcode.getModules();const margin2=function(includeMargin,marginSize){return null!=marginSize?Math.max(Math.floor(marginSize),0):includeMargin?4:0}(includeMargin,marginSize),numCells2=cells2.length+2*margin2,calculatedImageSettings2=function(cells,size,margin,imageSettings){if(null==imageSettings)return null;const numCells=cells.length+2*margin,defaultSize=Math.floor(.1*size),scale=numCells/size,w=(imageSettings.width||defaultSize)*scale,h=(imageSettings.height||defaultSize)*scale,x=null==imageSettings.x?cells.length/2-w/2:imageSettings.x*scale,y=null==imageSettings.y?cells.length/2-h/2:imageSettings.y*scale,opacity=null==imageSettings.opacity?1:imageSettings.opacity;let excavation=null;if(imageSettings.excavate){let floorX=Math.floor(x),floorY=Math.floor(y);excavation={x:floorX,y:floorY,w:Math.ceil(w+x-floorX),h:Math.ceil(h+y-floorY)}}return{x:x,y:y,h:h,w:w,excavation:excavation,opacity:opacity,crossOrigin:imageSettings.crossOrigin}}(cells2,size,margin2,imageSettings);return{cells:cells2,margin:margin2,numCells:numCells2,calculatedImageSettings:calculatedImageSettings2}},[qrcode,size,imageSettings,includeMargin,marginSize]);return{qrcode:qrcode,margin:margin,cells:cells,numCells:numCells,calculatedImageSettings:calculatedImageSettings}}var SUPPORTS_PATH2D=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}(),QRCodeCanvas=React.forwardRef(function(props,forwardedRef){const _a=props,{value:value,size:size=DEFAULT_SIZE,level:level=DEFAULT_LEVEL,bgColor:bgColor=DEFAULT_BGCOLOR,fgColor:fgColor=DEFAULT_FGCOLOR,includeMargin:includeMargin=DEFAULT_INCLUDEMARGIN,minVersion:minVersion=DEFAULT_MINVERSION,boostLevel:boostLevel,marginSize:marginSize,imageSettings:imageSettings}=_a,_b=__objRest(_a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:style}=_b,otherProps=__objRest(_b,["style"]),imgSrc=null==imageSettings?void 0:imageSettings.src,_canvas=React.useRef(null),_image=React.useRef(null),setCanvasRef=React.useCallback(node=>{_canvas.current=node,"function"==typeof forwardedRef?forwardedRef(node):forwardedRef&&(forwardedRef.current=node)},[forwardedRef]),[isImgLoaded,setIsImageLoaded]=React.useState(!1),{margin:margin,cells:cells,numCells:numCells,calculatedImageSettings:calculatedImageSettings}=useQRCode({value:value,level:level,minVersion:minVersion,boostLevel:boostLevel,includeMargin:includeMargin,marginSize:marginSize,imageSettings:imageSettings,size:size});React.useEffect(()=>{if(null!=_canvas.current){const canvas=_canvas.current,ctx=canvas.getContext("2d");if(!ctx)return;let cellsToDraw=cells;const image=_image.current,haveImageToRender=null!=calculatedImageSettings&&null!==image&&image.complete&&0!==image.naturalHeight&&0!==image.naturalWidth;haveImageToRender&&null!=calculatedImageSettings.excavation&&(cellsToDraw=excavateModules(cells,calculatedImageSettings.excavation));const pixelRatio=window.devicePixelRatio||1;canvas.height=canvas.width=size*pixelRatio;const scale=size/numCells*pixelRatio;ctx.scale(scale,scale),ctx.fillStyle=bgColor,ctx.fillRect(0,0,numCells,numCells),ctx.fillStyle=fgColor,SUPPORTS_PATH2D?ctx.fill(new Path2D(generatePath(cellsToDraw,margin))):cells.forEach(function(row,rdx){row.forEach(function(cell,cdx){cell&&ctx.fillRect(cdx+margin,rdx+margin,1,1)})}),calculatedImageSettings&&(ctx.globalAlpha=calculatedImageSettings.opacity),haveImageToRender&&ctx.drawImage(image,calculatedImageSettings.x+margin,calculatedImageSettings.y+margin,calculatedImageSettings.w,calculatedImageSettings.h)}}),React.useEffect(()=>{setIsImageLoaded(!1)},[imgSrc]);const canvasStyle=__spreadValues({height:size,width:size},style);let img=null;return null!=imgSrc&&(img=React.createElement("img",{src:imgSrc,key:imgSrc,style:{display:"none"},onLoad:()=>{setIsImageLoaded(!0)},ref:_image,crossOrigin:null==calculatedImageSettings?void 0:calculatedImageSettings.crossOrigin})),React.createElement(React.Fragment,null,React.createElement("canvas",__spreadValues({style:canvasStyle,height:size,width:size,ref:setCanvasRef,role:"img"},otherProps)),img)});QRCodeCanvas.displayName="QRCodeCanvas",React.forwardRef(function(props,forwardedRef){const _a=props,{value:value,size:size=DEFAULT_SIZE,level:level=DEFAULT_LEVEL,bgColor:bgColor=DEFAULT_BGCOLOR,fgColor:fgColor=DEFAULT_FGCOLOR,includeMargin:includeMargin=DEFAULT_INCLUDEMARGIN,minVersion:minVersion=DEFAULT_MINVERSION,boostLevel:boostLevel,title:title,marginSize:marginSize,imageSettings:imageSettings}=_a,otherProps=__objRest(_a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:margin,cells:cells,numCells:numCells,calculatedImageSettings:calculatedImageSettings}=useQRCode({value:value,level:level,minVersion:minVersion,boostLevel:boostLevel,includeMargin:includeMargin,marginSize:marginSize,imageSettings:imageSettings,size:size});let cellsToDraw=cells,image=null;null!=imageSettings&&null!=calculatedImageSettings&&(null!=calculatedImageSettings.excavation&&(cellsToDraw=excavateModules(cells,calculatedImageSettings.excavation)),image=React.createElement("image",{href:imageSettings.src,height:calculatedImageSettings.h,width:calculatedImageSettings.w,x:calculatedImageSettings.x+margin,y:calculatedImageSettings.y+margin,preserveAspectRatio:"none",opacity:calculatedImageSettings.opacity,crossOrigin:calculatedImageSettings.crossOrigin}));const fgPath=generatePath(cellsToDraw,margin);return React.createElement("svg",__spreadValues({height:size,width:size,viewBox:`0 0 ${numCells} ${numCells}`,ref:forwardedRef,role:"img"},otherProps),!!title&&React.createElement("title",null,title),React.createElement("path",{fill:bgColor,d:`M0,0 h${numCells}v${numCells}H0z`,shapeRendering:"crispEdges"}),React.createElement("path",{fill:fgColor,d:fgPath,shapeRendering:"crispEdges"}),image)}).displayName="QRCodeSVG";export{QRCodeCanvas as Q};
@@ -0,0 +1 @@
1
+ import{j as jsxRuntimeExports}from"./vendor-codemirror-tF6HNoR6.js";import{R as React,a as reactExports,c as ReactDOM}from"./vendor-antd-DADYo_zg.js";function un(t){return()=>t}function fo(t){t()}function re(t,e){return n=>t(e(n))}function an(t,e){return()=>t(e)}function Ae(t){return void 0!==t}function Xt(){}function ye(t,e){return e(t),t}function ho(t,e){return e(t)}function ot(...t){return t}function Y(t,e){return t(1,e)}function _(t,e){t(0,e)}function Me(t){t(2)}function it(t){return t(4)}function L(t,e){return Y(t,function(t,e){return n=>t(e,n)}(e,0))}function yt(t,e){const n=t(1,o=>{n(),e(o)});return n}function dn(t){let e,n;return o=>r=>{e=r,n&&clearTimeout(n),n=setTimeout(()=>{o(e)},t)}}function Ln(t,e){return t===e}function et(t=Ln){let e;return n=>o=>{t(e,o)||(e=o,n(o))}}function W(t){return e=>n=>{t(n)&&e(n)}}function B(t){return e=>re(e,t)}function Bt(t){return e=>()=>{e(t)}}function I(t,...e){const n=function(...t){return e=>t.reduceRight(ho,e)}(...e);return(o,r)=>{switch(o){case 2:return void Me(t);case 1:return Y(t,n(r))}}}function Ot(t,e){return n=>o=>{n(e=t(e,o))}}function $t(t){return e=>n=>{t>0?t--:e(n)}}function zt(t){let n,e=null;return o=>r=>{e=r,!n&&(n=setTimeout(()=>{n=void 0,o(e)},t))}}function $(...t){const e=new Array(t.length);let n=0,o=null;const r=2**t.length-1;return t.forEach((s,i)=>{const l=2**i;Y(s,c=>{const d=n;n|=l,e[i]=c,d!==r&&n===r&&o&&(o(),o=null)})}),s=>i=>{const l=()=>{s([i].concat(e))};n===r?l():o=l}}function v(t){let e=t;const n=U();return(o,r)=>{switch(o){case 0:e=r;break;case 1:r(e);break;case 4:return e}return n(o,r)}}function ht(t,e){return ye(v(e),n=>L(t,n))}function U(){const t=[];return(e,n)=>{switch(e){case 0:return void t.slice().forEach(o=>{o(n)});case 2:return void t.splice(0,t.length);case 1:return t.push(n),()=>{const o=t.indexOf(n);o>-1&&t.splice(o,1)}}}}function vt(t){return ye(U(),e=>L(t,e))}function j(t,e=[],{singleton:n}={singleton:!0}){return{constructor:t,dependencies:e,id:xo(),singleton:n}}const xo=()=>Symbol();function at(...t){const e=U(),n=new Array(t.length);let o=0;const r=2**t.length-1;return t.forEach((s,i)=>{const l=2**i;Y(s,c=>{n[i]=c,o|=l,o===r&&_(e,n)})}),function(s,i){switch(s){case 2:return void Me(e);case 1:return o===r&&i(n),Y(e,i)}}}function P(t,e=Ln){return I(t,et(e))}function ze(...t){return function(e,n){switch(e){case 2:return;case 1:return function(...t){return()=>{t.map(fo)}}(...t.map(o=>Y(o,n)))}}}const ft_DEBUG=0,ft_INFO=1,ft_WARN=2,ft_ERROR=3,To={[ft_DEBUG]:"debug",[ft_ERROR]:"error",[ft_INFO]:"log",[ft_WARN]:"warn"},Gt=j(()=>{const t=v(ft_ERROR);return{log:v((n,o,r=ft_INFO)=>{r>=((typeof globalThis>"u"?window:globalThis).VIRTUOSO_LOG_LEVEL??it(t))&&console[To[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",n,o)}),logLevel:t}},[],{singleton:!0});function kt(t,e,n){return _e(t,e,n).callbackRef}function _e(t,e,n){const o=React.useRef(null);let r=i=>{};const s=React.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const c=i[0].target;null!==c.offsetParent&&t(c)};n?l():requestAnimationFrame(l)}):null,[t,n]);return r=i=>{i&&e?(null==s||s.observe(i),o.current=i):(o.current&&(null==s||s.unobserve(o.current)),o.current=null)},{callbackRef:r,ref:o}}function zn(t,e,n,o,r,s,i,l,c){const d=React.useCallback(m=>{const x=function(t,e,n,o){const r=t.length;if(0===r)return null;const s=[];for(let i=0;i<r;i++){const l=t.item(i);if(void 0===l.dataset.index)continue;const c=parseInt(l.dataset.index),d=parseFloat(l.dataset.knownSize),m=e(l,n);if(0===m&&o("Zero-sized element, this should not happen",{child:l},ft_ERROR),m===d)continue;const x=s[s.length-1];0===s.length||x.size!==m||x.endIndex!==c-1?s.push({endIndex:c,size:m,startIndex:c}):s[s.length-1].endIndex++}return s}(m.children,e,l?"offsetWidth":"offsetHeight",r);let p=m.parentElement;for(;void 0===p.dataset.virtuosoScroller;)p=p.parentElement;const T="window"===p.lastElementChild.dataset.viewportType;let w;T&&(w=p.ownerDocument.defaultView);const R=i?l?i.scrollLeft:i.scrollTop:T?l?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:l?p.scrollLeft:p.scrollTop,h=i?l?i.scrollWidth:i.scrollHeight:T?l?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:l?p.scrollWidth:p.scrollHeight,f=i?l?i.offsetWidth:i.offsetHeight:T?l?w.innerWidth:w.innerHeight:l?p.offsetWidth:p.offsetHeight;o({scrollHeight:h,scrollTop:Math.max(R,0),viewportHeight:f}),null==s||s(l?fn("column-gap",getComputedStyle(m).columnGap,r):fn("row-gap",getComputedStyle(m).rowGap,r)),null!==x&&t(x)},[t,e,r,s,i,o,l]);return _e(d,n,c)}function fn(t,e,n){return"normal"!==e&&!0!==(null==e?void 0:e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,ft_WARN),"normal"===e?0:parseInt(e??"0",10)}function Ne(t,e,n){const o=React.useRef(null),r=React.useCallback(c=>{if(!(null==c?void 0:c.offsetParent))return;const d=c.getBoundingClientRect(),m=d.width;let x,p;if(e){const T=e.getBoundingClientRect(),w=d.top-T.top;p=T.height-Math.max(0,w),x=w+e.scrollTop}else{const T=i.current.ownerDocument.defaultView;p=T.innerHeight-Math.max(0,d.top),x=d.top+T.scrollY}o.current={listHeight:d.height,offsetTop:x,visibleHeight:p,visibleWidth:m},t(o.current)},[t,e]),{callbackRef:s,ref:i}=_e(r,!0,n),l=React.useCallback(()=>{r(i.current)},[r,i]);return React.useEffect(()=>{var _a;if(e){e.addEventListener("scroll",l);const d=new ResizeObserver(()=>{requestAnimationFrame(l)});return d.observe(e),()=>{e.removeEventListener("scroll",l),d.unobserve(e)}}const c=null==(_a=i.current)?void 0:_a.ownerDocument.defaultView;return null==c||c.addEventListener("scroll",l),null==c||c.addEventListener("resize",l),()=>{null==c||c.removeEventListener("scroll",l),null==c||c.removeEventListener("resize",l)}},[l,e,i]),s}const It=j(()=>{const t=U(),e=U(),n=v(0),o=U(),r=v(0),s=U(),i=U(),l=v(0),c=v(0),d=v(0),m=v(0),x=U(),p=U(),T=v(!1),w=v(!1),R=v(!1);return L(I(t,B(({scrollTop:h})=>h)),e),L(I(t,B(({scrollHeight:h})=>h)),i),L(e,r),{deviation:n,fixedFooterHeight:d,fixedHeaderHeight:c,footerHeight:m,headerHeight:l,horizontalDirection:w,scrollBy:p,scrollContainerState:t,scrollHeight:i,scrollingInProgress:T,scrollTo:x,scrollTop:e,skipAnimationFrameInResizeObserver:R,smoothScrollTargetReached:o,statefulScrollTop:r,viewportHeight:s}},[],{singleton:!0}),se={lvl:0};function Fn(t,e){const n=t.length;if(0===n)return[];let{index:o,value:r}=e(t[0]);const s=[];for(let i=1;i<n;i++){const{index:l,value:c}=e(t[i]);s.push({end:l-1,start:o,value:r}),o=l,r=c}return s.push({end:1/0,start:o,value:r}),s}function J(t){return t===se}function ie(t,e){if(!J(t))return e===t.k?t.v:e<t.k?ie(t.l,e):ie(t.r,e)}function Rt(t,e,n="k"){if(J(t))return[-1/0,void 0];if(Number(t[n])===e)return[t.k,t.v];if(Number(t[n])<e){const o=Rt(t.r,e,n);return o[0]===-1/0?[t.k,t.v]:o}return Rt(t.l,e,n)}function Tt(t,e,n){return J(t)?Wn(e,n,1):e===t.k?dt(t,{k:e,v:n}):e<t.k?mn(dt(t,{l:Tt(t.l,e,n)})):mn(dt(t,{r:Tt(t.r,e,n)}))}function qt(){return se}function Yt(t,e,n){if(J(t))return[];return function(t){return Fn(t,({k:e,v:n})=>({index:e,value:n}))}(Ve(t,Rt(t,e)[0],n))}function Fe(t,e){if(J(t))return se;const{k:n,l:o,r:r}=t;if(e===n){if(J(o))return r;if(J(r))return o;const[s,i]=Pn(o);return Se(dt(t,{k:s,l:Vn(o),v:i}))}return Se(dt(t,e<n?{l:Fe(o,e)}:{r:Fe(r,e)}))}function _t(t){return J(t)?[]:[..._t(t.l),{k:t.k,v:t.v},..._t(t.r)]}function Ve(t,e,n){if(J(t))return[];const{k:o,l:r,r:s,v:i}=t;let l=[];return o>e&&(l=l.concat(Ve(r,e,n))),o>=e&&o<=n&&l.push({k:o,v:i}),o<=n&&(l=l.concat(Ve(s,e,n))),l}function Se(t){const{l:e,lvl:n,r:o}=t;if(o.lvl>=n-1&&e.lvl>=n-1)return t;if(n>o.lvl+1){if(Ee(e))return Gn(dt(t,{lvl:n-1}));if(!J(e)&&!J(e.r))return dt(e.r,{l:dt(e,{r:e.r.l}),lvl:n,r:dt(t,{l:e.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(Ee(t))return Pe(dt(t,{lvl:n-1}));if(!J(o)&&!J(o.l)){const r=o.l,s=Ee(r)?o.lvl-1:o.lvl;return dt(r,{l:dt(t,{lvl:n-1,r:r.l}),lvl:r.lvl+1,r:Pe(dt(o,{l:r.r,lvl:s}))})}throw new Error("Unexpected empty nodes")}function dt(t,e){return Wn(void 0!==e.k?e.k:t.k,void 0!==e.v?e.v:t.v,void 0!==e.lvl?e.lvl:t.lvl,void 0!==e.l?e.l:t.l,void 0!==e.r?e.r:t.r)}function Vn(t){return J(t.r)?t.l:Se(dt(t,{r:Vn(t.r)}))}function Ee(t){return J(t)||t.lvl>t.r.lvl}function Pn(t){return J(t.r)?[t.k,t.v]:Pn(t.r)}function Wn(t,e,n,o=se,r=se){return{k:t,l:o,lvl:n,r:r,v:e}}function mn(t){return Pe(Gn(t))}function Gn(t){const{l:e}=t;return J(e)||e.lvl!==t.lvl?t:dt(e,{r:dt(t,{l:e.r})})}function Pe(t){const{lvl:e,r:n}=t;return J(n)||J(n.r)||n.lvl!==e||n.r.lvl!==e?t:dt(n,{l:dt(t,{r:n.l}),lvl:e+1})}function An(t,e){return!(!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex)}function le(t,e){return!(!t||t[0]!==e[0]||t[1]!==e[1])}const De=j(()=>({recalcInProgress:v(!1)}),[],{singleton:!0});function Mn(t,e,n){return t[ve(t,e,n)]}function ve(t,e,n,o=0){let r=t.length-1;for(;o<=r;){const s=Math.floor((o+r)/2),l=n(t[s],e);if(0===l)return s;if(-1===l){if(r-o<2)return s-1;r=s-1}else{if(r===o)return s;o=s+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function Ht(t,e){return Math.round(t.getBoundingClientRect()[e])}function be(t){return!J(t.groupOffsetTree)}function $e({index:t},e){return e===t?0:e<t?-1:1}function Eo({offset:t},e){return e===t?0:e<t?-1:1}function ce(t,e,n){if(0===e.length)return 0;const{index:o,offset:r,size:s}=Mn(e,t,$e),i=t-o,l=s*i+(i-1)*n+r;return l>0?l+n:l}function _n(t,e){if(!be(e))return t;let n=0;for(;e.groupIndices[n]<=t+n;)n++;return t+n}function Nn(t,e,n){if(function(t){return typeof t.groupIndex<"u"}(t))return e.groupIndices[t.groupIndex]+1;let r=_n("LAST"===t.index?n:t.index,e);return r=Math.max(0,r,Math.min(n,r)),r}function Bo(t,e,n,o=0){return o>0&&(e=Math.max(e,Mn(t,o,$e).offset)),Fn(function(t,e,n,o){const r=ve(t,e,o),s=ve(t,n,o,r);return t.slice(r,s+1)}(t,e,n,Eo),Lo)}function Oo(t,[e,n,o,r]){e.length>0&&o("received item sizes",e,ft_DEBUG);const s=t.sizeTree;let i=s,l=0;if(n.length>0&&J(s)&&2===e.length){const p=e[0].size,T=e[1].size;i=n.reduce((w,R)=>Tt(Tt(w,R,p),R+1,T),i)}else[i,l]=function(t,e){let n=J(t)?0:1/0;for(const o of e){const{endIndex:r,size:s,startIndex:i}=o;if(n=Math.min(n,i),J(t)){t=Tt(t,0,s);continue}const l=Yt(t,i-1,r+1);if(l.some(zo(o)))continue;let c=!1,d=!1;for(const{end:m,start:x,value:p}of l)c?(r>=x||s===p)&&(t=Fe(t,x)):(d=p!==s,c=!0),m>r&&r>=x&&p!==s&&(t=Tt(t,r+1,p));d&&(t=Tt(t,i,s))}return[t,n]}(i,e);if(i===s)return t;const{lastIndex:c,lastOffset:d,lastSize:m,offsetTree:x}=We(t.offsetTree,l,i,r);return{groupIndices:n,groupOffsetTree:n.reduce((p,T)=>Tt(p,T,ce(T,x,r)),qt()),lastIndex:c,lastOffset:d,lastSize:m,offsetTree:x,sizeTree:i}}function pn(t,e){let n=0,o=0;for(;n<t;)n+=e[o+1]-e[o]-1,o++;return o-(n===t?0:1)}function We(t,e,n,o){let r=t,s=0,i=0,l=0,c=0;if(0!==e){c=ve(r,e-1,$e),l=r[c].offset;const m=Rt(n,e-1);s=m[0],i=m[1],r.length&&r[c].size===Rt(n,e)[1]&&(c-=1),r=r.slice(0,c+1)}else r=[];for(const{start:d,value:m}of Yt(n,e,1/0)){const x=d-s,p=x*i+l+x*o;r.push({index:d,offset:p,size:m}),s=d,l=p,i=m}return{lastIndex:s,lastOffset:l,lastSize:i,offsetTree:r}}function Lo(t){return{index:t.index,value:t}}function zo(t){const{endIndex:e,size:n,startIndex:o}=t;return r=>r.start===o&&(r.end===e||r.end===1/0)&&r.value===n}const Fo={offsetHeight:"height",offsetWidth:"width"},Lt=j(([{log:t},{recalcInProgress:e}])=>{const n=U(),o=U(),r=ht(o,0),s=U(),i=U(),l=v(0),c=v([]),d=v(void 0),m=v(void 0),x=v(void 0),p=v(void 0),T=v((u,g)=>Ht(u,Fo[g])),w=v(void 0),R=v(0),h={groupIndices:[],groupOffsetTree:qt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:qt()},f=ht(I(n,$(c,t,R),Ot(Oo,h),et()),h),a=ht(I(c,et(),Ot((u,g)=>({current:g,prev:u.current}),{current:[],prev:[]}),B(({prev:u})=>u)),[]);L(I(c,W(u=>u.length>0),$(f,R),B(([u,g,C])=>{const z=u.reduce((O,V,N)=>Tt(O,V,ce(V,g.offsetTree,C)||N),qt());return{...g,groupIndices:u,groupOffsetTree:z}})),f),L(I(o,$(f),W(([u,{lastIndex:g}])=>u<g),B(([u,{lastIndex:g,lastSize:C}])=>[{endIndex:g,size:C,startIndex:u}])),n),L(d,m);const S=ht(I(d,B(u=>void 0===u)),!0);L(I(m,W(u=>void 0!==u&&J(it(f).sizeTree)),B(u=>{const g=it(x),C=it(c).length>0;return void 0!==g&&0!==g?C?[{endIndex:0,size:g,startIndex:0},{endIndex:1,size:u,startIndex:1}]:[]:[{endIndex:0,size:u,startIndex:0}]})),n),L(I(p,W(u=>void 0!==u&&u.length>0&&J(it(f).sizeTree)),B(u=>{const g=[];let C=u[0],z=0;for(let O=1;O<u.length;O++){const V=u[O];V!==C&&(g.push({endIndex:O-1,size:C,startIndex:z}),C=V,z=O)}return g.push({endIndex:u.length-1,size:C,startIndex:z}),g})),n),L(I(c,$(x,m),W(([,u,g])=>void 0!==u&&void 0!==g),B(([u,g,C])=>{const z=[];for(let O=0;O<u.length;O++){const V=u[O],N=u[O+1];z.push({startIndex:V,endIndex:V,size:g}),void 0!==N&&z.push({startIndex:V+1,endIndex:N-1,size:C})}return z})),n);const H=vt(I(n,$(f),Ot(({sizes:u},[g,C])=>({changed:C!==u,sizes:C}),{changed:!1,sizes:h}),B(u=>u.changed)));Y(I(l,Ot((u,g)=>({diff:u.prev-g,prev:g}),{diff:0,prev:0}),B(u=>u.diff)),u=>{const{groupIndices:g}=it(f);if(u>0)_(e,!0),_(s,u+pn(u,g));else if(u<0){const C=it(a);C.length>0&&(u-=pn(-u,C)),_(i,u)}}),Y(I(l,$(t)),([u,g])=>{u<0&&g("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},ft_ERROR)});const y=vt(s);L(I(s,$(f),B(([u,g])=>{const C=g.groupIndices.length>0,z=[],O=g.lastSize;if(C){const V=ie(g.sizeTree,0);let N=0,Z=0;for(;N<u;){const q=g.groupIndices[Z],Q=g.groupIndices.length===Z+1?1/0:g.groupIndices[Z+1]-q-1;z.push({endIndex:q,size:V,startIndex:q}),z.push({endIndex:q+1+Q-1,size:O,startIndex:q+1}),Z++,N+=Q+1}const F=_t(g.sizeTree);return N!==u&&F.shift(),F.reduce((q,{k:Q,v:gt})=>{let ut=q.ranges;return 0!==q.prevSize&&(ut=[...q.ranges,{endIndex:Q+u-1,size:q.prevSize,startIndex:q.prevIndex}]),{prevIndex:Q+u,prevSize:gt,ranges:ut}},{prevIndex:u,prevSize:0,ranges:z}).ranges}return _t(g.sizeTree).reduce((V,{k:N,v:Z})=>({prevIndex:N+u,prevSize:Z,ranges:[...V.ranges,{endIndex:N+u-1,size:V.prevSize,startIndex:V.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const k=vt(I(i,$(f,R),B(([u,{offsetTree:g},C])=>ce(-u,g,C))));return L(I(i,$(f,R),B(([u,g,C])=>{if(g.groupIndices.length>0){if(J(g.sizeTree))return g;let V=qt();const N=it(a);let Z=0,F=0,mt=0;for(;Z<-u;){mt=N[F];const Q=N[F+1]-mt-1;F++,Z+=Q+1}if(V=_t(g.sizeTree).reduce((Q,{k:gt,v:ut})=>Tt(Q,Math.max(0,gt+u),ut),V),Z!==-u){V=Tt(V,0,ie(g.sizeTree,mt));V=Tt(V,1,Rt(g.sizeTree,1-u)[1])}return{...g,sizeTree:V,...We(g.offsetTree,0,V,C)}}const O=_t(g.sizeTree).reduce((V,{k:N,v:Z})=>Tt(V,Math.max(0,N+u),Z),qt());return{...g,sizeTree:O,...We(g.offsetTree,0,O,C)}})),f),{beforeUnshiftWith:y,data:w,defaultItemSize:m,firstItemIndex:l,fixedItemSize:d,fixedGroupSize:x,gap:R,groupIndices:c,heightEstimates:p,itemSize:T,listRefresh:H,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:f,statefulTotalCount:r,totalCount:o,trackItemSizes:S,unshiftWith:s}},ot(Gt,De),{singleton:!0});function Vo(t){return t.reduce((e,n)=>(e.groupIndices.push(e.totalCount),e.totalCount+=n+1,e),{groupIndices:[],totalCount:0})}const Dn=j(([{groupIndices:t,sizes:e,totalCount:n},{headerHeight:o,scrollTop:r}])=>{const s=U(),i=U(),l=vt(I(s,B(Vo)));return L(I(l,B(c=>c.totalCount)),n),L(I(l,B(c=>c.groupIndices)),t),L(I(at(r,e,o),W(([c,d])=>be(d)),B(([c,d,m])=>Rt(d.groupOffsetTree,Math.max(c-m,0),"v")[0]),et(),B(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},ot(Lt,It)),At=j(([{log:t}])=>{const e=v(!1),n=vt(I(e,W(o=>o),et()));return Y(e,o=>{o&&it(t)("props updated",{},ft_DEBUG)}),{didMount:n,propsReady:e}},ot(Gt),{singleton:!0}),Po=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function $n(t){const e="number"==typeof t?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!Po)&&(e.behavior="auto"),void 0===e.offset&&(e.offset=0),e}const fe=j(([{gap:t,listRefresh:e,sizes:n,totalCount:o},{fixedFooterHeight:r,fixedHeaderHeight:s,footerHeight:i,headerHeight:l,scrollingInProgress:c,scrollTo:d,smoothScrollTargetReached:m,viewportHeight:x},{log:p}])=>{const T=U(),w=U(),R=v(0);let h=null,f=null,a=null;function S(){null!==h&&(h(),h=null),null!==a&&(a(),a=null),f&&(clearTimeout(f),f=null),_(c,!1)}return L(I(T,$(n,x,o,R,l,i,p),$(t,s,r),B(([[H,y,k,u,g,C,z,O],V,N,Z])=>{const F=$n(H),{align:mt,behavior:q,offset:Q}=F,gt=u-1,ut=Nn(F,y,gt);let xt=ce(ut,y.offsetTree,V)+C;"end"===mt?(xt+=N+Rt(y.sizeTree,ut)[1]-k+Z,ut===gt&&(xt+=z)):"center"===mt?xt+=(N+Rt(y.sizeTree,ut)[1]-k+Z)/2:xt-=g,void 0!==Q&&0!==Q&&(xt+=Q);const Ft=pt=>{S(),pt?(O("retrying to scroll to",{location:H},ft_DEBUG),_(T,H)):(_(w,!0),O("list did not change, scroll successful",{},ft_DEBUG))};if(S(),"smooth"===q){let pt=!1;a=Y(e,Kt=>{pt=pt||Kt}),h=yt(m,()=>{Ft(pt)})}else h=yt(I(e,function(t){return e=>{const n=setTimeout(()=>{e(!1)},t);return o=>{o&&(e(!0),clearTimeout(n))}}}(150)),Ft);return f=setTimeout(()=>{S()},1200),_(c,!0),O("scrolling from index to",{behavior:q,index:ut,top:xt},ft_DEBUG),{behavior:q,top:xt}})),d),{scrollTargetReached:w,scrollToIndex:T,topListHeight:R}},ot(Lt,It,Gt),{singleton:!0});function Ue(t,e){0===t?e():requestAnimationFrame(()=>{Ue(t-1,e)})}function Ke(t,e){const n=e-1;return"number"==typeof t?t:"LAST"===t.index?n:t.index}const me=j(([{defaultItemSize:t,listRefresh:e,sizes:n},{scrollTop:o},{scrollTargetReached:r,scrollToIndex:s},{didMount:i}])=>{const l=v(!0),c=v(0),d=v(!0);return L(I(i,$(c),W(([m,x])=>0!==x),Bt(!1)),l),L(I(i,$(c),W(([m,x])=>0!==x),Bt(!1)),d),Y(I(at(e,i),$(l,n,t,d),W(([[,m],x,{sizeTree:p},T,w])=>m&&(!J(p)||Ae(T))&&!x&&!w),$(c)),([,m])=>{yt(r,()=>{_(d,!0)}),Ue(4,()=>{yt(o,()=>{_(l,!0)}),_(s,m)})}),{initialItemFinalLocationReached:d,initialTopMostItemIndex:c,scrolledToInitialItem:l}},ot(Lt,It,fe,At),{singleton:!0});function Un(t,e){return Math.abs(t-e)<1.01}const ue="up",ne="down",Ao={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},pe=j(([{footerHeight:t,headerHeight:e,scrollBy:n,scrollContainerState:o,scrollTop:r,viewportHeight:s}])=>{const i=v(!1),l=v(!0),c=U(),d=U(),m=v(4),x=v(0),p=ht(I(ze(I(P(r),$t(1),Bt(!0)),I(P(r),$t(1),Bt(!1),dn(100))),et()),!1),T=ht(I(ze(I(n,Bt(!0)),I(n,Bt(!1),dn(200))),et()),!1);L(I(at(P(r),P(x)),B(([a,S])=>a<=S),et()),l),L(I(l,zt(50)),d);const w=vt(I(at(o,P(s),P(e),P(t),P(m)),Ot((a,[{scrollHeight:S,scrollTop:H},y,k,u,g])=>{const z={scrollHeight:S,scrollTop:H,viewportHeight:y};if(H+y-S>-g){let V,N;return H>a.state.scrollTop?(V="SCROLLED_DOWN",N=a.state.scrollTop-H):(V="SIZE_DECREASED",N=a.state.scrollTop-H||a.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:N,state:z}}let O;return O=z.scrollHeight>a.state.scrollHeight?"SIZE_INCREASED":y<a.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":H<a.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:O,state:z}},Ao),et((a,S)=>void 0!==a&&a.atBottom===S.atBottom))),R=ht(I(o,Ot((a,{scrollHeight:S,scrollTop:H,viewportHeight:y})=>{if(!Un(a.scrollHeight,S)){const k=S-(H+y)<1;return a.scrollTop!==H&&k?{changed:!0,jump:a.scrollTop-H,scrollHeight:S,scrollTop:H}:{changed:!0,jump:0,scrollHeight:S,scrollTop:H}}return{changed:!1,jump:0,scrollHeight:S,scrollTop:H}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),W(a=>a.changed),B(a=>a.jump)),0);L(I(w,B(a=>a.atBottom)),i),L(I(i,zt(50)),c);const h=v(ne);L(I(o,B(({scrollTop:a})=>a),et(),Ot((a,S)=>it(T)?{direction:a.direction,prevScrollTop:S}:{direction:S<a.prevScrollTop?ue:ne,prevScrollTop:S},{direction:ne,prevScrollTop:0}),B(a=>a.direction)),h),L(I(o,zt(50),Bt("none")),h);const f=v(0);return L(I(p,W(a=>!a),Bt(0)),f),L(I(r,zt(100),$(p),W(([a,S])=>S),Ot(([a,S],[H])=>[S,H],[0,0]),B(([a,S])=>S-a)),f),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:m,atTopStateChange:d,atTopThreshold:x,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:R,scrollDirection:h,scrollVelocity:f}},ot(It)),ae="top",de="bottom";function gn(t,e,n){return"number"==typeof t?n===ue&&e===ae||n===ne&&e===de?t:0:n===ue?e===ae?t.main:t.reverse:e===de?t.main:t.reverse}function In(t,e){return"number"==typeof t?t:t[e]??0}const je=j(([{deviation:t,fixedHeaderHeight:e,headerHeight:n,scrollTop:o,viewportHeight:r}])=>{const s=U(),i=v(0),l=v(0),c=v(0);return{increaseViewportBy:l,listBoundary:s,overscan:c,topListHeight:i,visibleRange:ht(I(at(P(o),P(r),P(n),P(s,le),P(c),P(i),P(e),P(t),P(l)),B(([m,x,p,[T,w],R,h,f,a,S])=>{const H=m-a,y=h+f,k=Math.max(p-H,0);let u="none";const g=In(S,ae),C=In(S,de);return T-=a,w+=p+f,(T+=p+f)>m+y-g&&(u=ue),(w-=a)<m-k+x+C&&(u=ne),"none"!==u?[Math.max(H-p-gn(R,ae,u)-g,0),H-k-f+x+gn(R,de,u)+C]:null}),W(m=>null!==m),et(le)),[0,0])}},ot(It),{singleton:!0});const Be={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Te(t,e,n,o,r,s){const{lastIndex:i,lastOffset:l,lastSize:c}=r;let d=0,m=0;if(t.length>0){d=t[0].offset;const R=t[t.length-1];m=R.offset+R.size}const x=n-i,T=d,w=l+x*c+(x-1)*o-m;return{bottom:m,firstItemIndex:s,items:xn(t,r,s),offsetBottom:w,offsetTop:d,top:T,topItems:xn(e,r,s),topListHeight:e.reduce((R,h)=>h.size+R,0),totalCount:n}}function Kn(t,e,n,o,r,s){let i=0;if(n.groupIndices.length>0)for(const m of n.groupIndices){if(m-i>=t)break;i++}const l=t+i,c=Ke(e,l);return Te(Array.from({length:l}).map((m,x)=>({data:s[x+c],index:x+c,offset:0,size:0})),[],l,r,n,o)}function xn(t,e,n){if(0===t.length)return[];if(!be(e))return t.map(d=>({...d,index:d.index+n,originalIndex:d.index}));const o=t[0].index,r=t[t.length-1].index,s=[],i=Yt(e.groupOffsetTree,o,r);let l,c=0;for(const d of t){let m;(!l||l.end<d.index)&&(l=i.shift(),c=e.groupIndices.indexOf(l.start)),m=d.index===l.start?{index:c,type:"group"}:{groupIndex:c,index:d.index-(c+1)+n},s.push({...m,data:d.data,offset:d.offset,originalIndex:d.index,size:d.size})}return s}function Sn(t,e){return void 0===t?0:"number"==typeof t?t:t[e]??0}const Ut=j(([{data:t,firstItemIndex:e,gap:n,sizes:o,totalCount:r},s,{listBoundary:i,topListHeight:l,visibleRange:c},{initialTopMostItemIndex:d,scrolledToInitialItem:m},{topListHeight:x},p,{didMount:T},{recalcInProgress:w}])=>{const R=v([]),h=v(0),f=U(),a=v(0);L(s.topItemsIndexes,R);const S=ht(I(at(T,w,P(c,le),P(r),P(o),P(d),m,P(R),P(e),P(n),P(a),t),W(([u,g,,C,,,,,,,,z])=>{const O=void 0!==z&&z.length!==C;return u&&!g&&!O}),B(([,,[u,g],C,z,O,V,N,Z,F,mt,q])=>{var _a,_b;const Q=z,{offsetTree:gt,sizeTree:ut}=Q,xt=it(h);if(0===C)return{...Be,totalCount:C};if(0===u&&0===g)return 0===xt?{...Be,totalCount:C}:Kn(xt,O,z,Z,F,q||[]);if(J(ut))return xt>0?null:Te(function(t,e,n){if(be(e)){const o=_n(t,e);return[{index:Rt(e.groupOffsetTree,o)[0],offset:0,size:0},{data:null==n?void 0:n[0],index:o,offset:0,size:0}]}return[{data:null==n?void 0:n[0],index:t,offset:0,size:0}]}(Ke(O,C),Q,q),[],C,F,Q,Z);const Ft=[];if(N.length>0){const D=N[0],K=N[N.length-1];let rt=0;for(const tt of Yt(ut,D,K)){const X=tt.value,lt=Math.max(tt.start,D),St=Math.min(tt.end,K);for(let ct=lt;ct<=St;ct++)Ft.push({data:null==q?void 0:q[ct],index:ct,offset:rt,size:X}),rt+=X}}if(!V)return Te([],Ft,C,F,Q,Z);const pt=N.length>0?N[N.length-1]+1:0,Kt=Bo(gt,u,g,pt);if(0===Kt.length)return null;const Qt=C-1,Et=ye([],D=>{for(const K of Kt){const rt=K.value;let tt=rt.offset,X=K.start;const lt=rt.size;if(rt.offset<u){X+=Math.floor((u-rt.offset+F)/(lt+F));const ct=X-K.start;tt+=ct*lt+ct*F}X<pt&&(tt+=(pt-X)*lt,X=pt);const St=Math.min(K.end,Qt);for(let ct=X;ct<=St&&!(tt>=g);ct++)D.push({data:null==q?void 0:q[ct],index:ct,offset:tt,size:lt}),tt+=lt+F}}),te=Sn(mt,ae),b=Sn(mt,de);if(Et.length>0&&(te>0||b>0)){const D=Et[0],K=Et[Et.length-1];if(te>0&&D.index>pt){const rt=Math.min(te,D.index-pt),tt=[];let X=D.offset;for(let lt=D.index-1;lt>=D.index-rt;lt--){const ct=(null==(_a=Yt(ut,lt,lt)[0])?void 0:_a.value)??D.size;X-=ct+F,tt.unshift({data:null==q?void 0:q[lt],index:lt,offset:X,size:ct})}Et.unshift(...tt)}if(b>0&&K.index<Qt){const rt=Math.min(b,Qt-K.index);let tt=K.offset+K.size+F;for(let X=K.index+1;X<=K.index+rt;X++){const St=(null==(_b=Yt(ut,X,X)[0])?void 0:_b.value)??K.size;Et.push({data:null==q?void 0:q[X],index:X,offset:tt,size:St}),tt+=St+F}}}return Te(Et,Ft,C,F,Q,Z)}),W(u=>null!==u),et()),Be);L(I(t,W(Ae),B(u=>null==u?void 0:u.length)),r),L(I(S,B(u=>u.topListHeight)),x),L(x,l),L(I(S,B(u=>[u.top,u.bottom])),i),L(I(S,B(u=>u.items)),f);const H=vt(I(S,W(({items:u})=>u.length>0),$(r,t),W(([{items:u},g])=>u[u.length-1].originalIndex===g-1),B(([,u,g])=>[u-1,g]),et(le),B(([u])=>u))),y=vt(I(S,zt(200),W(({items:u,topItems:g})=>u.length>0&&u[0].originalIndex===g.length),B(({items:u})=>u[0].index),et())),k=vt(I(S,W(({items:u})=>u.length>0),B(({items:u})=>{let g=0,C=u.length-1;for(;"group"===u[g].type&&g<C;)g++;for(;"group"===u[C].type&&C>g;)C--;return{endIndex:u[C].index,startIndex:u[g].index}}),et(An)));return{endReached:H,initialItemCount:h,itemsRendered:f,listState:S,minOverscanItemCount:a,rangeChanged:k,startReached:y,topItemsIndexes:R,...p}},ot(Lt,Dn,je,me,fe,pe,At,De),{singleton:!0}),jn=j(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:n,headerHeight:o},{listState:r}])=>{const s=U(),i=ht(I(at(n,t,o,e,r),B(([l,c,d,m,x])=>l+c+d+m+x.offsetBottom+x.bottom)),0);return L(P(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(It,Ut),{singleton:!0}),No=j(([{viewportHeight:t},{totalListHeight:e}])=>{const n=v(!1);return{alignToBottom:n,paddingTopAddition:ht(I(at(n,t,e),W(([r])=>r),B(([,r,s])=>Math.max(0,r-s)),zt(0),et()),0)}},ot(It,jn),{singleton:!0}),qn=j(()=>({context:v(null)})),Do=({itemBottom:t,itemTop:e,locationParams:{align:n,behavior:o,...r},viewportBottom:s,viewportTop:i})=>e<i?{...r,align:n??"start",...void 0!==o?{behavior:o}:{}}:t>s?{...r,align:n??"end",...void 0!==o?{behavior:o}:{}}:null,Yn=j(([{gap:t,sizes:e,totalCount:n},{fixedFooterHeight:o,fixedHeaderHeight:r,headerHeight:s,scrollingInProgress:i,scrollTop:l,viewportHeight:c},{scrollToIndex:d}])=>{const m=U();return L(I(m,$(e,c,n,s,r,o,l),$(t),B(([[x,p,T,w,R,h,f,a],S])=>{const{calculateViewLocation:H=Do,done:y,...k}=x,u=Nn(x,p,w-1),g=ce(u,p.offsetTree,S)+R+h,V=H({itemBottom:g+Rt(p.sizeTree,u)[1],itemTop:g,locationParams:k,viewportBottom:a+T-f,viewportTop:a+h});return null!==V?y&&yt(I(i,W(N=>!N),$t(it(i)?1:2)),y):null==y||y(),V}),W(x=>null!==x)),d),{scrollIntoView:m}},ot(Lt,It,fe,Ut,Gt),{singleton:!0});function Tn(t){return!1!==t&&("smooth"===t?"smooth":"auto")}const Uo=j(([{listRefresh:t,totalCount:e,fixedItemSize:n,data:o},{atBottomState:r,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:c,propsReady:d},{log:m},{scrollingInProgress:x},{context:p},{scrollIntoView:T}])=>{const w=v(!1),R=U();let h=null;function f(y){_(i,{align:"end",behavior:y,index:"LAST"})}function a(y){const k=yt(r,u=>{y&&!u.atBottom&&"SIZE_INCREASED"===u.notAtBottomBecause&&null===h&&(it(m)("scrolling to bottom due to increased size",{},ft_DEBUG),f("auto"))});setTimeout(k,100)}Y(I(at(I(P(e),$t(1)),c),$(P(w),s,l,x),B(([[y,k],u,g,C,z])=>{let O=k&&C,V="auto";return O&&(V=((t,e)=>"function"==typeof t?Tn(t(e)):e&&Tn(t))(u,g||z),O=O&&!1!==V),{followOutputBehavior:V,shouldFollow:O,totalCount:y}}),W(({shouldFollow:y})=>y)),({followOutputBehavior:y,totalCount:k})=>{null!==h&&(h(),h=null),void 0!==it(n)?requestAnimationFrame(()=>{it(m)("following output to ",{totalCount:k},ft_DEBUG),f(y)}):h=yt(t,()=>{it(m)("following output to ",{totalCount:k},ft_DEBUG),f(y),h=null})}),Y(I(at(P(w),e,d),W(([y,,k])=>!1!==y&&k),Ot(({value:y},[,k])=>({refreshed:y===k,value:k}),{refreshed:!1,value:0}),W(({refreshed:y})=>y),$(w,e)),([,y])=>{it(l)&&a(!1!==y)}),Y(R,()=>{a(!1!==it(w))}),Y(at(P(w),r),([y,k])=>{!1!==y&&!k.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===k.notAtBottomBecause&&f("auto")});const S=v(null),H=U();return L(ze(I(P(o),B(y=>(null==y?void 0:y.length)??0)),I(P(e))),H),Y(I(at(I(H,$t(1)),c),$(P(S),l,x,p),B(([[y,k],u,g,C,z])=>k&&g&&(null==u?void 0:u({context:z,totalCount:y,scrollingInProgress:C}))),W(y=>!!y),zt(0)),y=>{null!==h&&(h(),h=null),void 0!==it(n)?requestAnimationFrame(()=>{it(m)("scrolling into view",{}),_(T,y)}):h=yt(t,()=>{it(m)("scrolling into view",{}),_(T,y),h=null})}),{autoscrollToBottom:R,followOutput:w,scrollIntoViewOnChange:S}},ot(Lt,pe,fe,me,At,Gt,It,qn,Yn)),Ko=j(([{data:t,firstItemIndex:e,gap:n,sizes:o},{initialTopMostItemIndex:r},{initialItemCount:s,listState:i},{didMount:l}])=>(L(I(l,$(s),W(([,c])=>0!==c),$(r,o,e,n,t),B(([[,c],d,m,x,p,T=[]])=>Kn(c,d,m,x,p,T))),i),{}),ot(Lt,me,Ut,At),{singleton:!0}),jo=j(([{didMount:t},{scrollTo:e},{listState:n}])=>{const o=v(0);return Y(I(t,$(o),W(([,r])=>0!==r),B(([,r])=>({top:r}))),r=>{yt(I(n,$t(1),W(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_(e,r)})})}),{initialScrollTop:o}},ot(At,It,Ut),{singleton:!0}),Zn=j(([{scrollVelocity:t}])=>{const e=v(!1),n=U(),o=v(!1);return L(I(t,$(o,e,n),W(([r,s])=>!1!==s&&void 0!==s),B(([r,s,i,l])=>{const{enter:c,exit:d}=s;if(i){if(d(r,l))return!1}else if(c(r,l))return!0;return i}),et()),e),Y(I(at(e,t,n),$(o)),([[r,s,i],l])=>{r&&!1!==l&&void 0!==l&&l.change&&l.change(s,i)}),{isSeeking:e,scrollSeekConfiguration:o,scrollSeekRangeChanged:n,scrollVelocity:t}},ot(pe),{singleton:!0}),qe=j(([{scrollContainerState:t,scrollTo:e}])=>{const n=U(),o=U(),r=U(),s=v(!1),i=v(void 0);return L(I(at(n,o),B(([{scrollTop:l,viewportHeight:c},{offsetTop:d,listHeight:m}])=>({scrollHeight:m,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),L(I(e,$(o),B(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),r),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:r,windowViewportRect:o}},ot(It)),qo=j(([{sizeRanges:t,sizes:e},{headerHeight:n,scrollTop:o},{initialTopMostItemIndex:r},{didMount:s},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:c}])=>{const d=U(),m=v(void 0),x=v(null),p=v(null);return L(l,x),L(c,p),Y(I(d,$(e,o,i,x,p,n)),([T,w,R,h,f,a,S])=>{const H=function(t){return _t(t).map(({k:e,v:n},o,r)=>{const s=r[o+1];return{endIndex:void 0!==s?s.k-1:1/0,size:n,startIndex:e}})}(w.sizeTree);h&&null!==f&&null!==a&&(R=f.scrollTop-a.offsetTop),T({ranges:H,scrollTop:R-=S})}),L(I(m,W(Ae),B(Yo)),r),L(I(s,$(m),W(([,T])=>void 0!==T),et(),B(([,T])=>T.ranges)),t),{getState:d,restoreStateFrom:m}},ot(Lt,It,me,At,qe));function Yo(t){return{align:"start",index:0,offset:t.scrollTop}}const Zo=j(([{topItemsIndexes:t}])=>{const e=v(0);return L(I(e,W(n=>n>=0),B(n=>Array.from({length:n}).map((o,r)=>r))),t),{topItemCount:e}},ot(Ut));function Xn(t){let n,e=!1;return()=>(e||(e=!0,n=t()),n)}const Xo=Xn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jo=j(([{deviation:t,scrollBy:e,scrollingInProgress:n,scrollTop:o},{isAtBottom:r,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:l},{listState:c},{beforeUnshiftWith:d,gap:m,shiftWithOffset:x,sizes:p},{log:T},{recalcInProgress:w}])=>{const R=vt(I(c,$(i),Ot(([,f,a,S],[{bottom:H,items:y,offsetBottom:k,totalCount:u},g])=>{const C=H+k;let z=0;return a===u&&f.length>0&&y.length>0&&(0===y[0].originalIndex&&0===f[0].originalIndex||(z=C-S,0!==z&&(z+=g))),[z,y,u,C]},[0,[],0,0]),W(([f])=>0!==f),$(o,l,n,r,T,w),W(([,f,a,S,,,H])=>!H&&!S&&0!==f&&a===ue),B(([[f],,,,,a])=>(a("Upward scrolling compensation",{amount:f},ft_DEBUG),f))));function h(f){f>0?(_(e,{behavior:"auto",top:-f}),_(t,0)):(_(t,0),_(e,{behavior:"auto",top:-f}))}return Y(I(R,$(t,s)),([f,a,S])=>{S&&Xo()?_(t,a-f):h(-f)}),Y(I(at(ht(s,!1),t,w),W(([f,a,S])=>!f&&!S&&0!==a),B(([f,a])=>a),zt(1)),h),L(I(x,B(f=>({top:-f}))),e),Y(I(d,$(p,m),B(([f,{groupIndices:a,lastSize:S,sizeTree:H},y])=>{function k(O){return O*(S+y)}if(0===a.length)return k(f);let u=0;const g=ie(H,0);let C=0,z=0;for(;C<f;){C++,u+=g;let O=a.length===z+1?1/0:a[z+1]-a[z]-1;C+O>f&&(u-=g,O=f-C+1),C+=O,u+=k(O),z++}return u})),f=>{_(t,f),requestAnimationFrame(()=>{_(e,{top:f}),requestAnimationFrame(()=>{_(t,0),_(w,!1)})})}),{deviation:t}},ot(It,pe,Ut,Lt,Gt,De)),Qo=j(([t,e,n,o,r,s,i,l,c,d,m])=>({...t,...e,...n,...o,...r,...s,...i,...l,...c,...d,...m}),ot(je,Ko,At,Zn,jn,jo,No,qe,Yn,Gt,qn)),Jn=j(([{data:t,defaultItemSize:e,firstItemIndex:n,fixedItemSize:o,fixedGroupSize:r,gap:s,groupIndices:i,heightEstimates:l,itemSize:c,sizeRanges:d,sizes:m,statefulTotalCount:x,totalCount:p,trackItemSizes:T},{initialItemFinalLocationReached:w,initialTopMostItemIndex:R,scrolledToInitialItem:h},f,a,S,H,{scrollToIndex:y},k,{topItemCount:u},{groupCounts:g},C])=>{const{listState:z,minOverscanItemCount:O,topItemsIndexes:V,rangeChanged:N,...Z}=H;return L(N,C.scrollSeekRangeChanged),L(I(C.windowViewportRect,B(F=>F.visibleHeight)),f.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:n,fixedItemHeight:o,fixedGroupHeight:r,gap:s,groupCounts:g,heightEstimates:l,initialItemFinalLocationReached:w,initialTopMostItemIndex:R,scrolledToInitialItem:h,sizeRanges:d,topItemCount:u,topItemsIndexes:V,totalCount:p,...S,groupIndices:i,itemSize:c,listState:z,minOverscanItemCount:O,scrollToIndex:y,statefulTotalCount:x,trackItemSizes:T,rangeChanged:N,...Z,...C,...f,sizes:m,...a}},ot(Lt,me,It,qo,Uo,Ut,fe,Jo,Zo,Dn,Qo));function tr(t,e){const n={},o={};let r=0;const s=t.length;for(;r<s;)o[t[r]]=1,r+=1;for(const i in e)Object.hasOwn(o,i)||(n[i]=e[i]);return n}const Ie=typeof document<"u"?React.useLayoutEffect:React.useEffect;function Ye(t,e,n){const o=Object.keys(e.required||{}),r=Object.keys(e.optional||{}),s=Object.keys(e.methods||{}),i=Object.keys(e.events||{}),l=React.createContext({});function c(f,a){void 0!==f.propsReady&&_(f.propsReady,!1);for(const S of o){_(f[e.required[S]],a[S])}for(const S of r)if(S in a){_(f[e.optional[S]],a[S])}void 0!==f.propsReady&&_(f.propsReady,!0)}function m(f){return i.reduce((a,S)=>(a[S]=function(t){let e,n;const o=()=>null==e?void 0:e();return function(r,s){switch(r){case 1:return s?n===s?void 0:(o(),n=s,e=Y(t,s),e):(o(),Xt);case 2:return o(),void(n=null)}}}(f[e.events[S]]),a),{})}const x=React.forwardRef(function(a,S){const{children:H,...y}=a,[k]=React.useState(()=>ye(function(t){const e=new Map,n=({constructor:o,dependencies:r,id:s,singleton:i})=>{if(i&&e.has(s))return e.get(s);const l=o(r.map(c=>n(c)));return i&&e.set(s,l),l};return n(t)}(t),C=>{c(C,y)})),[u]=React.useState(an(m,k));var f;Ie(()=>{for(const C of i)C in y&&Y(u[C],y[C]);return()=>{Object.values(u).map(Me)}},[y,u,k]),Ie(()=>{c(k,y)}),React.useImperativeHandle(S,un((f=k,s.reduce((a,S)=>(a[S]=H=>{_(f[e.methods[S]],H)},a),{}))));const g=n;return jsxRuntimeExports.jsx(l.Provider,{value:k,children:void 0!==n?jsxRuntimeExports.jsx(g,{...tr([...o,...r,...i],y),children:H}):H})});return{Component:x,useEmitter:(f,a)=>{const H=React.useContext(l)[f];Ie(()=>Y(H,a),[a,H])},useEmitterValue:React.version.startsWith("18")?f=>{const S=React.useContext(l)[f],H=React.useCallback(y=>Y(S,y),[S]);return React.useSyncExternalStore(H,()=>it(S),()=>it(S))}:f=>{const S=React.useContext(l)[f],[H,y]=React.useState(an(it,S));return Ie(()=>Y(S,k=>{k!==H&&y(un(k))}),[S,H]),H},usePublisher:f=>{const a=React.useContext(l);return React.useCallback(S=>{_(a[f],S)},[a,f])}}}const Re=React.createContext(void 0),Qn=React.createContext(void 0),Oe="-webkit-sticky",Ze=Xn(()=>{if(typeof document>"u")return"sticky";const t=document.createElement("div");return t.style.position=Oe,t.style.position===Oe?Oe:"sticky"}),to=typeof document<"u"?React.useLayoutEffect:React.useEffect;function ke(t){return"self"in t}function eo(t,e,n,o=Xt,r,s){const i=React.useRef(null),l=React.useRef(null),c=React.useRef(null),d=React.useCallback(p=>{let T,w,R;const h=p.target;if(function(t){return"body"in t}(h)||ke(h)){const a=ke(h)?h:h.defaultView;R=!0===s?a.scrollX:a.scrollY,T=!0===s?a.document.documentElement.scrollWidth:a.document.documentElement.scrollHeight,w=!0===s?a.innerWidth:a.innerHeight}else R=!0===s?h.scrollLeft:h.scrollTop,T=!0===s?h.scrollWidth:h.scrollHeight,w=!0===s?h.offsetWidth:h.offsetHeight;const f=()=>{t({scrollHeight:T,scrollTop:Math.max(R,0),viewportHeight:w})};!0===p.suppressFlushSync?f():ReactDOM.flushSync(f),null!==l.current&&(R===l.current||R<=0||R===T-w)&&(l.current=null,e(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,e,s]);return React.useEffect(()=>{const p=r||i.current;return o(r||i.current),d({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",d,{passive:!0}),()=>{o(null),p.removeEventListener("scroll",d)}},[i,d,n,o,r]),{scrollByCallback:function(p){!0===s&&(p={...void 0!==p.behavior?{behavior:p.behavior}:{},...void 0!==p.top?{left:p.top}:{}}),i.current.scrollBy(p)},scrollerRef:i,scrollToCallback:function(p){const T=i.current;if(!T||(!0===s?"offsetWidth"in T&&0===T.offsetWidth:"offsetHeight"in T&&0===T.offsetHeight))return;const w="smooth"===p.behavior;let R,h,f;ke(T)?(h=Math.max(Ht(T.document.documentElement,!0===s?"width":"height"),!0===s?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight),R=!0===s?T.innerWidth:T.innerHeight,f=!0===s?window.scrollX:window.scrollY):(h=T[!0===s?"scrollWidth":"scrollHeight"],R=Ht(T,!0===s?"width":"height"),f=T[!0===s?"scrollLeft":"scrollTop"]);const a=h-R;if(p.top=Math.ceil(Math.max(Math.min(a,p.top),0)),Un(R,h)||p.top===f)return t({scrollHeight:h,scrollTop:f,viewportHeight:R}),void(w&&e(!0));w?(l.current=p.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,e(!0)},1e3)):l.current=null,!0===s&&(p={...void 0!==p.behavior?{behavior:p.behavior}:{},left:p.top}),T.scrollTo(p)}}}function Xe(t){return t}const or=j(([t,e])=>({...t,...e}),ot(Jn,j(()=>{const t=v(l=>`Item ${l}`),e=v(l=>`Group ${l}`),n=v({}),o=v(Xe),r=v("div"),s=v(Xt),i=(l,c=null)=>ht(I(n,B(d=>d[l]),et()),c);return{components:n,computeItemKey:o,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:e,HeaderComponent:i("Header"),HeaderFooterTag:r,ItemComponent:i("Item","div"),itemContent:t,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}))),rr=({height:t})=>jsxRuntimeExports.jsx("div",{style:{height:t}}),sr={overflowAnchor:"none",position:Ze(),zIndex:1},no={overflowAnchor:"none"},ir={...no,display:"inline-block",height:"100%"},Cn=React.memo(function({showTopList:e=!1}){const n=A("listState"),o=Ct("sizeRanges"),r=A("useWindowScroll"),s=A("customScrollParent"),i=Ct("windowScrollContainerState"),l=Ct("scrollContainerState"),c=s||r?i:l,d=A("itemContent"),m=A("context"),x=A("groupContent"),p=A("trackItemSizes"),T=A("itemSize"),w=A("log"),R=Ct("gap"),h=A("horizontalDirection"),{callbackRef:f}=zn(o,T,p,e?Xt:c,w,R,s,h,A("skipAnimationFrameInResizeObserver")),[a,S]=React.useState(0);tn("deviation",F=>{a!==F&&S(F)});const H=A("EmptyPlaceholder"),y=A("ScrollSeekPlaceholder")??rr,k=A("ListComponent"),u=A("ItemComponent"),g=A("GroupComponent"),C=A("computeItemKey"),z=A("isSeeking"),O=A("groupIndices").length>0,V=A("alignToBottom"),N=A("initialItemFinalLocationReached"),Z=e?{}:{boxSizing:"border-box",...h?{display:"inline-block",height:"100%",marginLeft:0!==a?a:V?"auto":0,paddingLeft:n.offsetTop,paddingRight:n.offsetBottom,whiteSpace:"nowrap"}:{marginTop:0!==a?a:V?"auto":0,paddingBottom:n.offsetBottom,paddingTop:n.offsetTop},...N?{}:{visibility:"hidden"}};return e||0!==n.totalCount||null==H?jsxRuntimeExports.jsx(k,{...nt(k,m),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:f,style:Z,children:(e?n.topItems:n.items).map(F=>{const mt=F.originalIndex,q=C(mt+n.firstItemIndex,F.data,m);return z?reactExports.createElement(y,{...nt(y,m),height:F.size,index:F.index,key:q,type:F.type||"item",..."group"===F.type?{}:{groupIndex:F.groupIndex}}):"group"===F.type?reactExports.createElement(g,{...nt(g,m),"data-index":mt,"data-item-index":F.index,"data-known-size":F.size,key:q,style:sr},x(F.index,m)):reactExports.createElement(u,{...nt(u,m),...oo(u,F.data),"data-index":mt,"data-item-group-index":F.groupIndex,"data-item-index":F.index,"data-known-size":F.size,key:q,style:h?ir:no},O?d(F.index,F.groupIndex,F.data,m):d(F.index,F.data,m))})}):jsxRuntimeExports.jsx(H,{...nt(H,m)})}),lr={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},cr={outline:"none",overflowX:"auto",position:"relative"},Jt=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),ur={position:Ze(),top:0,width:"100%",zIndex:1};function nt(t,e){if("string"!=typeof t)return{context:e}}function oo(t,e){return{item:"string"==typeof t?void 0:e}}const ar=React.memo(function(){const e=A("HeaderComponent"),n=Ct("headerHeight"),o=A("HeaderFooterTag"),r=kt(React.useMemo(()=>i=>{n(Ht(i,"height"))},[n]),!0,A("skipAnimationFrameInResizeObserver")),s=A("context");return null!=e?jsxRuntimeExports.jsx(o,{ref:r,children:jsxRuntimeExports.jsx(e,{...nt(e,s)})}):null}),dr=React.memo(function(){const e=A("FooterComponent"),n=Ct("footerHeight"),o=A("HeaderFooterTag"),r=kt(React.useMemo(()=>i=>{n(Ht(i,"height"))},[n]),!0,A("skipAnimationFrameInResizeObserver")),s=A("context");return null!=e?jsxRuntimeExports.jsx(o,{ref:r,children:jsxRuntimeExports.jsx(e,{...nt(e,s)})}):null});function Je({useEmitter:t,useEmitterValue:e,usePublisher:n}){return React.memo(function({children:s,style:i,context:l,...c}){const d=n("scrollContainerState"),m=e("ScrollerComponent"),x=n("smoothScrollTargetReached"),p=e("scrollerRef"),T=e("horizontalDirection")||!1,{scrollByCallback:w,scrollerRef:R,scrollToCallback:h}=eo(d,x,m,p,void 0,T);return t("scrollTo",h),t("scrollBy",w),jsxRuntimeExports.jsx(m,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:R,style:{...T?cr:lr,...i},tabIndex:0,...c,...nt(m,l),children:s})})}function Qe({useEmitter:t,useEmitterValue:e,usePublisher:n}){return React.memo(function({children:s,style:i,context:l,...c}){const d=n("windowScrollContainerState"),m=e("ScrollerComponent"),x=n("smoothScrollTargetReached"),p=e("totalListHeight"),T=e("deviation"),w=e("customScrollParent"),R=React.useRef(null),h=e("scrollerRef"),{scrollByCallback:f,scrollerRef:a,scrollToCallback:S}=eo(d,x,m,h,w);return to(()=>{var _a;return a.current=w||(null==(_a=R.current)?void 0:_a.ownerDocument.defaultView),()=>{a.current=null}},[a,w]),t("windowScrollTo",S),t("scrollBy",f),jsxRuntimeExports.jsx(m,{ref:R,"data-virtuoso-scroller":!0,style:{position:"relative",...i,...0!==p?{height:p+T}:void 0},...c,...nt(m,l),children:s})})}const fr=({children:t})=>{const e=React.useContext(Re),n=Ct("viewportHeight"),o=Ct("fixedItemHeight"),r=A("alignToBottom"),s=A("horizontalDirection"),l=kt(React.useMemo(()=>re(n,c=>Ht(c,s?"width":"height")),[n,s]),!0,A("skipAnimationFrameInResizeObserver"));return React.useEffect(()=>{e&&(n(e.viewportHeight),o(e.itemHeight))},[e,n,o]),jsxRuntimeExports.jsx("div",{"data-viewport-type":"element",ref:l,style:Jt(r),children:t})},mr=({children:t})=>{const e=React.useContext(Re),n=Ct("windowViewportRect"),o=Ct("fixedItemHeight"),r=A("customScrollParent"),s=Ne(n,r,A("skipAnimationFrameInResizeObserver")),i=A("alignToBottom");return React.useEffect(()=>{e&&(o(e.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,n,o]),jsxRuntimeExports.jsx("div",{"data-viewport-type":"window",ref:s,style:Jt(i),children:t})},pr=({children:t})=>{const e=A("TopItemListComponent")??"div",n=A("headerHeight"),o={...ur,marginTop:`${n}px`},r=A("context");return jsxRuntimeExports.jsx(e,{style:o,...nt(e,r),children:t})},hr=React.memo(function(e){const n=A("useWindowScroll"),o=A("topItemsIndexes").length>0,r=A("customScrollParent"),s=A("context");return jsxRuntimeExports.jsxs(r||n?Ir:gr,{...e,context:s,children:[o&&jsxRuntimeExports.jsx(pr,{children:jsxRuntimeExports.jsx(Cn,{showTopList:!0})}),jsxRuntimeExports.jsxs(r||n?mr:fr,{children:[jsxRuntimeExports.jsx(ar,{}),jsxRuntimeExports.jsx(Cn,{}),jsxRuntimeExports.jsx(dr,{})]})]})}),{Component:ro,useEmitter:tn,useEmitterValue:A,usePublisher:Ct}=Ye(or,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},hr),gr=Je({useEmitter:tn,useEmitterValue:A,usePublisher:Ct}),Ir=Qe({useEmitter:tn,useEmitterValue:A,usePublisher:Ct}),qr=ro;ot(Jn,j(()=>{const t=v(d=>jsxRuntimeExports.jsxs("td",{children:["Item $",d]})),e=v(null),n=v(d=>jsxRuntimeExports.jsxs("td",{colSpan:1e3,children:["Group ",d]})),o=v(null),r=v(null),s=v({}),i=v(Xe),l=v(Xt),c=(d,m=null)=>ht(I(s,B(x=>x[d]),et()),m);return{components:s,computeItemKey:i,context:e,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:r,fixedHeaderContent:o,itemContent:t,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Ze();const bn={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Br={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Rn,floor:Ce,max:oe,min:Le,round:Hn}=Math;function En(t,e,n){return Array.from({length:e-t+1}).map((o,r)=>({data:null===n?null:n[r+t],index:r+t}))}function xe(t,e){return void 0!==t&&t.width===e.width&&t.height===e.height}function kr(t,e){return void 0!==t&&t.column===e.column&&t.row===e.row}const Lr=j(([{increaseViewportBy:t,listBoundary:e,overscan:n,visibleRange:o},{footerHeight:r,headerHeight:s,scrollBy:i,scrollContainerState:l,scrollTo:c,scrollTop:d,smoothScrollTargetReached:m,viewportHeight:x},p,T,{didMount:w,propsReady:R},{customScrollParent:h,useWindowScroll:f,windowScrollContainerState:a,windowScrollTo:S,windowViewportRect:H},y])=>{const k=v(0),u=v(0),g=v(bn),C=v({height:0,width:0}),z=v({height:0,width:0}),O=U(),V=U(),N=v(0),Z=v(null),F=v({column:0,row:0}),mt=U(),q=U(),Q=v(!1),gt=v(0),ut=v(!0),xt=v(!1),Ft=v(!1);Y(I(w,$(gt),W(([b,D])=>0!==D)),()=>{_(ut,!1)}),Y(I(at(w,ut,z,C,gt,xt),W(([b,D,K,rt,,tt])=>b&&!D&&0!==K.height&&0!==rt.height&&!tt)),([,,,,b])=>{_(xt,!0),Ue(1,()=>{_(O,b)}),yt(I(d),()=>{_(e,[0,0]),_(ut,!0)})}),L(I(q,W(b=>null!=b&&b.scrollTop>0),Bt(0)),u),Y(I(w,$(q),W(([,b])=>null!=b)),([,b])=>{b&&(_(C,b.viewport),_(z,b.item),_(F,b.gap),b.scrollTop>0&&(_(Q,!0),yt(I(d,$t(1)),D=>{_(Q,!1)}),_(c,{top:b.scrollTop})))}),L(I(C,B(({height:b})=>b)),x),L(I(at(P(C,xe),P(z,xe),P(F,(b,D)=>void 0!==b&&b.column===D.column&&b.row===D.row),P(d)),B(([b,D,K,rt])=>({gap:K,item:D,scrollTop:rt,viewport:b}))),mt),L(I(at(P(k),o,P(F,kr),P(z,xe),P(C,xe),P(Z),P(u),P(Q),P(ut),P(gt)),W(([,,,,,,,b])=>!b),B(([b,[D,K],rt,tt,X,lt,St,,ct,Vt])=>{const{column:Pt,row:ee}=rt,{height:he,width:He}=tt,{width:nn}=X;if(0===St&&(0===b||0===nn))return bn;if(0===He){const cn=Ke(Vt,b);return function(t){return{...Br,items:t}}(En(cn,cn+Math.max(St-1,0),lt))}const ge=io(nn,He,Pt);let jt,Mt;ct?0===D&&0===K&&St>0?(jt=0,Mt=St-1):(jt=ge*Ce((D+ee)/(he+ee)),Mt=ge*Rn((K+ee)/(he+ee))-1,Mt=Le(b-1,oe(Mt,ge-1)),jt=Le(Mt,oe(0,jt))):(jt=0,Mt=-1);const on=En(jt,Mt,lt),{bottom:rn,top:sn}=Bn(X,rt,tt,on),ln=Rn(b/ge);return{bottom:rn,itemHeight:he,items:on,itemWidth:He,offsetBottom:ln*he+(ln-1)*ee-rn,offsetTop:sn,top:sn}})),g),L(I(Z,W(b=>null!==b),B(b=>b.length)),k),L(I(at(C,z,g,F),W(([b,D,{items:K}])=>K.length>0&&0!==D.height&&0!==b.height),B(([b,D,{items:K},rt])=>{const{bottom:tt,top:X}=Bn(b,rt,D,K);return[X,tt]}),et(le)),e);const pt=v(!1);L(I(d,$(pt),B(([b,D])=>D||0!==b)),pt);const Kt=vt(I(at(g,k),W(([{items:b}])=>b.length>0),$(pt),W(([[b,D],K])=>{const tt=b.items[b.items.length-1].index===D-1;return(K||b.bottom>0&&b.itemHeight>0&&0===b.offsetBottom&&b.items.length===D)&&tt}),B(([[,b]])=>b-1),et())),Qt=vt(I(P(g),W(({items:b})=>b.length>0&&0===b[0].index),Bt(0),et())),Et=vt(I(P(g),$(Q),W(([{items:b},D])=>b.length>0&&!D),B(([{items:b}])=>({endIndex:b[b.length-1].index,startIndex:b[0].index})),et(An),zt(0)));L(Et,T.scrollSeekRangeChanged),L(I(O,$(C,z,k,F),B(([b,D,K,rt,tt])=>{const X=$n(b),{align:lt,behavior:St,offset:ct}=X;let Vt=X.index;"LAST"===Vt&&(Vt=rt-1),Vt=oe(0,Vt,Le(rt-1,Vt));let Pt=Ge(D,tt,K,Vt);return"end"===lt?Pt=Hn(Pt-D.height+K.height):"center"===lt&&(Pt=Hn(Pt-D.height/2+K.height/2)),void 0!==ct&&0!==ct&&(Pt+=ct),{behavior:St,top:Pt}})),c);const te=ht(I(g,B(b=>b.offsetBottom+b.bottom)),0);return L(I(H,B(b=>({height:b.visibleHeight,width:b.visibleWidth}))),C),{customScrollParent:h,data:Z,deviation:N,footerHeight:r,gap:F,headerHeight:s,increaseViewportBy:t,initialItemCount:u,itemDimensions:z,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:l,scrollHeight:V,scrollTo:c,scrollToIndex:O,scrollTop:d,smoothScrollTargetReached:m,totalCount:k,useWindowScroll:f,viewportDimensions:C,windowScrollContainerState:a,windowScrollTo:S,windowViewportRect:H,...T,gridState:g,horizontalDirection:Ft,initialTopMostItemIndex:gt,totalListHeight:te,...p,endReached:Kt,propsReady:R,rangeChanged:Et,startReached:Qt,stateChanged:mt,stateRestoreInProgress:Q,...y}},ot(je,It,pe,Zn,At,qe,Gt));function io(t,e,n){return oe(1,Ce((t+n)/(Ce(e)+n)))}function Bn(t,e,n,o){const{height:r}=n;if(void 0===r||0===o.length)return{bottom:0,top:0};const s=Ge(t,e,n,o[0].index);return{bottom:Ge(t,e,n,o[o.length-1].index)+r,top:s}}function Ge(t,e,n,o){const r=io(t.width,n.width,e.column),s=Ce(o/r),i=s*n.height+oe(0,s-1)*e.row;return i>0?i+e.row:i}const Fr=j(([t,e])=>({...t,...e}),ot(Lr,j(()=>{const t=v(x=>`Item ${x}`),e=v({}),n=v(null),o=v("virtuoso-grid-item"),r=v("virtuoso-grid-list"),s=v(Xe),i=v("div"),l=v(Xt),c=(x,p=null)=>ht(I(e,B(T=>T[x]),et()),p),d=v(!1),m=v(!1);return L(P(m),d),{components:e,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:o,ItemComponent:c("Item","div"),itemContent:t,listClassName:r,ListComponent:c("List","div"),readyStateChanged:d,reportReadyState:m,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}))),Vr=React.memo(function(){const e=st("gridState"),n=st("listClassName"),o=st("itemClassName"),r=st("itemContent"),s=st("computeItemKey"),i=st("isSeeking"),l=wt("scrollHeight"),c=st("ItemComponent"),d=st("ListComponent"),m=st("ScrollSeekPlaceholder"),x=st("context"),p=wt("itemDimensions"),T=wt("gap"),w=st("log"),R=st("stateRestoreInProgress"),h=wt("reportReadyState"),f=kt(React.useMemo(()=>a=>{const S=a.parentElement.parentElement.scrollHeight;l(S);const H=a.firstChild;if(null!==H){const{height:y,width:k}=H.getBoundingClientRect();p({height:y,width:k})}T({column:On("column-gap",getComputedStyle(a).columnGap,w),row:On("row-gap",getComputedStyle(a).rowGap,w)})},[l,p,T,w]),!0,!1);return to(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),R?null:jsxRuntimeExports.jsx(d,{className:n,ref:f,...nt(d,x),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(a=>{const S=s(a.index,a.data,x);return i?jsxRuntimeExports.jsx(m,{...nt(m,x),height:e.itemHeight,index:a.index,width:e.itemWidth},S):reactExports.createElement(c,{...nt(c,x),className:o,"data-index":a.index,key:S},r(a.index,a.data,x))})})}),Pr=React.memo(function(){const e=st("HeaderComponent"),n=wt("headerHeight"),o=st("headerFooterTag"),r=kt(React.useMemo(()=>i=>{n(Ht(i,"height"))},[n]),!0,!1),s=st("context");return null!=e?jsxRuntimeExports.jsx(o,{ref:r,children:jsxRuntimeExports.jsx(e,{...nt(e,s)})}):null}),Wr=React.memo(function(){const e=st("FooterComponent"),n=wt("footerHeight"),o=st("headerFooterTag"),r=kt(React.useMemo(()=>i=>{n(Ht(i,"height"))},[n]),!0,!1),s=st("context");return null!=e?jsxRuntimeExports.jsx(o,{ref:r,children:jsxRuntimeExports.jsx(e,{...nt(e,s)})}):null}),Gr=({children:t})=>{const e=React.useContext(Qn),n=wt("itemDimensions"),o=wt("viewportDimensions"),r=kt(React.useMemo(()=>s=>{o(s.getBoundingClientRect())},[o]),!0,!1);return React.useEffect(()=>{e&&(o({height:e.viewportHeight,width:e.viewportWidth}),n({height:e.itemHeight,width:e.itemWidth}))},[e,o,n]),jsxRuntimeExports.jsx("div",{ref:r,style:Jt(!1),children:t})},Ar=({children:t})=>{const e=React.useContext(Qn),n=wt("windowViewportRect"),o=wt("itemDimensions"),r=st("customScrollParent"),s=Ne(n,r,!1);return React.useEffect(()=>{e&&(o({height:e.itemHeight,width:e.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,n,o]),jsxRuntimeExports.jsx("div",{ref:s,style:Jt(!1),children:t})},Mr=React.memo(function({...e}){const n=st("useWindowScroll"),o=st("customScrollParent"),r=o||n?Dr:Nr,s=o||n?Ar:Gr,i=st("context");return jsxRuntimeExports.jsx(r,{...e,...nt(r,i),children:jsxRuntimeExports.jsxs(s,{children:[jsxRuntimeExports.jsx(Pr,{}),jsxRuntimeExports.jsx(Vr,{}),jsxRuntimeExports.jsx(Wr,{})]})})}),{useEmitter:lo,useEmitterValue:st,usePublisher:wt}=Ye(Fr,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Mr),Nr=Je({useEmitter:lo,useEmitterValue:st,usePublisher:wt}),Dr=Qe({useEmitter:lo,useEmitterValue:st,usePublisher:wt});function On(t,e,n){return"normal"!==e&&!0!==(null==e?void 0:e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,ft_WARN),"normal"===e?0:parseInt(e??"0",10)}export{qr as q};
@@ -1 +1 @@
1
- import{aC as adjustChannel,s as setAccDescription,g as getAccDescription,q as getDiagramTitle,p as setDiagramTitle,a as getAccTitle,b as setAccTitle,_ as __name,C as getConfig,H as selectSvgElement,d as select,ar as at,U as isDark,V as lighten,W as darken,e as configureSvgSize,y as clear,E as cleanAndMerge,F as defaultConfig_default}from"./mermaid.core-BYpzUgET.js";import"./vendor-mdxeditor-C3Q4i3LX.js";import"./vendor-antd-CyudKxuD.js";import"./vendor-codemirror-BD02EJx5.js";import"./vendor-markdown-DOJHsAxX.js";const transparentize=(color,amount)=>adjustChannel(color,"a",-amount);function intersectionArea(circles,stats){const intersectionPoints=function(circles){const ret=[];for(let i=0;i<circles.length;++i)for(let j=i+1;j<circles.length;++j){const intersect=circleCircleIntersection(circles[i],circles[j]);for(const p of intersect)p.parentIndex=[i,j],ret.push(p)}return ret}(circles),innerPoints=intersectionPoints.filter(p=>function(point,circles){return circles.every(circle=>distance(point,circle)<circle.radius+1e-10)}(p,circles));let arcArea=0,polygonArea=0;const arcs=[];if(innerPoints.length>1){const center=getCenter(innerPoints);for(let i=0;i<innerPoints.length;++i){const p=innerPoints[i];p.angle=Math.atan2(p.x-center.x,p.y-center.y)}innerPoints.sort((a,b)=>b.angle-a.angle);let p2=innerPoints[innerPoints.length-1];for(let i=0;i<innerPoints.length;++i){const p1=innerPoints[i];polygonArea+=(p2.x+p1.x)*(p1.y-p2.y);const midPoint={x:(p1.x+p2.x)/2,y:(p1.y+p2.y)/2};let arc=null;for(let j=0;j<p1.parentIndex.length;++j)if(p2.parentIndex.includes(p1.parentIndex[j])){const circle=circles[p1.parentIndex[j]],a1=Math.atan2(p1.x-circle.x,p1.y-circle.y),a2=Math.atan2(p2.x-circle.x,p2.y-circle.y);let angleDiff=a2-a1;angleDiff<0&&(angleDiff+=2*Math.PI);const a=a2-angleDiff/2;let width=distance(midPoint,{x:circle.x+circle.radius*Math.sin(a),y:circle.y+circle.radius*Math.cos(a)});width>2*circle.radius&&(width=2*circle.radius),(null==arc||arc.width>width)&&(arc={circle:circle,width:width,p1:p1,p2:p2,large:width>circle.radius,sweep:!0})}null!=arc&&(arcs.push(arc),arcArea+=circleArea(arc.circle.radius,arc.width),p2=p1)}}else{let smallest=circles[0];for(let i=1;i<circles.length;++i)circles[i].radius<smallest.radius&&(smallest=circles[i]);let disjoint=!1;for(let i=0;i<circles.length;++i)if(distance(circles[i],smallest)>Math.abs(smallest.radius-circles[i].radius)){disjoint=!0;break}disjoint?arcArea=polygonArea=0:(arcArea=smallest.radius*smallest.radius*Math.PI,arcs.push({circle:smallest,p1:{x:smallest.x,y:smallest.y+smallest.radius},p2:{x:smallest.x-1e-10,y:smallest.y+smallest.radius},width:2*smallest.radius,large:!0,sweep:!0}))}return polygonArea/=2,stats&&(stats.area=arcArea+polygonArea,stats.arcArea=arcArea,stats.polygonArea=polygonArea,stats.arcs=arcs,stats.innerPoints=innerPoints,stats.intersectionPoints=intersectionPoints),arcArea+polygonArea}function circleArea(r,width){return r*r*Math.acos(1-width/r)-(r-width)*Math.sqrt(width*(2*r-width))}function distance(p1,p2){return Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))}function circleOverlap(r1,r2,d){if(d>=r1+r2)return 0;if(d<=Math.abs(r1-r2))return Math.PI*Math.min(r1,r2)*Math.min(r1,r2);const w2=r2-(d*d-r1*r1+r2*r2)/(2*d);return circleArea(r1,r1-(d*d-r2*r2+r1*r1)/(2*d))+circleArea(r2,w2)}function circleCircleIntersection(p1,p2){const d=distance(p1,p2),r1=p1.radius,r2=p2.radius;if(d>=r1+r2||d<=Math.abs(r1-r2))return[];const a=(r1*r1-r2*r2+d*d)/(2*d),h=Math.sqrt(r1*r1-a*a),x0=p1.x+a*(p2.x-p1.x)/d,y0=p1.y+a*(p2.y-p1.y)/d,rx=-(p2.y-p1.y)*(h/d),ry=-(p2.x-p1.x)*(h/d);return[{x:x0+rx,y:y0-ry},{x:x0-rx,y:y0+ry}]}function getCenter(points){const center={x:0,y:0};for(const point of points)center.x+=point.x,center.y+=point.y;return center.x/=points.length,center.y/=points.length,center}function zeros(x){const r=new Array(x);for(let i=0;i<x;++i)r[i]=0;return r}function zerosM(x,y){return zeros(x).map(()=>zeros(y))}function dot(a,b){let ret=0;for(let i=0;i<a.length;++i)ret+=a[i]*b[i];return ret}function norm2(a){return Math.sqrt(dot(a,a))}function scale(ret,value,c){for(let i=0;i<value.length;++i)ret[i]=value[i]*c}function weightedSum(ret,w1,v1,w2,v2){for(let j=0;j<ret.length;++j)ret[j]=w1*v1[j]+w2*v2[j]}function nelderMead(f,x0,parameters){const maxIterations=(parameters=parameters||{}).maxIterations||200*x0.length,nonZeroDelta=parameters.nonZeroDelta||1.05,zeroDelta=parameters.zeroDelta||.001,minErrorDelta=parameters.minErrorDelta||1e-6,minTolerance=parameters.minErrorDelta||1e-5,rho=void 0!==parameters.rho?parameters.rho:1,chi=void 0!==parameters.chi?parameters.chi:2,psi=void 0!==parameters.psi?parameters.psi:-.5,sigma=void 0!==parameters.sigma?parameters.sigma:.5;let maxDiff;const N=x0.length,simplex=new Array(N+1);simplex[0]=x0,simplex[0].fx=f(x0),simplex[0].id=0;for(let i=0;i<N;++i){const point=x0.slice();point[i]=point[i]?point[i]*nonZeroDelta:zeroDelta,simplex[i+1]=point,simplex[i+1].fx=f(point),simplex[i+1].id=i+1}function updateSimplex(value){for(let i=0;i<value.length;i++)simplex[N][i]=value[i];simplex[N].fx=value.fx}const sortOrder=(a,b)=>a.fx-b.fx,centroid=x0.slice(),reflected=x0.slice(),contracted=x0.slice(),expanded=x0.slice();for(let iteration=0;iteration<maxIterations;++iteration){if(simplex.sort(sortOrder),parameters.history){const sortedSimplex=simplex.map(x=>{const state=x.slice();return state.fx=x.fx,state.id=x.id,state});sortedSimplex.sort((a,b)=>a.id-b.id),parameters.history.push({x:simplex[0].slice(),fx:simplex[0].fx,simplex:sortedSimplex})}maxDiff=0;for(let i=0;i<N;++i)maxDiff=Math.max(maxDiff,Math.abs(simplex[0][i]-simplex[1][i]));if(Math.abs(simplex[0].fx-simplex[N].fx)<minErrorDelta&&maxDiff<minTolerance)break;for(let i=0;i<N;++i){centroid[i]=0;for(let j=0;j<N;++j)centroid[i]+=simplex[j][i];centroid[i]/=N}const worst=simplex[N];if(weightedSum(reflected,1+rho,centroid,-rho,worst),reflected.fx=f(reflected),reflected.fx<simplex[0].fx)weightedSum(expanded,1+chi,centroid,-chi,worst),expanded.fx=f(expanded),expanded.fx<reflected.fx?updateSimplex(expanded):updateSimplex(reflected);else if(reflected.fx>=simplex[N-1].fx){let shouldReduce=!1;if(reflected.fx>worst.fx?(weightedSum(contracted,1+psi,centroid,-psi,worst),contracted.fx=f(contracted),contracted.fx<worst.fx?updateSimplex(contracted):shouldReduce=!0):(weightedSum(contracted,1-psi*rho,centroid,psi*rho,worst),contracted.fx=f(contracted),contracted.fx<reflected.fx?updateSimplex(contracted):shouldReduce=!0),shouldReduce){if(sigma>=1)break;for(let i=1;i<simplex.length;++i)weightedSum(simplex[i],1-sigma,simplex[0],sigma,simplex[i]),simplex[i].fx=f(simplex[i])}}else updateSimplex(reflected)}return simplex.sort(sortOrder),{fx:simplex[0].fx,x:simplex[0]}}function wolfeLineSearch(f,pk,current,next,a,c1,c2){const phi0=current.fx,phiPrime0=dot(current.fxprime,pk);let phi=phi0,phi_old=phi0,phiPrime=phiPrime0,a0=0;function zoom(a_lo,a_high,phi_lo){for(let iteration=0;iteration<16;++iteration)if(a=(a_lo+a_high)/2,weightedSum(next.x,1,current.x,a,pk),phi=next.fx=f(next.x,next.fxprime),phiPrime=dot(next.fxprime,pk),phi>phi0+c1*a*phiPrime0||phi>=phi_lo)a_high=a;else{if(Math.abs(phiPrime)<=-c2*phiPrime0)return a;phiPrime*(a_high-a_lo)>=0&&(a_high=a_lo),a_lo=a,phi_lo=phi}return 0}a=a||1,c1=c1||1e-6,c2=c2||.1;for(let iteration=0;iteration<10;++iteration){if(weightedSum(next.x,1,current.x,a,pk),phi=next.fx=f(next.x,next.fxprime),phiPrime=dot(next.fxprime,pk),phi>phi0+c1*a*phiPrime0||iteration&&phi>=phi_old)return zoom(a0,a,phi_old);if(Math.abs(phiPrime)<=-c2*phiPrime0)return a;if(phiPrime>=0)return zoom(a,a0,phi);phi_old=phi,a0=a,a*=2}return a}function conjugateGradient(f,initial,params){let current={x:initial.slice(),fx:0,fxprime:initial.slice()},next={x:initial.slice(),fx:0,fxprime:initial.slice()};const yk=initial.slice();let pk,temp,maxIterations,a=1;maxIterations=(params=params||{}).maxIterations||20*initial.length,current.fx=f(current.x,current.fxprime),pk=current.fxprime.slice(),scale(pk,current.fxprime,-1);for(let i=0;i<maxIterations;++i){if(a=wolfeLineSearch(f,pk,current,next,a),params.history&&params.history.push({x:current.x.slice(),fx:current.fx,fxprime:current.fxprime.slice(),alpha:a}),a){weightedSum(yk,1,next.fxprime,-1,current.fxprime);const delta_k=dot(current.fxprime,current.fxprime);weightedSum(pk,Math.max(0,dot(yk,next.fxprime)/delta_k),pk,-1,next.fxprime),temp=current,current=next,next=temp}else scale(pk,current.fxprime,-1);if(norm2(current.fxprime)<=1e-5)break}return params.history&&params.history.push({x:current.x.slice(),fx:current.fx,fxprime:current.fxprime.slice(),alpha:a}),current}function venn(sets,parameters={}){parameters.maxIterations=parameters.maxIterations||500;const initialLayout=parameters.initialLayout||bestInitialLayout,loss=parameters.lossFunction||lossFunction,areas=function(areas,parameters={}){const distinct=parameters.distinct,r=areas.map(s=>Object.assign({},s));function toKey(arr){return arr.join(";")}if(distinct){const count=new Map;for(const area of r)for(let i=0;i<area.sets.length;i++){const si=String(area.sets[i]);count.set(si,area.size+(count.get(si)||0));for(let j=i+1;j<area.sets.length;j++){const sj=String(area.sets[j]),k1=`${si};${sj}`,k2=`${sj};${si}`;count.set(k1,area.size+(count.get(k1)||0)),count.set(k2,area.size+(count.get(k2)||0))}}for(const area of r)area.sets.length<3&&(area.size=count.get(toKey(area.sets)))}const ids=[],pairs=new Set;for(const area of r)if(1===area.sets.length)ids.push(area.sets[0]);else if(2===area.sets.length){const a=area.sets[0],b=area.sets[1];pairs.add(toKey(area.sets)),pairs.add(toKey([b,a]))}ids.sort((a,b)=>a===b?0:a<b?-1:1);for(let i=0;i<ids.length;++i){const a=ids[i];for(let j=i+1;j<ids.length;++j){const b=ids[j];pairs.has(toKey([a,b]))||r.push({sets:[a,b],size:0})}}return r}(sets,parameters),circles=initialLayout(areas,parameters),setids=Object.keys(circles),initial=[];for(const setid of setids)initial.push(circles[setid].x),initial.push(circles[setid].y);const positions=nelderMead(values=>{const current={};for(let i=0;i<setids.length;++i){const setid=setids[i];current[setid]={x:values[2*i],y:values[2*i+1],radius:circles[setid].radius}}return loss(current,areas)},initial,parameters).x;for(let i=0;i<setids.length;++i){const setid=setids[i];circles[setid].x=positions[2*i],circles[setid].y=positions[2*i+1]}return circles}const SMALL=1e-10;function distanceFromIntersectArea(r1,r2,overlap){return Math.min(r1,r2)*Math.min(r1,r2)*Math.PI<=overlap+SMALL?Math.abs(r1-r2):function(f,a,b,parameters){const maxIterations=(parameters=parameters||{}).maxIterations||100,tolerance=parameters.tolerance||1e-10,fA=f(a),fB=f(b);let delta=b-a;if(fA*fB>0)throw"Initial bisect points must have opposite signs";if(0===fA)return a;if(0===fB)return b;for(let i=0;i<maxIterations;++i){delta/=2;const mid=a+delta,fMid=f(mid);if(fMid*fA>=0&&(a=mid),Math.abs(delta)<tolerance||0===fMid)return mid}return a+delta}(distance2=>circleOverlap(r1,r2,distance2)-overlap,0,r1+r2)}function bestInitialLayout(areas,params={}){let initial=function(areas,params){const loss=params&&params.lossFunction?params.lossFunction:lossFunction,circles={},setOverlaps={};for(const area of areas)if(1===area.sets.length){const set=area.sets[0];circles[set]={x:1e10,y:1e10,rowid:circles.length,size:area.size,radius:Math.sqrt(area.size/Math.PI)},setOverlaps[set]=[]}areas=areas.filter(a=>2===a.sets.length);for(const current of areas){let weight=null!=current.weight?current.weight:1;const left=current.sets[0],right=current.sets[1];current.size+SMALL>=Math.min(circles[left].size,circles[right].size)&&(weight=0),setOverlaps[left].push({set:right,size:current.size,weight:weight}),setOverlaps[right].push({set:left,size:current.size,weight:weight})}const mostOverlapped=[];function sortOrder(a,b){return b.size-a.size}Object.keys(setOverlaps).forEach(set=>{let size=0;for(let i=0;i<setOverlaps[set].length;++i)size+=setOverlaps[set][i].size*setOverlaps[set][i].weight;mostOverlapped.push({set:set,size:size})}),mostOverlapped.sort(sortOrder);const positioned={};function isPositioned(element){return element.set in positioned}function positionSet(point,index){circles[index].x=point.x,circles[index].y=point.y,positioned[index]=!0}positionSet({x:0,y:0},mostOverlapped[0].set);for(let i=1;i<mostOverlapped.length;++i){const setIndex=mostOverlapped[i].set,overlap=setOverlaps[setIndex].filter(isPositioned),set=circles[setIndex];if(overlap.sort(sortOrder),0===overlap.length)throw"ERROR: missing pairwise overlap information";const points=[];for(var j=0;j<overlap.length;++j){const p1=circles[overlap[j].set],d1=distanceFromIntersectArea(set.radius,p1.radius,overlap[j].size);points.push({x:p1.x+d1,y:p1.y}),points.push({x:p1.x-d1,y:p1.y}),points.push({y:p1.y+d1,x:p1.x}),points.push({y:p1.y-d1,x:p1.x});for(let k=j+1;k<overlap.length;++k){const p2=circles[overlap[k].set],d2=distanceFromIntersectArea(set.radius,p2.radius,overlap[k].size),extraPoints=circleCircleIntersection({x:p1.x,y:p1.y,radius:d1},{x:p2.x,y:p2.y,radius:d2});points.push(...extraPoints)}}let bestLoss=1e50,bestPoint=points[0];for(const point of points){circles[setIndex].x=point.x,circles[setIndex].y=point.y;const localLoss=loss(circles,areas);localLoss<bestLoss&&(bestLoss=localLoss,bestPoint=point)}positionSet(bestPoint,setIndex)}return circles}(areas,params);const loss=params.lossFunction||lossFunction;if(areas.length>=8){const constrained=function(areas,params={}){const restarts=params.restarts||10,sets=[],setids={};for(const area of areas)1===area.sets.length&&(setids[area.sets[0]]=sets.length,sets.push(area));let{distances:distances,constraints:constraints}=function(areas,sets,setids){const distances=zerosM(sets.length,sets.length),constraints=zerosM(sets.length,sets.length);return areas.filter(x=>2===x.sets.length).forEach(current=>{const left=setids[current.sets[0]],right=setids[current.sets[1]],distance2=distanceFromIntersectArea(Math.sqrt(sets[left].size/Math.PI),Math.sqrt(sets[right].size/Math.PI),current.size);distances[left][right]=distances[right][left]=distance2;let c=0;current.size+1e-10>=Math.min(sets[left].size,sets[right].size)?c=1:current.size<=1e-10&&(c=-1),constraints[left][right]=constraints[right][left]=c}),{distances:distances,constraints:constraints}}(areas,sets,setids);const norm=norm2(distances.map(norm2))/distances.length;distances=distances.map(row=>row.map(value=>value/norm));const obj=(x,fxprime)=>function(x,fxprime,distances,constraints){for(let i=0;i<fxprime.length;++i)fxprime[i]=0;let loss=0;for(let i=0;i<distances.length;++i){const xi=x[2*i],yi=x[2*i+1];for(let j=i+1;j<distances.length;++j){const xj=x[2*j],yj=x[2*j+1],dij=distances[i][j],constraint=constraints[i][j],squaredDistance=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi),distance2=Math.sqrt(squaredDistance),delta=squaredDistance-dij*dij;constraint>0&&distance2<=dij||constraint<0&&distance2>=dij||(loss+=2*delta*delta,fxprime[2*i]+=4*delta*(xi-xj),fxprime[2*i+1]+=4*delta*(yi-yj),fxprime[2*j]+=4*delta*(xj-xi),fxprime[2*j+1]+=4*delta*(yj-yi))}}return loss}(x,fxprime,distances,constraints);let best=null;for(let i=0;i<restarts;++i){const current=conjugateGradient(obj,zeros(2*distances.length).map(Math.random),params);(!best||current.fx<best.fx)&&(best=current)}const positions=best.x,circles={};for(let i=0;i<sets.length;++i){const set=sets[i];circles[set.sets[0]]={x:positions[2*i]*norm,y:positions[2*i+1]*norm,radius:Math.sqrt(set.size/Math.PI)}}if(params.history)for(const h of params.history)scale(h.x,norm);return circles}(areas,params);loss(constrained,areas)+1e-8<loss(initial,areas)&&(initial=constrained)}return initial}function lossFunction(circles,overlaps){let output=0;for(const area of overlaps){if(1===area.sets.length)continue;let overlap;if(2===area.sets.length){const left=circles[area.sets[0]],right=circles[area.sets[1]];overlap=circleOverlap(left.radius,right.radius,distance(left,right))}else overlap=intersectionArea(area.sets.map(d=>circles[d]));output+=(null!=area.weight?area.weight:1)*(overlap-area.size)*(overlap-area.size)}return output}function logRatioLossFunction(circles,overlaps){let output=0;for(const area of overlaps){if(1===area.sets.length)continue;let overlap;if(2===area.sets.length){const left=circles[area.sets[0]],right=circles[area.sets[1]];overlap=circleOverlap(left.radius,right.radius,distance(left,right))}else overlap=intersectionArea(area.sets.map(d=>circles[d]));const weight=null!=area.weight?area.weight:1,differenceFromIdeal=Math.log((overlap+1)/(area.size+1));output+=weight*differenceFromIdeal*differenceFromIdeal}return output}function orientateCircles(circles,orientation,orientationOrder){if(null==orientationOrder?circles.sort((a,b)=>b.radius-a.radius):circles.sort(orientationOrder),circles.length>0){const largestX=circles[0].x,largestY=circles[0].y;for(const circle of circles)circle.x-=largestX,circle.y-=largestY}if(2===circles.length){distance(circles[0],circles[1])<Math.abs(circles[1].radius-circles[0].radius)&&(circles[1].x=circles[0].x+circles[0].radius-circles[1].radius-1e-10,circles[1].y=circles[0].y)}if(circles.length>1){const rotation=Math.atan2(circles[1].x,circles[1].y)-orientation,c=Math.cos(rotation),s=Math.sin(rotation);for(const circle of circles){const x=circle.x,y=circle.y;circle.x=c*x-s*y,circle.y=s*x+c*y}}if(circles.length>2){let angle=Math.atan2(circles[2].x,circles[2].y)-orientation;for(;angle<0;)angle+=2*Math.PI;for(;angle>2*Math.PI;)angle-=2*Math.PI;if(angle>Math.PI){const slope=circles[1].y/(1e-10+circles[1].x);for(const circle of circles){var d=(circle.x+slope*circle.y)/(1+slope*slope);circle.x=2*d-circle.x,circle.y=2*d*slope-circle.y}}}}function getBoundingBox(circles){const minMax=d=>({max:circles.reduce((acc,c)=>Math.max(acc,c[d]+c.radius),Number.NEGATIVE_INFINITY),min:circles.reduce((acc,c)=>Math.min(acc,c[d]-c.radius),Number.POSITIVE_INFINITY)});return{xRange:minMax("x"),yRange:minMax("y")}}function normalizeSolution(solution,orientation,orientationOrder){null==orientation&&(orientation=Math.PI/2);let circles=fromObjectNotation(solution).map(d=>Object.assign({},d));const clusters=function(circles){function find(circle){return circle.parent!==circle&&(circle.parent=find(circle.parent)),circle.parent}function union(x,y){const xRoot=find(x),yRoot=find(y);xRoot.parent=yRoot}circles.forEach(circle=>{circle.parent=circle});for(let i=0;i<circles.length;++i)for(let j=i+1;j<circles.length;++j){const maxDistance=circles[i].radius+circles[j].radius;distance(circles[i],circles[j])+1e-10<maxDistance&&union(circles[j],circles[i])}const disjointClusters=new Map;for(let i=0;i<circles.length;++i){const setid=find(circles[i]).parent.setid;disjointClusters.has(setid)||disjointClusters.set(setid,[]),disjointClusters.get(setid).push(circles[i])}return circles.forEach(circle=>{delete circle.parent}),Array.from(disjointClusters.values())}(circles);for(const cluster of clusters){orientateCircles(cluster,orientation,orientationOrder);const bounds=getBoundingBox(cluster);cluster.size=(bounds.xRange.max-bounds.xRange.min)*(bounds.yRange.max-bounds.yRange.min),cluster.bounds=bounds}clusters.sort((a,b)=>b.size-a.size),circles=clusters[0];let returnBounds=circles.bounds;const spacing=(returnBounds.xRange.max-returnBounds.xRange.min)/50;function addCluster(cluster,right,bottom){if(!cluster)return;const bounds=cluster.bounds;let xOffset,yOffset;if(right)xOffset=returnBounds.xRange.max-bounds.xRange.min+spacing;else{xOffset=returnBounds.xRange.max-bounds.xRange.max;const centreing=(bounds.xRange.max-bounds.xRange.min)/2-(returnBounds.xRange.max-returnBounds.xRange.min)/2;centreing<0&&(xOffset+=centreing)}if(bottom)yOffset=returnBounds.yRange.max-bounds.yRange.min+spacing;else{yOffset=returnBounds.yRange.max-bounds.yRange.max;const centreing=(bounds.yRange.max-bounds.yRange.min)/2-(returnBounds.yRange.max-returnBounds.yRange.min)/2;centreing<0&&(yOffset+=centreing)}for(const c of cluster)c.x+=xOffset,c.y+=yOffset,circles.push(c)}let index=1;for(;index<clusters.length;)addCluster(clusters[index],!0,!1),addCluster(clusters[index+1],!1,!0),addCluster(clusters[index+2],!0,!0),index+=3,returnBounds=getBoundingBox(circles);return toObjectNotation(circles)}function scaleSolution(solution,width,height,padding,scaleToFit){const circles=fromObjectNotation(solution);width-=2*padding,height-=2*padding;const{xRange:xRange,yRange:yRange}=getBoundingBox(circles);if(xRange.max===xRange.min||yRange.max===yRange.min)return console.log("not scaling solution: zero size detected"),solution;let xScaling,yScaling;if(scaleToFit){const toScaleDiameter=2*Math.sqrt(scaleToFit/Math.PI);xScaling=width/toScaleDiameter,yScaling=height/toScaleDiameter}else xScaling=width/(xRange.max-xRange.min),yScaling=height/(yRange.max-yRange.min);const scaling=Math.min(yScaling,xScaling),xOffset=(width-(xRange.max-xRange.min)*scaling)/2,yOffset=(height-(yRange.max-yRange.min)*scaling)/2;return toObjectNotation(circles.map(circle=>({radius:scaling*circle.radius,x:padding+xOffset+(circle.x-xRange.min)*scaling,y:padding+yOffset+(circle.y-yRange.min)*scaling,setid:circle.setid})))}function toObjectNotation(circles){const r={};for(const circle of circles)r[circle.setid]=circle;return r}function fromObjectNotation(solution){return Object.keys(solution).map(id=>Object.assign(solution[id],{setid:id}))}function VennDiagram(options={}){let useViewBox=!1,width=600,height=350,padding=15,duration=1e3,orientation=Math.PI/2,normalize=!0,scaleToFit=null,wrap=!0,styled=!0,fontSize=null,orientationOrder=null,distinct=!1,round=null,symmetricalTextCentre=!(!options||!options.symmetricalTextCentre)&&options.symmetricalTextCentre,colourMap={},colourScheme=options&&options.colourScheme?options.colourScheme:options&&options.colorScheme?options.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],colourIndex=0,colours=function(key){if(key in colourMap)return colourMap[key];var ret=colourMap[key]=colourScheme[colourIndex];return colourIndex+=1,colourIndex>=colourScheme.length&&(colourIndex=0),ret},layoutFunction=venn,loss=lossFunction;function chart(selection){let data=selection.datum();const toRemove=new Set;data.forEach(datum=>{0==datum.size&&1==datum.sets.length&&toRemove.add(datum.sets[0])}),data=data.filter(datum=>!datum.sets.some(set=>toRemove.has(set)));let circles={},textCentres={};if(data.length>0){let solution=layoutFunction(data,{lossFunction:loss,distinct:distinct});normalize&&(solution=normalizeSolution(solution,orientation,orientationOrder)),circles=scaleSolution(solution,width,height,padding,scaleToFit),textCentres=computeTextCentres(circles,data,symmetricalTextCentre)}const labels={};function label(d){return d.sets in labels?labels[d.sets]:1==d.sets.length?""+d.sets[0]:void 0}data.forEach(datum=>{datum.label&&(labels[datum.sets]=datum.label)}),selection.selectAll("svg").data([circles]).enter().append("svg");const svg=selection.select("svg");useViewBox?svg.attr("viewBox",`0 0 ${width} ${height}`):svg.attr("width",width).attr("height",height);const previous={};let hasPrevious=!1;function pathTween(d){return t=>intersectionAreaPath(d.sets.map(set=>{let start=previous[set],end=circles[set];return start||(start={x:width/2,y:height/2,radius:1}),end||(end={x:width/2,y:height/2,radius:1}),{x:start.x*(1-t)+end.x*t,y:start.y*(1-t)+end.y*t,radius:start.radius*(1-t)+end.radius*t}}),round)}svg.selectAll(".venn-area path").each(function(d){const path=this.getAttribute("d");1==d.sets.length&&path&&!distinct&&(hasPrevious=!0,previous[d.sets[0]]=function(path){const tokens=path.split(" ");return{x:Number.parseFloat(tokens[1]),y:Number.parseFloat(tokens[2]),radius:-Number.parseFloat(tokens[4])}}(path))});const nodes=svg.selectAll(".venn-area").data(data,d=>d.sets),enter=nodes.enter().append("g").attr("class",d=>`venn-area venn-${1==d.sets.length?"circle":"intersection"}${d.colour||d.color?" venn-coloured":""}`).attr("data-venn-sets",d=>d.sets.join("_")),enterPath=enter.append("path"),enterText=enter.append("text").attr("class","label").text(d=>label(d)).attr("text-anchor","middle").attr("dy",".35em").attr("x",width/2).attr("y",height/2);function asTransition(s){return"function"==typeof s.transition?s.transition("venn").duration(duration):s}styled&&(enterPath.style("fill-opacity","0").filter(d=>1==d.sets.length).style("fill",d=>d.colour?d.colour:d.color?d.color:colours(d.sets)).style("fill-opacity",".25"),enterText.style("fill",d=>d.colour||d.color?"#FFF":options.textFill?options.textFill:1==d.sets.length?colours(d.sets):"#444"));let update=selection;hasPrevious&&"function"==typeof update.transition?(update=asTransition(selection),update.selectAll("path").attrTween("d",pathTween)):update.selectAll("path").attr("d",d=>intersectionAreaPath(d.sets.map(set=>circles[set])),round);const updateText=update.selectAll("text").filter(d=>d.sets in textCentres).text(d=>label(d)).attr("x",d=>Math.floor(textCentres[d.sets].x)).attr("y",d=>Math.floor(textCentres[d.sets].y));wrap&&(hasPrevious?"on"in updateText?updateText.on("end",wrapText(circles,label)):updateText.each("end",wrapText(circles,label)):updateText.each(wrapText(circles,label)));const exit=asTransition(nodes.exit()).remove();"function"==typeof nodes.transition&&exit.selectAll("path").attrTween("d",pathTween);const exitText=exit.selectAll("text").attr("x",width/2).attr("y",height/2);return null!==fontSize&&(enterText.style("font-size","0px"),updateText.style("font-size",fontSize),exitText.style("font-size","0px")),{circles:circles,textCentres:textCentres,nodes:nodes,enter:enter,update:update,exit:exit}}return chart.wrap=function(_){return arguments.length?(wrap=_,chart):wrap},chart.useViewBox=function(){return useViewBox=!0,chart},chart.width=function(_){return arguments.length?(width=_,chart):width},chart.height=function(_){return arguments.length?(height=_,chart):height},chart.padding=function(_){return arguments.length?(padding=_,chart):padding},chart.distinct=function(_){return arguments.length?(distinct=_,chart):distinct},chart.colours=function(_){return arguments.length?(colours=_,chart):colours},chart.colors=function(_){return arguments.length?(colours=_,chart):colours},chart.fontSize=function(_){return arguments.length?(fontSize=_,chart):fontSize},chart.round=function(_){return arguments.length?(round=_,chart):round},chart.duration=function(_){return arguments.length?(duration=_,chart):duration},chart.layoutFunction=function(_){return arguments.length?(layoutFunction=_,chart):layoutFunction},chart.normalize=function(_){return arguments.length?(normalize=_,chart):normalize},chart.scaleToFit=function(_){return arguments.length?(scaleToFit=_,chart):scaleToFit},chart.styled=function(_){return arguments.length?(styled=_,chart):styled},chart.orientation=function(_){return arguments.length?(orientation=_,chart):orientation},chart.orientationOrder=function(_){return arguments.length?(orientationOrder=_,chart):orientationOrder},chart.lossFunction=function(_){return arguments.length?(loss="default"===_?lossFunction:"logRatio"===_?logRatioLossFunction:_,chart):loss},chart}function wrapText(circles,labeller){return function(data){const text=this,width=circles[data.sets[0]].radius||50,label=labeller(data)||"",words=label.split(/\s+/).reverse(),minChars=(label.length+words.length)/3;let word=words.pop(),line=[word],lineNumber=0;text.textContent=null;const tspans=[];function append(word2){const tspan2=text.ownerDocument.createElementNS(text.namespaceURI,"tspan");return tspan2.textContent=word2,tspans.push(tspan2),text.append(tspan2),tspan2}let tspan=append(word);for(;word=words.pop(),word;){line.push(word);const joined=line.join(" ");tspan.textContent=joined,joined.length>minChars&&tspan.getComputedTextLength()>width&&(line.pop(),tspan.textContent=line.join(" "),line=[word],tspan=append(word),lineNumber++)}const initial=.35-1.1*lineNumber/2,x=text.getAttribute("x"),y=text.getAttribute("y");tspans.forEach((t,i)=>{t.setAttribute("x",x),t.setAttribute("y",y),t.setAttribute("dy",`${initial+1.1*i}em`)})}}function circleMargin(current,interior,exterior){let margin=interior[0].radius-distance(interior[0],current);for(let i=1;i<interior.length;++i){const m=interior[i].radius-distance(interior[i],current);m<=margin&&(margin=m)}for(let i=0;i<exterior.length;++i){const m=distance(exterior[i],current)-exterior[i].radius;m<=margin&&(margin=m)}return margin}function computeTextCentre(interior,exterior,symmetricalTextCentre){const points=[];for(const c of interior)points.push({x:c.x,y:c.y}),points.push({x:c.x+c.radius/2,y:c.y}),points.push({x:c.x-c.radius/2,y:c.y}),points.push({x:c.x,y:c.y+c.radius/2}),points.push({x:c.x,y:c.y-c.radius/2});let initial=points[0],margin=circleMargin(points[0],interior,exterior);for(let i=1;i<points.length;++i){const m=circleMargin(points[i],interior,exterior);m>=margin&&(initial=points[i],margin=m)}const solution=nelderMead(p=>-1*circleMargin({x:p[0],y:p[1]},interior,exterior),[initial.x,initial.y],{maxIterations:500,minErrorDelta:1e-10}).x,ret={x:symmetricalTextCentre?0:solution[0],y:solution[1]};let valid=!0;for(const i of interior)if(distance(ret,i)>i.radius){valid=!1;break}for(const e of exterior)if(distance(ret,e)<e.radius){valid=!1;break}if(valid)return ret;if(1==interior.length)return{x:interior[0].x,y:interior[0].y};const areaStats={};return intersectionArea(interior,areaStats),0===areaStats.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==areaStats.arcs.length?{x:areaStats.arcs[0].circle.x,y:areaStats.arcs[0].circle.y}:exterior.length?computeTextCentre(interior,[]):getCenter(areaStats.arcs.map(a=>a.p1))}function computeTextCentres(circles,areas,symmetricalTextCentre){const ret={},overlapped=function(circles){const ret={},circleids=Object.keys(circles);for(const circleid of circleids)ret[circleid]=[];for(let i=0;i<circleids.length;i++){const ci=circleids[i],a=circles[ci];for(let j=i+1;j<circleids.length;++j){const cj=circleids[j],b=circles[cj],d=distance(a,b);d+b.radius<=a.radius+1e-10?ret[cj].push(ci):d+a.radius<=b.radius+1e-10&&ret[ci].push(cj)}}return ret}(circles);for(let i=0;i<areas.length;++i){const area=areas[i].sets,areaids={},exclude={};for(let j=0;j<area.length;++j){areaids[area[j]]=!0;const overlaps=overlapped[area[j]];for(let k=0;k<overlaps.length;++k)exclude[overlaps[k]]=!0}const interior=[],exterior=[];for(let setid in circles)setid in areaids?interior.push(circles[setid]):setid in exclude||exterior.push(circles[setid]);const centre=computeTextCentre(interior,exterior,symmetricalTextCentre);ret[area]=centre,centre.disjoint&&areas[i].size>0&&console.log("WARNING: area "+area+" not represented on screen")}return ret}function intersectionAreaArcs(circles){if(0===circles.length)return[];const stats={};return intersectionArea(circles,stats),stats.arcs}function arcsToPath(arcs,round){if(0===arcs.length)return"M 0 0";const rFactor=Math.pow(10,round||0),r=null!=round?v=>Math.round(v*rFactor)/rFactor:v=>v;if(1==arcs.length){const circle=arcs[0].circle;return function(x,y,r){const ret=[];return ret.push("\nM",x,y),ret.push("\nm",-r,0),ret.push("\na",r,r,0,1,0,2*r,0),ret.push("\na",r,r,0,1,0,2*-r,0),ret.join(" ")}(r(circle.x),r(circle.y),r(circle.radius))}const ret=["\nM",r(arcs[0].p2.x),r(arcs[0].p2.y)];for(const arc of arcs){const radius=r(arc.circle.radius);ret.push("\nA",radius,radius,0,arc.large?1:0,arc.sweep?1:0,r(arc.p1.x),r(arc.p1.y))}return ret.join(" ")}function intersectionAreaPath(circles,round){return arcsToPath(intersectionAreaArcs(circles),round)}var parser=function(){var o=__name(function(k,v,o2,l){for(o2=o2||{},l=k.length;l--;o2[k[l]]=v);return o2},"o"),$V0=[5,8],$V1=[7,8,11,12,17,19,22,24],$V2=[1,17],$V3=[1,18],$V4=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],$V5=[1,31],$V6=[1,39],$V7=[7,8,11,12,17,19,22,24,27],$V8=[1,57],$V9=[1,56],$Va=[1,58],$Vb=[1,59],$Vc=[1,60],$Vd=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],parser2={trace:__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:__name(function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:return $$[$0-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:$$[$0-1].push($$[$0]),this.$=$$[$0-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=$$[$0];break;case 8:yy.setDiagramTitle($$[$0].substr(6)),this.$=$$[$0].substr(6);break;case 9:yy.addSubsetData([$$[$0]],void 0,void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 10:yy.addSubsetData([$$[$0-1]],$$[$0],void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 11:yy.addSubsetData([$$[$0-2]],void 0,parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 12:yy.addSubsetData([$$[$0-3]],$$[$0-2],parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 13:if($$[$0].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0]),yy.addSubsetData($$[$0],void 0,void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 14:if($$[$0-1].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-1]),yy.addSubsetData($$[$0-1],$$[$0],void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 15:if($$[$0-2].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-2]),yy.addSubsetData($$[$0-2],void 0,parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 16:if($$[$0-3].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-3]),yy.addSubsetData($$[$0-3],$$[$0-2],parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 17:case 18:case 19:yy.addTextData($$[$0-1],$$[$0],void 0);break;case 20:case 21:yy.addTextData($$[$0-2],$$[$0-1],$$[$0]);break;case 23:yy.addStyleData($$[$0-1],$$[$0]);break;case 24:case 25:case 26:if(!(cs=yy.getCurrentSets()))throw new Error("text requires set");yy.addTextData(cs,$$[$0],void 0);break;case 27:case 28:var cs;if(!(cs=yy.getCurrentSets()))throw new Error("text requires set");yy.addTextData(cs,$$[$0-1],$$[$0]);break;case 29:case 41:case 34:this.$=[$$[$0]];break;case 30:case 42:this.$=[...$$[$0-2],$$[$0]];break;case 31:this.$=[$$[$0-2],$$[$0]];break;case 33:this.$=$$[$0].join(" ")}},"anonymous"),table:[o($V0,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},o($V1,[2,4],{6:5}),o($V0,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},o($V1,[2,5]),o($V1,[2,6]),o($V1,[2,7]),o($V1,[2,8]),{13:16,20:$V2,21:$V3},{13:20,18:19,20:$V2,21:$V3},{13:20,18:21,20:$V2,21:$V3},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:$V2,21:$V3},o($V1,[2,9],{14:[1,27],15:[1,28]}),o($V4,[2,43]),o($V4,[2,44]),o($V1,[2,13],{14:[1,29],15:[1,30],27:$V5}),o($V4,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:$V5},o($V1,[2,22]),o($V1,[2,24],{14:[1,35]}),o($V1,[2,25],{14:[1,36]}),o($V1,[2,26]),{20:$V6,25:37,26:38,27:$V5},o($V1,[2,10],{15:[1,40]}),{16:[1,41]},o($V1,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:$V2,21:$V3},o($V1,[2,17],{14:[1,45]}),o($V1,[2,18],{14:[1,46]}),o($V1,[2,19]),o($V1,[2,27]),o($V1,[2,28]),o($V1,[2,23],{27:[1,47]}),o($V7,[2,29]),{15:[1,48]},{16:[1,49]},o($V1,[2,11]),{16:[1,50]},o($V1,[2,15]),o($V4,[2,42]),o($V1,[2,20]),o($V1,[2,21]),{20:$V6,26:51},{16:$V8,20:$V9,21:[1,53],28:52,29:54,30:55,31:$Va,32:$Vb,33:$Vc},o($V1,[2,12]),o($V1,[2,16]),o($V7,[2,30]),o($V7,[2,31]),o($V7,[2,32]),o($V7,[2,33],{30:61,16:$V8,20:$V9,31:$Va,32:$Vb,33:$Vc}),o($Vd,[2,34]),o($Vd,[2,36]),o($Vd,[2,37]),o($Vd,[2,38]),o($Vd,[2,39]),o($Vd,[2,40]),o($Vd,[2,35])],defaultActions:{6:[2,1]},parseError:__name(function(str,hash){if(!hash.recoverable){var error=new Error(str);throw error.hash=hash,error}this.trace(str)},"parseError"),parse:__name(function(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,args=lstack.slice.call(arguments,1),lexer2=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer2.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer2,sharedState.yy.parser=this,void 0===lexer2.yylloc&&(lexer2.yylloc={});var yyloc=lexer2.yylloc;lstack.push(yyloc);var ranges=lexer2.options&&lexer2.options.ranges;function lex(){var token;return"number"!=typeof(token=tstack.pop()||lexer2.lex()||1)&&(token instanceof Array&&(token=(tstack=token).pop()),token=self.symbols_[token]||token),token}"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,__name(function(n){stack.length=stack.length-2*n,vstack.length=vstack.length-n,lstack.length=lstack.length-n},"popStack"),__name(lex,"lex");for(var symbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null==symbol&&(symbol=lex()),action=table[state]&&table[state][symbol]),void 0===action||!action.length||!action[0]){var errStr="";for(p in expected=[],table[state])this.terminals_[p]&&p>2&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer2.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer2.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(1==symbol?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer2.match,token:this.terminals_[symbol]||symbol,line:lexer2.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer2.yytext),lstack.push(lexer2.yylloc),stack.push(action[1]),symbol=null,yyleng=lexer2.yyleng,yytext=lexer2.yytext,yylineno=lexer2.yylineno,yyloc=lexer2.yylloc;break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),void 0!==(r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args))))return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0},"parse")},lexer=function(){return{EOF:1,parseError:__name(function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},"parseError"),setInput:__name(function(input,yy){return this.yy=yy||this.yy||{},this._input=input,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:__name(function(){var ch=this._input[0];return this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch,ch.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},"input"),unput:__name(function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),lines.length-1&&(this.yylineno-=lines.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),this.yyleng=this.yytext.length,this},"unput"),more:__name(function(){return this._more=!0,this},"more"),reject:__name(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:__name(function(n){this.unput(this.match.slice(n))},"less"),pastInput:__name(function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:__name(function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:__name(function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},"showPosition"),test_match:__name(function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(backup.yylloc.range=this.yylloc.range.slice(0))),(lines=match[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},"test_match"),next:__name(function(){if(this.done)return this.EOF;var token,match,tempMatch,index;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;i<rules.length;i++)if((tempMatch=this._input.match(this.rules[rules[i]]))&&(!match||tempMatch[0].length>match[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(!1!==(token=this.test_match(tempMatch,rules[i])))return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?!1!==(token=this.test_match(match,rules[index]))&&token:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:__name(function(){var r=this.next();return r||this.lex()},"lex"),begin:__name(function(condition){this.conditionStack.push(condition)},"begin"),popState:__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:__name(function(n){return(n=this.conditionStack.length-1-Math.abs(n||0))>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:__name(function(condition){this.begin(condition)},"pushState"),stateStackSize:__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:__name(function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(yy.getIndentMode&&yy.getIndentMode())return yy.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:yy.setIndentMode&&yy.setIndentMode(!1),this.begin("INITIAL"),this.unput(yy_.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!yy.consumeIndentText)return 19;yy.consumeIndentText=!1;break;case 15:return 24;case 16:return yy_.yytext=yy_.yytext.slice(2,-2),14;case 17:return yy_.yytext=yy_.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}}}();function Parser(){this.yy={}}return parser2.lexer=lexer,__name(Parser,"Parser"),Parser.prototype=parser2,parser2.Parser=Parser,new Parser}();parser.parser=parser;var currentSets,venn_default=parser,subsets=[],textNodes=[],styleEntries=[],knownSets=new Set,indentMode=!1,addSubsetData=__name((identifierList,label,size)=>{const sets=normalizeIdentifierList(identifierList).sort(),resolvedSize=size??10/Math.pow(identifierList.length,2);currentSets=sets,1===sets.length&&knownSets.add(sets[0]),subsets.push({sets:sets,size:resolvedSize,label:label?normalizeText(label):void 0})},"addSubsetData"),getSubsetData=__name(()=>subsets,"getSubsetData"),normalizeText=__name(text=>{const trimmed=text.trim();return trimmed.length>=2&&trimmed.startsWith('"')&&trimmed.endsWith('"')?trimmed.slice(1,-1):trimmed},"normalizeText"),normalizeStyleValue=__name(value=>value?normalizeText(value):value,"normalizeStyleValue"),addTextData=__name((identifierList,id,label)=>{const normalizedId=normalizeText(id);textNodes.push({sets:normalizeIdentifierList(identifierList).sort(),id:normalizedId,label:label?normalizeText(label):void 0})},"addTextData"),addStyleData=__name((identifierList,data)=>{const targets=normalizeIdentifierList(identifierList).sort(),styles={};for(const[key,value]of data)styles[key]=normalizeStyleValue(value)??value;styleEntries.push({targets:targets,styles:styles})},"addStyleData"),getStyleData=__name(()=>styleEntries,"getStyleData"),normalizeIdentifierList=__name(identifierList=>identifierList.map(identifier=>normalizeText(identifier)),"normalizeIdentifierList"),validateUnionIdentifiers=__name(identifierList=>{const unknown=normalizeIdentifierList(identifierList).filter(identifier=>!knownSets.has(identifier));if(unknown.length>0)throw new Error(`unknown set identifier: ${unknown.join(", ")}`)},"validateUnionIdentifiers"),getTextData=__name(()=>textNodes,"getTextData"),getCurrentSets=__name(()=>currentSets,"getCurrentSets"),getIndentMode=__name(()=>indentMode,"getIndentMode"),setIndentMode=__name(enabled=>{indentMode=enabled},"setIndentMode"),DEFAULT_VENN_CONFIG=defaultConfig_default.venn;function getConfig2(){return cleanAndMerge(DEFAULT_VENN_CONFIG,getConfig().venn)}__name(getConfig2,"getConfig");var db={getConfig:getConfig2,clear:__name(()=>{clear(),subsets.length=0,textNodes.length=0,styleEntries.length=0,knownSets.clear(),currentSets=void 0,indentMode=!1},"customClear"),setAccTitle:setAccTitle,getAccTitle:getAccTitle,setDiagramTitle:setDiagramTitle,getDiagramTitle:getDiagramTitle,getAccDescription:getAccDescription,setAccDescription:setAccDescription,addSubsetData:addSubsetData,getSubsetData:getSubsetData,addTextData:addTextData,addStyleData:addStyleData,validateUnionIdentifiers:validateUnionIdentifiers,getTextData:getTextData,getStyleData:getStyleData,getCurrentSets:getCurrentSets,getIndentMode:getIndentMode,setIndentMode:setIndentMode},styles_default=__name(options=>`\n .venn-title {\n font-size: 32px;\n fill: ${options.vennTitleTextColor};\n font-family: ${options.fontFamily};\n }\n\n .venn-circle text {\n font-size: 48px;\n font-family: ${options.fontFamily};\n }\n\n .venn-intersection text {\n font-size: 48px;\n fill: ${options.vennSetTextColor};\n font-family: ${options.fontFamily};\n }\n\n .venn-text-node {\n font-family: ${options.fontFamily};\n color: ${options.vennSetTextColor};\n }\n`,"getStyles");function buildStyleByKey(styleData){const map=new Map;for(const entry of styleData){const key=entry.targets.join("|"),existing=map.get(key);existing?Object.assign(existing,entry.styles):map.set(key,{...entry.styles})}return map}__name(buildStyleByKey,"buildStyleByKey");var draw=__name((_text,id,_version,diagObj)=>{var _a,_b,_c;const db2=diagObj.db,config=null==(_a=db2.getConfig)?void 0:_a.call(db2),{themeVariables:themeVariables,look:look,handDrawnSeed:handDrawnSeed}=getConfig(),isHandDrawn="handDrawn"===look,themeColors=[themeVariables.venn1,themeVariables.venn2,themeVariables.venn3,themeVariables.venn4,themeVariables.venn5,themeVariables.venn6,themeVariables.venn7,themeVariables.venn8].filter(Boolean),title=null==(_b=db2.getDiagramTitle)?void 0:_b.call(db2),sets=db2.getSubsetData(),textNodes2=db2.getTextData(),styleByKey=buildStyleByKey(db2.getStyleData()),svgWidth=(null==config?void 0:config.width)??800,svgHeight=(null==config?void 0:config.height)??450,scale2=svgWidth/1600,titleHeight=title?48*scale2:0,defaultTextColor=themeVariables.primaryTextColor??themeVariables.textColor,svg=selectSvgElement(id);svg.attr("viewBox",`0 0 ${svgWidth} ${svgHeight}`),title&&svg.append("text").text(title).attr("class","venn-title").attr("font-size",32*scale2+"px").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*scale2).style("fill",themeVariables.vennTitleTextColor||themeVariables.titleColor);const dummyD3root=select(document.createElement("div")),vennDiagram=VennDiagram().width(svgWidth).height(svgHeight-titleHeight);dummyD3root.datum(sets).call(vennDiagram);const roughSvg=isHandDrawn?at.svg(dummyD3root.select("svg").node()):void 0,layoutAreas=function(data,options={}){const{lossFunction:loss,layoutFunction:layout2=venn,normalize:normalize=!0,orientation:orientation=Math.PI/2,orientationOrder:orientationOrder,width:width=600,height:height=350,padding:padding=15,scaleToFit:scaleToFit=!1,symmetricalTextCentre:symmetricalTextCentre=!1,distinct:distinct,round:round=2}=options;let solution=layout2(data,{lossFunction:"default"!==loss&&loss?"logRatio"===loss?logRatioLossFunction:loss:lossFunction,distinct:distinct});normalize&&(solution=normalizeSolution(solution,orientation,orientationOrder));const circles=scaleSolution(solution,width,height,padding,scaleToFit),textCentres=computeTextCentres(circles,data,symmetricalTextCentre),circleLookup=new Map(Object.keys(circles).map(set=>[set,{set:set,x:circles[set].x,y:circles[set].y,radius:circles[set].radius}])),helpers=data.map(area=>{const circles2=area.sets.map(s=>circleLookup.get(s)),arcs=intersectionAreaArcs(circles2);return{circles:circles2,arcs:arcs,path:arcsToPath(arcs,round),area:area,has:new Set(area.sets)}});function genDistinctPath(sets){let r="";for(const e of helpers)e.has.size>sets.length&&sets.every(s=>e.has.has(s))&&(r+=" "+e.path);return r}return helpers.map(({circles:circles2,arcs:arcs,path:path,area:area})=>({data:area,text:textCentres[area.sets],circles:circles2,arcs:arcs,path:path,distinctPath:path+genDistinctPath(area.sets)}))}(sets,{width:svgWidth,height:svgHeight-titleHeight,padding:(null==config?void 0:config.padding)??15}),layoutByKey=new Map;for(const area of layoutAreas){const key=stableSetsKey([...area.data.sets].sort());layoutByKey.set(key,area)}textNodes2.length>0&&renderTextNodes(config,layoutByKey,dummyD3root,textNodes2,scale2,styleByKey);const themeDark=isDark(themeVariables.background||"#f4f4f4");dummyD3root.selectAll(".venn-circle").each(function(d,i){var _a2;const group=select(this),setsKey=stableSetsKey([...d.sets].sort()),customStyle=styleByKey.get(setsKey),baseColor=(null==customStyle?void 0:customStyle.fill)||themeColors[i%themeColors.length]||themeVariables.primaryColor;group.classed("venn-set-"+i%8,!0);const fillOpacity=(null==customStyle?void 0:customStyle["fill-opacity"])??.1,strokeColor=(null==customStyle?void 0:customStyle.stroke)||baseColor,strokeWidthVal=(null==customStyle?void 0:customStyle["stroke-width"])||""+5*scale2;if(isHandDrawn&&roughSvg){const layoutArea=layoutByKey.get(setsKey);if(layoutArea&&layoutArea.circles.length>0){const c=layoutArea.circles[0],roughNode=roughSvg.circle(c.x,c.y,2*c.radius,{roughness:.7,seed:handDrawnSeed,fill:transparentize(baseColor,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:60*i-41,stroke:strokeColor,strokeWidth:parseFloat(String(strokeWidthVal))});group.select("path").remove(),null==(_a2=group.node())||_a2.insertBefore(roughNode,group.select("text").node())}}else group.select("path").style("fill",baseColor).style("fill-opacity",fillOpacity).style("stroke",strokeColor).style("stroke-width",strokeWidthVal).style("stroke-opacity",.95);const textColor=(null==customStyle?void 0:customStyle.color)||(themeDark?lighten(baseColor,30):darken(baseColor,30));group.select("text").style("font-size",48*scale2+"px").style("fill",textColor)}),isHandDrawn&&roughSvg?dummyD3root.selectAll(".venn-intersection").each(function(d){var _a2;const group=select(this),setsKey=stableSetsKey([...d.sets].sort()),customStyle=styleByKey.get(setsKey),customFill=null==customStyle?void 0:customStyle.fill;if(customFill){const pathEl=group.select("path"),pathD=pathEl.attr("d");if(pathD){const roughNode=roughSvg.path(pathD,{roughness:.7,seed:handDrawnSeed,fill:transparentize(customFill,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),existingPath=pathEl.node();null==(_a2=null==existingPath?void 0:existingPath.parentNode)||_a2.insertBefore(roughNode,existingPath),pathEl.remove()}}else group.select("path").style("fill-opacity",0);group.select("text").style("font-size",48*scale2+"px").style("fill",(null==customStyle?void 0:customStyle.color)??themeVariables.vennSetTextColor??defaultTextColor)}):(dummyD3root.selectAll(".venn-intersection text").style("font-size",48*scale2+"px").style("fill",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.color)??themeVariables.vennSetTextColor??defaultTextColor}),dummyD3root.selectAll(".venn-intersection path").style("fill-opacity",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.fill)?1:0}).style("fill",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.fill)??"transparent"}));const vennGroup=svg.append("g").attr("transform",`translate(0, ${titleHeight})`),dummySvg=dummyD3root.select("svg").node();if(dummySvg&&"childNodes"in dummySvg)for(const child of[...dummySvg.childNodes])null==(_c=vennGroup.node())||_c.appendChild(child);configureSvgSize(svg,svgHeight,svgWidth,(null==config?void 0:config.useMaxWidth)??!0)},"draw");function stableSetsKey(setIds){return setIds.join("|")}function renderTextNodes(config,layoutByKey,dummyD3root,textNodes2,scale2,styleByKey){var _a;const useDebugLayout=(null==config?void 0:config.useDebugLayout)??!1,textGroup=dummyD3root.select("svg").append("g").attr("class","venn-text-nodes"),nodesByArea=new Map;for(const node of textNodes2){const key=stableSetsKey(node.sets),existing=nodesByArea.get(key);existing?existing.push(node):nodesByArea.set(key,[node])}for(const[key,nodes]of nodesByArea.entries()){const area=layoutByKey.get(key);if(!(null==area?void 0:area.text))continue;const centerX=area.text.x,centerY=area.text.y,minCircleRadius=Math.min(...area.circles.map(c=>c.radius)),innerRadiusRaw=Math.min(...area.circles.map(c=>c.radius-Math.hypot(centerX-c.x,centerY-c.y)));let innerRadius=Number.isFinite(innerRadiusRaw)?Math.max(0,innerRadiusRaw):0;0===innerRadius&&Number.isFinite(minCircleRadius)&&(innerRadius=.6*minCircleRadius);const areaGroup=textGroup.append("g").attr("class","venn-text-area").attr("font-size",40*scale2+"px");useDebugLayout&&areaGroup.append("circle").attr("class","venn-text-debug-circle").attr("cx",centerX).attr("cy",centerY).attr("r",innerRadius).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*scale2).attr("stroke-dasharray",`${6*scale2} ${4*scale2}`);const innerWidth=Math.max(80*scale2,2*innerRadius*.95),innerHeight=Math.max(60*scale2,2*innerRadius*.95),labelOffset=(area.data.label&&area.data.label.length>0?Math.min(32*scale2,.25*innerRadius):0)+(nodes.length<=2?30*scale2:0),startX=centerX-innerWidth/2,startY=centerY-innerHeight/2+labelOffset,cols=Math.max(1,Math.ceil(Math.sqrt(nodes.length))),cellWidth=innerWidth/cols,cellHeight=innerHeight/Math.max(1,Math.ceil(nodes.length/cols));for(const[i,node]of nodes.entries()){const col=i%cols,row=Math.floor(i/cols),x=startX+cellWidth*(col+.5),y=startY+cellHeight*(row+.5);useDebugLayout&&areaGroup.append("rect").attr("class","venn-text-debug-cell").attr("x",startX+cellWidth*col).attr("y",startY+cellHeight*row).attr("width",cellWidth).attr("height",cellHeight).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*scale2).attr("stroke-dasharray",`${4*scale2} ${3*scale2}`);const boxWidth=.9*cellWidth,boxHeight=.9*cellHeight,container=areaGroup.append("foreignObject").attr("class","venn-text-node-fo").attr("width",boxWidth).attr("height",boxHeight).attr("x",x-boxWidth/2).attr("y",y-boxHeight/2).attr("overflow","visible"),textColor=null==(_a=styleByKey.get(node.id))?void 0:_a.color,text=container.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(node.label??node.id);textColor&&text.style("color",textColor)}}}__name(stableSetsKey,"stableSetsKey"),__name(renderTextNodes,"renderTextNodes");var diagram={parser:venn_default,db:db,renderer:{draw:draw},styles:styles_default};export{diagram};
1
+ import{aC as adjustChannel,s as setAccDescription,g as getAccDescription,q as getDiagramTitle,p as setDiagramTitle,a as getAccTitle,b as setAccTitle,_ as __name,C as getConfig,H as selectSvgElement,d as select,ar as at,U as isDark,V as lighten,W as darken,e as configureSvgSize,y as clear,E as cleanAndMerge,F as defaultConfig_default}from"./mermaid.core-Cbqxn86C.js";import"./vendor-mdxeditor-CFAmRN3Y.js";import"./vendor-antd-DADYo_zg.js";import"./vendor-codemirror-tF6HNoR6.js";import"./vendor-markdown-DOJHsAxX.js";const transparentize=(color,amount)=>adjustChannel(color,"a",-amount);function intersectionArea(circles,stats){const intersectionPoints=function(circles){const ret=[];for(let i=0;i<circles.length;++i)for(let j=i+1;j<circles.length;++j){const intersect=circleCircleIntersection(circles[i],circles[j]);for(const p of intersect)p.parentIndex=[i,j],ret.push(p)}return ret}(circles),innerPoints=intersectionPoints.filter(p=>function(point,circles){return circles.every(circle=>distance(point,circle)<circle.radius+1e-10)}(p,circles));let arcArea=0,polygonArea=0;const arcs=[];if(innerPoints.length>1){const center=getCenter(innerPoints);for(let i=0;i<innerPoints.length;++i){const p=innerPoints[i];p.angle=Math.atan2(p.x-center.x,p.y-center.y)}innerPoints.sort((a,b)=>b.angle-a.angle);let p2=innerPoints[innerPoints.length-1];for(let i=0;i<innerPoints.length;++i){const p1=innerPoints[i];polygonArea+=(p2.x+p1.x)*(p1.y-p2.y);const midPoint={x:(p1.x+p2.x)/2,y:(p1.y+p2.y)/2};let arc=null;for(let j=0;j<p1.parentIndex.length;++j)if(p2.parentIndex.includes(p1.parentIndex[j])){const circle=circles[p1.parentIndex[j]],a1=Math.atan2(p1.x-circle.x,p1.y-circle.y),a2=Math.atan2(p2.x-circle.x,p2.y-circle.y);let angleDiff=a2-a1;angleDiff<0&&(angleDiff+=2*Math.PI);const a=a2-angleDiff/2;let width=distance(midPoint,{x:circle.x+circle.radius*Math.sin(a),y:circle.y+circle.radius*Math.cos(a)});width>2*circle.radius&&(width=2*circle.radius),(null==arc||arc.width>width)&&(arc={circle:circle,width:width,p1:p1,p2:p2,large:width>circle.radius,sweep:!0})}null!=arc&&(arcs.push(arc),arcArea+=circleArea(arc.circle.radius,arc.width),p2=p1)}}else{let smallest=circles[0];for(let i=1;i<circles.length;++i)circles[i].radius<smallest.radius&&(smallest=circles[i]);let disjoint=!1;for(let i=0;i<circles.length;++i)if(distance(circles[i],smallest)>Math.abs(smallest.radius-circles[i].radius)){disjoint=!0;break}disjoint?arcArea=polygonArea=0:(arcArea=smallest.radius*smallest.radius*Math.PI,arcs.push({circle:smallest,p1:{x:smallest.x,y:smallest.y+smallest.radius},p2:{x:smallest.x-1e-10,y:smallest.y+smallest.radius},width:2*smallest.radius,large:!0,sweep:!0}))}return polygonArea/=2,stats&&(stats.area=arcArea+polygonArea,stats.arcArea=arcArea,stats.polygonArea=polygonArea,stats.arcs=arcs,stats.innerPoints=innerPoints,stats.intersectionPoints=intersectionPoints),arcArea+polygonArea}function circleArea(r,width){return r*r*Math.acos(1-width/r)-(r-width)*Math.sqrt(width*(2*r-width))}function distance(p1,p2){return Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))}function circleOverlap(r1,r2,d){if(d>=r1+r2)return 0;if(d<=Math.abs(r1-r2))return Math.PI*Math.min(r1,r2)*Math.min(r1,r2);const w2=r2-(d*d-r1*r1+r2*r2)/(2*d);return circleArea(r1,r1-(d*d-r2*r2+r1*r1)/(2*d))+circleArea(r2,w2)}function circleCircleIntersection(p1,p2){const d=distance(p1,p2),r1=p1.radius,r2=p2.radius;if(d>=r1+r2||d<=Math.abs(r1-r2))return[];const a=(r1*r1-r2*r2+d*d)/(2*d),h=Math.sqrt(r1*r1-a*a),x0=p1.x+a*(p2.x-p1.x)/d,y0=p1.y+a*(p2.y-p1.y)/d,rx=-(p2.y-p1.y)*(h/d),ry=-(p2.x-p1.x)*(h/d);return[{x:x0+rx,y:y0-ry},{x:x0-rx,y:y0+ry}]}function getCenter(points){const center={x:0,y:0};for(const point of points)center.x+=point.x,center.y+=point.y;return center.x/=points.length,center.y/=points.length,center}function zeros(x){const r=new Array(x);for(let i=0;i<x;++i)r[i]=0;return r}function zerosM(x,y){return zeros(x).map(()=>zeros(y))}function dot(a,b){let ret=0;for(let i=0;i<a.length;++i)ret+=a[i]*b[i];return ret}function norm2(a){return Math.sqrt(dot(a,a))}function scale(ret,value,c){for(let i=0;i<value.length;++i)ret[i]=value[i]*c}function weightedSum(ret,w1,v1,w2,v2){for(let j=0;j<ret.length;++j)ret[j]=w1*v1[j]+w2*v2[j]}function nelderMead(f,x0,parameters){const maxIterations=(parameters=parameters||{}).maxIterations||200*x0.length,nonZeroDelta=parameters.nonZeroDelta||1.05,zeroDelta=parameters.zeroDelta||.001,minErrorDelta=parameters.minErrorDelta||1e-6,minTolerance=parameters.minErrorDelta||1e-5,rho=void 0!==parameters.rho?parameters.rho:1,chi=void 0!==parameters.chi?parameters.chi:2,psi=void 0!==parameters.psi?parameters.psi:-.5,sigma=void 0!==parameters.sigma?parameters.sigma:.5;let maxDiff;const N=x0.length,simplex=new Array(N+1);simplex[0]=x0,simplex[0].fx=f(x0),simplex[0].id=0;for(let i=0;i<N;++i){const point=x0.slice();point[i]=point[i]?point[i]*nonZeroDelta:zeroDelta,simplex[i+1]=point,simplex[i+1].fx=f(point),simplex[i+1].id=i+1}function updateSimplex(value){for(let i=0;i<value.length;i++)simplex[N][i]=value[i];simplex[N].fx=value.fx}const sortOrder=(a,b)=>a.fx-b.fx,centroid=x0.slice(),reflected=x0.slice(),contracted=x0.slice(),expanded=x0.slice();for(let iteration=0;iteration<maxIterations;++iteration){if(simplex.sort(sortOrder),parameters.history){const sortedSimplex=simplex.map(x=>{const state=x.slice();return state.fx=x.fx,state.id=x.id,state});sortedSimplex.sort((a,b)=>a.id-b.id),parameters.history.push({x:simplex[0].slice(),fx:simplex[0].fx,simplex:sortedSimplex})}maxDiff=0;for(let i=0;i<N;++i)maxDiff=Math.max(maxDiff,Math.abs(simplex[0][i]-simplex[1][i]));if(Math.abs(simplex[0].fx-simplex[N].fx)<minErrorDelta&&maxDiff<minTolerance)break;for(let i=0;i<N;++i){centroid[i]=0;for(let j=0;j<N;++j)centroid[i]+=simplex[j][i];centroid[i]/=N}const worst=simplex[N];if(weightedSum(reflected,1+rho,centroid,-rho,worst),reflected.fx=f(reflected),reflected.fx<simplex[0].fx)weightedSum(expanded,1+chi,centroid,-chi,worst),expanded.fx=f(expanded),expanded.fx<reflected.fx?updateSimplex(expanded):updateSimplex(reflected);else if(reflected.fx>=simplex[N-1].fx){let shouldReduce=!1;if(reflected.fx>worst.fx?(weightedSum(contracted,1+psi,centroid,-psi,worst),contracted.fx=f(contracted),contracted.fx<worst.fx?updateSimplex(contracted):shouldReduce=!0):(weightedSum(contracted,1-psi*rho,centroid,psi*rho,worst),contracted.fx=f(contracted),contracted.fx<reflected.fx?updateSimplex(contracted):shouldReduce=!0),shouldReduce){if(sigma>=1)break;for(let i=1;i<simplex.length;++i)weightedSum(simplex[i],1-sigma,simplex[0],sigma,simplex[i]),simplex[i].fx=f(simplex[i])}}else updateSimplex(reflected)}return simplex.sort(sortOrder),{fx:simplex[0].fx,x:simplex[0]}}function wolfeLineSearch(f,pk,current,next,a,c1,c2){const phi0=current.fx,phiPrime0=dot(current.fxprime,pk);let phi=phi0,phi_old=phi0,phiPrime=phiPrime0,a0=0;function zoom(a_lo,a_high,phi_lo){for(let iteration=0;iteration<16;++iteration)if(a=(a_lo+a_high)/2,weightedSum(next.x,1,current.x,a,pk),phi=next.fx=f(next.x,next.fxprime),phiPrime=dot(next.fxprime,pk),phi>phi0+c1*a*phiPrime0||phi>=phi_lo)a_high=a;else{if(Math.abs(phiPrime)<=-c2*phiPrime0)return a;phiPrime*(a_high-a_lo)>=0&&(a_high=a_lo),a_lo=a,phi_lo=phi}return 0}a=a||1,c1=c1||1e-6,c2=c2||.1;for(let iteration=0;iteration<10;++iteration){if(weightedSum(next.x,1,current.x,a,pk),phi=next.fx=f(next.x,next.fxprime),phiPrime=dot(next.fxprime,pk),phi>phi0+c1*a*phiPrime0||iteration&&phi>=phi_old)return zoom(a0,a,phi_old);if(Math.abs(phiPrime)<=-c2*phiPrime0)return a;if(phiPrime>=0)return zoom(a,a0,phi);phi_old=phi,a0=a,a*=2}return a}function conjugateGradient(f,initial,params){let current={x:initial.slice(),fx:0,fxprime:initial.slice()},next={x:initial.slice(),fx:0,fxprime:initial.slice()};const yk=initial.slice();let pk,temp,maxIterations,a=1;maxIterations=(params=params||{}).maxIterations||20*initial.length,current.fx=f(current.x,current.fxprime),pk=current.fxprime.slice(),scale(pk,current.fxprime,-1);for(let i=0;i<maxIterations;++i){if(a=wolfeLineSearch(f,pk,current,next,a),params.history&&params.history.push({x:current.x.slice(),fx:current.fx,fxprime:current.fxprime.slice(),alpha:a}),a){weightedSum(yk,1,next.fxprime,-1,current.fxprime);const delta_k=dot(current.fxprime,current.fxprime);weightedSum(pk,Math.max(0,dot(yk,next.fxprime)/delta_k),pk,-1,next.fxprime),temp=current,current=next,next=temp}else scale(pk,current.fxprime,-1);if(norm2(current.fxprime)<=1e-5)break}return params.history&&params.history.push({x:current.x.slice(),fx:current.fx,fxprime:current.fxprime.slice(),alpha:a}),current}function venn(sets,parameters={}){parameters.maxIterations=parameters.maxIterations||500;const initialLayout=parameters.initialLayout||bestInitialLayout,loss=parameters.lossFunction||lossFunction,areas=function(areas,parameters={}){const distinct=parameters.distinct,r=areas.map(s=>Object.assign({},s));function toKey(arr){return arr.join(";")}if(distinct){const count=new Map;for(const area of r)for(let i=0;i<area.sets.length;i++){const si=String(area.sets[i]);count.set(si,area.size+(count.get(si)||0));for(let j=i+1;j<area.sets.length;j++){const sj=String(area.sets[j]),k1=`${si};${sj}`,k2=`${sj};${si}`;count.set(k1,area.size+(count.get(k1)||0)),count.set(k2,area.size+(count.get(k2)||0))}}for(const area of r)area.sets.length<3&&(area.size=count.get(toKey(area.sets)))}const ids=[],pairs=new Set;for(const area of r)if(1===area.sets.length)ids.push(area.sets[0]);else if(2===area.sets.length){const a=area.sets[0],b=area.sets[1];pairs.add(toKey(area.sets)),pairs.add(toKey([b,a]))}ids.sort((a,b)=>a===b?0:a<b?-1:1);for(let i=0;i<ids.length;++i){const a=ids[i];for(let j=i+1;j<ids.length;++j){const b=ids[j];pairs.has(toKey([a,b]))||r.push({sets:[a,b],size:0})}}return r}(sets,parameters),circles=initialLayout(areas,parameters),setids=Object.keys(circles),initial=[];for(const setid of setids)initial.push(circles[setid].x),initial.push(circles[setid].y);const positions=nelderMead(values=>{const current={};for(let i=0;i<setids.length;++i){const setid=setids[i];current[setid]={x:values[2*i],y:values[2*i+1],radius:circles[setid].radius}}return loss(current,areas)},initial,parameters).x;for(let i=0;i<setids.length;++i){const setid=setids[i];circles[setid].x=positions[2*i],circles[setid].y=positions[2*i+1]}return circles}const SMALL=1e-10;function distanceFromIntersectArea(r1,r2,overlap){return Math.min(r1,r2)*Math.min(r1,r2)*Math.PI<=overlap+SMALL?Math.abs(r1-r2):function(f,a,b,parameters){const maxIterations=(parameters=parameters||{}).maxIterations||100,tolerance=parameters.tolerance||1e-10,fA=f(a),fB=f(b);let delta=b-a;if(fA*fB>0)throw"Initial bisect points must have opposite signs";if(0===fA)return a;if(0===fB)return b;for(let i=0;i<maxIterations;++i){delta/=2;const mid=a+delta,fMid=f(mid);if(fMid*fA>=0&&(a=mid),Math.abs(delta)<tolerance||0===fMid)return mid}return a+delta}(distance2=>circleOverlap(r1,r2,distance2)-overlap,0,r1+r2)}function bestInitialLayout(areas,params={}){let initial=function(areas,params){const loss=params&&params.lossFunction?params.lossFunction:lossFunction,circles={},setOverlaps={};for(const area of areas)if(1===area.sets.length){const set=area.sets[0];circles[set]={x:1e10,y:1e10,rowid:circles.length,size:area.size,radius:Math.sqrt(area.size/Math.PI)},setOverlaps[set]=[]}areas=areas.filter(a=>2===a.sets.length);for(const current of areas){let weight=null!=current.weight?current.weight:1;const left=current.sets[0],right=current.sets[1];current.size+SMALL>=Math.min(circles[left].size,circles[right].size)&&(weight=0),setOverlaps[left].push({set:right,size:current.size,weight:weight}),setOverlaps[right].push({set:left,size:current.size,weight:weight})}const mostOverlapped=[];function sortOrder(a,b){return b.size-a.size}Object.keys(setOverlaps).forEach(set=>{let size=0;for(let i=0;i<setOverlaps[set].length;++i)size+=setOverlaps[set][i].size*setOverlaps[set][i].weight;mostOverlapped.push({set:set,size:size})}),mostOverlapped.sort(sortOrder);const positioned={};function isPositioned(element){return element.set in positioned}function positionSet(point,index){circles[index].x=point.x,circles[index].y=point.y,positioned[index]=!0}positionSet({x:0,y:0},mostOverlapped[0].set);for(let i=1;i<mostOverlapped.length;++i){const setIndex=mostOverlapped[i].set,overlap=setOverlaps[setIndex].filter(isPositioned),set=circles[setIndex];if(overlap.sort(sortOrder),0===overlap.length)throw"ERROR: missing pairwise overlap information";const points=[];for(var j=0;j<overlap.length;++j){const p1=circles[overlap[j].set],d1=distanceFromIntersectArea(set.radius,p1.radius,overlap[j].size);points.push({x:p1.x+d1,y:p1.y}),points.push({x:p1.x-d1,y:p1.y}),points.push({y:p1.y+d1,x:p1.x}),points.push({y:p1.y-d1,x:p1.x});for(let k=j+1;k<overlap.length;++k){const p2=circles[overlap[k].set],d2=distanceFromIntersectArea(set.radius,p2.radius,overlap[k].size),extraPoints=circleCircleIntersection({x:p1.x,y:p1.y,radius:d1},{x:p2.x,y:p2.y,radius:d2});points.push(...extraPoints)}}let bestLoss=1e50,bestPoint=points[0];for(const point of points){circles[setIndex].x=point.x,circles[setIndex].y=point.y;const localLoss=loss(circles,areas);localLoss<bestLoss&&(bestLoss=localLoss,bestPoint=point)}positionSet(bestPoint,setIndex)}return circles}(areas,params);const loss=params.lossFunction||lossFunction;if(areas.length>=8){const constrained=function(areas,params={}){const restarts=params.restarts||10,sets=[],setids={};for(const area of areas)1===area.sets.length&&(setids[area.sets[0]]=sets.length,sets.push(area));let{distances:distances,constraints:constraints}=function(areas,sets,setids){const distances=zerosM(sets.length,sets.length),constraints=zerosM(sets.length,sets.length);return areas.filter(x=>2===x.sets.length).forEach(current=>{const left=setids[current.sets[0]],right=setids[current.sets[1]],distance2=distanceFromIntersectArea(Math.sqrt(sets[left].size/Math.PI),Math.sqrt(sets[right].size/Math.PI),current.size);distances[left][right]=distances[right][left]=distance2;let c=0;current.size+1e-10>=Math.min(sets[left].size,sets[right].size)?c=1:current.size<=1e-10&&(c=-1),constraints[left][right]=constraints[right][left]=c}),{distances:distances,constraints:constraints}}(areas,sets,setids);const norm=norm2(distances.map(norm2))/distances.length;distances=distances.map(row=>row.map(value=>value/norm));const obj=(x,fxprime)=>function(x,fxprime,distances,constraints){for(let i=0;i<fxprime.length;++i)fxprime[i]=0;let loss=0;for(let i=0;i<distances.length;++i){const xi=x[2*i],yi=x[2*i+1];for(let j=i+1;j<distances.length;++j){const xj=x[2*j],yj=x[2*j+1],dij=distances[i][j],constraint=constraints[i][j],squaredDistance=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi),distance2=Math.sqrt(squaredDistance),delta=squaredDistance-dij*dij;constraint>0&&distance2<=dij||constraint<0&&distance2>=dij||(loss+=2*delta*delta,fxprime[2*i]+=4*delta*(xi-xj),fxprime[2*i+1]+=4*delta*(yi-yj),fxprime[2*j]+=4*delta*(xj-xi),fxprime[2*j+1]+=4*delta*(yj-yi))}}return loss}(x,fxprime,distances,constraints);let best=null;for(let i=0;i<restarts;++i){const current=conjugateGradient(obj,zeros(2*distances.length).map(Math.random),params);(!best||current.fx<best.fx)&&(best=current)}const positions=best.x,circles={};for(let i=0;i<sets.length;++i){const set=sets[i];circles[set.sets[0]]={x:positions[2*i]*norm,y:positions[2*i+1]*norm,radius:Math.sqrt(set.size/Math.PI)}}if(params.history)for(const h of params.history)scale(h.x,norm);return circles}(areas,params);loss(constrained,areas)+1e-8<loss(initial,areas)&&(initial=constrained)}return initial}function lossFunction(circles,overlaps){let output=0;for(const area of overlaps){if(1===area.sets.length)continue;let overlap;if(2===area.sets.length){const left=circles[area.sets[0]],right=circles[area.sets[1]];overlap=circleOverlap(left.radius,right.radius,distance(left,right))}else overlap=intersectionArea(area.sets.map(d=>circles[d]));output+=(null!=area.weight?area.weight:1)*(overlap-area.size)*(overlap-area.size)}return output}function logRatioLossFunction(circles,overlaps){let output=0;for(const area of overlaps){if(1===area.sets.length)continue;let overlap;if(2===area.sets.length){const left=circles[area.sets[0]],right=circles[area.sets[1]];overlap=circleOverlap(left.radius,right.radius,distance(left,right))}else overlap=intersectionArea(area.sets.map(d=>circles[d]));const weight=null!=area.weight?area.weight:1,differenceFromIdeal=Math.log((overlap+1)/(area.size+1));output+=weight*differenceFromIdeal*differenceFromIdeal}return output}function orientateCircles(circles,orientation,orientationOrder){if(null==orientationOrder?circles.sort((a,b)=>b.radius-a.radius):circles.sort(orientationOrder),circles.length>0){const largestX=circles[0].x,largestY=circles[0].y;for(const circle of circles)circle.x-=largestX,circle.y-=largestY}if(2===circles.length){distance(circles[0],circles[1])<Math.abs(circles[1].radius-circles[0].radius)&&(circles[1].x=circles[0].x+circles[0].radius-circles[1].radius-1e-10,circles[1].y=circles[0].y)}if(circles.length>1){const rotation=Math.atan2(circles[1].x,circles[1].y)-orientation,c=Math.cos(rotation),s=Math.sin(rotation);for(const circle of circles){const x=circle.x,y=circle.y;circle.x=c*x-s*y,circle.y=s*x+c*y}}if(circles.length>2){let angle=Math.atan2(circles[2].x,circles[2].y)-orientation;for(;angle<0;)angle+=2*Math.PI;for(;angle>2*Math.PI;)angle-=2*Math.PI;if(angle>Math.PI){const slope=circles[1].y/(1e-10+circles[1].x);for(const circle of circles){var d=(circle.x+slope*circle.y)/(1+slope*slope);circle.x=2*d-circle.x,circle.y=2*d*slope-circle.y}}}}function getBoundingBox(circles){const minMax=d=>({max:circles.reduce((acc,c)=>Math.max(acc,c[d]+c.radius),Number.NEGATIVE_INFINITY),min:circles.reduce((acc,c)=>Math.min(acc,c[d]-c.radius),Number.POSITIVE_INFINITY)});return{xRange:minMax("x"),yRange:minMax("y")}}function normalizeSolution(solution,orientation,orientationOrder){null==orientation&&(orientation=Math.PI/2);let circles=fromObjectNotation(solution).map(d=>Object.assign({},d));const clusters=function(circles){function find(circle){return circle.parent!==circle&&(circle.parent=find(circle.parent)),circle.parent}function union(x,y){const xRoot=find(x),yRoot=find(y);xRoot.parent=yRoot}circles.forEach(circle=>{circle.parent=circle});for(let i=0;i<circles.length;++i)for(let j=i+1;j<circles.length;++j){const maxDistance=circles[i].radius+circles[j].radius;distance(circles[i],circles[j])+1e-10<maxDistance&&union(circles[j],circles[i])}const disjointClusters=new Map;for(let i=0;i<circles.length;++i){const setid=find(circles[i]).parent.setid;disjointClusters.has(setid)||disjointClusters.set(setid,[]),disjointClusters.get(setid).push(circles[i])}return circles.forEach(circle=>{delete circle.parent}),Array.from(disjointClusters.values())}(circles);for(const cluster of clusters){orientateCircles(cluster,orientation,orientationOrder);const bounds=getBoundingBox(cluster);cluster.size=(bounds.xRange.max-bounds.xRange.min)*(bounds.yRange.max-bounds.yRange.min),cluster.bounds=bounds}clusters.sort((a,b)=>b.size-a.size),circles=clusters[0];let returnBounds=circles.bounds;const spacing=(returnBounds.xRange.max-returnBounds.xRange.min)/50;function addCluster(cluster,right,bottom){if(!cluster)return;const bounds=cluster.bounds;let xOffset,yOffset;if(right)xOffset=returnBounds.xRange.max-bounds.xRange.min+spacing;else{xOffset=returnBounds.xRange.max-bounds.xRange.max;const centreing=(bounds.xRange.max-bounds.xRange.min)/2-(returnBounds.xRange.max-returnBounds.xRange.min)/2;centreing<0&&(xOffset+=centreing)}if(bottom)yOffset=returnBounds.yRange.max-bounds.yRange.min+spacing;else{yOffset=returnBounds.yRange.max-bounds.yRange.max;const centreing=(bounds.yRange.max-bounds.yRange.min)/2-(returnBounds.yRange.max-returnBounds.yRange.min)/2;centreing<0&&(yOffset+=centreing)}for(const c of cluster)c.x+=xOffset,c.y+=yOffset,circles.push(c)}let index=1;for(;index<clusters.length;)addCluster(clusters[index],!0,!1),addCluster(clusters[index+1],!1,!0),addCluster(clusters[index+2],!0,!0),index+=3,returnBounds=getBoundingBox(circles);return toObjectNotation(circles)}function scaleSolution(solution,width,height,padding,scaleToFit){const circles=fromObjectNotation(solution);width-=2*padding,height-=2*padding;const{xRange:xRange,yRange:yRange}=getBoundingBox(circles);if(xRange.max===xRange.min||yRange.max===yRange.min)return console.log("not scaling solution: zero size detected"),solution;let xScaling,yScaling;if(scaleToFit){const toScaleDiameter=2*Math.sqrt(scaleToFit/Math.PI);xScaling=width/toScaleDiameter,yScaling=height/toScaleDiameter}else xScaling=width/(xRange.max-xRange.min),yScaling=height/(yRange.max-yRange.min);const scaling=Math.min(yScaling,xScaling),xOffset=(width-(xRange.max-xRange.min)*scaling)/2,yOffset=(height-(yRange.max-yRange.min)*scaling)/2;return toObjectNotation(circles.map(circle=>({radius:scaling*circle.radius,x:padding+xOffset+(circle.x-xRange.min)*scaling,y:padding+yOffset+(circle.y-yRange.min)*scaling,setid:circle.setid})))}function toObjectNotation(circles){const r={};for(const circle of circles)r[circle.setid]=circle;return r}function fromObjectNotation(solution){return Object.keys(solution).map(id=>Object.assign(solution[id],{setid:id}))}function VennDiagram(options={}){let useViewBox=!1,width=600,height=350,padding=15,duration=1e3,orientation=Math.PI/2,normalize=!0,scaleToFit=null,wrap=!0,styled=!0,fontSize=null,orientationOrder=null,distinct=!1,round=null,symmetricalTextCentre=!(!options||!options.symmetricalTextCentre)&&options.symmetricalTextCentre,colourMap={},colourScheme=options&&options.colourScheme?options.colourScheme:options&&options.colorScheme?options.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],colourIndex=0,colours=function(key){if(key in colourMap)return colourMap[key];var ret=colourMap[key]=colourScheme[colourIndex];return colourIndex+=1,colourIndex>=colourScheme.length&&(colourIndex=0),ret},layoutFunction=venn,loss=lossFunction;function chart(selection){let data=selection.datum();const toRemove=new Set;data.forEach(datum=>{0==datum.size&&1==datum.sets.length&&toRemove.add(datum.sets[0])}),data=data.filter(datum=>!datum.sets.some(set=>toRemove.has(set)));let circles={},textCentres={};if(data.length>0){let solution=layoutFunction(data,{lossFunction:loss,distinct:distinct});normalize&&(solution=normalizeSolution(solution,orientation,orientationOrder)),circles=scaleSolution(solution,width,height,padding,scaleToFit),textCentres=computeTextCentres(circles,data,symmetricalTextCentre)}const labels={};function label(d){return d.sets in labels?labels[d.sets]:1==d.sets.length?""+d.sets[0]:void 0}data.forEach(datum=>{datum.label&&(labels[datum.sets]=datum.label)}),selection.selectAll("svg").data([circles]).enter().append("svg");const svg=selection.select("svg");useViewBox?svg.attr("viewBox",`0 0 ${width} ${height}`):svg.attr("width",width).attr("height",height);const previous={};let hasPrevious=!1;function pathTween(d){return t=>intersectionAreaPath(d.sets.map(set=>{let start=previous[set],end=circles[set];return start||(start={x:width/2,y:height/2,radius:1}),end||(end={x:width/2,y:height/2,radius:1}),{x:start.x*(1-t)+end.x*t,y:start.y*(1-t)+end.y*t,radius:start.radius*(1-t)+end.radius*t}}),round)}svg.selectAll(".venn-area path").each(function(d){const path=this.getAttribute("d");1==d.sets.length&&path&&!distinct&&(hasPrevious=!0,previous[d.sets[0]]=function(path){const tokens=path.split(" ");return{x:Number.parseFloat(tokens[1]),y:Number.parseFloat(tokens[2]),radius:-Number.parseFloat(tokens[4])}}(path))});const nodes=svg.selectAll(".venn-area").data(data,d=>d.sets),enter=nodes.enter().append("g").attr("class",d=>`venn-area venn-${1==d.sets.length?"circle":"intersection"}${d.colour||d.color?" venn-coloured":""}`).attr("data-venn-sets",d=>d.sets.join("_")),enterPath=enter.append("path"),enterText=enter.append("text").attr("class","label").text(d=>label(d)).attr("text-anchor","middle").attr("dy",".35em").attr("x",width/2).attr("y",height/2);function asTransition(s){return"function"==typeof s.transition?s.transition("venn").duration(duration):s}styled&&(enterPath.style("fill-opacity","0").filter(d=>1==d.sets.length).style("fill",d=>d.colour?d.colour:d.color?d.color:colours(d.sets)).style("fill-opacity",".25"),enterText.style("fill",d=>d.colour||d.color?"#FFF":options.textFill?options.textFill:1==d.sets.length?colours(d.sets):"#444"));let update=selection;hasPrevious&&"function"==typeof update.transition?(update=asTransition(selection),update.selectAll("path").attrTween("d",pathTween)):update.selectAll("path").attr("d",d=>intersectionAreaPath(d.sets.map(set=>circles[set])),round);const updateText=update.selectAll("text").filter(d=>d.sets in textCentres).text(d=>label(d)).attr("x",d=>Math.floor(textCentres[d.sets].x)).attr("y",d=>Math.floor(textCentres[d.sets].y));wrap&&(hasPrevious?"on"in updateText?updateText.on("end",wrapText(circles,label)):updateText.each("end",wrapText(circles,label)):updateText.each(wrapText(circles,label)));const exit=asTransition(nodes.exit()).remove();"function"==typeof nodes.transition&&exit.selectAll("path").attrTween("d",pathTween);const exitText=exit.selectAll("text").attr("x",width/2).attr("y",height/2);return null!==fontSize&&(enterText.style("font-size","0px"),updateText.style("font-size",fontSize),exitText.style("font-size","0px")),{circles:circles,textCentres:textCentres,nodes:nodes,enter:enter,update:update,exit:exit}}return chart.wrap=function(_){return arguments.length?(wrap=_,chart):wrap},chart.useViewBox=function(){return useViewBox=!0,chart},chart.width=function(_){return arguments.length?(width=_,chart):width},chart.height=function(_){return arguments.length?(height=_,chart):height},chart.padding=function(_){return arguments.length?(padding=_,chart):padding},chart.distinct=function(_){return arguments.length?(distinct=_,chart):distinct},chart.colours=function(_){return arguments.length?(colours=_,chart):colours},chart.colors=function(_){return arguments.length?(colours=_,chart):colours},chart.fontSize=function(_){return arguments.length?(fontSize=_,chart):fontSize},chart.round=function(_){return arguments.length?(round=_,chart):round},chart.duration=function(_){return arguments.length?(duration=_,chart):duration},chart.layoutFunction=function(_){return arguments.length?(layoutFunction=_,chart):layoutFunction},chart.normalize=function(_){return arguments.length?(normalize=_,chart):normalize},chart.scaleToFit=function(_){return arguments.length?(scaleToFit=_,chart):scaleToFit},chart.styled=function(_){return arguments.length?(styled=_,chart):styled},chart.orientation=function(_){return arguments.length?(orientation=_,chart):orientation},chart.orientationOrder=function(_){return arguments.length?(orientationOrder=_,chart):orientationOrder},chart.lossFunction=function(_){return arguments.length?(loss="default"===_?lossFunction:"logRatio"===_?logRatioLossFunction:_,chart):loss},chart}function wrapText(circles,labeller){return function(data){const text=this,width=circles[data.sets[0]].radius||50,label=labeller(data)||"",words=label.split(/\s+/).reverse(),minChars=(label.length+words.length)/3;let word=words.pop(),line=[word],lineNumber=0;text.textContent=null;const tspans=[];function append(word2){const tspan2=text.ownerDocument.createElementNS(text.namespaceURI,"tspan");return tspan2.textContent=word2,tspans.push(tspan2),text.append(tspan2),tspan2}let tspan=append(word);for(;word=words.pop(),word;){line.push(word);const joined=line.join(" ");tspan.textContent=joined,joined.length>minChars&&tspan.getComputedTextLength()>width&&(line.pop(),tspan.textContent=line.join(" "),line=[word],tspan=append(word),lineNumber++)}const initial=.35-1.1*lineNumber/2,x=text.getAttribute("x"),y=text.getAttribute("y");tspans.forEach((t,i)=>{t.setAttribute("x",x),t.setAttribute("y",y),t.setAttribute("dy",`${initial+1.1*i}em`)})}}function circleMargin(current,interior,exterior){let margin=interior[0].radius-distance(interior[0],current);for(let i=1;i<interior.length;++i){const m=interior[i].radius-distance(interior[i],current);m<=margin&&(margin=m)}for(let i=0;i<exterior.length;++i){const m=distance(exterior[i],current)-exterior[i].radius;m<=margin&&(margin=m)}return margin}function computeTextCentre(interior,exterior,symmetricalTextCentre){const points=[];for(const c of interior)points.push({x:c.x,y:c.y}),points.push({x:c.x+c.radius/2,y:c.y}),points.push({x:c.x-c.radius/2,y:c.y}),points.push({x:c.x,y:c.y+c.radius/2}),points.push({x:c.x,y:c.y-c.radius/2});let initial=points[0],margin=circleMargin(points[0],interior,exterior);for(let i=1;i<points.length;++i){const m=circleMargin(points[i],interior,exterior);m>=margin&&(initial=points[i],margin=m)}const solution=nelderMead(p=>-1*circleMargin({x:p[0],y:p[1]},interior,exterior),[initial.x,initial.y],{maxIterations:500,minErrorDelta:1e-10}).x,ret={x:symmetricalTextCentre?0:solution[0],y:solution[1]};let valid=!0;for(const i of interior)if(distance(ret,i)>i.radius){valid=!1;break}for(const e of exterior)if(distance(ret,e)<e.radius){valid=!1;break}if(valid)return ret;if(1==interior.length)return{x:interior[0].x,y:interior[0].y};const areaStats={};return intersectionArea(interior,areaStats),0===areaStats.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==areaStats.arcs.length?{x:areaStats.arcs[0].circle.x,y:areaStats.arcs[0].circle.y}:exterior.length?computeTextCentre(interior,[]):getCenter(areaStats.arcs.map(a=>a.p1))}function computeTextCentres(circles,areas,symmetricalTextCentre){const ret={},overlapped=function(circles){const ret={},circleids=Object.keys(circles);for(const circleid of circleids)ret[circleid]=[];for(let i=0;i<circleids.length;i++){const ci=circleids[i],a=circles[ci];for(let j=i+1;j<circleids.length;++j){const cj=circleids[j],b=circles[cj],d=distance(a,b);d+b.radius<=a.radius+1e-10?ret[cj].push(ci):d+a.radius<=b.radius+1e-10&&ret[ci].push(cj)}}return ret}(circles);for(let i=0;i<areas.length;++i){const area=areas[i].sets,areaids={},exclude={};for(let j=0;j<area.length;++j){areaids[area[j]]=!0;const overlaps=overlapped[area[j]];for(let k=0;k<overlaps.length;++k)exclude[overlaps[k]]=!0}const interior=[],exterior=[];for(let setid in circles)setid in areaids?interior.push(circles[setid]):setid in exclude||exterior.push(circles[setid]);const centre=computeTextCentre(interior,exterior,symmetricalTextCentre);ret[area]=centre,centre.disjoint&&areas[i].size>0&&console.log("WARNING: area "+area+" not represented on screen")}return ret}function intersectionAreaArcs(circles){if(0===circles.length)return[];const stats={};return intersectionArea(circles,stats),stats.arcs}function arcsToPath(arcs,round){if(0===arcs.length)return"M 0 0";const rFactor=Math.pow(10,round||0),r=null!=round?v=>Math.round(v*rFactor)/rFactor:v=>v;if(1==arcs.length){const circle=arcs[0].circle;return function(x,y,r){const ret=[];return ret.push("\nM",x,y),ret.push("\nm",-r,0),ret.push("\na",r,r,0,1,0,2*r,0),ret.push("\na",r,r,0,1,0,2*-r,0),ret.join(" ")}(r(circle.x),r(circle.y),r(circle.radius))}const ret=["\nM",r(arcs[0].p2.x),r(arcs[0].p2.y)];for(const arc of arcs){const radius=r(arc.circle.radius);ret.push("\nA",radius,radius,0,arc.large?1:0,arc.sweep?1:0,r(arc.p1.x),r(arc.p1.y))}return ret.join(" ")}function intersectionAreaPath(circles,round){return arcsToPath(intersectionAreaArcs(circles),round)}var parser=function(){var o=__name(function(k,v,o2,l){for(o2=o2||{},l=k.length;l--;o2[k[l]]=v);return o2},"o"),$V0=[5,8],$V1=[7,8,11,12,17,19,22,24],$V2=[1,17],$V3=[1,18],$V4=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],$V5=[1,31],$V6=[1,39],$V7=[7,8,11,12,17,19,22,24,27],$V8=[1,57],$V9=[1,56],$Va=[1,58],$Vb=[1,59],$Vc=[1,60],$Vd=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],parser2={trace:__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:__name(function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:return $$[$0-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:$$[$0-1].push($$[$0]),this.$=$$[$0-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=$$[$0];break;case 8:yy.setDiagramTitle($$[$0].substr(6)),this.$=$$[$0].substr(6);break;case 9:yy.addSubsetData([$$[$0]],void 0,void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 10:yy.addSubsetData([$$[$0-1]],$$[$0],void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 11:yy.addSubsetData([$$[$0-2]],void 0,parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 12:yy.addSubsetData([$$[$0-3]],$$[$0-2],parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 13:if($$[$0].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0]),yy.addSubsetData($$[$0],void 0,void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 14:if($$[$0-1].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-1]),yy.addSubsetData($$[$0-1],$$[$0],void 0),yy.setIndentMode&&yy.setIndentMode(!0);break;case 15:if($$[$0-2].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-2]),yy.addSubsetData($$[$0-2],void 0,parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 16:if($$[$0-3].length<2)throw new Error("union requires multiple identifiers");yy.validateUnionIdentifiers&&yy.validateUnionIdentifiers($$[$0-3]),yy.addSubsetData($$[$0-3],$$[$0-2],parseFloat($$[$0])),yy.setIndentMode&&yy.setIndentMode(!0);break;case 17:case 18:case 19:yy.addTextData($$[$0-1],$$[$0],void 0);break;case 20:case 21:yy.addTextData($$[$0-2],$$[$0-1],$$[$0]);break;case 23:yy.addStyleData($$[$0-1],$$[$0]);break;case 24:case 25:case 26:if(!(cs=yy.getCurrentSets()))throw new Error("text requires set");yy.addTextData(cs,$$[$0],void 0);break;case 27:case 28:var cs;if(!(cs=yy.getCurrentSets()))throw new Error("text requires set");yy.addTextData(cs,$$[$0-1],$$[$0]);break;case 29:case 41:case 34:this.$=[$$[$0]];break;case 30:case 42:this.$=[...$$[$0-2],$$[$0]];break;case 31:this.$=[$$[$0-2],$$[$0]];break;case 33:this.$=$$[$0].join(" ")}},"anonymous"),table:[o($V0,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},o($V1,[2,4],{6:5}),o($V0,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},o($V1,[2,5]),o($V1,[2,6]),o($V1,[2,7]),o($V1,[2,8]),{13:16,20:$V2,21:$V3},{13:20,18:19,20:$V2,21:$V3},{13:20,18:21,20:$V2,21:$V3},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:$V2,21:$V3},o($V1,[2,9],{14:[1,27],15:[1,28]}),o($V4,[2,43]),o($V4,[2,44]),o($V1,[2,13],{14:[1,29],15:[1,30],27:$V5}),o($V4,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:$V5},o($V1,[2,22]),o($V1,[2,24],{14:[1,35]}),o($V1,[2,25],{14:[1,36]}),o($V1,[2,26]),{20:$V6,25:37,26:38,27:$V5},o($V1,[2,10],{15:[1,40]}),{16:[1,41]},o($V1,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:$V2,21:$V3},o($V1,[2,17],{14:[1,45]}),o($V1,[2,18],{14:[1,46]}),o($V1,[2,19]),o($V1,[2,27]),o($V1,[2,28]),o($V1,[2,23],{27:[1,47]}),o($V7,[2,29]),{15:[1,48]},{16:[1,49]},o($V1,[2,11]),{16:[1,50]},o($V1,[2,15]),o($V4,[2,42]),o($V1,[2,20]),o($V1,[2,21]),{20:$V6,26:51},{16:$V8,20:$V9,21:[1,53],28:52,29:54,30:55,31:$Va,32:$Vb,33:$Vc},o($V1,[2,12]),o($V1,[2,16]),o($V7,[2,30]),o($V7,[2,31]),o($V7,[2,32]),o($V7,[2,33],{30:61,16:$V8,20:$V9,31:$Va,32:$Vb,33:$Vc}),o($Vd,[2,34]),o($Vd,[2,36]),o($Vd,[2,37]),o($Vd,[2,38]),o($Vd,[2,39]),o($Vd,[2,40]),o($Vd,[2,35])],defaultActions:{6:[2,1]},parseError:__name(function(str,hash){if(!hash.recoverable){var error=new Error(str);throw error.hash=hash,error}this.trace(str)},"parseError"),parse:__name(function(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,args=lstack.slice.call(arguments,1),lexer2=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer2.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer2,sharedState.yy.parser=this,void 0===lexer2.yylloc&&(lexer2.yylloc={});var yyloc=lexer2.yylloc;lstack.push(yyloc);var ranges=lexer2.options&&lexer2.options.ranges;function lex(){var token;return"number"!=typeof(token=tstack.pop()||lexer2.lex()||1)&&(token instanceof Array&&(token=(tstack=token).pop()),token=self.symbols_[token]||token),token}"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,__name(function(n){stack.length=stack.length-2*n,vstack.length=vstack.length-n,lstack.length=lstack.length-n},"popStack"),__name(lex,"lex");for(var symbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null==symbol&&(symbol=lex()),action=table[state]&&table[state][symbol]),void 0===action||!action.length||!action[0]){var errStr="";for(p in expected=[],table[state])this.terminals_[p]&&p>2&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer2.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer2.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(1==symbol?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer2.match,token:this.terminals_[symbol]||symbol,line:lexer2.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer2.yytext),lstack.push(lexer2.yylloc),stack.push(action[1]),symbol=null,yyleng=lexer2.yyleng,yytext=lexer2.yytext,yylineno=lexer2.yylineno,yyloc=lexer2.yylloc;break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),void 0!==(r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args))))return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0},"parse")},lexer=function(){return{EOF:1,parseError:__name(function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},"parseError"),setInput:__name(function(input,yy){return this.yy=yy||this.yy||{},this._input=input,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:__name(function(){var ch=this._input[0];return this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch,ch.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},"input"),unput:__name(function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),lines.length-1&&(this.yylineno-=lines.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),this.yyleng=this.yytext.length,this},"unput"),more:__name(function(){return this._more=!0,this},"more"),reject:__name(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:__name(function(n){this.unput(this.match.slice(n))},"less"),pastInput:__name(function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:__name(function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:__name(function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},"showPosition"),test_match:__name(function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(backup.yylloc.range=this.yylloc.range.slice(0))),(lines=match[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},"test_match"),next:__name(function(){if(this.done)return this.EOF;var token,match,tempMatch,index;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;i<rules.length;i++)if((tempMatch=this._input.match(this.rules[rules[i]]))&&(!match||tempMatch[0].length>match[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(!1!==(token=this.test_match(tempMatch,rules[i])))return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?!1!==(token=this.test_match(match,rules[index]))&&token:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:__name(function(){var r=this.next();return r||this.lex()},"lex"),begin:__name(function(condition){this.conditionStack.push(condition)},"begin"),popState:__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:__name(function(n){return(n=this.conditionStack.length-1-Math.abs(n||0))>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:__name(function(condition){this.begin(condition)},"pushState"),stateStackSize:__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:__name(function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(yy.getIndentMode&&yy.getIndentMode())return yy.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:yy.setIndentMode&&yy.setIndentMode(!1),this.begin("INITIAL"),this.unput(yy_.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!yy.consumeIndentText)return 19;yy.consumeIndentText=!1;break;case 15:return 24;case 16:return yy_.yytext=yy_.yytext.slice(2,-2),14;case 17:return yy_.yytext=yy_.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}}}();function Parser(){this.yy={}}return parser2.lexer=lexer,__name(Parser,"Parser"),Parser.prototype=parser2,parser2.Parser=Parser,new Parser}();parser.parser=parser;var currentSets,venn_default=parser,subsets=[],textNodes=[],styleEntries=[],knownSets=new Set,indentMode=!1,addSubsetData=__name((identifierList,label,size)=>{const sets=normalizeIdentifierList(identifierList).sort(),resolvedSize=size??10/Math.pow(identifierList.length,2);currentSets=sets,1===sets.length&&knownSets.add(sets[0]),subsets.push({sets:sets,size:resolvedSize,label:label?normalizeText(label):void 0})},"addSubsetData"),getSubsetData=__name(()=>subsets,"getSubsetData"),normalizeText=__name(text=>{const trimmed=text.trim();return trimmed.length>=2&&trimmed.startsWith('"')&&trimmed.endsWith('"')?trimmed.slice(1,-1):trimmed},"normalizeText"),normalizeStyleValue=__name(value=>value?normalizeText(value):value,"normalizeStyleValue"),addTextData=__name((identifierList,id,label)=>{const normalizedId=normalizeText(id);textNodes.push({sets:normalizeIdentifierList(identifierList).sort(),id:normalizedId,label:label?normalizeText(label):void 0})},"addTextData"),addStyleData=__name((identifierList,data)=>{const targets=normalizeIdentifierList(identifierList).sort(),styles={};for(const[key,value]of data)styles[key]=normalizeStyleValue(value)??value;styleEntries.push({targets:targets,styles:styles})},"addStyleData"),getStyleData=__name(()=>styleEntries,"getStyleData"),normalizeIdentifierList=__name(identifierList=>identifierList.map(identifier=>normalizeText(identifier)),"normalizeIdentifierList"),validateUnionIdentifiers=__name(identifierList=>{const unknown=normalizeIdentifierList(identifierList).filter(identifier=>!knownSets.has(identifier));if(unknown.length>0)throw new Error(`unknown set identifier: ${unknown.join(", ")}`)},"validateUnionIdentifiers"),getTextData=__name(()=>textNodes,"getTextData"),getCurrentSets=__name(()=>currentSets,"getCurrentSets"),getIndentMode=__name(()=>indentMode,"getIndentMode"),setIndentMode=__name(enabled=>{indentMode=enabled},"setIndentMode"),DEFAULT_VENN_CONFIG=defaultConfig_default.venn;function getConfig2(){return cleanAndMerge(DEFAULT_VENN_CONFIG,getConfig().venn)}__name(getConfig2,"getConfig");var db={getConfig:getConfig2,clear:__name(()=>{clear(),subsets.length=0,textNodes.length=0,styleEntries.length=0,knownSets.clear(),currentSets=void 0,indentMode=!1},"customClear"),setAccTitle:setAccTitle,getAccTitle:getAccTitle,setDiagramTitle:setDiagramTitle,getDiagramTitle:getDiagramTitle,getAccDescription:getAccDescription,setAccDescription:setAccDescription,addSubsetData:addSubsetData,getSubsetData:getSubsetData,addTextData:addTextData,addStyleData:addStyleData,validateUnionIdentifiers:validateUnionIdentifiers,getTextData:getTextData,getStyleData:getStyleData,getCurrentSets:getCurrentSets,getIndentMode:getIndentMode,setIndentMode:setIndentMode},styles_default=__name(options=>`\n .venn-title {\n font-size: 32px;\n fill: ${options.vennTitleTextColor};\n font-family: ${options.fontFamily};\n }\n\n .venn-circle text {\n font-size: 48px;\n font-family: ${options.fontFamily};\n }\n\n .venn-intersection text {\n font-size: 48px;\n fill: ${options.vennSetTextColor};\n font-family: ${options.fontFamily};\n }\n\n .venn-text-node {\n font-family: ${options.fontFamily};\n color: ${options.vennSetTextColor};\n }\n`,"getStyles");function buildStyleByKey(styleData){const map=new Map;for(const entry of styleData){const key=entry.targets.join("|"),existing=map.get(key);existing?Object.assign(existing,entry.styles):map.set(key,{...entry.styles})}return map}__name(buildStyleByKey,"buildStyleByKey");var draw=__name((_text,id,_version,diagObj)=>{var _a,_b,_c;const db2=diagObj.db,config=null==(_a=db2.getConfig)?void 0:_a.call(db2),{themeVariables:themeVariables,look:look,handDrawnSeed:handDrawnSeed}=getConfig(),isHandDrawn="handDrawn"===look,themeColors=[themeVariables.venn1,themeVariables.venn2,themeVariables.venn3,themeVariables.venn4,themeVariables.venn5,themeVariables.venn6,themeVariables.venn7,themeVariables.venn8].filter(Boolean),title=null==(_b=db2.getDiagramTitle)?void 0:_b.call(db2),sets=db2.getSubsetData(),textNodes2=db2.getTextData(),styleByKey=buildStyleByKey(db2.getStyleData()),svgWidth=(null==config?void 0:config.width)??800,svgHeight=(null==config?void 0:config.height)??450,scale2=svgWidth/1600,titleHeight=title?48*scale2:0,defaultTextColor=themeVariables.primaryTextColor??themeVariables.textColor,svg=selectSvgElement(id);svg.attr("viewBox",`0 0 ${svgWidth} ${svgHeight}`),title&&svg.append("text").text(title).attr("class","venn-title").attr("font-size",32*scale2+"px").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*scale2).style("fill",themeVariables.vennTitleTextColor||themeVariables.titleColor);const dummyD3root=select(document.createElement("div")),vennDiagram=VennDiagram().width(svgWidth).height(svgHeight-titleHeight);dummyD3root.datum(sets).call(vennDiagram);const roughSvg=isHandDrawn?at.svg(dummyD3root.select("svg").node()):void 0,layoutAreas=function(data,options={}){const{lossFunction:loss,layoutFunction:layout2=venn,normalize:normalize=!0,orientation:orientation=Math.PI/2,orientationOrder:orientationOrder,width:width=600,height:height=350,padding:padding=15,scaleToFit:scaleToFit=!1,symmetricalTextCentre:symmetricalTextCentre=!1,distinct:distinct,round:round=2}=options;let solution=layout2(data,{lossFunction:"default"!==loss&&loss?"logRatio"===loss?logRatioLossFunction:loss:lossFunction,distinct:distinct});normalize&&(solution=normalizeSolution(solution,orientation,orientationOrder));const circles=scaleSolution(solution,width,height,padding,scaleToFit),textCentres=computeTextCentres(circles,data,symmetricalTextCentre),circleLookup=new Map(Object.keys(circles).map(set=>[set,{set:set,x:circles[set].x,y:circles[set].y,radius:circles[set].radius}])),helpers=data.map(area=>{const circles2=area.sets.map(s=>circleLookup.get(s)),arcs=intersectionAreaArcs(circles2);return{circles:circles2,arcs:arcs,path:arcsToPath(arcs,round),area:area,has:new Set(area.sets)}});function genDistinctPath(sets){let r="";for(const e of helpers)e.has.size>sets.length&&sets.every(s=>e.has.has(s))&&(r+=" "+e.path);return r}return helpers.map(({circles:circles2,arcs:arcs,path:path,area:area})=>({data:area,text:textCentres[area.sets],circles:circles2,arcs:arcs,path:path,distinctPath:path+genDistinctPath(area.sets)}))}(sets,{width:svgWidth,height:svgHeight-titleHeight,padding:(null==config?void 0:config.padding)??15}),layoutByKey=new Map;for(const area of layoutAreas){const key=stableSetsKey([...area.data.sets].sort());layoutByKey.set(key,area)}textNodes2.length>0&&renderTextNodes(config,layoutByKey,dummyD3root,textNodes2,scale2,styleByKey);const themeDark=isDark(themeVariables.background||"#f4f4f4");dummyD3root.selectAll(".venn-circle").each(function(d,i){var _a2;const group=select(this),setsKey=stableSetsKey([...d.sets].sort()),customStyle=styleByKey.get(setsKey),baseColor=(null==customStyle?void 0:customStyle.fill)||themeColors[i%themeColors.length]||themeVariables.primaryColor;group.classed("venn-set-"+i%8,!0);const fillOpacity=(null==customStyle?void 0:customStyle["fill-opacity"])??.1,strokeColor=(null==customStyle?void 0:customStyle.stroke)||baseColor,strokeWidthVal=(null==customStyle?void 0:customStyle["stroke-width"])||""+5*scale2;if(isHandDrawn&&roughSvg){const layoutArea=layoutByKey.get(setsKey);if(layoutArea&&layoutArea.circles.length>0){const c=layoutArea.circles[0],roughNode=roughSvg.circle(c.x,c.y,2*c.radius,{roughness:.7,seed:handDrawnSeed,fill:transparentize(baseColor,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:60*i-41,stroke:strokeColor,strokeWidth:parseFloat(String(strokeWidthVal))});group.select("path").remove(),null==(_a2=group.node())||_a2.insertBefore(roughNode,group.select("text").node())}}else group.select("path").style("fill",baseColor).style("fill-opacity",fillOpacity).style("stroke",strokeColor).style("stroke-width",strokeWidthVal).style("stroke-opacity",.95);const textColor=(null==customStyle?void 0:customStyle.color)||(themeDark?lighten(baseColor,30):darken(baseColor,30));group.select("text").style("font-size",48*scale2+"px").style("fill",textColor)}),isHandDrawn&&roughSvg?dummyD3root.selectAll(".venn-intersection").each(function(d){var _a2;const group=select(this),setsKey=stableSetsKey([...d.sets].sort()),customStyle=styleByKey.get(setsKey),customFill=null==customStyle?void 0:customStyle.fill;if(customFill){const pathEl=group.select("path"),pathD=pathEl.attr("d");if(pathD){const roughNode=roughSvg.path(pathD,{roughness:.7,seed:handDrawnSeed,fill:transparentize(customFill,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),existingPath=pathEl.node();null==(_a2=null==existingPath?void 0:existingPath.parentNode)||_a2.insertBefore(roughNode,existingPath),pathEl.remove()}}else group.select("path").style("fill-opacity",0);group.select("text").style("font-size",48*scale2+"px").style("fill",(null==customStyle?void 0:customStyle.color)??themeVariables.vennSetTextColor??defaultTextColor)}):(dummyD3root.selectAll(".venn-intersection text").style("font-size",48*scale2+"px").style("fill",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.color)??themeVariables.vennSetTextColor??defaultTextColor}),dummyD3root.selectAll(".venn-intersection path").style("fill-opacity",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.fill)?1:0}).style("fill",e=>{var _a2;const setsKey=stableSetsKey([...e.sets].sort());return(null==(_a2=styleByKey.get(setsKey))?void 0:_a2.fill)??"transparent"}));const vennGroup=svg.append("g").attr("transform",`translate(0, ${titleHeight})`),dummySvg=dummyD3root.select("svg").node();if(dummySvg&&"childNodes"in dummySvg)for(const child of[...dummySvg.childNodes])null==(_c=vennGroup.node())||_c.appendChild(child);configureSvgSize(svg,svgHeight,svgWidth,(null==config?void 0:config.useMaxWidth)??!0)},"draw");function stableSetsKey(setIds){return setIds.join("|")}function renderTextNodes(config,layoutByKey,dummyD3root,textNodes2,scale2,styleByKey){var _a;const useDebugLayout=(null==config?void 0:config.useDebugLayout)??!1,textGroup=dummyD3root.select("svg").append("g").attr("class","venn-text-nodes"),nodesByArea=new Map;for(const node of textNodes2){const key=stableSetsKey(node.sets),existing=nodesByArea.get(key);existing?existing.push(node):nodesByArea.set(key,[node])}for(const[key,nodes]of nodesByArea.entries()){const area=layoutByKey.get(key);if(!(null==area?void 0:area.text))continue;const centerX=area.text.x,centerY=area.text.y,minCircleRadius=Math.min(...area.circles.map(c=>c.radius)),innerRadiusRaw=Math.min(...area.circles.map(c=>c.radius-Math.hypot(centerX-c.x,centerY-c.y)));let innerRadius=Number.isFinite(innerRadiusRaw)?Math.max(0,innerRadiusRaw):0;0===innerRadius&&Number.isFinite(minCircleRadius)&&(innerRadius=.6*minCircleRadius);const areaGroup=textGroup.append("g").attr("class","venn-text-area").attr("font-size",40*scale2+"px");useDebugLayout&&areaGroup.append("circle").attr("class","venn-text-debug-circle").attr("cx",centerX).attr("cy",centerY).attr("r",innerRadius).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*scale2).attr("stroke-dasharray",`${6*scale2} ${4*scale2}`);const innerWidth=Math.max(80*scale2,2*innerRadius*.95),innerHeight=Math.max(60*scale2,2*innerRadius*.95),labelOffset=(area.data.label&&area.data.label.length>0?Math.min(32*scale2,.25*innerRadius):0)+(nodes.length<=2?30*scale2:0),startX=centerX-innerWidth/2,startY=centerY-innerHeight/2+labelOffset,cols=Math.max(1,Math.ceil(Math.sqrt(nodes.length))),cellWidth=innerWidth/cols,cellHeight=innerHeight/Math.max(1,Math.ceil(nodes.length/cols));for(const[i,node]of nodes.entries()){const col=i%cols,row=Math.floor(i/cols),x=startX+cellWidth*(col+.5),y=startY+cellHeight*(row+.5);useDebugLayout&&areaGroup.append("rect").attr("class","venn-text-debug-cell").attr("x",startX+cellWidth*col).attr("y",startY+cellHeight*row).attr("width",cellWidth).attr("height",cellHeight).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*scale2).attr("stroke-dasharray",`${4*scale2} ${3*scale2}`);const boxWidth=.9*cellWidth,boxHeight=.9*cellHeight,container=areaGroup.append("foreignObject").attr("class","venn-text-node-fo").attr("width",boxWidth).attr("height",boxHeight).attr("x",x-boxWidth/2).attr("y",y-boxHeight/2).attr("overflow","visible"),textColor=null==(_a=styleByKey.get(node.id))?void 0:_a.color,text=container.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(node.label??node.id);textColor&&text.style("color",textColor)}}}__name(stableSetsKey,"stableSetsKey"),__name(renderTextNodes,"renderTextNodes");var diagram={parser:venn_default,db:db,renderer:{draw:draw},styles:styles_default};export{diagram};