qsharp-lang 1.15.2-dev → 1.15.4-dev

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 (330) hide show
  1. package/dist/katas-content.generated.js +5 -5
  2. package/dist/katas-content.generated.md.js +5 -5
  3. package/dist/samples.generated.js +6 -0
  4. package/dist/shared/legacyCircuitUpdate.js +1 -0
  5. package/dist/shared/register.d.ts +5 -5
  6. package/docs/Microsoft.Quantum.Core/Length.md +1 -1
  7. package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
  8. package/docs/Microsoft.Quantum.Core/index.md +1 -1
  9. package/docs/Std.Arithmetic/AddLE.md +1 -1
  10. package/docs/Std.Arithmetic/ApplyIfEqualL.md +1 -1
  11. package/docs/Std.Arithmetic/ApplyIfEqualLE.md +1 -1
  12. package/docs/Std.Arithmetic/ApplyIfGreaterL.md +1 -1
  13. package/docs/Std.Arithmetic/ApplyIfGreaterLE.md +1 -1
  14. package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
  15. package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
  16. package/docs/Std.Arithmetic/ApplyIfLessL.md +1 -1
  17. package/docs/Std.Arithmetic/ApplyIfLessLE.md +1 -1
  18. package/docs/Std.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
  19. package/docs/Std.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
  20. package/docs/Std.Arithmetic/FourierTDIncByLE.md +1 -1
  21. package/docs/Std.Arithmetic/IncByI.md +1 -1
  22. package/docs/Std.Arithmetic/IncByIUsingIncByLE.md +1 -1
  23. package/docs/Std.Arithmetic/IncByL.md +1 -1
  24. package/docs/Std.Arithmetic/IncByLE.md +1 -1
  25. package/docs/Std.Arithmetic/IncByLEUsingAddLE.md +1 -1
  26. package/docs/Std.Arithmetic/IncByLUsingIncByLE.md +1 -1
  27. package/docs/Std.Arithmetic/LookAheadDKRSAddLE.md +1 -1
  28. package/docs/Std.Arithmetic/MAJ.md +1 -1
  29. package/docs/Std.Arithmetic/ReflectAboutInteger.md +1 -1
  30. package/docs/Std.Arithmetic/RippleCarryCGAddLE.md +1 -1
  31. package/docs/Std.Arithmetic/RippleCarryCGIncByLE.md +1 -1
  32. package/docs/Std.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
  33. package/docs/Std.Arithmetic/index.md +1 -1
  34. package/docs/Std.Arrays/All.md +1 -1
  35. package/docs/Std.Arrays/Any.md +1 -1
  36. package/docs/Std.Arrays/Chunks.md +1 -1
  37. package/docs/Std.Arrays/CircularlyShifted.md +1 -1
  38. package/docs/Std.Arrays/ColumnAt.md +1 -1
  39. package/docs/Std.Arrays/Count.md +1 -1
  40. package/docs/Std.Arrays/Diagonal.md +1 -1
  41. package/docs/Std.Arrays/DrawMany.md +1 -1
  42. package/docs/Std.Arrays/Enumerated.md +1 -1
  43. package/docs/Std.Arrays/Excluding.md +1 -1
  44. package/docs/Std.Arrays/Filtered.md +1 -1
  45. package/docs/Std.Arrays/FlatMapped.md +1 -1
  46. package/docs/Std.Arrays/Flattened.md +1 -1
  47. package/docs/Std.Arrays/Fold.md +1 -1
  48. package/docs/Std.Arrays/ForEach.md +1 -1
  49. package/docs/Std.Arrays/Head.md +1 -1
  50. package/docs/Std.Arrays/HeadAndRest.md +1 -1
  51. package/docs/Std.Arrays/IndexOf.md +1 -1
  52. package/docs/Std.Arrays/IndexRange.md +1 -1
  53. package/docs/Std.Arrays/Interleaved.md +1 -1
  54. package/docs/Std.Arrays/IsEmpty.md +1 -1
  55. package/docs/Std.Arrays/IsRectangularArray.md +1 -1
  56. package/docs/Std.Arrays/IsSorted.md +1 -1
  57. package/docs/Std.Arrays/IsSquareArray.md +1 -1
  58. package/docs/Std.Arrays/Mapped.md +1 -1
  59. package/docs/Std.Arrays/MappedByIndex.md +1 -1
  60. package/docs/Std.Arrays/MappedOverRange.md +1 -1
  61. package/docs/Std.Arrays/Most.md +1 -1
  62. package/docs/Std.Arrays/MostAndTail.md +1 -1
  63. package/docs/Std.Arrays/Padded.md +1 -1
  64. package/docs/Std.Arrays/Partitioned.md +1 -1
  65. package/docs/Std.Arrays/Rest.md +1 -1
  66. package/docs/Std.Arrays/Reversed.md +1 -1
  67. package/docs/Std.Arrays/SequenceI.md +1 -1
  68. package/docs/Std.Arrays/SequenceL.md +1 -1
  69. package/docs/Std.Arrays/Sorted.md +1 -1
  70. package/docs/Std.Arrays/Subarray.md +1 -1
  71. package/docs/Std.Arrays/Swapped.md +1 -1
  72. package/docs/Std.Arrays/Tail.md +1 -1
  73. package/docs/Std.Arrays/Transposed.md +1 -1
  74. package/docs/Std.Arrays/Unzipped.md +1 -1
  75. package/docs/Std.Arrays/Where.md +1 -1
  76. package/docs/Std.Arrays/Windows.md +1 -1
  77. package/docs/Std.Arrays/Zipped.md +1 -1
  78. package/docs/Std.Arrays/index.md +1 -1
  79. package/docs/Std.Canon/ApplyCNOTChain.md +1 -1
  80. package/docs/Std.Canon/ApplyControlledOnBitString.md +1 -1
  81. package/docs/Std.Canon/ApplyControlledOnInt.md +1 -1
  82. package/docs/Std.Canon/ApplyOperationPowerA.md +25 -0
  83. package/docs/Std.Canon/ApplyP.md +1 -1
  84. package/docs/Std.Canon/ApplyPauli.md +1 -1
  85. package/docs/Std.Canon/ApplyPauliFromBitString.md +1 -1
  86. package/docs/Std.Canon/ApplyPauliFromInt.md +1 -1
  87. package/docs/Std.Canon/ApplyQFT.md +1 -1
  88. package/docs/Std.Canon/ApplyToEach.md +1 -1
  89. package/docs/Std.Canon/ApplyToEachA.md +1 -1
  90. package/docs/Std.Canon/ApplyToEachC.md +1 -1
  91. package/docs/Std.Canon/ApplyToEachCA.md +1 -1
  92. package/docs/Std.Canon/ApplyXorInPlace.md +1 -1
  93. package/docs/Std.Canon/ApplyXorInPlaceL.md +1 -1
  94. package/docs/Std.Canon/CX.md +1 -1
  95. package/docs/Std.Canon/CY.md +1 -1
  96. package/docs/Std.Canon/CZ.md +1 -1
  97. package/docs/Std.Canon/Fst.md +1 -1
  98. package/docs/Std.Canon/Relabel.md +1 -1
  99. package/docs/Std.Canon/Snd.md +1 -1
  100. package/docs/Std.Canon/SwapReverseRegister.md +1 -1
  101. package/docs/Std.Canon/index.md +2 -1
  102. package/docs/Std.Convert/BigIntAsBoolArray.md +1 -1
  103. package/docs/Std.Convert/BigIntAsInt.md +30 -0
  104. package/docs/Std.Convert/BoolArrayAsBigInt.md +1 -1
  105. package/docs/Std.Convert/BoolArrayAsInt.md +1 -1
  106. package/docs/Std.Convert/BoolArrayAsResultArray.md +1 -1
  107. package/docs/Std.Convert/BoolAsResult.md +1 -1
  108. package/docs/Std.Convert/ComplexAsComplexPolar.md +1 -1
  109. package/docs/Std.Convert/ComplexPolarAsComplex.md +1 -1
  110. package/docs/Std.Convert/DoubleAsStringWithPrecision.md +1 -1
  111. package/docs/Std.Convert/IntAsBigInt.md +1 -1
  112. package/docs/Std.Convert/IntAsBoolArray.md +1 -1
  113. package/docs/Std.Convert/IntAsDouble.md +1 -1
  114. package/docs/Std.Convert/ResultArrayAsBoolArray.md +1 -1
  115. package/docs/Std.Convert/ResultArrayAsInt.md +1 -1
  116. package/docs/Std.Convert/ResultAsBool.md +1 -1
  117. package/docs/Std.Convert/index.md +2 -1
  118. package/docs/Std.Core/Length.md +1 -1
  119. package/docs/Std.Core/Repeated.md +1 -1
  120. package/docs/Std.Core/index.md +1 -1
  121. package/docs/Std.Diagnostics/ApplyIdleNoise.md +1 -1
  122. package/docs/Std.Diagnostics/BitFlipNoise.md +1 -1
  123. package/docs/Std.Diagnostics/CheckAllZero.md +1 -1
  124. package/docs/Std.Diagnostics/CheckOperationsAreEqual.md +1 -1
  125. package/docs/Std.Diagnostics/CheckZero.md +1 -1
  126. package/docs/Std.Diagnostics/ConfigurePauliNoise.md +1 -1
  127. package/docs/Std.Diagnostics/DepolarizingNoise.md +1 -1
  128. package/docs/Std.Diagnostics/DumpMachine.md +1 -1
  129. package/docs/Std.Diagnostics/DumpOperation.md +1 -1
  130. package/docs/Std.Diagnostics/DumpRegister.md +1 -1
  131. package/docs/Std.Diagnostics/Fact.md +1 -1
  132. package/docs/Std.Diagnostics/NoNoise.md +1 -1
  133. package/docs/Std.Diagnostics/PhaseFlipNoise.md +1 -1
  134. package/docs/Std.Diagnostics/StartCountingFunction.md +1 -1
  135. package/docs/Std.Diagnostics/StartCountingOperation.md +1 -1
  136. package/docs/Std.Diagnostics/StartCountingQubits.md +1 -1
  137. package/docs/Std.Diagnostics/StopCountingFunction.md +1 -1
  138. package/docs/Std.Diagnostics/StopCountingOperation.md +1 -1
  139. package/docs/Std.Diagnostics/StopCountingQubits.md +1 -1
  140. package/docs/Std.Diagnostics/index.md +1 -1
  141. package/docs/Std.Intrinsic/AND.md +1 -1
  142. package/docs/Std.Intrinsic/ApplyUnitary.md +1 -1
  143. package/docs/Std.Intrinsic/CCNOT.md +1 -1
  144. package/docs/Std.Intrinsic/CNOT.md +1 -1
  145. package/docs/Std.Intrinsic/Exp.md +1 -1
  146. package/docs/Std.Intrinsic/H.md +1 -1
  147. package/docs/Std.Intrinsic/I.md +1 -1
  148. package/docs/Std.Intrinsic/M.md +1 -1
  149. package/docs/Std.Intrinsic/Measure.md +1 -1
  150. package/docs/Std.Intrinsic/Message.md +1 -1
  151. package/docs/Std.Intrinsic/R.md +1 -1
  152. package/docs/Std.Intrinsic/R1.md +1 -1
  153. package/docs/Std.Intrinsic/R1Frac.md +1 -1
  154. package/docs/Std.Intrinsic/RFrac.md +1 -1
  155. package/docs/Std.Intrinsic/Reset.md +1 -1
  156. package/docs/Std.Intrinsic/ResetAll.md +1 -1
  157. package/docs/Std.Intrinsic/Rx.md +1 -1
  158. package/docs/Std.Intrinsic/Rxx.md +1 -1
  159. package/docs/Std.Intrinsic/Ry.md +1 -1
  160. package/docs/Std.Intrinsic/Ryy.md +1 -1
  161. package/docs/Std.Intrinsic/Rz.md +1 -1
  162. package/docs/Std.Intrinsic/Rzz.md +1 -1
  163. package/docs/Std.Intrinsic/S.md +1 -1
  164. package/docs/Std.Intrinsic/SWAP.md +1 -1
  165. package/docs/Std.Intrinsic/T.md +1 -1
  166. package/docs/Std.Intrinsic/X.md +1 -1
  167. package/docs/Std.Intrinsic/Y.md +1 -1
  168. package/docs/Std.Intrinsic/Z.md +1 -1
  169. package/docs/Std.Intrinsic/index.md +1 -1
  170. package/docs/Std.Logical/Xor.md +1 -1
  171. package/docs/Std.Logical/index.md +1 -1
  172. package/docs/Std.Math/AbsComplex.md +1 -1
  173. package/docs/Std.Math/AbsComplexPolar.md +1 -1
  174. package/docs/Std.Math/AbsD.md +1 -1
  175. package/docs/Std.Math/AbsI.md +1 -1
  176. package/docs/Std.Math/AbsL.md +1 -1
  177. package/docs/Std.Math/AbsSquaredComplex.md +1 -1
  178. package/docs/Std.Math/AbsSquaredComplexPolar.md +1 -1
  179. package/docs/Std.Math/ApproximateFactorial.md +1 -1
  180. package/docs/Std.Math/ArcCos.md +1 -1
  181. package/docs/Std.Math/ArcCosh.md +1 -1
  182. package/docs/Std.Math/ArcSin.md +1 -1
  183. package/docs/Std.Math/ArcSinh.md +1 -1
  184. package/docs/Std.Math/ArcTan.md +1 -1
  185. package/docs/Std.Math/ArcTan2.md +1 -1
  186. package/docs/Std.Math/ArcTanh.md +1 -1
  187. package/docs/Std.Math/ArgComplex.md +1 -1
  188. package/docs/Std.Math/ArgComplexPolar.md +1 -1
  189. package/docs/Std.Math/Binom.md +1 -1
  190. package/docs/Std.Math/BitSizeI.md +1 -1
  191. package/docs/Std.Math/BitSizeL.md +1 -1
  192. package/docs/Std.Math/Ceiling.md +1 -1
  193. package/docs/Std.Math/Complex.md +1 -1
  194. package/docs/Std.Math/ComplexPolar.md +1 -1
  195. package/docs/Std.Math/ContinuedFractionConvergentI.md +1 -1
  196. package/docs/Std.Math/ContinuedFractionConvergentL.md +1 -1
  197. package/docs/Std.Math/Cos.md +1 -1
  198. package/docs/Std.Math/Cosh.md +1 -1
  199. package/docs/Std.Math/DivRemI.md +1 -1
  200. package/docs/Std.Math/DivRemL.md +1 -1
  201. package/docs/Std.Math/DividedByC.md +1 -1
  202. package/docs/Std.Math/DividedByCP.md +1 -1
  203. package/docs/Std.Math/E.md +1 -1
  204. package/docs/Std.Math/ExpModI.md +1 -1
  205. package/docs/Std.Math/ExpModL.md +1 -1
  206. package/docs/Std.Math/ExtendedGreatestCommonDivisorI.md +1 -1
  207. package/docs/Std.Math/ExtendedGreatestCommonDivisorL.md +1 -1
  208. package/docs/Std.Math/FactorialI.md +1 -1
  209. package/docs/Std.Math/FactorialL.md +1 -1
  210. package/docs/Std.Math/Floor.md +1 -1
  211. package/docs/Std.Math/GreatestCommonDivisorI.md +1 -1
  212. package/docs/Std.Math/GreatestCommonDivisorL.md +1 -1
  213. package/docs/Std.Math/HammingWeightI.md +1 -1
  214. package/docs/Std.Math/InverseModI.md +1 -1
  215. package/docs/Std.Math/InverseModL.md +1 -1
  216. package/docs/Std.Math/IsCoprimeI.md +1 -1
  217. package/docs/Std.Math/IsCoprimeL.md +1 -1
  218. package/docs/Std.Math/IsInfinite.md +1 -1
  219. package/docs/Std.Math/IsNaN.md +1 -1
  220. package/docs/Std.Math/LargestFixedPoint.md +1 -1
  221. package/docs/Std.Math/Lg.md +1 -1
  222. package/docs/Std.Math/Log.md +1 -1
  223. package/docs/Std.Math/Log10.md +1 -1
  224. package/docs/Std.Math/LogFactorialD.md +1 -1
  225. package/docs/Std.Math/LogGammaD.md +1 -1
  226. package/docs/Std.Math/LogOf2.md +1 -1
  227. package/docs/Std.Math/Max.md +1 -1
  228. package/docs/Std.Math/MaxD.md +1 -1
  229. package/docs/Std.Math/MaxI.md +1 -1
  230. package/docs/Std.Math/MaxL.md +1 -1
  231. package/docs/Std.Math/Min.md +1 -1
  232. package/docs/Std.Math/MinD.md +1 -1
  233. package/docs/Std.Math/MinI.md +1 -1
  234. package/docs/Std.Math/MinL.md +1 -1
  235. package/docs/Std.Math/MinusC.md +1 -1
  236. package/docs/Std.Math/MinusCP.md +1 -1
  237. package/docs/Std.Math/ModulusI.md +1 -1
  238. package/docs/Std.Math/ModulusL.md +1 -1
  239. package/docs/Std.Math/NegationC.md +1 -1
  240. package/docs/Std.Math/NegationCP.md +1 -1
  241. package/docs/Std.Math/PI.md +1 -1
  242. package/docs/Std.Math/PNorm.md +1 -1
  243. package/docs/Std.Math/PNormalized.md +1 -1
  244. package/docs/Std.Math/PlusC.md +1 -1
  245. package/docs/Std.Math/PlusCP.md +1 -1
  246. package/docs/Std.Math/PowC.md +1 -1
  247. package/docs/Std.Math/PowCP.md +1 -1
  248. package/docs/Std.Math/RealMod.md +1 -1
  249. package/docs/Std.Math/Round.md +8 -5
  250. package/docs/Std.Math/RoundHalfAwayFromZero.md +27 -0
  251. package/docs/Std.Math/SignD.md +1 -1
  252. package/docs/Std.Math/SignI.md +1 -1
  253. package/docs/Std.Math/SignL.md +1 -1
  254. package/docs/Std.Math/Sin.md +1 -1
  255. package/docs/Std.Math/Sinh.md +1 -1
  256. package/docs/Std.Math/SmallestFixedPoint.md +1 -1
  257. package/docs/Std.Math/Sqrt.md +1 -1
  258. package/docs/Std.Math/SquaredNorm.md +1 -1
  259. package/docs/Std.Math/Tan.md +1 -1
  260. package/docs/Std.Math/Tanh.md +1 -1
  261. package/docs/Std.Math/TimesC.md +1 -1
  262. package/docs/Std.Math/TimesCP.md +1 -1
  263. package/docs/Std.Math/TrailingZeroCountI.md +1 -1
  264. package/docs/Std.Math/TrailingZeroCountL.md +1 -1
  265. package/docs/Std.Math/Truncate.md +1 -1
  266. package/docs/Std.Math/index.md +3 -2
  267. package/docs/Std.Measurement/MResetEachZ.md +1 -1
  268. package/docs/Std.Measurement/MResetX.md +1 -1
  269. package/docs/Std.Measurement/MResetY.md +1 -1
  270. package/docs/Std.Measurement/MResetZ.md +1 -1
  271. package/docs/Std.Measurement/MeasureAllZ.md +1 -1
  272. package/docs/Std.Measurement/MeasureEachZ.md +1 -1
  273. package/docs/Std.Measurement/MeasureInteger.md +1 -1
  274. package/docs/Std.Measurement/index.md +1 -1
  275. package/docs/Std.Random/DrawRandomBool.md +1 -1
  276. package/docs/Std.Random/DrawRandomDouble.md +1 -1
  277. package/docs/Std.Random/DrawRandomInt.md +1 -1
  278. package/docs/Std.Random/index.md +1 -1
  279. package/docs/Std.Range/IsRangeEmpty.md +1 -1
  280. package/docs/Std.Range/RangeEnd.md +1 -1
  281. package/docs/Std.Range/RangeReverse.md +1 -1
  282. package/docs/Std.Range/RangeStart.md +1 -1
  283. package/docs/Std.Range/RangeStep.md +1 -1
  284. package/docs/Std.Range/index.md +1 -1
  285. package/docs/Std.ResourceEstimation/AccountForEstimates.md +1 -1
  286. package/docs/Std.ResourceEstimation/AuxQubitCount.md +1 -1
  287. package/docs/Std.ResourceEstimation/BeginEstimateCaching.md +1 -1
  288. package/docs/Std.ResourceEstimation/BeginRepeatEstimates.md +1 -1
  289. package/docs/Std.ResourceEstimation/CczCount.md +1 -1
  290. package/docs/Std.ResourceEstimation/EndEstimateCaching.md +1 -1
  291. package/docs/Std.ResourceEstimation/EndRepeatEstimates.md +1 -1
  292. package/docs/Std.ResourceEstimation/MeasurementCount.md +1 -1
  293. package/docs/Std.ResourceEstimation/PSSPCLayout.md +1 -1
  294. package/docs/Std.ResourceEstimation/RepeatEstimates.md +1 -1
  295. package/docs/Std.ResourceEstimation/RotationCount.md +1 -1
  296. package/docs/Std.ResourceEstimation/RotationDepth.md +1 -1
  297. package/docs/Std.ResourceEstimation/SingleVariant.md +1 -1
  298. package/docs/Std.ResourceEstimation/TCount.md +1 -1
  299. package/docs/Std.ResourceEstimation/index.md +1 -1
  300. package/docs/Std.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
  301. package/docs/Std.StatePreparation/PreparePureStateD.md +1 -1
  302. package/docs/Std.StatePreparation/PrepareUniformSuperposition.md +1 -1
  303. package/docs/Std.StatePreparation/index.md +1 -1
  304. package/docs/Std.TableLookup/Select.md +1 -1
  305. package/docs/Std.TableLookup/index.md +1 -1
  306. package/docs/index.md +1 -1
  307. package/docs/toc.yml +3 -0
  308. package/lib/node/qsc_wasm.cjs +2 -2
  309. package/lib/node/qsc_wasm.d.cts +3 -6
  310. package/lib/node/qsc_wasm_bg.wasm +0 -0
  311. package/lib/web/qsc_wasm.d.ts +3 -6
  312. package/lib/web/qsc_wasm.js +2 -2
  313. package/lib/web/qsc_wasm_bg.wasm +0 -0
  314. package/package.json +1 -1
  315. package/ux/circuit-vis/circuitManipulation.ts +31 -9
  316. package/ux/circuit-vis/contextMenu.ts +42 -18
  317. package/ux/circuit-vis/draggable.ts +3 -3
  318. package/ux/circuit-vis/events.ts +21 -6
  319. package/ux/circuit-vis/formatters/formatUtils.ts +3 -3
  320. package/ux/circuit-vis/formatters/gateFormatter.ts +106 -65
  321. package/ux/circuit-vis/formatters/inputFormatter.ts +9 -31
  322. package/ux/circuit-vis/formatters/registerFormatter.ts +4 -4
  323. package/ux/circuit-vis/{metadata.ts → gateRenderData.ts} +4 -4
  324. package/ux/circuit-vis/panel.ts +31 -32
  325. package/ux/circuit-vis/process.ts +114 -106
  326. package/ux/circuit-vis/register.ts +1 -1
  327. package/ux/circuit-vis/sqore.ts +14 -10
  328. package/ux/circuit-vis/utils.ts +56 -4
  329. package/ux/circuit.tsx +7 -1
  330. package/ux/qsharp-circuit.css +353 -334
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
 
4
- import { Metadata, GateType } from "../metadata";
4
+ import { GateRenderData, GateType } from "../gateRenderData";
5
5
  import {
6
6
  minGateWidth,
7
7
  gateHeight,
@@ -26,58 +26,68 @@ import {
26
26
  dashedBox,
27
27
  } from "./formatUtils";
28
28
 
29
+ import { mathChars } from "../utils";
30
+
29
31
  /**
30
- * Given an array of operations (in metadata format), return the SVG representation.
32
+ * Given an array of operations render data, return the SVG representation.
31
33
  *
32
- * @param opsMetadata 2D array of Metadata representation of operations.
34
+ * @param renderData 2D array of rendering data for gates.
33
35
  * @param nestedDepth Depth of nested operations (used in classically controlled and grouped operations).
34
36
  *
35
37
  * @returns SVG representation of operations.
36
38
  */
37
39
  const formatGates = (
38
- opsMetadata: Metadata[][],
40
+ renderData: GateRenderData[][],
39
41
  nestedDepth = 0,
40
42
  ): SVGElement => {
41
- const formattedGates: SVGElement[] = opsMetadata
42
- .map((col) => col.map((metadata) => formatGate(metadata, nestedDepth)))
43
+ const formattedGates: SVGElement[] = renderData
44
+ .map((col) => col.map((renderData) => formatGate(renderData, nestedDepth)))
43
45
  .flat();
44
46
  return group(formattedGates);
45
47
  };
46
48
 
47
49
  /**
48
- * Takes in an operation's metadata and formats it into SVG.
50
+ * Takes in an operation's rendering data and formats it into SVG.
49
51
  *
50
- * @param metadata Metadata object representation of gate.
52
+ * @param renderData The rendering data of the gate.
51
53
  * @param nestedDepth Depth of nested operations (used in classically controlled and grouped operations).
52
54
  *
53
55
  * @returns SVG representation of gate.
54
56
  */
55
- const formatGate = (metadata: Metadata, nestedDepth = 0): SVGElement => {
56
- const { type, x, controlsY, targetsY, label, displayArgs, width } = metadata;
57
+ const formatGate = (
58
+ renderData: GateRenderData,
59
+ nestedDepth = 0,
60
+ ): SVGElement => {
61
+ const { type, x, controlsY, targetsY, label, displayArgs, width } =
62
+ renderData;
57
63
  switch (type) {
58
64
  case GateType.Measure:
59
- return _createGate([_measure(x, controlsY[0])], metadata, nestedDepth);
65
+ return _createGate([_measure(x, controlsY[0])], renderData, nestedDepth);
60
66
  case GateType.Unitary:
61
67
  return _createGate(
62
68
  [_unitary(label, x, targetsY as number[][], width, displayArgs)],
63
- metadata,
69
+ renderData,
64
70
  nestedDepth,
65
71
  );
66
72
  case GateType.X:
67
- return _createGate([_x(metadata, nestedDepth)], metadata, nestedDepth);
73
+ return _createGate([_x(renderData)], renderData, nestedDepth);
68
74
  case GateType.Ket:
69
- return _createGate([_ket(label, metadata)], metadata, nestedDepth);
75
+ return _createGate([_ket(label, renderData)], renderData, nestedDepth);
70
76
  case GateType.Swap:
71
77
  return controlsY.length > 0
72
- ? _controlledGate(metadata, nestedDepth)
73
- : _createGate([_swap(metadata, nestedDepth)], metadata, nestedDepth);
78
+ ? _controlledGate(renderData, nestedDepth)
79
+ : _createGate(
80
+ [_swap(renderData, nestedDepth)],
81
+ renderData,
82
+ nestedDepth,
83
+ );
74
84
  case GateType.Cnot:
75
85
  case GateType.ControlledUnitary:
76
- return _controlledGate(metadata, nestedDepth);
86
+ return _controlledGate(renderData, nestedDepth);
77
87
  case GateType.Group:
78
- return _groupedOperations(metadata, nestedDepth);
88
+ return _groupedOperations(renderData, nestedDepth);
79
89
  case GateType.ClassicalControlled:
80
- return _classicalControlled(metadata);
90
+ return _classicalControlled(renderData);
81
91
  default:
82
92
  throw new Error(`ERROR: unknown gate (${label}) of type ${type}.`);
83
93
  }
@@ -86,23 +96,24 @@ const formatGate = (metadata: Metadata, nestedDepth = 0): SVGElement => {
86
96
  /**
87
97
  * Groups SVG elements into a gate SVG group.
88
98
  *
89
- * @param svgElems Array of SVG elements.
90
- * @param dataAttributes Custom data attributes to be attached to SVG group.
99
+ * @param svgElems - Array of SVG elements that make up the gate.
100
+ * @param renderData - Render data containing information about the gate, such as data attributes.
101
+ * @param nestedDepth - Depth of nested operation.
91
102
  *
92
103
  * @returns SVG representation of a gate.
93
104
  */
94
105
  const _createGate = (
95
106
  svgElems: SVGElement[],
96
- metadata: Metadata,
107
+ renderData: GateRenderData,
97
108
  nestedDepth: number,
98
109
  ): SVGElement => {
99
- const { dataAttributes } = metadata || {};
110
+ const { dataAttributes } = renderData || {};
100
111
  const attributes: { [attr: string]: string } = { class: "gate" };
101
112
  Object.entries(dataAttributes || {}).forEach(
102
113
  ([attr, val]) => (attributes[`data-${attr}`] = val),
103
114
  );
104
115
 
105
- const zoomBtn: SVGElement | null = _zoomButton(metadata, nestedDepth);
116
+ const zoomBtn: SVGElement | null = _zoomButton(renderData, nestedDepth);
106
117
  if (zoomBtn != null) svgElems = svgElems.concat([zoomBtn]);
107
118
  return group(svgElems, attributes);
108
119
  };
@@ -111,19 +122,19 @@ const _createGate = (
111
122
  * Returns the expand/collapse button for an operation if it can be zoomed-in or zoomed-out,
112
123
  * respectively. If neither are allowed, return `null`.
113
124
  *
114
- * @param metadata Operation metadata.
125
+ * @param renderData Operation render data.
115
126
  * @param nestedDepth Depth of nested operation.
116
127
  *
117
128
  * @returns SVG element for expand/collapse button if needed, or null otherwise.
118
129
  */
119
130
  const _zoomButton = (
120
- metadata: Metadata,
131
+ renderData: GateRenderData,
121
132
  nestedDepth: number,
122
133
  ): SVGElement | null => {
123
- if (metadata == undefined) return null;
134
+ if (renderData == undefined) return null;
124
135
 
125
- const [x1, y1] = _gatePosition(metadata, nestedDepth);
126
- let { dataAttributes } = metadata;
136
+ const [x1, y1] = _gatePosition(renderData, nestedDepth);
137
+ let { dataAttributes } = renderData;
127
138
  dataAttributes = dataAttributes || {};
128
139
 
129
140
  const expanded = "expanded" in dataAttributes;
@@ -154,16 +165,16 @@ const _zoomButton = (
154
165
  /**
155
166
  * Calculate position of gate.
156
167
  *
157
- * @param metadata Operation metadata.
168
+ * @param renderData Operation render data.
158
169
  * @param nestedDepth Depth of nested operations.
159
170
  *
160
171
  * @returns Coordinates of gate: [x1, y1, x2, y2].
161
172
  */
162
173
  const _gatePosition = (
163
- metadata: Metadata,
174
+ renderData: GateRenderData,
164
175
  nestedDepth: number,
165
176
  ): [number, number, number, number] => {
166
- const { x, width, type, targetsY } = metadata;
177
+ const { x, width, type, targetsY } = renderData;
167
178
 
168
179
  const ys = targetsY?.flatMap((y) => y as number[]) || [];
169
180
  const maxY = Math.max(...ys);
@@ -225,6 +236,31 @@ const _measure = (x: number, y: number): SVGElement => {
225
236
  return group([mBox, mArc, meter]);
226
237
  };
227
238
 
239
+ const use_katex = true;
240
+
241
+ function _style_gate_text(gate: SVGTextElement) {
242
+ if (!use_katex) return;
243
+ let label = gate.textContent || "";
244
+
245
+ // In general, use the regular math font
246
+ gate.classList.add("qs-maintext");
247
+
248
+ // Wrap any latin or greek letters in tspan with KaTeX_Math font
249
+ // Style the entire Greek + Coptic block (https://unicodeplus.com/block/0370)
250
+ // Note this deliberately leaves ASCII digits [0-9] non-italic
251
+ const italicChars = /[a-zA-Z\u{0370}-\u{03ff}]+/gu;
252
+
253
+ label = label.replace(italicChars, `<tspan class='qs-mathtext'>$&</tspan>`);
254
+
255
+ // Replace a trailing ' with the proper unicode dagger symbol
256
+ label = label.replace(
257
+ /'$/,
258
+ `<tspan dx="2" dy="-3" style="font-size: 0.8em;">${mathChars.dagger}</tspan>`,
259
+ );
260
+
261
+ gate.innerHTML = label;
262
+ }
263
+
228
264
  /**
229
265
  * Creates the SVG for a unitary gate on an arbitrary number of qubits.
230
266
  *
@@ -302,12 +338,15 @@ const _unitaryBox = (
302
338
  uBox.setAttribute("class", cssClass);
303
339
  }
304
340
  const labelY = y + height / 2 - (displayArgs == null ? 0 : 7);
305
- const labelText: SVGElement = text(label, x, labelY);
341
+ const labelText = text(label, x, labelY);
342
+ _style_gate_text(labelText);
343
+
306
344
  const elems = [uBox, labelText];
307
345
  if (displayArgs != null) {
308
346
  const argStrY = y + height / 2 + 8;
309
347
 
310
- const argButton: SVGElement = text(displayArgs, x, argStrY, argsFontSize);
348
+ const argButton = text(displayArgs, x, argStrY, argsFontSize);
349
+ _style_gate_text(argButton);
311
350
  argButton.setAttribute("class", "arg-button");
312
351
  elems.push(argButton);
313
352
  }
@@ -315,18 +354,18 @@ const _unitaryBox = (
315
354
  };
316
355
 
317
356
  /**
318
- * Creates the SVG for a SWAP gate on y coords given by targetsY.
357
+ * Creates the SVG for a SWAP gate on y coords given by `renderData`.
319
358
  *
320
- * @param x Centre x coord of SWAP gate.
321
- * @param targetsY y coords of target registers.
359
+ * @param renderData - The render data containing information about the gate, including position and targets.
360
+ * @param nestedDepth - The depth of nested operations (used for adjusting padding and positioning).
322
361
  *
323
362
  * @returns SVG representation of SWAP gate.
324
363
  */
325
- const _swap = (metadata: Metadata, nestedDepth: number): SVGElement => {
326
- const { x, targetsY } = metadata;
364
+ const _swap = (renderData: GateRenderData, nestedDepth: number): SVGElement => {
365
+ const { x, targetsY } = renderData;
327
366
 
328
367
  // Get SVGs of crosses
329
- const [x1, y1, x2, y2] = _gatePosition(metadata, nestedDepth);
368
+ const [x1, y1, x2, y2] = _gatePosition(renderData, nestedDepth);
330
369
  const ys = targetsY?.flatMap((y) => y as number[]) || [];
331
370
 
332
371
  const bg: SVGElement = box(x1, y1, x2, y2, "gate-swap");
@@ -339,11 +378,12 @@ const _swap = (metadata: Metadata, nestedDepth: number): SVGElement => {
339
378
  /**
340
379
  * Creates the SVG for an X gate
341
380
  *
381
+ * @param renderData - The render data containing information about the gate, including position and targets.
382
+ *
342
383
  * @returns SVG representation of X gate.
343
384
  */
344
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
345
- const _x = (metadata: Metadata, _: number): SVGElement => {
346
- const { x, targetsY } = metadata;
385
+ const _x = (renderData: GateRenderData): SVGElement => {
386
+ const { x, targetsY } = renderData;
347
387
  const ys = targetsY.flatMap((y) => y as number[]);
348
388
  return _oplus(x, ys[0]);
349
389
  };
@@ -352,14 +392,14 @@ const _x = (metadata: Metadata, _: number): SVGElement => {
352
392
  * Creates the SVG for a ket notation (e.g "|0⟩" or "|1⟩") gate.
353
393
  *
354
394
  * @param label The label for the ket notation (e.g., "0" or "1").
355
- * @param metadata The metadata object containing information about the gate's position and appearance.
395
+ * @param renderData The render data containing information about the gate's position and appearance.
356
396
  *
357
397
  * @returns SVG representation of the ket notation gate.
358
398
  */
359
- const _ket = (label: string, metadata: Metadata): SVGElement => {
360
- const { x, targetsY, width } = metadata;
399
+ const _ket = (label: string, renderData: GateRenderData): SVGElement => {
400
+ const { x, targetsY, width } = renderData;
361
401
  const gate = _unitary(
362
- `|${label}〉`,
402
+ `|${label}${mathChars.rangle}`,
363
403
  x,
364
404
  targetsY as number[][],
365
405
  width,
@@ -367,7 +407,7 @@ const _ket = (label: string, metadata: Metadata): SVGElement => {
367
407
  false,
368
408
  "gate-ket",
369
409
  );
370
- gate.querySelector("text")!.setAttribute("class", "ket-text");
410
+ gate.querySelector("text")!.classList.add("ket-text");
371
411
  return gate;
372
412
  };
373
413
 
@@ -399,17 +439,17 @@ const _cross = (x: number, y: number): SVGElement => {
399
439
  /**
400
440
  * Produces the SVG representation of a controlled gate on multiple qubits.
401
441
  *
402
- * @param metadata Metadata of controlled gate.
442
+ * @param renderData Render data of controlled gate.
403
443
  *
404
444
  * @returns SVG representation of controlled gate.
405
445
  */
406
446
  const _controlledGate = (
407
- metadata: Metadata,
447
+ renderData: GateRenderData,
408
448
  nestedDepth: number,
409
449
  ): SVGElement => {
410
450
  const targetGateSvgs: SVGElement[] = [];
411
- const { type, x, controlsY, label, displayArgs, width } = metadata;
412
- let { targetsY } = metadata;
451
+ const { type, x, controlsY, label, displayArgs, width } = renderData;
452
+ let { targetsY } = renderData;
413
453
 
414
454
  // Get SVG for target gates
415
455
  switch (type) {
@@ -442,7 +482,7 @@ const _controlledGate = (
442
482
  vertLine.style.pointerEvents = "none";
443
483
  const svg: SVGElement = _createGate(
444
484
  [vertLine, ...controlledDotsSvg, ...targetGateSvgs],
445
- metadata,
485
+ renderData,
446
486
  nestedDepth,
447
487
  );
448
488
  return svg;
@@ -467,42 +507,43 @@ const _oplus = (x: number, y: number, r = 15): SVGElement => {
467
507
  /**
468
508
  * Generates the SVG for a group of nested operations.
469
509
  *
470
- * @param metadata Metadata representation of gate.
510
+ * @param renderData Render data of gate.
471
511
  * @param nestedDepth Depth of nested operations (used in classically controlled and grouped operations).
472
512
  *
473
513
  * @returns SVG representation of gate.
474
514
  */
475
515
  const _groupedOperations = (
476
- metadata: Metadata,
516
+ renderData: GateRenderData,
477
517
  nestedDepth: number,
478
518
  ): SVGElement => {
479
- const { children } = metadata;
480
- const [x1, y1, x2, y2] = _gatePosition(metadata, nestedDepth);
519
+ const { children } = renderData;
520
+ const [x1, y1, x2, y2] = _gatePosition(renderData, nestedDepth);
481
521
 
482
522
  // Draw dashed box around children gates
483
523
  const box: SVGElement = dashedBox(x1, y1, x2, y2);
484
524
  const elems: SVGElement[] = [box];
485
525
  if (children != null)
486
- elems.push(formatGates(children as Metadata[][], nestedDepth + 1));
487
- return _createGate(elems, metadata, nestedDepth);
526
+ elems.push(formatGates(children as GateRenderData[][], nestedDepth + 1));
527
+ return _createGate(elems, renderData, nestedDepth);
488
528
  };
489
529
 
490
530
  /**
491
531
  * Generates the SVG for a classically controlled group of operations.
492
532
  *
493
- * @param metadata Metadata representation of gate.
533
+ * @param renderData Render data of gate.
494
534
  * @param padding Padding within dashed box.
495
535
  *
496
536
  * @returns SVG representation of gate.
497
537
  */
498
538
  const _classicalControlled = (
499
- metadata: Metadata,
539
+ renderData: GateRenderData,
500
540
  padding: number = groupBoxPadding,
501
541
  ): SVGElement => {
502
- const { controlsY, dataAttributes } = metadata;
503
- const targetsY: number[] = metadata.targetsY as number[];
504
- const children: Metadata[][][] = metadata.children as Metadata[][][];
505
- let { x, width } = metadata;
542
+ const { controlsY, dataAttributes } = renderData;
543
+ const targetsY: number[] = renderData.targetsY as number[];
544
+ const children: GateRenderData[][][] =
545
+ renderData.children as GateRenderData[][][];
546
+ let { x, width } = renderData;
506
547
 
507
548
  const controlY = controlsY[0];
508
549
 
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT license.
3
3
 
4
4
  import { Qubit } from "../circuit";
5
- import { RegisterType, RegisterMap, RegisterMetadata } from "../register";
5
+ import { RegisterType, RegisterMap, RegisterRenderData } from "../register";
6
6
  import {
7
7
  leftPadding,
8
8
  startY,
@@ -10,10 +10,11 @@ import {
10
10
  classicalRegHeight,
11
11
  } from "../constants";
12
12
  import { group, text } from "./formatUtils";
13
+ import { mathChars } from "../utils";
13
14
 
14
15
  /**
15
16
  * `formatInputs` takes in an array of Qubits and outputs the SVG string of formatted
16
- * qubit wires and a mapping from register IDs to register metadata (for rendering).
17
+ * qubit wires and a mapping from register IDs to register rendering data.
17
18
  *
18
19
  * @param qubits List of declared qubits.
19
20
  *
@@ -45,7 +46,7 @@ const formatInputs = (
45
46
 
46
47
  // Add classical wires
47
48
  registers[id].children = Array.from(Array(numResults), () => {
48
- const clsReg: RegisterMetadata = {
49
+ const clsReg: RegisterRenderData = {
49
50
  type: RegisterType.Classical,
50
51
  y: currY,
51
52
  };
@@ -71,38 +72,15 @@ const formatInputs = (
71
72
  const _qubitInput = (y: number, subscript?: string): SVGElement => {
72
73
  const el: SVGElement = text("", leftPadding, y, 16);
73
74
 
74
- // Create the main text node
75
- const mainText = document.createElementNS(
76
- "http://www.w3.org/2000/svg",
77
- "tspan",
78
- );
79
- mainText.textContent = "|𝜓";
75
+ const subtext = subscript
76
+ ? `<tspan baseline-shift="sub" font-size="65%">${subscript}</tspan>`
77
+ : "";
80
78
 
81
- // Create the subscript node if provided
82
- if (subscript) {
83
- const subscriptText = document.createElementNS(
84
- "http://www.w3.org/2000/svg",
85
- "tspan",
86
- );
87
- subscriptText.textContent = subscript;
88
- subscriptText.setAttribute("baseline-shift", "sub");
89
- subscriptText.setAttribute("font-size", "65%");
90
- mainText.appendChild(subscriptText);
91
- }
92
-
93
- // Add the closing part of the text
94
- const closingText = document.createElementNS(
95
- "http://www.w3.org/2000/svg",
96
- "tspan",
97
- );
98
- closingText.textContent = "⟩";
99
-
100
- // Append all parts to the main SVG text element
101
- el.appendChild(mainText);
102
- el.appendChild(closingText);
79
+ el.innerHTML = `|<tspan class="qs-mathtext">${mathChars.psi}</tspan>${subtext}${mathChars.rangle}</tspan>`;
103
80
 
104
81
  el.setAttribute("text-anchor", "start");
105
82
  el.setAttribute("dominant-baseline", "middle");
83
+ el.classList.add("qs-maintext");
106
84
  return el;
107
85
  };
108
86
 
@@ -3,22 +3,22 @@
3
3
 
4
4
  import { RegisterMap } from "../register";
5
5
  import { regLineStart } from "../constants";
6
- import { Metadata, GateType } from "../metadata";
6
+ import { GateRenderData, GateType } from "../gateRenderData";
7
7
  import { group, line } from "./formatUtils";
8
8
 
9
9
  /**
10
10
  * Generate the SVG representation of the qubit register wires in `registers` and the classical wires
11
11
  * stemming from each measurement gate.
12
12
  *
13
- * @param registers Map from register IDs to register metadata.
14
- * @param measureGates Array of measurement gates metadata.
13
+ * @param registers Map from register IDs to register render data.
14
+ * @param measureGates Array of measurement gate render data.
15
15
  * @param endX End x coord.
16
16
  *
17
17
  * @returns SVG representation of register wires.
18
18
  */
19
19
  const formatRegisters = (
20
20
  registers: RegisterMap,
21
- measureGates: Metadata[],
21
+ measureGates: GateRenderData[],
22
22
  endX: number,
23
23
  ): SVGElement => {
24
24
  const formattedRegs: SVGElement[] = [];
@@ -15,7 +15,7 @@ export enum GateType {
15
15
  Swap,
16
16
  /** X gate. */
17
17
  X,
18
- /** |0or |1 gate. */
18
+ /** |0or |1 gate. */
19
19
  Ket,
20
20
  /** Single/multi qubit unitary gate. */
21
21
  Unitary,
@@ -30,10 +30,10 @@ export enum GateType {
30
30
  }
31
31
 
32
32
  /**
33
- * Metadata used to store information pertaining to a given
33
+ * Rendering data used to store information pertaining to a given
34
34
  * operation for rendering its corresponding SVG.
35
35
  */
36
- export interface Metadata {
36
+ export interface GateRenderData {
37
37
  /** Gate type. */
38
38
  type: GateType;
39
39
  /** Centre x coord for gate position. */
@@ -52,7 +52,7 @@ export interface Metadata {
52
52
  /** Gate width. */
53
53
  width: number;
54
54
  /** Children operations as part of group. */
55
- children?: Metadata[][] | Metadata[][][];
55
+ children?: GateRenderData[][] | GateRenderData[][][];
56
56
  /** Custom data attributes to attach to gate element. */
57
57
  dataAttributes?: DataAttributes;
58
58
  }
@@ -9,7 +9,7 @@ import {
9
9
  verticalGap,
10
10
  } from "./constants";
11
11
  import { formatGate } from "./formatters/gateFormatter";
12
- import { GateType, Metadata } from "./metadata";
12
+ import { GateType, GateRenderData } from "./gateRenderData";
13
13
  import { getGateWidth } from "./utils";
14
14
 
15
15
  /**
@@ -83,7 +83,7 @@ const _createToolbox = (): HTMLElement => {
83
83
  let prefixX = 0;
84
84
  let prefixY = 0;
85
85
  const gateElems = Object.keys(toolboxGateDictionary).map((key, index) => {
86
- const { width: gateWidth } = toMetadata(toolboxGateDictionary[key], 0, 0);
86
+ const { width: gateWidth } = toRenderData(toolboxGateDictionary[key], 0, 0);
87
87
 
88
88
  // Increment prefixX for every gate, and reset after 2 gates (2 columns)
89
89
  if (index % 2 === 0 && index !== 0) {
@@ -169,19 +169,19 @@ const _title = (text: string): HTMLElement => {
169
169
  };
170
170
 
171
171
  /**
172
- * Wrapper to generate metadata based on _opToMetadata with mock registers and limited support
172
+ * Wrapper to generate render data based on _opToRenderData with mock registers and limited support
173
173
  * @param operation Operation object
174
174
  * @param x x coordinate at starting point from the left
175
175
  * @param y y coordinate at starting point from the top
176
- * @returns Metadata object
176
+ * @returns GateRenderData object
177
177
  */
178
- const toMetadata = (
178
+ const toRenderData = (
179
179
  operation: Operation | undefined,
180
180
  x: number,
181
181
  y: number,
182
- ): Metadata => {
182
+ ): GateRenderData => {
183
183
  const target = y + 1 + gateHeight / 2; // offset by 1 for top padding
184
- const metadata: Metadata = {
184
+ const renderData: GateRenderData = {
185
185
  type: GateType.Invalid,
186
186
  x: x + 1 + minGateWidth / 2, // offset by 1 for left padding
187
187
  controlsY: [],
@@ -190,54 +190,54 @@ const toMetadata = (
190
190
  width: -1,
191
191
  };
192
192
 
193
- if (operation === undefined) return metadata;
193
+ if (operation === undefined) return renderData;
194
194
 
195
195
  switch (operation.kind) {
196
196
  case "unitary": {
197
197
  const { gate, controls } = operation;
198
198
 
199
199
  if (gate === "SWAP") {
200
- metadata.type = GateType.Swap;
200
+ renderData.type = GateType.Swap;
201
201
  } else if (controls && controls.length > 0) {
202
- metadata.type =
202
+ renderData.type =
203
203
  gate === "X" ? GateType.Cnot : GateType.ControlledUnitary;
204
- metadata.label = gate;
204
+ renderData.label = gate;
205
205
  if (gate !== "X") {
206
- metadata.targetsY = [[target]];
206
+ renderData.targetsY = [[target]];
207
207
  }
208
208
  } else if (gate === "X") {
209
- metadata.type = GateType.X;
210
- metadata.label = gate;
209
+ renderData.type = GateType.X;
210
+ renderData.label = gate;
211
211
  } else {
212
- metadata.type = GateType.Unitary;
213
- metadata.label = gate;
214
- metadata.targetsY = [[target]];
212
+ renderData.type = GateType.Unitary;
213
+ renderData.label = gate;
214
+ renderData.targetsY = [[target]];
215
215
  }
216
216
  break;
217
217
  }
218
218
  case "measurement":
219
- metadata.type = GateType.Measure;
220
- metadata.controlsY = [target];
219
+ renderData.type = GateType.Measure;
220
+ renderData.controlsY = [target];
221
221
  break;
222
222
  case "ket":
223
- metadata.type = GateType.Ket;
224
- metadata.label = operation.gate;
225
- metadata.targetsY = [[target]];
223
+ renderData.type = GateType.Ket;
224
+ renderData.label = operation.gate;
225
+ renderData.targetsY = [[target]];
226
226
  break;
227
227
  }
228
228
 
229
229
  if (operation.args !== undefined && operation.args.length > 0)
230
- metadata.displayArgs = operation.args[0];
230
+ renderData.displayArgs = operation.args[0];
231
231
 
232
- metadata.width = getGateWidth(metadata);
233
- metadata.x = x + 1 + metadata.width / 2; // offset by 1 for left padding
232
+ renderData.width = getGateWidth(renderData);
233
+ renderData.x = x + 1 + renderData.width / 2; // offset by 1 for left padding
234
234
 
235
- return metadata;
235
+ return renderData;
236
236
  };
237
237
 
238
238
  /**
239
239
  * Generate an SVG gate element for the Toolbox panel based on the type of gate.
240
- * This function retrieves the operation metadata from the gate dictionary,
240
+ * This function retrieves the operation render data from the gate dictionary,
241
241
  * formats the gate, and returns the corresponding SVG element.
242
242
  *
243
243
  * @param gateDictionary - The dictionary containing gate operations.
@@ -255,9 +255,9 @@ const _gate = (
255
255
  ): SVGElement => {
256
256
  const gate = gateDictionary[type];
257
257
  if (gate == null) throw new Error(`Gate ${type} not available`);
258
- const metadata = toMetadata(gate, x, y);
259
- metadata.dataAttributes = { type: type };
260
- const gateElem = formatGate(metadata).cloneNode(true) as SVGElement;
258
+ const renderData = toRenderData(gate, x, y);
259
+ renderData.dataAttributes = { type: type };
260
+ const gateElem = formatGate(renderData).cloneNode(true) as SVGElement;
261
261
  gateElem.setAttribute("toolbox-item", "true");
262
262
 
263
263
  return gateElem;
@@ -322,7 +322,6 @@ const toolboxGateDictionary: GateDictionary = {
322
322
  H: _makeUnitary("H"),
323
323
  SX: _makeUnitary("SX"),
324
324
  Reset: _makeKet("0"),
325
- ResetOne: _makeKet("1"),
326
325
  Measure: _makeMeasurement("Measure"),
327
326
  };
328
327
 
@@ -330,4 +329,4 @@ toolboxGateDictionary["RX"].params = [{ name: "theta", type: "Double" }];
330
329
  toolboxGateDictionary["RY"].params = [{ name: "theta", type: "Double" }];
331
330
  toolboxGateDictionary["RZ"].params = [{ name: "theta", type: "Double" }];
332
331
 
333
- export { createPanel, toolboxGateDictionary, toMetadata };
332
+ export { createPanel, toolboxGateDictionary, toRenderData };