daiquiri-ui 2025.12.1__py3-none-any.whl → 2026.2.0__py3-none-any.whl

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 (143) hide show
  1. daiquiri_ui/__init__.py +0 -1
  2. daiquiri_ui/static/assets/Anchor-0b4a3d33.js +1 -0
  3. daiquiri_ui/static/assets/AutoscaleOption-3cb99678.js +1 -0
  4. daiquiri_ui/static/assets/{BPMVideoStream-7dfae0bb.js → BPMVideoStream-c3e09e8b.js} +1 -1
  5. daiquiri_ui/static/assets/{CanvasEnhancer-16124b1e.js → CanvasEnhancer-dd82c090.js} +1 -1
  6. daiquiri_ui/static/assets/ColorMap-be59ad21.js +1 -0
  7. daiquiri_ui/static/assets/CompositeMap-c93f5466.js +1 -0
  8. daiquiri_ui/static/assets/{ConnectUtils-b8bfa186.js → ConnectUtils-3923fa2f.js} +1 -1
  9. daiquiri_ui/static/assets/{Console-42bf9fd1.js → Console-d0028912.js} +1 -1
  10. daiquiri_ui/static/assets/{Cross-d0a1a410.js → Cross-d5df0df3.js} +1 -1
  11. daiquiri_ui/static/assets/{CrossMarker-2285e102.js → CrossMarker-71cd11cf.js} +2 -2
  12. daiquiri_ui/static/assets/DraggableRect-25d91c7d.js +1 -0
  13. daiquiri_ui/static/assets/DropdownButton-29cc265b.js +1 -0
  14. daiquiri_ui/static/assets/DropdownDetector-5016908a.js +1 -0
  15. daiquiri_ui/static/assets/{Editor-8c26c281.js → Editor-7b500b85.js} +9 -9
  16. daiquiri_ui/static/assets/EditorTree-7fc000d8.js +1 -0
  17. daiquiri_ui/static/assets/H5Viewer-d1305c58.js +1 -0
  18. daiquiri_ui/static/assets/{H5WebCurvePlot-136dfa6f.js → H5WebCurvePlot-61b08211.js} +1 -1
  19. daiquiri_ui/static/assets/HSegment-8d2c001e.js +43 -0
  20. daiquiri_ui/static/assets/HardwareButton-af41c610.js +1 -0
  21. daiquiri_ui/static/assets/Hdf5Plot-bbffc65f.js +1 -0
  22. daiquiri_ui/static/assets/{HistogramDomainSlider-5572e533.js → HistogramDomainSlider-304bdab4.js} +1 -1
  23. daiquiri_ui/static/assets/Image-ee61818a.js +1 -0
  24. daiquiri_ui/static/assets/Label-9d8979b3.js +1 -0
  25. daiquiri_ui/static/assets/{LoadingMessage-e1e479c5.js → LoadingMessage-03b4fa4f.js} +1 -1
  26. daiquiri_ui/static/assets/NewScanButton-0051d220.js +1 -0
  27. daiquiri_ui/static/assets/NewScanButton-57cf0c17.js +1 -0
  28. daiquiri_ui/static/assets/OptionsProcess-da629bfb.js +1 -0
  29. daiquiri_ui/static/assets/ParametersList-2d01832f.js +1 -0
  30. daiquiri_ui/static/assets/RectRoi-3693cc65.js +1 -0
  31. daiquiri_ui/static/assets/RectRuler-1fee3fd8.js +543 -0
  32. daiquiri_ui/static/assets/RulerButton-a95a6035.js +139 -0
  33. daiquiri_ui/static/assets/SampleDCList-dce0bd2b.js +1 -0
  34. daiquiri_ui/static/assets/SampleRegistration-544aa4bd.js +1 -0
  35. daiquiri_ui/static/assets/SavingButton-c3efc92c.js +1 -0
  36. daiquiri_ui/static/assets/ScanDataService-16f29ecd.js +1 -0
  37. daiquiri_ui/static/assets/ScanPlot0d-67c76bfe.js +1 -0
  38. daiquiri_ui/static/assets/ScanPlot0dValue-c0dd01b5.js +1 -0
  39. daiquiri_ui/static/assets/ScanPlot1d-3c930b95.js +1 -0
  40. daiquiri_ui/static/assets/ScanPlot1d-ee33c98b.js +1 -0
  41. daiquiri_ui/static/assets/{ScanPlot2d-c49ba2bc.js → ScanPlot2d-af57d8ad.js} +1 -1
  42. daiquiri_ui/static/assets/{ScanTable-4e677d2b.js → ScanTable-bc13760e.js} +1 -1
  43. daiquiri_ui/static/assets/ScanValue-00aab91b.js +1 -0
  44. daiquiri_ui/static/assets/SceneScale-e2a42af2.js +1 -0
  45. daiquiri_ui/static/assets/SchemaForm-7d897a32.js +1 -0
  46. daiquiri_ui/static/assets/{ScreenScale-ae820d30.js → ScreenScale-b2417934.js} +1 -1
  47. daiquiri_ui/static/assets/{SelectionPoint-d30865f3.js → SelectionPoint-a2cb4dfc.js} +1 -1
  48. daiquiri_ui/static/assets/{StackedNameState-3f198174.js → StackedNameState-4e8dc742.js} +1 -1
  49. daiquiri_ui/static/assets/Statistics.worker-54a0d965.js +46 -0
  50. daiquiri_ui/static/assets/{Synoptic-0f3dac61.js → Synoptic-8a3c67f3.js} +5 -5
  51. daiquiri_ui/static/assets/TomoAlign-b80a68c3.js +7 -0
  52. daiquiri_ui/static/assets/TomoBeamShaping-65a115e9.js +1 -0
  53. daiquiri_ui/static/assets/TomoDetector-500d46af.js +1 -0
  54. daiquiri_ui/static/assets/TomoDetector-e04a5a8b.js +1 -0
  55. daiquiri_ui/static/assets/TomoDetectorView-952499e6.js +64 -0
  56. daiquiri_ui/static/assets/TomoHolo-db2c8449.js +1 -0
  57. daiquiri_ui/static/assets/TomoPusherView-a50e2acd.js +1 -0
  58. daiquiri_ui/static/assets/TomoReconstructedSinogram-deee0779.js +191 -0
  59. daiquiri_ui/static/assets/TomoScanInfo-972a690b.js +1 -0
  60. daiquiri_ui/static/assets/{TomoScanList-d9bea762.js → TomoScanList-ede05c2a.js} +1 -1
  61. daiquiri_ui/static/assets/TomoService-e9741d6a.js +1 -0
  62. daiquiri_ui/static/assets/TomoSinogram-dce5808e.js +1 -0
  63. daiquiri_ui/static/assets/TomoTiling-04701bb7.js +69 -0
  64. daiquiri_ui/static/assets/TwoD-fee9523f.js +3 -0
  65. daiquiri_ui/static/assets/TwoDObject-2f30deac.js +1 -0
  66. daiquiri_ui/static/assets/TwoDObjectList-458e4824.js +1 -0
  67. daiquiri_ui/static/assets/{UseMouseModeInteraction-fc86164b.js → UseMouseModeInteraction-51c6269c.js} +1 -1
  68. daiquiri_ui/static/assets/VLineRoi-b38fe841.js +1 -0
  69. daiquiri_ui/static/assets/{VSegment-cf1ceafc.js → VSegment-f0d42c9a.js} +2 -2
  70. daiquiri_ui/static/assets/VSegmentRoi-d5e035cc.js +1 -0
  71. daiquiri_ui/static/assets/{VideoStream-4b855f43.js → VideoStream-a5200b21.js} +1 -1
  72. daiquiri_ui/static/assets/{VisViewpointRestore-097e2edf.js → VisViewpointRestore-4aa338ea.js} +3 -3
  73. daiquiri_ui/static/assets/{WorldScale-6e6ac5b5.js → WorldScale-23bd1dfb.js} +1 -1
  74. daiquiri_ui/static/assets/{ZoomPanCanvas-8f437b75.js → ZoomPanCanvas-23b61dbb.js} +1 -1
  75. daiquiri_ui/static/assets/{colormap-344855f8.js → colormap-6e43299c.js} +1 -1
  76. daiquiri_ui/static/assets/fontawesomemore-webfont-6ae56ae3.woff2 +0 -0
  77. daiquiri_ui/static/assets/{geometry-1fc3c1a0.js → geometry-cd448ec1.js} +1 -1
  78. daiquiri_ui/static/assets/hooks-171c0765.js +1 -0
  79. daiquiri_ui/static/assets/{hooks-cf59b64f.js → hooks-e0d9229c.js} +1 -1
  80. daiquiri_ui/static/assets/index-779a56ef.css +9 -0
  81. daiquiri_ui/static/assets/{index-a0f7b98c.js → index-a9bb7636.js} +7 -7
  82. daiquiri_ui/static/assets/index-b3c0133a.js +3576 -0
  83. daiquiri_ui/static/assets/{plotly-basic-889d4727.js → plotly-basic-ccc5794d.js} +2 -2
  84. daiquiri_ui/static/assets/{plotly-gl2d-e2e89493.js → plotly-gl2d-345cb34a.js} +2 -2
  85. daiquiri_ui/static/assets/store-5d136a2c.js +1 -0
  86. daiquiri_ui/static/assets/{types-46afffa0.js → types-c366a377.js} +1 -1
  87. daiquiri_ui/static/index.html +2 -2
  88. daiquiri_ui/static/meta.json +1 -1
  89. {daiquiri_ui-2025.12.1.dist-info → daiquiri_ui-2026.2.0.dist-info}/METADATA +1 -1
  90. daiquiri_ui-2026.2.0.dist-info/RECORD +134 -0
  91. {daiquiri_ui-2025.12.1.dist-info → daiquiri_ui-2026.2.0.dist-info}/WHEEL +1 -1
  92. daiquiri_ui/static/assets/Anchor-3fa6d19c.js +0 -1
  93. daiquiri_ui/static/assets/AutoscaleOption-d8d0ca8d.js +0 -1
  94. daiquiri_ui/static/assets/DraggableRect-db33e02e.js +0 -1
  95. daiquiri_ui/static/assets/DropdownButton-d066ece0.js +0 -1
  96. daiquiri_ui/static/assets/DropdownDetector-4ddfa946.js +0 -1
  97. daiquiri_ui/static/assets/EditorTree-b390ece1.js +0 -1
  98. daiquiri_ui/static/assets/H5Viewer-bbcf29f5.js +0 -1
  99. daiquiri_ui/static/assets/HSegment-8966b13f.js +0 -43
  100. daiquiri_ui/static/assets/HardwareButton-2e65150e.js +0 -1
  101. daiquiri_ui/static/assets/Hdf5Plot-3b35de75.js +0 -1
  102. daiquiri_ui/static/assets/Image-1ff7dca9.js +0 -1
  103. daiquiri_ui/static/assets/Label-3c95fb14.js +0 -1
  104. daiquiri_ui/static/assets/NewScanButton-25f65a41.js +0 -1
  105. daiquiri_ui/static/assets/NewScanButton-f40700e9.js +0 -1
  106. daiquiri_ui/static/assets/OptionsProcess-6fd11ce7.js +0 -1
  107. daiquiri_ui/static/assets/ParametersList-c91938bf.js +0 -1
  108. daiquiri_ui/static/assets/RectRoi-19381507.js +0 -1
  109. daiquiri_ui/static/assets/RulerButton-5c2020aa.js +0 -139
  110. daiquiri_ui/static/assets/SampleDCList-64bd9100.js +0 -1
  111. daiquiri_ui/static/assets/SampleRegistration-a354b270.js +0 -1
  112. daiquiri_ui/static/assets/SavingButton-c1839199.js +0 -1
  113. daiquiri_ui/static/assets/ScanPlot0d-d180ecd3.js +0 -1
  114. daiquiri_ui/static/assets/ScanPlot0dValue-0e33cb2c.js +0 -1
  115. daiquiri_ui/static/assets/ScanPlot1d-38bddb23.js +0 -1
  116. daiquiri_ui/static/assets/ScanPlot1d-543e4ac4.js +0 -1
  117. daiquiri_ui/static/assets/ScanValue-a303a86d.js +0 -1
  118. daiquiri_ui/static/assets/SceneScale-33094e68.js +0 -1
  119. daiquiri_ui/static/assets/SchemaForm-b27ccd55.js +0 -1
  120. daiquiri_ui/static/assets/TomoAlign-03e37551.js +0 -4
  121. daiquiri_ui/static/assets/TomoBeamShaping-6ec15838.js +0 -1
  122. daiquiri_ui/static/assets/TomoDetector-aead72a5.js +0 -1
  123. daiquiri_ui/static/assets/TomoDetectorView-aadf1539.js +0 -64
  124. daiquiri_ui/static/assets/TomoHolo-7eb20a1e.js +0 -1
  125. daiquiri_ui/static/assets/TomoReconstructedSinogram-53bbfb3b.js +0 -191
  126. daiquiri_ui/static/assets/TomoScanInfo-5ca06333.js +0 -1
  127. daiquiri_ui/static/assets/TomoSinogram-ecd9dca2.js +0 -1
  128. daiquiri_ui/static/assets/TomoTiling-1b9f4bf4.js +0 -69
  129. daiquiri_ui/static/assets/TwoD-ca5cd677.js +0 -3
  130. daiquiri_ui/static/assets/TwoDObject-86b91ffb.js +0 -1
  131. daiquiri_ui/static/assets/TwoDObjectList-143af6e7.js +0 -1
  132. daiquiri_ui/static/assets/VLineRoi-5130fa5a.js +0 -1
  133. daiquiri_ui/static/assets/colors-2395de5a.js +0 -1
  134. daiquiri_ui/static/assets/fontawesomemore-webfont-97d0220a.woff2 +0 -0
  135. daiquiri_ui/static/assets/hooks-457bfe32.js +0 -1
  136. daiquiri_ui/static/assets/index-0751d893.js +0 -3576
  137. daiquiri_ui/static/assets/index-f085dfca.css +0 -9
  138. daiquiri_ui/static/assets/store-c3eddf46.js +0 -1
  139. daiquiri_ui/static/resources/shaders/compare.frag.glsl +0 -386
  140. daiquiri_ui/static/resources/shaders/compare.vert.glsl +0 -11
  141. daiquiri_ui-2025.12.1.dist-info/RECORD +0 -128
  142. {daiquiri_ui-2025.12.1.dist-info → daiquiri_ui-2026.2.0.dist-info}/licenses/LICENSE +0 -0
  143. {daiquiri_ui-2025.12.1.dist-info → daiquiri_ui-2026.2.0.dist-info}/top_level.txt +0 -0
@@ -1,191 +0,0 @@
1
- var fe=Object.defineProperty;var he=(t,a,s)=>a in t?fe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s;var D=(t,a,s)=>(he(t,typeof a!="symbol"?a+"":a,s),s);import{r as v,j as e,w as xe,c as ge,m as pe,aa as q,aP as T,aU as O,aj as U,B as P,ay as V,g as L,R as S,C as f,O as ve,x as F,aM as oe,aO as ie,a_ as K,aN as ne,b8 as ye,a7 as I,aL as re,u as le,b9 as je,A as z,ba as Se,bb as be,aX as we,aY as Ce,bc as J,bd as Ae,a1 as ee,be as Me,q as _e}from"./index-0751d893.js";import{b as De,L as Fe,u as Ne,T as te,D as Re,S as Pe}from"./UseMouseModeInteraction-fc86164b.js";import{S as ze}from"./StackedNameState-3f198174.js";import{a as G,r as Ie}from"./HSegment-8966b13f.js";import{H as ke}from"./HistogramDomainSlider-5572e533.js";import{e as We,f as Te,g as Ee,h as qe,i as He,j as ae,k as Be}from"./hooks-457bfe32.js";import{u as $e,L as Le,I as Oe,A as Ve}from"./AutoscaleOption-d8d0ca8d.js";import{u as Ge}from"./colormap-344855f8.js";import{u as Ye}from"./hooks-cf59b64f.js";import{w as Xe}from"./index-a0f7b98c.js";import{C as Ue}from"./Cross-d0a1a410.js";import{S as Ke}from"./SceneScale-33094e68.js";import{p as A,f as Qe,c as Ze}from"./geometry-1fc3c1a0.js";import{c as Q}from"./colors-2395de5a.js";import{L as W}from"./Label-3c95fb14.js";import{C as Je}from"./CrossMarker-2285e102.js";import{S as et}from"./ScreenScale-ae820d30.js";import{P as tt}from"./SelectionPoint-d30865f3.js";import"./Image-1ff7dca9.js";import"./VSegment-cf1ceafc.js";import"./QtyHelper-8429914f.js";function at(t){return t?t.status===null?["PROCESSING","warning"]:t.status===0?["FAILED","danger"]:t.status===1?["DONE","success"]:["UNKNOWN","fatal"]:["NONE","secondary"]}function st(t){v.useEffect(()=>{if(t.datacollectionid!==void 0&&t.programs!==void 0){const o=setInterval(()=>{t.datacollectionid!==void 0&&t.programs!==void 0&&t.actions.fetch({datacollectionid:t.datacollectionid,programs:t.programs})},500);return()=>{clearInterval(o)}}},[t.datacollectionid,t.programs]);const[a,s]=at(t.autoprocprogram);return e.jsx(ze,{className:t.className,name:`${t.name}`,state:a,stateVariant:s,description:`${t.description}`,minWidth:5})}const ot=(t,a)=>{const{autoprocprograms:s}=a.providers.metadata,o=s.selector("order",t);return{autoprocprogram:o&&o[0]?o[0][0]:null}},it=(t,a)=>{const{autoprocprograms:s}=a.providers.metadata;return{actions:{fetch:o=>{s.setParams({...o,order:"desc"},!0)}}}},nt=xe({metadata:pe})(ge(ot,it)(st));class H extends Error{}class rt{constructor(a,s){D(this,"isAborted");D(this,"request");D(this,"supportsFloat16Array");D(this,"error");D(this,"updateCallback");this.isAborted=!1,this.request=void 0,this.updateCallback=a,this.supportsFloat16Array=s}async fetchGroup(a){const s=await q.get("/h5grove/meta/",{...this.request,path:a});if(this.isAborted)throw new H;const o=s.data;if(o.type!=="group")throw new Error(`The path '${a}' is not a group`);let i;const n={},r={},l=async()=>{i=await this.fetchAttributes(a,o.attributes)},h=o.children.map(async c=>{c.type==="group"?r[c.name]=await this.fetchGroup(`${a}/${c.name}`):c.dtype==="|O"?n[c.name]=await this.fetchObjDataset(`${a}/${c.name}`,c):n[c.name]=await this.fetchDataset(`${a}/${c.name}`,c)});await Promise.all([...h,l()]);for(const c of o.children)if(this.isAborted)throw new H;if(i===void 0)throw new Error(`Attributes from path '${a}' was not fetched`);return{attrs:i,datasets:n,groups:r,name:o.name}}async fetchObjDataset(a,s){const o=await this.fetchAttributes(a,s.attributes),i=await q.get("/h5grove/data/",{...this.request,path:a,format:"json"}).then(n=>n.data).catch(n=>{});return{...s,attrs:o,data:i}}async fetchDataset(a,s){let o,i;const n=async()=>{o=await this.fetchAttributes(a,s.attributes)},r=this.supportsFloat16Array&&s.dtype==="<f2",l=async()=>{const h=await q.get("/h5grove/data/",{...this.request,path:a,format:"bin",dtype:r?"origin":"safe"},!0,"arraybuffer").then(m=>m.data).catch(m=>{console.error(m)});function c(m){if(!m)return;const g=s.shape.length===0?[1]:s.shape;if(r){const p=We(m,"<u2");return new Te(p,g)}const d=Ee(s.dtype);return qe(m,g,d)}i=c(h)};if(await Promise.all([l(),n()]),o===void 0)throw new Error(`Attributes from path '${a}' was not fetched`);return{...s,attrs:o,data:i}}async fetchAttributes(a,s){const i=(await q.get("/h5grove/attr/",{...this.request,path:a,attr_keys:s.map(r=>r.name)})).data,n={};return s.forEach(r=>{n[r.name]={...r,data:i[r.name]}}),n}async fetch(a){const{request:s}=a;if(this.isAborted=!1,this.request=s,s.datacollectionid===void 0){this.updateCallback({loading:!1});return}try{this.updateCallback({loading:!0});const o=await this.fetchGroup(s.path);if(this.isAborted)throw new H;this.updateCallback({loading:!1,group:o,request:s})}catch(o){if(!(o instanceof H)){const i=o instanceof Error?o.message:String(o);this.updateCallback({loading:!1,error:i,request:s})}}}abort(){this.isAborted=!0}}function lt(t){const[a,s]=v.useState({loading:!1});return v.useEffect(()=>{const o=new rt(s,t.supportsFloat16Array??!1);return o.fetch({request:{datacollectionid:t.datacollectionid,autoprocprogramid:t.autoprocprogramid,autoprocprogramattachmentid:t.autoprocprogramattachmentid,path:t.path,type:t.type}}),()=>{o.abort()}},[t.datacollectionid,t.autoprocprogramid,t.autoprocprogramattachmentid,t.path,t.type]),a}function ct(t){if(t===void 0||t.dtype!=="|O")return null;const a=t.data;return typeof a=="string"?[a]:t}function $(t){if(t===void 0||t.dtype!=="|O")return null;const a=t.data;return typeof a!="string"?null:a}function N(t){var s;if(!t)return null;const a=(s=t.data)==null?void 0:s.get(0);return a===void 0?null:a}function R(t){var o;if(!t)return null;const a=(o=t.data)==null?void 0:o.get(0);if(a===void 0)return null;const s=$(t.attrs.units);return s===null?null:new T(a,s)}function dt(){const t=$e({name:"tomo/slicecolormap"}),[a,s]=O("tomo/slicereconstruction/delta-beta",200),[o,i]=O("tomo/sliceview/axes",!0),[n,r]=O("tomo/sliceview/crosshair",!1);return{deltaBeta:a,setDeltaBeta:s,...t,displayAxes:o,setDisplayAxes:i,crossHair:n,setCrossHair:r}}function ut(t){const{as:a=void 0,className:s}=t;function o(i,n){const l=t.lut===i?"primary":"secondary";return e.jsx(P,{disabled:t.disabled,variant:l,onClick:()=>{t.onSelectLut(i)},className:"text-nowrap",title:n,size:"sm",children:e.jsx(Le,{name:i})})}return e.jsxs(U,{as:a,className:s,children:[o("Greys","Gray"),o("Viridis","Viridis"),o("Cividis","Cividis"),o("Magma","Magma"),o("Inferno","Inferno"),o("Plasma","Plasma")]})}function mt(t,a){return t===a?"primary":"secondary"}function B(t){return e.jsx(P,{variant:mt(t.var,t.value),onClick:()=>{t.setter(t.value)},className:"text-nowrap",size:"sm",children:t.children})}function ft(t){const{as:a=void 0,variant:s="secondary",config:o}=t;return e.jsxs(V,{as:a,className:`${t.dropDirection==="up"?"dropup":""}`,children:[e.jsx(V.Toggle,{id:"dropdown-basic",variant:s,className:"d-flex align-items-center",children:e.jsx("i",{className:"fa fa-sliders fa-fw fa-lg"})}),e.jsx(V.Menu,{className:"dropdown-menu-center",children:e.jsx("div",{className:"ms-1 me-1",style:{minWidth:"300px"},children:e.jsxs(L,{children:[e.jsxs(S,{children:[e.jsx(f,{className:"my-auto",children:"Colormap"}),e.jsx(f,{xs:7,children:e.jsx(ut,{lut:o.colorMap,onSelectLut:o.setColorMap})})]}),e.jsxs(S,{className:"mt-1",children:[e.jsx(f,{className:"my-auto",children:"Display axes"}),e.jsx(f,{xs:7,children:e.jsxs(U,{children:[e.jsx(B,{var:o.displayAxes,value:!0,setter:o.setDisplayAxes,children:"Yes"}),e.jsx(B,{var:o.displayAxes,value:!1,setter:o.setDisplayAxes,children:"No"})]})})]}),e.jsxs(S,{className:"mt-1",children:[e.jsx(f,{className:"my-auto",children:"Crosshair"}),e.jsx(f,{xs:7,children:e.jsxs(U,{children:[e.jsx(B,{var:o.crossHair,value:!0,setter:o.setCrossHair,children:"Yes"}),e.jsx(B,{var:o.crossHair,value:!1,setter:o.setCrossHair,children:"No"})]})})]})]})})})]})}class k extends Error{}function ht(t){if(!t)return null;const a=ct(t.attrs.signal);if(!a)throw new k("No signal found in NXdata");if(a.length!==1)throw new k(`Expect one and only one signal, found ${a.length}`);function s(w){try{const j=w.groups.histo,M=j.datasets.counts,C=j.datasets.bin_edges,_=M.data,u=C.data;return ae(_),ae(u),{values:_,bins:u}}catch(j){console.error(j);return}}function o(w){try{const j=w.groups.stats;return j===void 0?void 0:{min:N(j.datasets.min),max:N(j.datasets.max),minPositive:N(j.datasets.min_positive),mean:N(j.datasets.mean),std:N(j.datasets.std)}}catch{return}}const i=t.datasets[a[0]];if(!i)throw new k(`Dataset from signal ${a[0]} does not exists`);if(i.shape.length!==2)throw new k(`Dataset from signal ${a[0]} must be 2 ndim (found ${i.shape.length})`);const n=i.data;He(n);const r=R(t.datasets.sample_x_axis),l=R(t.datasets.sample_y_axis),h=R(t.datasets.y_axis),c=R(t.datasets.sample_pixel_size),m=R(t.datasets.used_axis_position)||new T(0,"px"),g=R(t.datasets.estimated_axis_position)||new T(0,"px"),d=N(t.datasets.delta_beta),p=$(t.datasets.backend),x=$(t.datasets.cor_backend),y=$(t.datasets.source_filename);return{histogram:s(t),imageArray:n,sampxPosition:r,sampyPosition:l,syPosition:h,axisPosition:m,samplePixelSize:c,estimatedAxisPosition:g,deltaBeta:d,backend:p,corBackend:x,stats:o(t),sourceFilename:y}}function xt(t){const{event:a}=t,[s,o]=v.useState({});return v.useEffect(()=>{if(a&&a.type===t.type){const{datacollectionid:i,autoprocprogramid:n}=a;console.log("event",a),i!==void 0&&n!==void 0&&o(r=>({...r,[`${i}`]:n}))}},[t.event]),v.useMemo(()=>{if(t.datacollectionid===void 0)return;const i=s[`${t.datacollectionid}`];return i!==void 0&&s[`group${t.datacollectiongroupid}`]!==i&&o(n=>({...n,[`group${t.datacollectiongroupid}`]:i})),i??s[`group${t.datacollectiongroupid}`]},[s,t.datacollectionid])}function gt(t){var r,l,h,c,m;const{datacollectionid:a,actions:s}=t,o=((l=(r=t.reconstructionInfo)==null?void 0:r.estimatedAxisPosition)==null?void 0:l.scalar)??void 0,i=((c=(h=t.reconstructionInfo)==null?void 0:h.axisPosition)==null?void 0:c.scalar)??void 0,n=((m=t.reconstructionInfo)==null?void 0:m.sourceFilename)??void 0;return v.useEffect(()=>{o!==void 0&&a!==void 0&&(s==null||s.updateDataCollectionMeta(a,{sourceFilename:n}))},[n]),v.useEffect(()=>{o!==void 0&&a!==void 0&&(s==null||s.updateDataCollectionMeta(a,{estimatedCor:o}))},[o]),v.useEffect(()=>{o!==void 0&&a!==void 0&&(s==null||s.updateDataCollectionMeta(a,{actualCor:i,requestedCor:null}))},[i]),e.jsx(e.Fragment,{})}function pt(t){function a(){t.datacollectionid!==void 0&&t.actions.requestSliceReconstruction({datacollectionid:t.datacollectionid,filename:t.sourceFilename})}return e.jsx(P,{variant:"secondary",title:"Recompute the slice from the sinogram",disabled:t.datacollectionid===null,onClick:a,children:e.jsx("i",{className:"fa fa-rotate-right fa-solid"})})}function vt(t){const{fetchedResult:a,reconstructedInfo:s}=t;function o(i){var n,r,l,h;return s===null?e.jsxs(F,{id:"reconstructed-slice-info",...i,children:[e.jsx(F.Header,{as:"h3",children:"Displayed data info"}),e.jsx(F.Body,{children:"No data"})]}):e.jsxs(F,{id:"reconstructed-slice-info",...i,children:[e.jsx(F.Header,{as:"h3",children:"Displayed data info"}),e.jsx(F.Body,{children:e.jsxs(L,{style:{width:"17em"},children:[a.request&&e.jsxs(e.Fragment,{children:[e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"Collection ID"}),e.jsx(f,{children:(n=a==null?void 0:a.request)==null?void 0:n.datacollectionid})]}),e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"Program ID"}),e.jsx(f,{children:((r=a==null?void 0:a.request)==null?void 0:r.autoprocprogramid)??"last"})]})]}),e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"Backend"}),e.jsx(f,{children:s==null?void 0:s.backend})]}),e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"COR backend"}),e.jsx(f,{children:s==null?void 0:s.corBackend})]}),e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"Axis position"}),e.jsxs(f,{children:[(l=s.axisPosition)==null?void 0:l.scalar.toFixed(2)," px"]})]}),e.jsxs(S,{className:"g-0",children:[e.jsx(f,{children:"Delta/beta"}),e.jsx(f,{children:(h=s.deltaBeta)==null?void 0:h.toFixed(2)})]})]})})]})}return e.jsx(ve,{trigger:["hover","focus"],placement:"bottom",overlay:o,children:e.jsx(P,{variant:"secondary",disabled:s===null,children:e.jsx("i",{className:"fa-solid fa-info fa-fw fa-lg"})})},"arg")}function yt(t){function a(o,i){return Math.round(o)===o?o.toFixed(0):o.toFixed(i)}const s=4;return e.jsxs(L,{style:{width:"150px"},children:[e.jsxs(S,{children:[e.jsx(f,{xs:3,children:"u"}),e.jsx(f,{xs:8,children:t.py.toFixed(s)}),e.jsx(f,{xs:1,children:t.inMotorSpace?"mm":"px"})]}),e.jsxs(S,{children:[e.jsx(f,{xs:3,children:"v"}),e.jsx(f,{xs:8,children:t.px.toFixed(s)}),e.jsx(f,{xs:1,children:t.inMotorSpace?"mm":"px"})]}),t.pixel&&e.jsxs(S,{children:[e.jsx(f,{xs:3,children:"pixel"}),e.jsx(f,{xs:8,children:a(t.pixel,s)}),e.jsx(f,{xs:1})]})]})}class jt extends ie{constructor(){super({uniforms:{color:{value:new K},gapColor:{value:new K},radius:{value:0},dashSize:{value:0},gapSize:{value:0},scaleX:{value:0},scaleY:{value:0},lineWidth:{value:0}},vertexShader:`
2
- uniform float scaleX; // signed scale
3
- uniform float scaleY; // signed scale
4
- out vec2 pixelCoord;
5
- // out vec2 dataCoord;
6
-
7
- void main() {
8
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
9
- vec2 pixelScale = abs(vec2(scaleX, scaleY));
10
- // dataCoord = vec2(position.x, position.y);
11
- pixelCoord = vec2(position.x, position.y) / pixelScale;
12
- }
13
- `,fragmentShader:`
14
- uniform vec4 color;
15
- uniform vec4 gapColor;
16
- uniform float gapSize;
17
- uniform float dashSize;
18
- uniform float lineWidth;
19
- uniform float scaleX; // signed scale
20
- uniform float scaleY; // signed scale
21
- uniform float radius;
22
- in vec2 pixelCoord;
23
-
24
- const float M_PI = 3.1415926535897932384626433832795;
25
- const float AA_DASH = 0.5;
26
-
27
- /**
28
- * Antialiasing following the line of dash and gap
29
- */
30
- vec4 aa_dash_gap(float dist, float alpha) {
31
- dist = mod(dist, (dashSize + gapSize));
32
- float sd1 = (dist < dashSize) ? dist : dist - (dashSize + gapSize);
33
- float sd2 = -(dist - dashSize);
34
- if (abs(sd1) <= AA_DASH || abs(sd2) <= AA_DASH) {
35
- if (abs(sd1) < abs(sd2)) {
36
- float c = (sd1 + AA_DASH) * (0.5 / AA_DASH);
37
- return (
38
- vec4(color.r, color.g, color.b, alpha * color.a) * c
39
- + vec4(gapColor.r, gapColor.g, gapColor.b, alpha * gapColor.a) * (1.0 - c)
40
- );
41
- } else {
42
- float c = (sd2 + AA_DASH) * (0.5 / AA_DASH);
43
- return (
44
- vec4(color.r, color.g, color.b, alpha * color.a) * c
45
- + vec4(gapColor.r, gapColor.g, gapColor.b, alpha * gapColor.a) * (1.0 - c)
46
- );
47
- }
48
- }
49
- if (dist <= dashSize) {
50
- return vec4(color.r, color.g, color.b, alpha * color.a);
51
- }
52
- return vec4(gapColor.r, gapColor.g, gapColor.b, alpha * gapColor.a);
53
- }
54
-
55
- void main() {
56
- float r = length(pixelCoord);
57
- float s = (abs(scaleX) + abs(scaleY)) * 0.5;
58
- float d = abs(r - radius / s) - lineWidth * 0.5;
59
- if (d > 1.5) {
60
- discard;
61
- }
62
- float alpha;
63
- if (lineWidth >= 1.0) {
64
- alpha = smoothstep(0.25, 0.0, d);
65
- } else {
66
- // simulate line thiner than 1px with alpha
67
- alpha = lineWidth;
68
- }
69
-
70
- if (dashSize == 0.0) {
71
- gl_FragColor = vec4(color.r, color.g, color.b, alpha * color.a);
72
- return;
73
- }
74
-
75
- // try to fit a fixed integer number of dashes + gaps
76
- // could be computed in the vertex shader
77
- float full = 2.0 * M_PI * (radius / s) / (dashSize + gapSize);
78
- float coef = ceil(full) / full;
79
-
80
- float dist = 2.0 * atan(pixelCoord.y, pixelCoord.x) * (radius / s) * coef;
81
- gl_FragColor = aa_dash_gap(dist, alpha);
82
- }
83
- `})}}oe({CircleDashMaterial:jt});function Y(t){const{center:a,radius:s,lineWidth:o=1,color:i="black",gapColor:n,dashSize:r=0,gapSize:l=r,opacity:h=1,zIndex:c=0}=t,m=v.useRef(null),g=Be();return v.useEffect(()=>{const d=Q(i,h),p=Q(n??"transparent",h);if(m.current){const x=m.current.uniforms;x.color.value=d,x.radius.value=s,x.gapColor.value=p,x.dashSize.value=r,x.gapSize.value=l,x.lineWidth.value=o,ne()}},[i,s,n,r,l,h,o]),ye(({camera:d})=>{if(m.current===null)return;const p=d.scale.x/g.sx,x=d.scale.y/g.sy,y=m.current.uniforms;y.scaleX.value=p,y.scaleY.value=x}),e.jsx("group",{position:[a[0],a[1],c],children:e.jsxs("mesh",{children:[e.jsx("ambientLight",{}),e.jsx("planeGeometry",{attach:"geometry",args:[(s+o)*2,(s+o)*2,1,1]}),e.jsx("circleDashMaterial",{attach:"material",transparent:!0,ref:m})]})})}function St(t){const{sampleStage:a}=t,s=a.sampu?A(a.sampu):null,o=a.sampv?A(a.sampv):null,{tomoDetector:i,detector:n}=a;if(i===null||n===null||s===null||o===null)return e.jsx(e.Fragment,{});const r=Qe(i,n);if(r===null)return e.jsx(e.Fragment,{});const l=new I(o,s),h=r[0]*.5,c=r[0];function m(){const d=a.sy?A(a.sy):null;return d===null||r===null?null:r[0]*.5+Math.abs(d)}const g=m();return e.jsxs(e.Fragment,{children:[e.jsx(Y,{center:[l.x,l.y],radius:h,color:"#000000",gapColor:"#FF0000",opacity:.5,dashSize:5,gapSize:5,lineWidth:1}),e.jsx(W,{datapos:[l.x-h*.95,l.y-h*.35],color:"#FF0000",text:"Full"}),e.jsx(Y,{center:[l.x,l.y],radius:c,color:"#000000",gapColor:"#FF0000",opacity:.5,dashSize:5,gapSize:5,lineWidth:1}),e.jsx(W,{datapos:[l.x-c*.95,l.y-c*.35],color:"#FF0000",text:"Half"}),g!==null&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{center:[l.x,l.y],radius:g,color:"#000000",gapColor:"#FF0000",dashSize:5,gapSize:5,lineWidth:1}),e.jsx(W,{datapos:[l.x-g,l.y-g*.175],color:"#FF0000",text:"Actual region"})]})]})}function bt(t){const{sampleStage:a}=t,s=a.sampu?A(a.sampu):null,o=a.sampv?A(a.sampv):null;return(a.sy?A(a.sy):null)===null||s===null||o===null?e.jsx(e.Fragment,{}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{x:o,y:s,color:"red",sizeInScreen:30,lineWidth:2.5}),e.jsx(W,{datapos:[o,s],color:"#FF0000",anchor:"top-right",text:"Actual axis position"})]})}class wt extends ie{constructor(){super({uniforms:{color:{value:new K},lineWidth:{value:0},sizeInScreen:{value:0},angle:{value:0}},vertexShader:`
84
- out vec2 pixelCoord;
85
-
86
- void main() {
87
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
88
- pixelCoord = vec2(position.x, position.y);
89
- }
90
- `,fragmentShader:`
91
- // Based on antialiased arrow fields
92
- // Nicolas P. Rougier (http://www.loria.fr/~rougier)
93
- // https://www.shadertoy.com/view/ldlSWj
94
- // Released under BSD license.
95
-
96
- uniform vec4 color;
97
- uniform float lineWidth;
98
- uniform float sizeInScreen;
99
- uniform float angle;
100
- in vec2 pixelCoord;
101
-
102
- // Computes the signed distance from a line
103
- float sdf_line(vec2 p, vec2 p1, vec2 p2) {
104
- vec2 center = (p1 + p2) * 0.5;
105
- float len = length(p2 - p1);
106
- vec2 dir = (p2 - p1) / len;
107
- vec2 rel_p = p - center;
108
- return dot(rel_p, vec2(dir.y, -dir.x));
109
- }
110
-
111
- // Computes the signed distance from a line segment
112
- float sdf_segment(vec2 p, vec2 p1, vec2 p2) {
113
- vec2 center = (p1 + p2) * 0.5;
114
- float len = length(p2 - p1);
115
- vec2 dir = (p2 - p1) / len;
116
- vec2 rel_p = p - center;
117
- float dist1 = abs(dot(rel_p, vec2(dir.y, -dir.x)));
118
- float dist2 = abs(dot(rel_p, dir)) - 0.5*len;
119
- return max(dist1, dist2);
120
- }
121
-
122
- float sdf_arrow(vec2 texcoord,
123
- float body, float head, float height,
124
- float linewidth, float antialias
125
- ) {
126
- float d;
127
- float w = linewidth/2.0 + antialias;
128
- vec2 start = -vec2(body / 2.0, 0.0);
129
- vec2 end = +vec2(body / 2.0, 0.0);
130
-
131
- // Arrow tip (beyond segment end)
132
- if( texcoord.x > body / 2.0) {
133
- // Head : 2 segments
134
- float d1 = sdf_line(texcoord, end, end - head*vec2(+1.0, -height));
135
- float d2 = sdf_line(texcoord, end - head*vec2(+1.0, +height), end);
136
- // Body : 1 segment
137
- float d3 = end.x - texcoord.x;
138
- d = max(max(d1, d2), d3);
139
- } else {
140
- // Head : 2 segments
141
- float d1 = sdf_segment(texcoord, end - head * vec2(+1.0, -height), end);
142
- float d2 = sdf_segment(texcoord, end - head * vec2(+1.0, +height), end);
143
- // Body : 1 segment
144
- float d3 = sdf_segment(texcoord, start, end - vec2(linewidth, 0.0));
145
- d = min(min(d1, d2), d3);
146
- }
147
- return d;
148
- }
149
-
150
- vec4 filled(float distance, float linewidth, float antialias, vec4 fill)
151
- {
152
- vec4 frag_color;
153
- float t = linewidth / 2.0 - antialias;
154
- float signed_distance = distance;
155
- float border_distance = abs(signed_distance) - t;
156
- float alpha = border_distance / antialias;
157
- alpha = exp(-alpha * alpha);
158
-
159
- // Within linestroke
160
- if (border_distance < 0.0) {
161
- return fill;
162
- }
163
- // Within shape
164
- if (signed_distance < 0.0) {
165
- return fill;
166
- }
167
- // Outside shape
168
- if (border_distance > (linewidth / 2.0 + antialias)) {
169
- discard;
170
- }
171
- // Line stroke exterior border
172
- return vec4(fill.rgb, alpha);
173
- }
174
-
175
- void main() {
176
- const float M_PI = 3.1415926535897932384626433832795;
177
-
178
- float theta = angle * M_PI / 180.0;
179
- float cos_theta = cos(theta);
180
- float sin_theta = sin(theta);
181
- vec2 pixelCoord2 = vec2(
182
- cos_theta * pixelCoord.x - sin_theta * pixelCoord.y,
183
- sin_theta * pixelCoord.x + cos_theta * pixelCoord.y
184
- );
185
-
186
- const float antialias = 1.0;
187
- float body = sizeInScreen;
188
- float d = sdf_arrow(pixelCoord2, body, 0.30 * body, 0.8, lineWidth, antialias);
189
- gl_FragColor = filled(d, lineWidth, antialias, color);
190
- }
191
- `})}}oe({ArrowMarkerMaterial:wt});function X(t){const{x:a,y:s,color:o="black",opacity:i,sizeInScreen:n,angle:r,lineWidth:l=1,zIndex:h=0}=t,c=v.useRef(null);return v.useEffect(()=>{const m=Q(o,i);if(c.current){const g=c.current.uniforms;g.color.value=m,g.lineWidth.value=l,g.sizeInScreen.value=n,g.angle.value=r,ne()}},[o,i,l,n,r]),e.jsx("group",{position:[a,s,h],children:e.jsx(et,{screenDirection:!1,children:e.jsxs("mesh",{children:[e.jsx("ambientLight",{}),e.jsx("planeGeometry",{attach:"geometry",args:[n+l,n+l,1,1]}),e.jsx("arrowMarkerMaterial",{attach:"material",transparent:!0,ref:c})]})})})}function Ct(t){const{sampleStage:a}=t,s=a.sampu?A(a.sampu):null,o=a.sampv?A(a.sampv):null,i=a.somega?-Ze(a.somega):null;if(i===null||s===null||o===null)return e.jsx(e.Fragment,{});const n=i/Math.PI*180,r=(t.viewRange[0][1]-t.viewRange[0][0])*.5+(t.viewRange[1][1]-t.viewRange[1][0])*.5,l=new I(0,1).rotateAround(new I(0,0),i),h=new I(-l.y,l.x).multiplyScalar(.3*r),m=new I(o,s).clone().add(l.clone().multiplyScalar(.375*r)),g=m.clone().add(h),d=m,p=m.clone().sub(h);return e.jsxs(e.Fragment,{children:[e.jsx(X,{x:g.x,y:g.y,sizeInScreen:80,angle:90-n,color:"red",lineWidth:3}),e.jsx(X,{x:d.x,y:d.y,sizeInScreen:80,angle:90-n,color:"red",lineWidth:3}),e.jsx(X,{x:p.x,y:p.y,sizeInScreen:80,angle:90-n,color:"red",lineWidth:3}),e.jsx(W,{datapos:[d.x,d.y],color:"#FF0000",text:"Beam",anchor:"bottom"})]})}const se=re("daiquiri.components.tomo.reconstructedslice.MoveMotorInteraction");function At(t){const a=De(),{mouseMode:s}=a??{},{disabled:o,requestMoveSampleAxisAtPosition:i}=t,n=v.useCallback(r=>{const l=r.dataPt.x,h=r.dataPt.y;i(h,l)},[i]);return o||s!=="move-sample-to-axis"?(se("MoveMotorInteraction disabled."),e.jsx(e.Fragment,{})):(se("MoveMotorInteraction enabled."),e.jsx(tt,{onClick:n}))}function Mt(t){var g;const{sampleStage:a,mouseMode:s}=t,o=(g=t.reconstructedInfo)==null?void 0:g.imageArray,i=v.useRef(null),n=le();if(!t.reconstructedInfo||o===void 0)return e.jsx(e.Fragment,{});const l=(a.somega!==null?je(a.somega):!0)?1:-1;function h(d){const p=(o==null?void 0:o.shape[1])??0,x=(o==null?void 0:o.shape[0])??0;if(d.samplePixelSize===null||d.sampxPosition===null||d.sampyPosition===null||d.imageArray===null)return{inMotorSpace:!1,xRange:[0,x],yRange:[0,p],center:[p/2,x/2,0],scale:[1,1,1],height:x,width:p};const y=d.samplePixelSize.to("mm").scalar,w=d.sampxPosition.to("mm").scalar,j=d.sampyPosition.to("mm").scalar,M=d.imageArray.shape[1]*.5,C=d.imageArray.shape[0]*.5;return{inMotorSpace:!0,xRange:[j-M*y,j+M*y],yRange:[w-C*y,w+C*y],center:[j,w,0],scale:[-y,-l*y,1],width:M*y*2,height:C*y*2}}const c=h(t.reconstructedInfo);function m(d,p){return d===null||!c.inMotorSpace?`${p} (px)`:`${d.alias??d.name} (mm)`}return e.jsx("div",{style:{flex:"1 1 auto",display:"flex",margin:0,minHeight:0},className:t.className,children:e.jsxs(Fe,{plotRef:t.plotRef,abscissaConfig:{visDomain:c.xRange,label:m(a.sampv,"lateral-axis"),flip:!0},ordinateConfig:{visDomain:c.yRange,label:m(a.sampu,"x-axis")},mouseMode:s,aspect:"equal",showAxes:t.config.displayAxes,children:[e.jsx(Oe,{ref:i,values:o,domain:t.imageDomain,colorMap:t.imageColorMap,invertColorMap:t.imageInvertColorMap,position:c.center,scale:c.scale,scaleType:t.imageScaleType,size:{width:o.shape[1],height:o.shape[0]}}),e.jsx(Xe,{guides:t.config.crossHair?"both":void 0,renderTooltip:(d,p)=>{var y;const x=(y=i.current)==null?void 0:y.pick(d,p);return e.jsx(yt,{px:d,py:p,pixel:x,inMotorSpace:c.inMotorSpace})}}),e.jsx(Ue,{centerX:c.center[0],centerY:c.center[1],width:c.width,height:c.height,color:"white",gapColor:"black",dashSize:5,gapSize:5,lineWidth:1}),c.inMotorSpace&&e.jsxs(e.Fragment,{children:[e.jsx(St,{sampleStage:a}),e.jsx(bt,{sampleStage:a}),e.jsx(Ct,{sampleStage:a,viewRange:[c.xRange,c.yRange]})]}),e.jsx(At,{disabled:!n,requestMoveSampleAxisAtPosition:t.requestMoveSampleAxisAtPosition}),e.jsx(Ke,{unit:c.inMotorSpace?"mm":"px"})]})})}function _t(t){const{fetchedResult:a}=t;return t.datacollectionid===void 0?e.jsx(z,{variant:"secondary",children:"Not yet datacollection"}):t.autoprocprogramid===void 0&&a.group===void 0?e.jsxs(z,{variant:"secondary",children:["Not yet reconstruction for datacollection ",t.datacollectionid]}):a.loading?e.jsx(z,{variant:"warning",children:"Waiting for data"}):a.error?e.jsxs(z,{variant:"danger",children:[e.jsx("p",{children:"Error during fetching:"}),e.jsx("p",{children:a.error})]}):t.parsingError?e.jsxs(z,{variant:"danger",children:[e.jsx("p",{children:"Data format unsupported:"}),e.jsx("p",{children:t.parsingError})]}):e.jsx(e.Fragment,{})}const Dt=re("daiquiri.components.tomo.TomoReconstructedSinogram");function Ft(t){var Z;const{options:a}=t,s=Se(a.datacollectionid),o=v.useRef(),i=(s==null?void 0:s.datacollectionid)??void 0,n=be(),{uri:r,tomoconfig:l,events:h,...c}=a,m=le(),g=v.useRef(null),d=Ne("zoom"),{mouseMode:p}=d,x=dt(),y=we(l??""),w=Ce(y),j=Ye(t.options.events);function M(){g.current&&g.current.actions.resetZoom()}const C=xt({type:"tomo-sinogram-reconstruction",datacollectionid:s.datacollectionid,datacollectiongroupid:s.datacollectiongroupid,event:j??void 0});v.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const _=lt({datacollectionid:s.datacollectionid,autoprocprogramid:C,type:"processing",path:r,supportsFloat16Array:!0}),[u,ce]=v.useMemo(()=>{try{return[ht(_.group),void 0]}catch(b){if(b instanceof k)return[null,b.message];throw b}},[_]);function de(b,E){if(d.resetMouseMode(),u===null){Dt("Move cancelled: reconstructedInfo is null");return}const ue=T(b,"mm"),me=T(E,"mm");Ie({sampu:ue,sampv:me})}return Ge({statistics:u==null?void 0:u.stats,...x}),e.jsxs("div",{className:"plot2d-container w-100 h-100",style:{flex:"1 1 0%",display:"flex",flexDirection:"column"},children:[e.jsxs(te,{align:"center",children:[e.jsx(gt,{reconstructionInfo:u,datacollectionid:i,actions:n}),e.jsx(Re,{mouseModeInteraction:d}),e.jsx(P,{title:"Reset zoom (sample stage overview)",variant:"secondary",onClick:()=>{M()},children:e.jsx("i",{className:"fa fa-expand fa-fw fa-lg"})}),e.jsx(Pe,{}),e.jsx(P,{title:m?"Move the motors to set rotation axis on the sample":"You have to get the control on the session to move motors",disabled:!m,variant:p==="move-sample-to-axis"?"danger":"secondary",onClick:()=>{d.setOrResetMouseMode("move-sample-to-axis")},children:e.jsx("i",{className:"fa fam-arrow-h-over-rot fa-fw fa-lg"})}),e.jsx(nt,{name:"Worker",description:"Automatic slice reconstruction from sinogram",datacollectionid:s.datacollectionid,programs:"tomo-sinogram-reconstruction",providers:{metadata:{autoprocprograms:{namespace:"tomosinogramreconstruction"}}}}),e.jsx(pt,{datacollectionid:s.datacollectionid,sourceFilename:(u==null?void 0:u.sourceFilename)??void 0,actions:{requestSliceReconstruction:G}})]}),e.jsxs(te,{align:"center",children:[e.jsx(Ve,{disabled:(u==null?void 0:u.stats)===void 0,...x}),e.jsx(ke,{disabled:u===void 0,histogram:u==null?void 0:u.histogram,...x}),e.jsx(vt,{fetchedResult:_,reconstructedInfo:u}),e.jsx(ft,{config:x})]}),e.jsxs(L,{children:[e.jsxs(S,{className:"g-0 align-items-center",children:[e.jsx(f,{xs:"3",title:"Location of the rotation axis from the left side of the sinogram (in pixel)",children:"Axis position:"}),e.jsx(f,{xs:"9",children:e.jsx(J,{hardwareValue:((Z=u==null?void 0:u.axisPosition)==null?void 0:Z.scalar)??0,hardwareIsDisabled:u===null,onMoveRequested:b=>(s.datacollectionid!==void 0&&G({datacollectionid:s.datacollectionid,axisposition:b,deltabeta:x.deltaBeta,filename:(u==null?void 0:u.sourceFilename)??void 0}),null)})})]}),e.jsxs(S,{className:"g-0 align-items-center",children:[e.jsx(f,{xs:"3",title:"Delta/beta ratio for the Paganin filter",children:"Delta/beta:"}),e.jsx(f,{xs:"9",children:e.jsx(J,{hardwareValue:x.deltaBeta,hardwareIsDisabled:!1,onMoveRequested:b=>{var E;return x.setDeltaBeta(b),s.datacollectionid!==void 0&&G({datacollectionid:s.datacollectionid,axisposition:(E=u==null?void 0:u.axisPosition)==null?void 0:E.scalar,deltabeta:b,filename:(u==null?void 0:u.sourceFilename)??void 0}),null}})})]})]}),e.jsx(_t,{datacollectionid:s.datacollectionid,autoprocprogramid:C,fetchedResult:_,parsingError:ce}),e.jsx(Mt,{config:x,imageColorMap:x.colorMap,imageInvertColorMap:x.invertColorMap,imageDomain:x.scaleDomain,imageScaleType:x.scaleType,reconstructedInfo:u,className:"flex-grow-1",sampleStage:w,mouseMode:p,plotRef:g,requestMoveSampleAxisAtPosition:de})]})}function Nt(t){return e.jsx(Ft,{...t})}function Jt(t){const{yamlNode:a,datacollectionid:s,uri:o,tomoconfig:i,events:n,...r}=t;Ae(a,"events",n),ee(a,"tomoconfig",i),ee(a,"uri",o),Me(a,"datacollectionid",s),_e(a,r);const l={datacollectionid:s,uri:o,tomoconfig:i,events:n};return e.jsx(Nt,{options:l})}export{Jt as default};
@@ -1 +0,0 @@
1
- import{bg as I,r as g,bh as v,bi as k,j as t,bj as m,bk as h,au as E,bl as N,aL as R,bm as D,l as C,q}from"./index-0751d893.js";import{g as L}from"./TomoScans-82e1e23b.js";function w(e,n){const r=I(e);g.useEffect(()=>{if(!n&&n!==0)return;const o=setInterval(()=>r.current(),n);return()=>clearInterval(o)},[n])}const T=R("daiquiri.components.tomo.TomoScanInfo");function b(e){return e==="tomo:dark"?["Dark","Acquire dark projection"]:e==="tomo:flat"?["Flat","Acquire flat projection"]:e==="tomo:return_ref"?["Return","Return to origin and acquiring few projection as reference"]:e==="tomo:step"?["Step scan","Tomo scan using rotation as step motor"]:e==="tomo:continuous"?["Continuous scan","Tomo scan using rotation as continuous motor"]:[e,"No description"]}function F(){const e=v();if(!e)return T("Skipped: lastgroup missing."),t.jsx(t.Fragment,{});const{subscans:n}=e;if(!n)return T("Skipped: subscans missing."),t.jsx(t.Fragment,{});const{activesubscan:r}=e;function o(s){return e?s<r?"DONE":s===r?e.state:"IDLE":""}const f=n.reduce((s,i)=>{const[a]=b(i);return s+a.length},0);function l(s,i,a){function j(S){return S.charAt(0).toUpperCase()+S.slice(1).toLowerCase()}const[c,d]=L(i),[u,x]=b(a),p=c==="RUNNING";return t.jsx(D,{animated:p,variant:d,label:`${j(u)}`,title:x,now:u.length,max:f},s)}return t.jsx(D,{children:C.map(n,(s,i)=>{const a=o(i);return l(i,a,s)})})}function P(e){const[n,r]=g.useState(0);w(()=>{r(Date.now())},5e3);const o=g.useMemo(()=>{if(n<=0)return 0;const f=h(e.starttime),l=(n-f.getTime())/1e3;return l<0?0:l},[e.starttime,n]);return t.jsxs(t.Fragment,{children:[N(o)," ",t.jsx("i",{className:"fa-solid fa-spinner fa-spin-pulse"})]})}function Y(e){const n=v(),r=k(c=>{if(n)return c.metadata.ns_datacollections.default.results[n.datacollectionid]});if(!n)return t.jsx(m,{children:t.jsx(m.Contents,{children:"No scan"})});const[o,f]=L(n.state);function l(c){const{subscans:d}=c;if(!d)return"";const{activesubscan:u}=c;if(u<0)return"Not yet started";if(u+1===d.length&&c.state!=="STARTING")return"Done";const x=d[u],[,p]=b(x);return`${u+1}/${d.length}: ${p}`}const{starttime:s,endtime:i,duration:a}=r??{},j=l(n);return t.jsx(m,{children:t.jsx(m.Contents,{children:t.jsxs("ul",{children:[n.datacollectionid&&t.jsxs("li",{children:[t.jsx("b",{children:"Data collection"}),": ",n.datacollectionid]}),t.jsxs("li",{children:[t.jsx("b",{children:"Scan"}),": ",n.scanid]}),t.jsxs("li",{children:[t.jsx("b",{children:"Start"}),":"," ",s?h(s).toLocaleTimeString():""]}),t.jsxs("li",{children:[t.jsx("b",{children:"Status"}),":"," ",t.jsx(E,{bg:f,title:`BLISS state: ${n.state}`,children:o})]}),t.jsxs("li",{children:[t.jsx("b",{children:"Progress"}),": ",t.jsx(F,{})]}),t.jsxs("li",{children:[t.jsx("b",{children:"Description"}),": ",j]}),i&&t.jsxs("li",{children:[t.jsx("b",{children:"End"}),": ",h(i).toLocaleTimeString()]}),s&&t.jsxs("li",{children:[t.jsx("b",{children:"Duration"}),":"," ",a?N(a):t.jsx(P,{starttime:s})]})]})})})}function B(e){const{providers:n,yamlNode:r,...o}=e;return q(r,o),t.jsx(Y,{})}export{B as default};
@@ -1 +0,0 @@
1
- import{j as e,r as f,an as I,aL as P,ay as S,aU as R,g as J,R as V,C as y,aj as q,B as k,ba as Q,bb as ee,u as ae,aX as te,aY as oe,A as se,bB as U,bC as ne,q as G,a1 as re,be as ie}from"./index-0751d893.js";import{S as A,a as K,n as le,p as ce,F as de,r as ue}from"./index-a0f7b98c.js";import{L as me,b as xe,u as ge,T as fe,D as pe,S as H}from"./UseMouseModeInteraction-fc86164b.js";import{V as Y}from"./VSegment-cf1ceafc.js";import{L as N}from"./Label-3c95fb14.js";import{l as L}from"./hooks-457bfe32.js";import{L as he}from"./LoadingMessage-e1e479c5.js";import{W as je}from"./WorldScale-6e6ac5b5.js";import{V as ve,u as ye}from"./VLineRoi-5130fa5a.js";import{D as Ce}from"./DropdownButton-d066ece0.js";import{P as Se}from"./SelectionPoint-d30865f3.js";import{H as be,a as Me}from"./HSegment-8966b13f.js";import"./colors-2395de5a.js";import"./ScreenScale-ae820d30.js";import"./DraggableRect-db33e02e.js";import"./types-46afffa0.js";const D=.1;function we(t,a){if(!t)return{translationrange:A([0,1024],D),rotationrange:A([0,360],D)};const{rotationrange:s,translationrange:o}=t;if(a==="marker")return{translationrange:A(o,D),rotationrange:A(s,D)};if(a==="solid"){const{rotationaxispoints:r}=t,n=Math.abs(s[1]-s[0])/r;return{translationrange:o,rotationrange:[s[0]-n/2,s[1]-n/2]}}throw new Error(`Expected "marker" or "solid" render mode. Got ${a}`)}function Fe(t){return f.useMemo(()=>{if(t===void 0)return;const a=t instanceof Float32Array?t:Float32Array.from(t.data);return I(a,t.shape)},[t])}function Re(t){const{vData:a,xRange:s,xAxisSize:o,yRange:r,yAxisSize:n,colorMap:i,scaleType:l,invertColorMap:c,domain:p}=t,d=f.useMemo(()=>{const g=(a==null?void 0:a.shape[0])??0;return(g-g%o)/o},[a,o]),h=f.useMemo(()=>{if(a===void 0||d===0)return;const g=a.data.subarray(0,d*o);return I(g,[d,o])},[d,o]),u=Fe(h);if(u===void 0)return e.jsx(e.Fragment,{});const j=Math.abs(r[1]-r[0]),m=Math.abs(s[1]-s[0])/o,x=j/n;return e.jsx(ce,{position:[(s[0]+s[1])*.5,r[0]+j*(u.shape[0]/n)*.5,0],size:{width:u.shape[1],height:u.shape[0]},scale:[m,x,1],values:u,domain:p,colorMap:i,scaleType:l,invertColorMap:c})}function Ae(t){const{xData:a,yData:s,vData:o,domain:r,colorMap:n="Viridis",invertColorMap:i=!1,scaleType:l=K.Linear,markerSize:c=8,renderMode:p,...d}=t;return a===void 0||s===void 0||o===void 0?e.jsx(e.Fragment,{}):p==="marker"?e.jsx(je,{children:e.jsx(le,{abscissas:a.data,ordinates:s.data,data:o.data,size:c,domain:r,scaleType:l,invertColorMap:!1,colorMap:n})}):e.jsx(Re,{xData:a,yData:s,vData:o,domain:r,scaleType:l,invertColorMap:!1,colorMap:n,...d})}P("daiquiri.components.tomo.SinogramPlot");function De(t){const{datacollectionMeta:a}=t,s=a.requestedCor!==null&&a.requestedCor!==a.actualCor;return e.jsxs(e.Fragment,{children:[a.estimatedCor!==null&&a.estimatedCor!==a.actualCor&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{x:a.estimatedCor,y1:0,y2:360,color:"#505050",gapColor:"#909090",dashSize:10,gapSize:10}),e.jsx(N,{datapos:[a.estimatedCor,10],color:"#A0A0A0",text:"Estimated CoR"})]}),a.actualCor!==null&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{geometry:{x:a.requestedCor??a.actualCor},onGeometryChanged:(o,r)=>{t.setRequestedCor(o.x,r)}}),e.jsx(N,{datapos:[a.requestedCor??a.actualCor,s?40:25],color:"#FFFFFF",text:s?"Requested CoR":"Actual CoR"})]}),s&&a.actualCor!==null&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{x:a.actualCor,y1:0,y2:360,color:"#000000",gapColor:"#FFFFFF",dashSize:10,gapSize:10}),e.jsx(N,{datapos:[a.actualCor,25],color:"#FFFFFF",text:"Actual CoR"})]})]})}function Ne(t){var m,x;const{xdata:a,ydata:s,vdata:o,sinogram:r,renderMode:n,datacollectionMeta:i,mouseMode:l}=t,{translationrange:c,rotationrange:p}=we(r,n),d=de(o),h=Math.min(a.size,s.size,o.size),u=L(a,0,h),j=L(s,0,h),b=L(o,0,h);return e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",margin:0,minHeight:0},children:[e.jsxs(me,{plotRef:t.plotRef,showAxes:((m=t.viewConfig)==null?void 0:m.displayAxes)??!0,title:"Sinogram",abscissaConfig:{visDomain:c,showGrid:!0,label:"Profile"},ordinateConfig:{visDomain:p,showGrid:!0,label:"Rotation",flip:!0},mouseMode:l,children:[r&&d&&e.jsx(Ae,{xData:u,yData:j,vData:b,domain:d,colorMap:"Viridis",xAxisSize:r.translationaxispoints,yAxisSize:r.rotationaxispoints,xRange:r.translationrange,yRange:r.rotationrange,renderMode:n}),i!==void 0&&e.jsx(De,{setRequestedCor:t.setRequestedCor,datacollectionMeta:i}),e.jsx(he,{...t.message}),t.children]}),(((x=t.viewConfig)==null?void 0:x.colorbarVisible)??!0)&&e.jsx(ue,{domain:d??[0,0],withBounds:!0,colorMap:"Viridis",invertColorMap:!1,scaleType:K.Linear})]})}function ze(t){const{onSelect:a,value:s}=t,o={marker:"Marker",solid:"Solid"},r=o[s];return e.jsxs(Ce,{title:r,id:"bg-vertical-dropdown-4",variant:"secondary",onSelect:n=>{n!==null&&a(n)},children:[e.jsx(S.Item,{eventKey:"marker",children:o.marker}),e.jsx(S.Item,{eventKey:"solid",children:o.solid})]})}const T=P("daiquiri.components.tomo.sinogram.AxisRotationPositionInteraction");function Ve(t){const{operator:a,resetMouseMode:s}=t,o=xe(),{mouseMode:r,actions:n}=o??{},i=f.useCallback(l=>{const c=l.dataPt.x;s(),t.setRequestedCor(c)},[t.setRequestedCor,n]);return a?r!=="set-axis-rotation"?(T("disabled: mouseMode dont match"),e.jsx(e.Fragment,{})):(T("enabled"),e.jsx(Se,{onClick:i})):(T("disabled: not operator"),e.jsx(e.Fragment,{}))}function qe(t){var n;const{rotationHardware:a,detectorWidth:s}=t,o=(n=a==null?void 0:a.properties)==null?void 0:n.position;if(o==null||s===void 0)return e.jsx(e.Fragment,{});const r=a==null?void 0:a.name;return e.jsxs(e.Fragment,{children:[e.jsx(be,{y:o,x1:0,x2:s,color:"red",gapColor:"write",dashSize:10,gapSize:10,lineWidth:3}),e.jsx(N,{datapos:[10,o],color:"#FF0000",anchor:"top",vmargin:10,text:r??"srot"})]})}function Le(){const[t,a]=R("tomo/sinogramview/axes",!0),[s,o]=R("tomo/sinogramview/colorbar-visible",!1),[r,n]=R("tomo/sinogramview/crosshair",!1),[i,l]=R("tomo/sinogramview/displayed",!0);return{colorbarVisible:s,setColorbarVisible:o,displayAxes:t,setDisplayAxes:a,crossHair:r,setCrossHair:n,displayedSinogram:i,setDisplayedSinogram:l}}function Te(t,a,s){return t!==a?"secondary":s||"primary"}function C(t){return e.jsx(k,{variant:Te(t.var,t.value,t.variantWhenSelected),onClick:()=>{t.setter(t.value)},className:"text-nowrap",size:"sm",children:t.children})}function ke(t){const{as:a=void 0,variant:s="secondary",config:o}=t;return e.jsxs(S,{as:a,children:[e.jsx(S.Toggle,{id:"dropdown-basic",variant:s,className:"d-flex align-items-center",children:e.jsx("i",{className:"fa fa-sliders fa-fw fa-lg"})}),e.jsx(S.Menu,{className:"dropdown-menu-center",children:e.jsx("div",{className:"ms-1 me-1",style:{minWidth:"300px"},children:e.jsxs(J,{children:[e.jsxs(V,{children:[e.jsx(y,{className:"my-auto",children:"Sinogram"}),e.jsx(y,{xs:7,children:e.jsxs(q,{children:[e.jsx(C,{var:o.displayedSinogram,value:!0,setter:o.setDisplayedSinogram,children:"Displayed"}),e.jsx(C,{var:o.displayedSinogram,value:!1,setter:o.setDisplayedSinogram,variantWhenSelected:"warning",children:"Hide"})]})})]}),e.jsxs(V,{className:"mt-1",children:[e.jsx(y,{className:"my-auto",children:"Display axes"}),e.jsx(y,{xs:7,children:e.jsxs(q,{children:[e.jsx(C,{var:o.displayAxes,value:!0,setter:o.setDisplayAxes,children:"Yes"}),e.jsx(C,{var:o.displayAxes,value:!1,setter:o.setDisplayAxes,children:"No"})]})})]}),e.jsxs(V,{className:"mt-1",children:[e.jsx(y,{className:"my-auto",children:"Color bar"}),e.jsx(y,{xs:7,children:e.jsxs(q,{children:[e.jsx(C,{var:o.colorbarVisible,value:!0,setter:o.setColorbarVisible,children:"Displayed"}),e.jsx(C,{var:o.colorbarVisible,value:!1,setter:o.setColorbarVisible,children:"Hide"})]})})]})]})})})]})}P("daiquiri.components.tomo.TomoSinogram");function Ie(t){var B,O;const{sinogram:a,selectedScan:s,options:o}=t,{tomoconfig:r}=o,{datacollectionid:n,datacollectionMeta:i}=Q(o.datacollectionid),l=ee(),c=Le(),p=c.displayedSinogram?(a==null?void 0:a.actualnbpoints)??0:0,[d,h]=f.useState("solid"),u=ae(),j=te(r??""),b=oe(j);f.useEffect(()=>{n!==void 0&&l.updateDataCollectionMeta(n,{estimatedCor:null,requestedCor:null,actualCor:null})},[n]);const m=ye({scanId:a!==void 0?s??void 0:void 0,channelNames:["sinogram","rotation","translation"],start:0,stop:p}),x=f.useRef(null),g=ge("zoom"),{mouseMode:E}=g,z=I(new Float32Array([]),[0]),M=m.data.translation,w=m.data.rotation,F=m.data.sinogram;function X(){if(s===null)return{info:"No scan"};if(!a)return{info:"No sinogram defined"};if(!M||!w||!F){if(m.loading)return{warning:"Waiting for data..."};if(!M)return{danger:"Data for x-axis are missing"};if(!w)return{danger:"Data for y-axis are missing"};if(!F)return{danger:"Data for intensity are missing"}}return Math.min(M.size,w.size,F.size)===0?{warning:"Waiting for data..."}:{}}const Z=X(),_=(O=(B=t.sinogram)==null?void 0:B.translationrange)==null?void 0:O[1],W=f.useCallback((v,$)=>{n!==void 0&&($||Me({datacollectionid:n,axisposition:v,filename:(i==null?void 0:i.sourceFilename)??void 0}),l.updateDataCollectionMeta(n,{requestedCor:v}))},[n,i==null?void 0:i.sourceFilename]);return e.jsxs("div",{className:"plot2d-container w-100 h-100",style:{flex:"1 1 0%",display:"flex",flexDirection:"column"},children:[e.jsxs(fe,{align:"center",children:[e.jsx(pe,{mouseModeInteraction:g}),e.jsx(k,{title:"Reset zoom (sample stage overview)",variant:"secondary",onClick:()=>{var v;(v=x==null?void 0:x.current)==null||v.actions.resetZoom()},children:e.jsx("i",{className:"fa fa-expand fa-fw fa-lg"})}),e.jsx(H,{}),e.jsx(k,{title:u?"Select another center of rotation for the slice reconstruction":"You have to get the control on the session to set the center of rotation",disabled:!u,variant:E==="set-axis-rotation"?"warning":"secondary",onClick:()=>{g.setOrResetMouseMode("set-axis-rotation")},children:e.jsx("i",{className:"fad fam-tomo-cor fa-fw fa-lg"})}),e.jsx(H,{}),e.jsx(ze,{value:d,onSelect:h}),e.jsx(ke,{config:c})]}),!c.displayedSinogram&&e.jsx(se,{variant:"warning",children:"Sinogram was disabled by user"}),c.displayedSinogram&&e.jsxs(Ne,{viewConfig:c,message:Z,mouseMode:E,xdata:M??z,ydata:w??z,vdata:F??z,sinogram:a,renderMode:d,plotRef:x,datacollectionMeta:i,setRequestedCor:W,children:[e.jsx(Ve,{operator:u,resetMouseMode:g.resetMouseMode,setRequestedCor:W}),e.jsx(qe,{rotationHardware:b.somega,detectorWidth:_})]})]})}function Pe(){return U(t=>{const a=t.scaninfo.lastgroup;return(a==null?void 0:a.sinogram)??void 0},ne)}function Ee(){return U(t=>{const a=t.scaninfo.lastgroup;return(a==null?void 0:a.scanid)??null})}function We(t){const a=Pe(),s=Ee();return e.jsx(Ie,{...t,sinogram:a,selectedScan:s})}function oa(t){const{yamlNode:a,tomoconfig:s,datacollectionid:o,...r}=t;G(a,r),re(a,"tomoconfig",s),ie(a,"datacollectionid",o),G(a,r);const n={datacollectionid:o,tomoconfig:s};return e.jsx(We,{options:n})}export{oa as default};
@@ -1,69 +0,0 @@
1
- import{bE as re,j as t,ay as F,g as ve,R as A,aj as E,B as N,r as g,a6 as O,a7 as w,an as Ke,a8 as fe,a9 as Wt,aa as et,aL as q,l as Te,ab as T,b9 as St,ax as k,C as L,x as ce,O as wt,au as bt,aU as H,aP as G,aM as Xt,aO as Qt,a_ as Jt,aN as Kt,b8 as en,aY as Fe,bF as tn,u as zt,bG as Re,Q as de,b as V,aQ as Ee,aZ as nn,bH as on,bI as sn,am as an,bJ as rn,bK as cn,bL as ln,aX as dn,b4 as un,bM as mn,b3 as xn,bA as fn,bB as gn,a1 as hn,aw as tt,q as yn}from"./index-0751d893.js";import{a as ge,b as vn,Q as jn,O as pn,j as Sn,t as wn,u as Le,w as nt,r as bn}from"./index-a0f7b98c.js";import{b as Ae,L as zn,u as Cn,T as Mn,D as Dn,S as ie,V as ot}from"./UseMouseModeInteraction-fc86164b.js";import{A as ae,u as Ct,a as Rn}from"./colormap-344855f8.js";import{L as st,S as Nn,b as In,I as Pn,u as kn,A as Tn}from"./AutoscaleOption-d8d0ca8d.js";import{C as Fn,f as it,a as at,H as rt,L as En,V as ct}from"./VisViewpointRestore-097e2edf.js";import{s as Ln,k as An,n as On,t as _n}from"./hooks-457bfe32.js";import{L as Y}from"./Label-3c95fb14.js";import{p as K,a as X,f as te,r as he,t as Mt}from"./geometry-1fc3c1a0.js";import{H as lt,r as ke}from"./HSegment-8966b13f.js";import{V as ye}from"./VSegment-cf1ceafc.js";import{C as Vn}from"./CrossMarker-2285e102.js";import{R as je}from"./RectRoi-19381507.js";import{P as Oe}from"./SelectionPoint-d30865f3.js";import{a as $n,R as Bn}from"./RulerButton-5c2020aa.js";import{c as Gn}from"./colors-2395de5a.js";import{S as Dt}from"./StackedNameState-3f198174.js";import{g as Hn}from"./TomoScans-82e1e23b.js";import{N as _e}from"./NewScanButton-f40700e9.js";import{D as Yn}from"./DropdownButton-d066ece0.js";import{u as Un,a as Zn,b as qn,D as Wn}from"./DropdownDetector-4ddfa946.js";import{H as Xn}from"./HistogramDomainSlider-5572e533.js";import{W as dt}from"./WorldScale-6e6ac5b5.js";import"./Image-1ff7dca9.js";import"./ScreenScale-ae820d30.js";import"./Anchor-3fa6d19c.js";import"./DraggableRect-db33e02e.js";import"./QtyHelper-8429914f.js";import"./types-46afffa0.js";import"./ConnectUtils-b8bfa186.js";function Z(e,n,o,s){if(n)return re(e,n);if(o){const a=`${o}.${s}`;return re(e,a)}return null}function pe(e,n){const o=n.tomoconfig??"ACTIVE_TOMOCONFIG.ref",s=Z(e,n.sampleStageId,o,"sample_stage"),a=Z(e,n.syId,o,"sample_stage.sy"),i=Z(e,n.sampxId,o,"sample_stage.sampx"),l=Z(e,n.sampyId,o,"sample_stage.sampy"),r=Z(e,n.sampuId,o,"sample_stage.sampu"),c=Z(e,n.sampvId,o,"sample_stage.sampv"),u=Z(e,n.szId,o,"sample_stage.sz"),m=Z(e,n.somegaId,o,"sample_stage.somega"),d=Z(e,n.detectorId,o,"detectors.active_detector.detector"),x=Z(e,n.tomoDetectorId,o,"detectors.active_detector");return{sy:a,sampx:i,sampy:l,sampu:r,sampv:c,sz:u,somega:m,detector:d,tomoDetector:x,sampleStage:s}}function Qn(e){const{as:n=void 0,variant:o="secondary"}=e;function s(c,u){const d=e.lut===c?"primary":"secondary";return t.jsx(N,{variant:d,onClick:()=>{e.onSelectLut(c)},className:"text-nowrap",title:u,size:"sm",children:t.jsx(st,{name:c})})}function a(){const c=e.isInverted?"primary":"secondary";return t.jsxs(N,{variant:c,onClick:()=>{e.onSelectInvertion(!e.isInverted)},size:"sm",children:[t.jsx("i",{className:"fa fa-fw fa-arrows-alt-v"})," Inverted LUT"]})}function i(c,u){const d=e.norm===c?"primary":"secondary";return t.jsx(N,{variant:d,onClick:()=>{e.onSelectNorm(c)},size:"sm",children:u})}function l(c){const u=e.autoscaleMode===c,m=u&&e.autoscale?"primary":u?"warning":"secondary",x={[ae.Minmax]:"Minmax",[ae.StdDev3]:"3×std",[ae.None]:"Manual"}[c];return t.jsx(N,{variant:m,onClick:()=>{var h,f;(h=e.onSelectAutoscaleMode)==null||h.call(e,c),e.autoscale||(f=e.onSelectAutoscale)==null||f.call(e,!0)},size:"sm",children:x})}function r(){const c=e.autoscale?"primary":"secondary";return t.jsxs(N,{variant:c,onClick:()=>{var u;(u=e.onSelectAutoscale)==null||u.call(e,!e.autoscale)},size:"sm",children:[t.jsx("i",{className:"fa-solid fa-circle-half-stroke fa-fw fa-lg"})," Auto scale enabled"]})}return t.jsxs(F,{as:n,className:`${e.dropDirection==="up"?"dropup":""}`,children:[t.jsxs(F.Toggle,{id:"dropdown-basic",variant:o,className:"d-flex align-items-center",children:[t.jsx(st,{name:e.lut}),t.jsx(Nn,{scale:e.norm}),e.autoscale&&t.jsx(In,{autoscale:e.autoscaleMode})]}),t.jsx(F.Menu,{className:"dropdown-menu-center",children:t.jsx("div",{className:"ms-1 me-1",children:t.jsxs(ve,{children:[t.jsx(A,{children:t.jsx("h6",{className:"flex-grow-1 text-center",children:"Lookup table"})}),t.jsx(A,{children:t.jsxs(E,{className:"flex-grow-1",children:[s("Greys","Gray"),s("Viridis","Viridis"),s("Cividis","Cividis"),s("Magma","Magma"),s("Inferno","Inferno"),s("Plasma","Plasma")]})}),t.jsx(A,{children:t.jsx(E,{className:"flex-grow-1 mt-1",children:a()})}),e.onSelectAutoscale&&t.jsxs(t.Fragment,{children:[t.jsx(A,{className:"mt-2",children:t.jsx("h6",{className:"flex-grow-1 text-center",children:"Autoscale"})}),t.jsx(A,{children:t.jsxs(E,{className:"flex-grow-1",children:[l(ae.Minmax),l(ae.StdDev3)]})}),t.jsx(A,{children:t.jsx(E,{className:"flex-grow-1 mt-1 mb-2",children:r()})})]}),t.jsx(A,{className:"mt-2",children:t.jsx("h6",{className:"flex-grow-1 text-center",children:"Normalization"})}),t.jsx(A,{children:t.jsxs(E,{className:"flex-grow-1",children:[i(ge.Linear,"Linear"),i(ge.Log,"Log"),i(ge.SymLog,"SymLog"),i(ge.Sqrt,"Sqrt")]})})]})})})]})}function Jn(e,n){const[o,s]=g.useState(!1),[a,i]=g.useState(!1),[l,r]=g.useState(void 0),[c,u]=g.useState(void 0),[m,d]=g.useState(),[x,h]=g.useState(new O(new w,new w(1,1))),[f,y]=g.useState(new O(new w,new w(1,1))),v=g.useCallback(()=>{r(void 0),u(void 0),d(void 0),h(new O(new w,new w(1,1))),y(new O(new w,new w(1,1)))},[r,u,d,h,y]);return g.useEffect(()=>{const b={width:256,height:256};if(e){if(e.defaults.baseURL==="mock"){const p=new Fn({width:2048,height:4096},b);r(p),u(p),d(void 0),h(new O(new w(-50,-100),new w(50,100))),y(new O(new w(-50,-100),new w(50,100)));return}if(!n){v();return}e.get(`/image_tiling/${n}`).then(p=>{const{status:j,output:M}=p.data;if(j!=="done"&&j!=="running")throw new Error("Status is not done");if(M.length!==2)throw new Error("Error in retrieve tiling information");const{location:S,hdf5_entry:C}=M[0],{location:D,hdf5_entry:I}=M[1];if(!S||!C)throw new Error("Error in retrieved tiling locations");return Promise.all([it(e,S,C),it(e,D,I),at(e,S,"/sequence/histogram/count"),at(e,S,"/sequence/histogram/bin_edges")])}).catch(p=>v()).then(p=>{if(!p){v();return}const{layers:j,yDomain:M,zDomain:S}=p[0];r(new rt(b,j)),h(new O(new w(M[0],S[0]),new w(M[1],S[1])));const{layers:C,yDomain:D,zDomain:I}=p[1];u(new rt(b,C)),y(new O(new w(D[0],I[0]),new w(D[1],I[1])));const R=Ln({values:p[2].data,bins:p[3].data});d({values:Ke(new Float64Array(R.values),[R.values.length]),bins:Ke(new Float64Array(R.bins),[R.bins.length])})})}},[n,e,o,v]),g.useEffect(()=>{if(!a)return()=>{};if(!c||!l)return v(),s(j=>!j),i(!1),()=>{};if(c.getPendingTilesCount()+l.getPendingTilesCount()===0)return v(),s(j=>!j),i(!1),()=>{};const p=setInterval(()=>{v(),s(j=>!j),i(!1)},1e3);return()=>{clearInterval(p)}},[c,l,a,v]),{apiFront:l,apiSide:c,histogram:m,tilingBoxFront:x,tilingBoxSide:f,invalidate:()=>{v(),s(b=>!b)},lazyRefresh:()=>{i(!0)}}}function Kn(e,n){const[o,s]=g.useState(void 0);return g.useEffect(()=>{if(!e&&!n){s(void 0);return}if(e==="mock"){s(()=>fe.create({baseURL:e}));return}s(n?()=>fe.create({baseURL:new URL(n,Wt()).toString(),...et.getOptions()}):void 0),e&&fe.get("status",{baseURL:e,timeout:3e3}).then(a=>s(()=>fe.create({baseURL:e}))).catch(()=>{})},[e,n,et.token]),o}const ut=q("daiquiri.services.TomovisService");function eo(e,n,o){const[s,a]=g.useState([]),[i,l]=g.useState(null),[r,c]=g.useState("UNKNOWN"),u=g.useCallback(f=>{let y=0;f.forEach(v=>{v.status!=="done"&&(y+=1),v.id===n&&(v.status==="done"||v.status==="running")&&l(n)}),c(y?"PROCESSING":"READY")},[n,i,c]),m=g.useCallback(()=>{e&&(e.defaults.baseURL==="mock"&&a([{id:"chessboard",status:"done",create_time:"1871-03-18"}]),e.get("/image_tiling/").then(f=>{const y=f.data.items;if(y===void 0)throw new Error("No items field received.");u(y),a(v=>Te.isEqual(v,y)?v:y)}).catch(f=>{f.response.status===404?c("OFFLINE"):(c("FAILED"),console.error("Error while reading available tomovis tiling",f))}))},[e,i,n,u,c]);g.useEffect(()=>{m()},[m]);const d=g.useCallback(f=>{e&&e.delete(`/image_tiling/${f}`).then(y=>{const v=s.filter(b=>b.id!==f);return a(v),null}).catch(y=>{console.error('Error while requesting tiling deletion: "%s"',f,y)})},[e,s]),[x,h]=g.useState(o);return g.useEffect(()=>{const f=setInterval(()=>{m()},x);return()=>clearInterval(f)},[m,x]),g.useEffect(()=>{n&&n!==i||r==="PROCESSING"?o>2e3&&(ut("Polling every %sms",2e3),h(2e3)):(ut("Polling every %sms",o),h(o))},[i,n,o,r]),{imageTilings:s,lastReadyImageTiling:i,updateImageTilings:m,deleteImageTiling:d,state:r}}function le(e){const{startPoint:n,endPoint:o,lineWidth:s=1,lineColor:a="black",gapColor:i,gapSize:l,dashSize:r,opacity:c=1,zIndex:u=1}=e;return t.jsxs(t.Fragment,{children:[t.jsx(lt,{y:n[1],x1:n[0],x2:o[0],zIndex:u,color:a,gapColor:i,gapSize:l,dashSize:r,opacity:c,lineWidth:s}),t.jsx(lt,{y:o[1],x1:n[0],x2:o[0],zIndex:u,color:a,gapColor:i,gapSize:l,dashSize:r,opacity:c,lineWidth:s}),t.jsx(ye,{x:n[0],y1:n[1],y2:o[1],zIndex:u,color:a,gapColor:i,gapSize:l,dashSize:r,opacity:c,lineWidth:s}),t.jsx(ye,{x:o[0],y1:n[1],y2:o[1],zIndex:u,color:a,gapColor:i,gapSize:l,dashSize:r,opacity:c,lineWidth:s})]})}const to=q("daiquiri.components.tomo.tiling.ActualDetectorLocation");function no(e){const n=(e.rotation+e.projRotation)/180*Math.PI,{x:o,y:s,fov:a}=e,i=Math.abs(Math.cos(n)*a[0]*.5),l=a[1]*.5,r=[o-a[0]*.5,s-a[1]*.5],c=[o+a[0]*.5,s+a[1]*.5],u=t.jsx(t.Fragment,{children:t.jsx(le,{startPoint:r,endPoint:c,lineColor:T.danger,gapColor:T.light,dashSize:4,gapSize:4,lineWidth:1,zIndex:2})});return i<.001?t.jsxs(t.Fragment,{children:[u,t.jsx(ye,{x:o,y1:s-l,y2:s+l,color:T.danger,lineWidth:2,zIndex:2})]}):t.jsxs(t.Fragment,{children:[u,t.jsx(le,{startPoint:[o-i,s-l],endPoint:[o+i,s+l],lineColor:T.danger,lineWidth:2,zIndex:2})]})}function oo(e){const{xAxisDelta:n,y:o,fov:s,detectorX:a}=e,i=s?s[1]*.5:50;function l(h){const{startPoint:f,endPoint:y}=h;return t.jsx(ye,{x:f.x,y1:f.y,y2:y.y,dashSize:8,gapSize:4,color:T.danger,gapColor:T.light})}const r=a+n;if(s===null){const h=new k(r,o-i),f=new k(r,o+i);return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[r+1,o-i],color:T.danger,text:"Axis"}),t.jsx(l,{startPoint:h,endPoint:f})]})}if(Math.abs(n)*2>s[0]){const h=s[0]*.5,f=new k(r,o-h-i),y=new k(r,o+h+i);return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[r+1,o-i],color:T.danger,text:"Axis"}),t.jsx(l,{startPoint:f,endPoint:y})]})}const c=s[1]*.5,u=new k(r,o-c),m=new k(r,o-c-i),d=new k(r,o+c),x=new k(r,o+c+i);return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[r+1,o-c-i],color:T.danger,text:"Axis"}),t.jsx(l,{startPoint:u,endPoint:m}),t.jsx(l,{startPoint:d,endPoint:x})]})}function so(e){const{tomoHardware:n}=e,{sy:o,sz:s,somega:a,sampu:i,sampv:l,tomoDetector:r,detector:c,sampleStage:u}=n;if(o===null||s===null)return to("Skipped: one of sy, sz is missing."),t.jsx(t.Fragment,{});function m(I){if(I===null)return null;const{position:R}=I.properties;if(R===null)return R;const _=St(I)?1:-1;return R*_}const d=(u==null?void 0:u.properties.detector_center)??[0,0],x=d[0]??0,h=d[1]??0,f=K(s),y=X(i)??0,v=X(l)??0,b=K(o),p=m(a),j=te(r,c);function M(){const I=e.projRotation*Math.PI/180;return-Math.sin(I)*y+Math.cos(I)*v+b}const S=M()-x,C=f-h,D=b-x;return t.jsxs(t.Fragment,{children:[t.jsx(Vn,{x:S,y:C,color:T.danger,sizeInScreen:20,lineWidth:2,zIndex:2}),t.jsx(Y,{datapos:[S-(j?j[0]*.5:0)+1,C-(j?j[1]*.5:0)],color:T.danger,text:(c==null?void 0:c.name)??"Detector"}),p!==null&&j!==null&&t.jsx(no,{x:S,y:C,fov:j,rotation:p,projRotation:e.projRotation}),t.jsx(oo,{xAxisDelta:D,y:C,fov:j,detectorX:S})]})}function Ve(e,n){if(e===null||n===null)return null;const o=e.properties.sample_pixel_size,s=n.properties.size;if(s===null||o===null)return null;const a=o/1e3;return[s[0]*a,s[1]*a]}function Rt(e,n){const{sy:o,sz:s,sampu:a,sampv:i,tomoDetector:l,detector:r}=e;if(s===null)return{motorBox:new O,visibleBox:new O,maxBox:new O};const c=n*Math.PI/180,u=o?K(o):0,[m,d]=he(o),[x,h]=he(a),[f,y]=he(i),[v,b]=he(s),p=-Math.sin(c)*x+Math.cos(c)*f+u,j=-Math.sin(c)*h+Math.cos(c)*y+u,M=Ve(l,r),[S,C]=M||[0,0],{sampleStage:D}=e,I=(D==null?void 0:D.properties.detector_center)??[0,0],R=I[0]??0,_=I[1]??0,$=new O().setFromPoints([new w(p-R,v-_),new w(j-R,b-_)]),B=$.clone().expandByVector(new w(S*.5,C*.5)),z=new O().setFromPoints([new w(x+f+m-R,v-_),new w(h+y+d-R,b-_)]).expandByVector(new w(S*.5,C*.5));return{motorBox:$,visibleBox:B,maxBox:z}}function Se(e){const{sz:n,sampu:o,sampv:s}=e;if(n===null)return;const a=X(o)??0,i=X(s)??0,l=K(n),{sampleStage:r}=e,c=(r==null?void 0:r.properties.detector_center)??[0,0],u=c[0]??0,m=c[1]??0;return new k(a-u,i-u,l-m)}function io(e){const{projRotation:n,tomoHardware:o}=e,{motorBox:s,visibleBox:a}=Rt(o,n);return t.jsxs(t.Fragment,{children:[!s.isEmpty()&&t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:a.min,color:T.info,text:"Visible limit"}),t.jsx(le,{startPoint:[a.min.x,a.min.y],endPoint:[a.max.x,a.max.y],lineColor:T.info,dashSize:8,gapSize:4})]}),!a.isEmpty()&&t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:s.min,color:T.info,text:"Motor limit"}),t.jsx(le,{startPoint:[s.min.x,s.min.y],endPoint:[s.max.x,s.max.y],lineColor:T.info,dashSize:2,gapSize:2})]})]})}const ao=2;function Nt(e){return t.jsxs(A,{className:"flex-nowrap",xs:12,children:[t.jsx(L,{xs:3,children:e.title}),t.jsx(L,{className:"text-end",xs:6,children:e.value.toFixed(ao)}),t.jsx(L,{className:"text-start",xs:3,children:e.unit})]})}function Ne(e){const{motor:n}=e,[o,s]=Mt(n,e.position),a=(n==null?void 0:n.alias)??(n==null?void 0:n.name)??e.defaultName;return t.jsx(Nt,{title:a,value:o,unit:s})}function ro(e){const{tomoHardware:n,value:o}=e,{sampleStage:s}=n,a=(s==null?void 0:s.properties.detector_center)??[0,0],i=a[0]??0,l=a[1]??0,r=n.sy?K(n.sy):0;return t.jsxs(ve,{children:[e.x!==void 0&&t.jsx(Ne,{motor:n.sampu,position:e.x-r+i,defaultName:"sample-u-axis"}),e.y!==void 0&&t.jsx(Ne,{motor:n.sampv,position:e.y-r+i,defaultName:"sample-v-axis"}),e.z!==void 0&&t.jsx(Ne,{motor:n.sz,position:e.z+l,defaultName:"z-axis"}),t.jsx(Nt,{title:"intensity",value:o,unit:""})]})}function co(e,n){return e.expandByVector(e.getSize(new w).multiplyScalar(n*.5))}function lo(e){return{x:[e.min.x,e.max.x],y:[e.min.y,e.max.y]}}function uo(e){const{task:n,view:o,dragTomoScanRoi:s,readOnly:a=!1}=e,{active:i,roi:l}=n,{centerZ:r,width:c,height:u}=l,{x:m,y:d}=l.center,x=g.useCallback((v,b)=>{const p=(v.x1+v.x2)*.5,j=(v.y1+v.y2)*.5;s(n.id,o==="front"?p:m,o==="front"?d:p,j)},[o,s,m,d,r]);if(c===null||u===null||c===null||u===null)return null;const h=o==="front"?m:d,f=new w(h-c/2,r-u/2),y=new w(h+c/2,r+u/2);return t.jsx(je,{geometry:{x1:f.x,y1:f.y,x2:y.x,y2:y.y},color:T.info,lineWidth:2,readOnly:!i,onGeometryChanged:x})}function mt(e,n){return n[0]<n[1]?n[0]<=e&&e<=n[1]:n[1]<=e&&e<=n[0]}function mo(e,n){return mt(e.x,n.xVisibleDomain)&&mt(e.y,n.yVisibleDomain)}function xo(e,n){const o=e===null||n===null?null:new k(e,n),{dataToHtml:s,getVisibleDomains:a}=vn();return jn(i=>{if(o===null)return null;const l=a(i);return{isVisible:mo(o,l),displayedCoords:s(i,o)}},[e,n])}const fo=q("daiquiri.components.tomo.tiling.MotorMarker"),go=g.forwardRef((e,n)=>{const{popper:o,children:s,show:a,displayed:i,displayedCoords:l,...r}=e;return g.useEffect(()=>{o&&o.scheduleUpdate()},[s,o]),g.useEffect(()=>{o&&o.scheduleUpdate()},[l,o]),t.jsx(ce,{ref:n,body:!0,...r,children:s})});function Ie(e){const{motor:o}=e,[s,a]=Mt(o,e.position),i=(o==null?void 0:o.alias)??(o==null?void 0:o.name)??e.defaultName;return t.jsxs(A,{className:"flex-nowrap text-nowrap",xs:12,children:[t.jsx(L,{xs:3,children:i}),t.jsx(L,{className:"text-end",xs:6,children:s.toFixed(2)}),t.jsx(L,{className:"text-start",xs:3,children:t.jsx("span",{className:"text-nowrap",children:a})})]})}function ho(e){const{tomoHardware:n,projRotation:o,variant:s="primary"}=e,[a,i]=g.useState(!1),l=g.useRef(null);function r(){if(o===0){const[M,S,C]=e.coords;return[S,C]}else if(o===-90){const[M,S,C]=e.coords;return[M,C]}return console.error(`Unimplemented projRotation ${o}`),[null,null]}const[c,u]=r(),m=xo(c,u);if(c===null||u===null)return fo("Skipped: projected pixel size is null."),t.jsx(t.Fragment,{});const[d,x,h]=e.coords,f=n.sy?K(n.sy):0,{sampleStage:y}=n,v=(y==null?void 0:y.properties.detector_center)??[0,0],b=v[0]??0,p=v[1]??0,j=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-end mb-2",children:t.jsx(N,{size:"sm",variant:"light",onClick:()=>{e.onDelete&&e.onDelete(s)},title:"Remove the marker",children:t.jsx("i",{className:"fa fa-fw fa-trash fa-lg"})})}),t.jsxs(ve,{children:[d!==null&&t.jsx(Ie,{motor:n.sampu,position:d-f+b,defaultName:"sample-u-axis"}),x!==null&&t.jsx(Ie,{motor:n.sampv,position:x-f+b,defaultName:"sample-v-axis"}),h!==null&&t.jsx(Ie,{motor:n.sz,position:h+p,defaultName:"z-axis"}),(e.onDelete||e.onMove)&&t.jsx(A,{className:"g-0 mt-2 justify-content-center",children:t.jsxs(E,{children:[t.jsx(N,{size:"sm",variant:"danger",title:"Move the sample stage at this location",onClick:()=>{e.onMove&&e.onMove(s)},children:"Move motors"}),t.jsx(N,{size:"sm",variant:"secondary",title:"Copy bliss command to clipboard",onClick:()=>{e.onCopyToClipboard&&e.onCopyToClipboard(s)},children:t.jsx("i",{className:"fa fa-fw fa-clipboard"})})]})})]})]});return t.jsx(t.Fragment,{children:t.jsx(pn,{x:c,y:u,children:t.jsx(wt,{trigger:"click",rootClose:!0,overlay:t.jsx(go,{id:"popover-contained",show:a&&!(m!=null&&m.isVisible),displayed:a,displayedCoords:(m==null?void 0:m.displayedCoords)??null,children:j}),children:t.jsx(bt,{bg:"none",onClick:()=>i(!a),style:{pointerEvents:"auto",top:"50%",left:"50%",position:"relative",transform:"translate(-100%, -100%)"},children:t.jsx("i",{ref:l,style:{cursor:"pointer"},className:`fa fa-map-marker fa-3x text-${s}`})})})})})}function yo(e){const{getCenter:n}=e,[o,s]=H("tomo/tiling/markers",{}),a=g.useCallback((i,l,r,c)=>{const u=n()??{x:null,y:null,z:null},m=o[i]??[null,null,null],d={...o},x=l===null&&r===null&&c===null;d[i]=x?[null,null,null]:[l??m[0]??u.x,r??m[1]??u.y,c??m[2]??u.z],s(d)},[s,o]);return[o,a]}function vo(e){return t.jsx(t.Fragment,{children:Te.map(e.markers,(n,o)=>t.jsx(ho,{projRotation:e.projRotation,tomoHardware:e.tomoHardware,variant:o,coords:n,onDelete:s=>{e.setMarker(s,null,null,null)},onMove:s=>{const a=e.markers[s],i=e.computeSampleStageAtPlotLocation(a[0],a[1],a[2]);ke(i)},onCopyToClipboard:s=>{const a=e.markers[s],i=e.computeSampleStageAtPlotLocation(a[0],a[1],a[2]);function l(c,u,m){if(m===void 0||u===null)return;const d=m.to(u.properties.unit).scalar;c.push(`${u.alias??u.name}`,`${d.toFixed(4)}`)}const r=[];l(r,e.tomoHardware.sz,i.sz),l(r,e.tomoHardware.sampu,i.sampu),l(r,e.tomoHardware.sampv,i.sampv),navigator.clipboard.writeText(`umv(${r.join(", ")})`)}},o))})}function jo(e){const{disabled:n,projRotation:o,selectedMarker:s,setMarker:a}=e,i=g.useCallback(l=>{if(n){console.error("Unexpected click action");return}o===0?a(s,null,l.dataPt.x,l.dataPt.y):o===-90?a(s,l.dataPt.x,null,l.dataPt.y):console.error(`Unexpected projRotation ${o}`)},[n,o,a,s]);return t.jsx(t.Fragment,{children:!n&&t.jsx(Oe,{onClick:i})})}const It=q("daiquiri.components.tomo.tiling.TilingInteraction");function po(e){const{disabled:n,onActionRequested:o,projRotation:s,computeSampleStageAtPlotLocation:a,sampleStage:i}=e,{sy:l}=i,r=g.useCallback(c=>{if(o(),s===0){const u=c.dataPt.x,m=c.dataPt.y,d=a(null,u,m);ke(d)}else if(s===-90){const u=c.dataPt.x,m=c.dataPt.y,d=a(u,null,m);ke(d)}else console.error(`Unexpected projRotation ${s}`)},[l,a,o]);return n?(It("MoveMotorInteraction disabled."),t.jsx(t.Fragment,{})):t.jsx(Oe,{onClick:r})}function So(e){const{disabled:n,roiFov:o,projRotation:s,actions:a,onActionRequested:i}=e,l=g.useCallback((c,u,m)=>{o&&a.createScanTask({x:new G(c,"mm"),y:new G(u,"mm"),z:new G(m,"mm"),detector:o.detector,magnification:o.magnification,fov:[new G(o.fov[0],"mm"),new G(o.fov[1],"mm")],pixelSize:[new G(o.pixelSize[0],"um"),new G(o.pixelSize[1],"um")],active:!0})},[o,a]),r=g.useCallback(c=>{i(),s===0?l(c.dataPt.x,0,c.dataPt.y):s===-90?l(0,c.dataPt.x,c.dataPt.y):console.error(`Unexpected projRotation ${s}`)},[l,i,s]);return n||o===null?(It("CreateRoiInteraction disabled."),t.jsx(t.Fragment,{})):t.jsx(Oe,{onClick:r})}function wo(e){const{projRotation:n,mouseMode:o,resetMouseMode:s,actions:a,computeSampleStageAtPlotLocation:i,operator:l,sampleStage:r,roiFov:c,markerName:u,setMarker:m,mouseOverlay:d}=e;return t.jsxs(t.Fragment,{children:[t.jsx($n,{mouseMode:o,disabled:d!==void 0,plotUnit:"mm"}),t.jsx(So,{projRotation:n,disabled:d!==void 0||o!=="create",roiFov:c,actions:a,onActionRequested:()=>s()}),t.jsx(po,{projRotation:n,disabled:d!==void 0||!l||o!=="move-motors",computeSampleStageAtPlotLocation:i,sampleStage:r,onActionRequested:()=>s()}),t.jsx(jo,{projRotation:n,disabled:d!==void 0||o!=="mark-position",selectedMarker:u,setMarker:m})]})}function bo(e){const{api:n,box:o,renderTooltip:s,...a}=e;if(!n||o.isEmpty())return null;const i=o.getSize(new w),l=o.getCenter(new w);return t.jsxs("group",{position:[l.x,l.y,0],children:[t.jsx(Sn,{api:n,size:{width:i.x,height:i.y},...a}),s&&t.jsx(wn,{size:i,renderTooltip:s})]})}class zo extends Qt{constructor(){super({uniforms:{color:{value:new Jt},size:{value:new w},nbCells:{value:new w},overlap:{value:new w},scaleX:{value:0},scaleY:{value:0},lineWidth:{value:0}},vertexShader:`
2
- uniform float scaleX; // signed scale
3
- uniform float scaleY; // signed scale
4
- out vec2 pixelCoord;
5
- // out vec2 dataCoord;
6
-
7
- void main() {
8
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
9
- vec2 pixelScale = abs(vec2(scaleX, scaleY));
10
- // dataCoord = vec2(position.x, position.y);
11
- pixelCoord = vec2(position.x, position.y) / pixelScale;
12
- }
13
- `,fragmentShader:`
14
- uniform vec4 color;
15
- uniform vec4 gapColor;
16
- uniform float gapSize;
17
- uniform float dashSize;
18
- uniform float lineWidth;
19
- uniform float scaleX; // signed scale
20
- uniform float scaleY; // signed scale
21
- uniform vec2 size;
22
- uniform vec2 nbCells;
23
- uniform vec2 overlap;
24
- in vec2 pixelCoord;
25
-
26
- /**
27
- * @param position: pixel position
28
- * @param size: size of the rectangle
29
- * @param nbCells: number of cells
30
- * @param overlap: size of the overlap in ratio of a cell
31
- * (0.5 means same size with the cell)
32
- */
33
- float sdf_grid(in vec2 position, in vec2 size, in vec2 nbCells, in vec2 overlap) {
34
- vec2 maxSize = size / (nbCells - overlap * (nbCells - 1.0));
35
- vec2 tableDist = min(abs(abs(position) - size * 0.5), maxSize);
36
- vec2 overlapSize = maxSize * overlap;
37
- vec2 cellSize = maxSize - overlapSize;
38
- vec2 p = position - cellSize * 0.5 * (1.0 - mod(nbCells, 2.0));
39
- vec2 gridDist = abs(abs(mod(p, cellSize)) - cellSize * 0.5);
40
- gridDist -= overlapSize * 0.5;
41
- gridDist = max(gridDist, cellSize - tableDist);
42
- return min(gridDist.x, gridDist.y);
43
- }
44
-
45
- void main() {
46
- vec2 scale = abs(vec2(scaleX, scaleY));
47
- float d = sdf_grid(pixelCoord, size / scale, nbCells, overlap);
48
-
49
- //#define DEBUG_DIST
50
- #ifdef DEBUG_DIST
51
- vec2 n = size / nbCells / scale;
52
- float c = d / min(n.x, n.y);
53
- gl_FragColor = vec4(max(-c, 0.0), abs(c), max(c, 0.0), 1.0);
54
- return;
55
- #endif
56
-
57
- if (d > lineWidth) {
58
- discard;
59
- }
60
- float alpha;
61
- if (lineWidth >= 1.0) {
62
- alpha = smoothstep(1.0, 0.0, d - lineWidth * 0.5);
63
- } else {
64
- // simulate line thiner than 1px with alpha
65
- alpha = lineWidth;
66
- }
67
- gl_FragColor = vec4(color.rgb, color.a * alpha);
68
- }
69
- `})}}Xt({GridDashMaterial:zo});function Pt(e){const{center:n,size:o,nbCells:s,overlap:a=[0,0],lineWidth:i=1,color:l="black",opacity:r=1,zIndex:c=0}=e,u=g.useRef(null),m=An();return g.useEffect(()=>{const d=Gn(l,r);if(u.current){const x=u.current.uniforms;x.color.value=d,x.size.value=o,x.nbCells.value=s,x.overlap.value=a,x.lineWidth.value=i,Kt()}},[l,o,s,a,r,i]),en(({camera:d})=>{if(u.current===null)return;const x=d.scale.x/m.sx,h=d.scale.y/m.sy,f=u.current.uniforms;f.scaleX.value=x,f.scaleY.value=h}),t.jsx("group",{position:[n[0],n[1],c],children:t.jsxs("mesh",{children:[t.jsx("ambientLight",{}),t.jsx("planeGeometry",{attach:"geometry",args:[o[0],o[1],1,1]}),t.jsx("gridDashMaterial",{attach:"material",transparent:!0,ref:u})]})})}const Co=q("daiquiri.components.tomo.tiling.rois.CubeRoi");function xt(e,n){return n===0?new w(e.y,e.z):n===-90?new w(e.x,e.z):(console.error(`Unimplemented projRotation ${n}`),null)}function Mo(e,n){return n===void 0?{}:e===0?{nbRow:n.z,nbCol:n.y}:e===-90?{nbRow:n.z,nbCol:n.x}:{}}function Do(e,n,o){if(e===null)return{box:new O};const s=xt(e.start,n),a=xt(e.stop,n);if(s===null||a===null)return{box:new O};const i=Mo(n,o);return{box:new O().setFromPoints([s,a]),...i}}function kt(e,n,o){function s(a,i,l){return l===0?new k((a==null?void 0:a.x)??0,i.x,i.y):l===-90?new k(i.x,(a==null?void 0:a.y)??0,i.y):(console.error(`Unexpected projRotation ${l}`),a)}return{start:s(e.start,new w(n.x1,n.y1),o),stop:s(e.stop,new w(n.x2,n.y2),o)}}function ft(e,n,o){const s={x1:n[0].x,y1:n[0].y,x2:n[1].x,y2:n[1].y};return kt(e,s,o)}function Ro(e){const n=Se(e),{tomoDetector:o,detector:s}=e,a=te(o,s)??[1,1];return n?{start:new k(n.x-a[0]*1.4,n.y-a[0]*1.4,n.z-a[1]*1.4),stop:new k(n.x+a[0]*1.4,n.y+a[0]*1.4,n.z+a[1]*1.4)}:(console.error("oups center",n),Co("Roi reset skipped: center is undefined."),null)}function No(e){const{roi:n,projRotation:o,maxCellSize:s=[0,0]}=e,a=g.useCallback((x,h)=>{const f=kt(n,x,o);h?e.onDragMove&&e.onDragMove(f):e.onDragEnd&&e.onDragEnd(f)},[n,e.onDragMove,e.onDragEnd,o]),{box:i,nbRow:l,nbCol:r}=Do(n,o,e.grid),c=new w;i.getSize(c);const u=new w;i.getCenter(u);function m(){if(e.readOnly)return;const[x,h]=s,f=Math.ceil(c.x/x),y=Math.ceil(c.y/h),v=(x*f-c.x)/(f-1),b=(h*y-c.y)/(y-1),p=f<=1?0:v/x,j=y<=1?0:b/h;return[p,j]}const d=m();return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[(i.min.x+i.max.x)*.5,i.min.y],text:e.label??"",color:e.color,anchor:"bottom"}),t.jsx(Pt,{center:[u.x,u.y],size:[c.x,c.y],color:e.color,opacity:.25,nbCells:[r??1,l??1],overlap:d,lineWidth:1,zIndex:.5}),t.jsx(je,{geometry:{x1:i.min.x,y1:i.min.y,x2:i.max.x,y2:i.max.y},readOnly:e.readOnly,onGeometryChanged:a,color:e.color})]})}function Io(e,n,o){return g.useMemo(()=>{const s=te(n,o);if(s===null)return;const a=new k;return a.add(e.start),a.sub(e.stop),[new k(Math.ceil(Math.abs(a.x)/s[0]),Math.ceil(Math.abs(a.y)/s[0]),Math.ceil(Math.abs(a.z)/s[1])),s]},[e,n])}function Po(e){const[n,o]=Io(e.roi,e.tomoDetector,e.detector)??[void 0,void 0];return t.jsx(No,{roi:e.roi,grid:n,maxCellSize:o,onDragEnd:e.onDragEnd,onDragMove:e.onDragMove,projRotation:e.projRotation,color:T.success,label:"Tiling",readOnly:e.readOnly})}function ko(e){const{disabled:n,projRotation:o,geometry:s,onGeometryChanged:a,sampleStage:i,resetMouseMode:l}=e,r=Ae();return t.jsx(Le,{id:e.id,disabled:n||(r==null?void 0:r.overlayCursor)!==void 0,onSelectionStart:()=>{r==null||r.actions.captureMouseInteraction()},onSelectionEnd:()=>{r==null||r.actions.releaseMouseInteraction(),l()},onSelectionChange:c=>{if(c===void 0)return;function u(){return s||Ro(i)}const m=u();if(m===null)return;const d=ft(m,c.data,o);a(d)},onValidSelection:c=>{if(s===null)return;const u=ft(s,c.data,o);a(u)},children:c=>t.jsx(t.Fragment,{})})}q("daiquiri.components.tomo.tiling.FlatLocation");function To(e){const{x:n,y:o,fov:s}=e,a=s[0]*.5,i=s[1]*.5;return t.jsx(le,{startPoint:[n-a,o-i],endPoint:[n+a,o+i],lineColor:T.secondary,lineWidth:2,zIndex:2})}function gt(e,n){return g.useMemo(()=>{if(n===null||e===void 0)return null;for(const o of e){const s=o.axisRef.slice(9);if(s===n.alias||s===n.id||s===n.name)return o}return null},[e,n==null?void 0:n.alias,n==null?void 0:n.name,n==null?void 0:n.id])}function Fo(e){const{tomoHardware:n,tomoFlatMotion:o}=e,{sy:s,sz:a,sampu:i,sampv:l,tomoDetector:r,detector:c,sampleStage:u}=n,m=gt(o==null?void 0:o.properties.motion,s),d=gt(o==null?void 0:o.properties.motion,a);if(m===null&&d===null)return t.jsx(t.Fragment,{});const x=(u==null?void 0:u.properties.detector_center)??[0,0],h=x[0]??0,f=x[1]??0,y=X(a),v=X(i)??0,b=X(l)??0,p=X(s),j=te(r,c);if(j===null)return t.jsx(t.Fragment,{});function M(){const z=e.projRotation*Math.PI/180;return y===null||p===null?null:[-Math.sin(z)*v+Math.cos(z)*b+p-h,y-f]}const S=(d==null?void 0:d.absolute_position)??null,C=(d==null?void 0:d.relative_position)??null,D=(m==null?void 0:m.absolute_position)??null,I=(m==null?void 0:m.relative_position)??null;function R(){if(D!==null&&S!==null)return[D,S];const z=M();if(z===null)return null;const P=D??z[0]+(I??0),Q=S??z[1]+(C??0);return[P,Q]}const _=R();if(_===null)return t.jsx(t.Fragment,{});const[$,B]=_;return t.jsxs(t.Fragment,{children:[t.jsx(Y,{vmargin:0,hmargin:0,anchor:"center",datapos:[$,B],color:T.primary,text:"Flat"}),t.jsx(To,{x:$,y:B,fov:j})]})}const Eo=q("daiquiri.components.tomo.Point3DRoi");function Lo(e,n){return e===null?{x:0,y:0}:n===0?{x:e.y,y:e.z}:n===-90?{x:e.x,y:e.z}:(console.error(`Unimplemented projRotation ${n}`),{x:0,y:0})}function Ao(e,n,o){const s=(n.x1+n.x2)*.5,a=(n.y1+n.y2)*.5;return o===0?{x:e.x,y:s,z:a}:o===-90?{x:s,y:e.y,z:a}:(console.error(`Unimplemented projRotation ${o}`),{x:0,y:0,z:0})}function ht(e,n,o){const{x:s,y:a}=n[1];return o===0?{x:e.x,y:s,z:a}:o===-90?{x:s,y:e.y,z:a}:(console.error(`Unexpected projRotation ${o}`),e)}function Oo(e){const n=Se(e);return n?{x:n.x,y:n.y,z:n.z}:(Eo("Roi reset skipped: center is undefined."),null)}function _o(e){const{roi:n,projRotation:o,cellSize:s=[0,0]}=e,a=g.useCallback((l,r)=>{const c=Ao(n,l,o);r?e.onDragMove&&e.onDragMove(c):e.onDragEnd&&e.onDragEnd(c)},[n,e.onDragMove,e.onDragEnd,o]),i=Lo(n,o);return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[i.x,i.y-s[1]*.5],text:e.label??"",color:e.color,anchor:"bottom"}),t.jsx(je,{geometry:{x1:i.x-s[0]*.5,y1:i.y-s[1]*.5,x2:i.x+s[0]*.5,y2:i.y+s[1]*.5},readOnly:e.readOnly,onGeometryChanged:a,color:e.color})]})}function Vo(e){const n=g.useMemo(()=>te(e.tomoDetector,e.detector),[e.tomoDetector,e.detector]);return t.jsx(_o,{roi:e.roi,cellSize:n??void 0,onDragEnd:e.onDragEnd,onDragMove:e.onDragMove,projRotation:e.projRotation,color:T.success,label:"Tomo",readOnly:e.readOnly})}function $o(e){const{disabled:n,projRotation:o,geometry:s,onGeometryChanged:a,sampleStage:i,resetMouseMode:l}=e,r=Ae();return t.jsx(Le,{id:e.id,disabled:n||(r==null?void 0:r.overlayCursor)!==void 0,onSelectionStart:()=>{r==null||r.actions.captureMouseInteraction()},onSelectionEnd:()=>{r==null||r.actions.releaseMouseInteraction(),l()},onSelectionChange:c=>{if(c===void 0)return;function u(){return s||Oo(i)}const m=u();if(m===null)return;const d=ht(m,c.data,o);a(d)},onValidSelection:c=>{if(s===null)return;const u=ht(s,c.data,o);a(u)},children:c=>t.jsx(t.Fragment,{})})}const Bo=q("daiquiri.components.tomo.Point3DRoi");function Go(e,n){return e===null?{x:0,ystart:0,ystop:0}:n===0?{x:e.y,ystart:e.zstart,ystop:e.zstop}:n===-90?{x:e.x,ystart:e.zstart,ystop:e.zstop}:(console.error(`Unimplemented projRotation ${n}`),{x:0,ystart:0,ystop:0})}function Ho(e,n,o){const s=(n.x1+n.x2)*.5;return(n.y1+n.y2)*.5,o===0?{x:e.x,y:s,zstart:n.y1,zstop:n.y2}:o===-90?{x:s,y:e.y,zstart:n.y1,zstop:n.y2}:(console.error(`Unimplemented projRotation ${o}`),{x:0,y:0,zstart:0,zstop:0})}function yt(e,n,o){const{x:s,y:a}=n[0];return o===0?{x:e.x,y:s,zstart:n[0].y,zstop:n[1].y}:o===-90?{x:s,y:e.y,zstart:n[0].y,zstop:n[1].y}:(console.error(`Unexpected projRotation ${o}`),e)}function Yo(e){const n=Se(e),{tomoDetector:o,detector:s}=e,a=Ve(o,s)??[1,1];return n?{x:n.x,y:n.y,zstart:n.z-a[0]*.5,zstop:n.z-a[0]*.5}:(Bo("Roi reset skipped: center is undefined."),null)}function Uo(e){const{roi:n,projRotation:o,cellSize:s=[0,0]}=e,a=g.useCallback((x,h)=>{const f=Ho(n,x,o);h?e.onDragMove&&e.onDragMove(f):e.onDragEnd&&e.onDragEnd(f)},[n,e.onDragMove,e.onDragEnd,o]),i=Go(n,o),l=Math.abs(i.ystop-i.ystart),r=(i.ystart+i.ystop)*.5,c=s[1],u=Math.ceil(l/c);function m(){if(e.readOnly)return;const x=(c*u-l)/(u-1);return[0,u<=1?0:x/c]}const d=m();return t.jsxs(t.Fragment,{children:[t.jsx(Y,{datapos:[i.x,Math.min(i.ystart,i.ystop)],text:e.label??"",color:e.color,anchor:"bottom"}),t.jsx(Y,{datapos:[i.x,i.ystart],text:"Start",color:e.color,anchor:"top"}),t.jsx(Y,{datapos:[i.x,i.ystop],text:"Stop",color:e.color,anchor:"top"}),t.jsx(Pt,{center:[i.x,r],size:[s[0],l],color:e.color,opacity:.25,nbCells:[1,u??1],overlap:d,lineWidth:1,zIndex:.5}),t.jsx(je,{geometry:{x1:i.x-s[0]*.5,y1:i.ystart,x2:i.x+s[0]*.5,y2:i.ystop},readOnly:e.readOnly,onGeometryChanged:a,color:e.color})]})}function Zo(e){const n=g.useMemo(()=>te(e.tomoDetector,e.detector),[e.tomoDetector,e.detector]);return t.jsx(Uo,{roi:e.roi,cellSize:n??void 0,onDragEnd:e.onDragEnd,onDragMove:e.onDragMove,projRotation:e.projRotation,color:T.success,label:"Zseries",readOnly:e.readOnly})}function qo(e){const{disabled:n,projRotation:o,geometry:s,onGeometryChanged:a,sampleStage:i,resetMouseMode:l}=e,r=Ae();return t.jsx(Le,{id:e.id,disabled:n||(r==null?void 0:r.overlayCursor)!==void 0,onSelectionStart:()=>{r==null||r.actions.captureMouseInteraction()},onSelectionEnd:()=>{r==null||r.actions.releaseMouseInteraction(),l()},onSelectionChange:c=>{if(c===void 0)return;function u(){return s||Yo(i)}const m=u();if(m===null)return;const d=yt(m,c.data,o);a(d)},onValidSelection:c=>{if(s===null)return;const u=yt(s,c.data,o);a(u)},children:c=>t.jsx(t.Fragment,{})})}function Wo(e){const{color:n="black",domainX:o,domainY:s,zIndex:a=0}=e,i=Math.abs(o[1]-o[0]),l=(o[0]+o[1])*.5,r=Math.abs(s[1]-s[0]),c=(s[0]+s[1])*.5;return t.jsxs(t.Fragment,{children:[t.jsxs("mesh",{position:[l-i,c,a],children:[t.jsx("ambientLight",{}),t.jsx("planeGeometry",{attach:"geometry",args:[i,r*10,1,1]}),t.jsx("meshBasicMaterial",{attach:"material",color:n,opacity:1})]}),t.jsxs("mesh",{position:[l+i,c,a],children:[t.jsx("ambientLight",{}),t.jsx("planeGeometry",{attach:"geometry",args:[i,r*10,1,1]}),t.jsx("meshBasicMaterial",{attach:"material",color:n,opacity:1})]}),t.jsxs("mesh",{position:[l,c-r,a],children:[t.jsx("ambientLight",{}),t.jsx("planeGeometry",{attach:"geometry",args:[i*10,r,1,1]}),t.jsx("meshBasicMaterial",{attach:"material",color:n,opacity:1})]}),t.jsxs("mesh",{position:[l,c+r,a],children:[t.jsx("ambientLight",{}),t.jsx("planeGeometry",{attach:"geometry",args:[i*10,r,1,1]}),t.jsx("meshBasicMaterial",{attach:"material",color:n,opacity:1})]})]})}function Xo(e,n){const o=Fe(e);return g.useMemo(()=>{const{maxBox:s}=Rt(o,n);return lo(co(s,.1))},[o])}function vt(e){const{projRotation:n,config:o,api:s,tilingBox:a,actions:i,tasks:l,computeSampleStageAtPlotLocation:r,operator:c,roiFov:u,markerName:m,children:d,mouseModeInteraction:x,setMarker:h,markers:f,editScanRoi:y,tomoFlatMotion:v,...b}=e,p=Xo(e.sampleStage,n),{mouseMode:j,resetMouseMode:M}=x,S=Fe(e.sampleStage),{tomoDetector:C,detector:D}=S,I=g.useCallback((P,Q,ne,ue)=>i.moveScanTaskRoi(P,new G(Q,"mm"),new G(ne,"mm"),new G(ue,"mm")),[]),R=n===0?"front":"side",_=g.useCallback(P=>(s==null?void 0:s.layerDType)===En.Float16?On(P):P,[s]),$=g.useMemo(()=>({"create-tiling-roi":"crosshair","move-motors":"crosshair",create:"crosshair","measure-distance":"crosshair","mark-position":"crosshair","edit-tiling-roi":"crosshair"}),[]),[B,z]=g.useState(void 0);return t.jsxs(zn,{abscissaConfig:{visDomain:p.x,flip:R==="front"},ordinateConfig:{visDomain:p.y,flip:!0},aspect:"equal",title:`${Te.capitalize(R)} (in mm)`,showAxes:o.displayAxes,mouseMode:j,onMouseInteractionOverlayChanged:z,cursors:$,children:[t.jsx(Wo,{domainX:p.x,domainY:p.y,color:T.light}),e.tilingRoi&&t.jsx(Po,{roi:e.tilingRoi,tomoDetector:C,detector:D,onDragMove:e.setTilingRoi,onDragEnd:e.setTilingRoi,projRotation:n,readOnly:y!=="tiling"}),e.scanRoi&&t.jsx(Vo,{roi:e.scanRoi,tomoDetector:C,detector:D,onDragMove:e.setScanRoi,onDragEnd:e.setScanRoi,projRotation:n,readOnly:y!=="scan"}),e.zseriesRoi&&t.jsx(Zo,{roi:e.zseriesRoi,tomoDetector:C,detector:D,onDragMove:e.setZseriesRoi,onDragEnd:e.setZseriesRoi,projRotation:n,readOnly:y!=="zseries"}),t.jsx(ko,{id:"tiling-roi-selection-tool",disabled:B!==void 0||j!=="create-tiling-roi"||y!=="tiling",geometry:e.tilingRoi,onGeometryChanged:e.setTilingRoi,projRotation:n,sampleStage:S,resetMouseMode:M}),t.jsx($o,{id:"scan-roi-selection-tool",disabled:B!==void 0||j!=="create-tiling-roi"||y!=="scan",geometry:e.scanRoi,onGeometryChanged:e.setScanRoi,projRotation:n,sampleStage:S,resetMouseMode:M}),t.jsx(qo,{id:"zseries-roi-selection-tool",disabled:B!==void 0||j!=="create-tiling-roi"||y!=="zseries",geometry:e.zseriesRoi,onGeometryChanged:e.setZseriesRoi,projRotation:n,sampleStage:S,resetMouseMode:M}),t.jsx(wo,{mouseOverlay:B,projRotation:n,mouseMode:j,resetMouseMode:x.resetMouseMode,roiFov:u,actions:i,computeSampleStageAtPlotLocation:r,sampleStage:S,markerName:m,operator:c,setMarker:h}),t.jsx(bo,{api:s,box:a,renderTooltip:(P,Q,ne)=>t.jsx(ro,{projRotation:n,x:R==="side"?P:void 0,y:R==="front"?P:void 0,z:Q,tomoHardware:S,value:_(ne)}),...b}),l.map(P=>t.jsx(uo,{task:P,view:R,readOnly:j!=="pan"&&j!=="zoom",dragTomoScanRoi:I},P.id)),S&&t.jsxs(t.Fragment,{children:[t.jsx(io,{projRotation:n,tomoHardware:S}),t.jsx(so,{projRotation:n,tomoHardware:S}),t.jsx(Fo,{projRotation:n,tomoHardware:S,tomoFlatMotion:v})]}),t.jsx(vo,{projRotation:n,tomoHardware:S,markers:f,setMarker:h,computeSampleStageAtPlotLocation:r}),d]})}function Qo(e){const{tomovisRestService:n,tomovisService:o}=e;function s(){if(!n)return["secondary","UNDECLARED","Tomovis service not declared at the Daiquiri server config. No tiling can be retrieved"];const r=n.defaults.baseURL;return o?[{OFFLINE:"secondary",READY:"success",FAILED:"danger",UNKNOWN:"secondary",PROCESSING:"warning"}[o.state],o.state,`Tomovis service is declared at ${r}`]:["danger","OFFLINE",`Tomovis service can be setup at ${r}`]}const[a,i,l]=s();return t.jsx(Dt,{className:e.className,name:"Tomovis",state:i,stateVariant:a,description:l})}function Jo(e){const n=tn()??{state:"NONE"},[o,s]=Hn(n.state);return t.jsx(Dt,{className:e.className,name:"Scan",state:o,stateVariant:s,description:"Tiling scan state"})}function Ko(e){const{as:n=void 0,onSelect:o,value:s,variant:a}=e,i=["primary","success","info","warning","danger","dark"];return t.jsx(E,{as:n,id:"bg-vertical-dropdown-3",variant:a,children:i.map((l,r)=>{const c=s!==null&&l===s;return t.jsx(N,{variant:c?"primary":"secondary",onClick:()=>{o(l)},children:t.jsx("i",{className:`fa fa-map-marker fa-lg text-${c&&l==="primary"?"secondary":l}`})},r)})})}function es(e){const{mouseModeInteraction:n,dropDirection:o="down",showRoiTools:s=!0}=e,{mouseMode:a,setOrResetMouseMode:i}=n,l=a==="mark-position",[r,c]=g.useState(!1),u=zt();g.useEffect(()=>{c(l)},[l]);const m=t.jsx(ce,{id:"popover-container",body:!0,children:t.jsx(Ko,{value:e.markerName,onSelect:e.onSelectMarkerName})});function d(x){return x==="up"?"top":"bottom"}return t.jsxs(t.Fragment,{children:[t.jsx(wt,{trigger:"click",placement:d(o),overlay:m,children:t.jsx(N,{variant:a==="mark-position"?"primary":"secondary",title:"Pin a position in the sample stage",onClick:()=>{i("mark-position")},children:t.jsx("i",{className:"fa fa-map-marker fa-fw fa-lg"})})}),t.jsx(N,{variant:a==="move-motors"?"danger":"secondary",title:"Click on the scene to move the active detector at a specific location",disabled:!u,onClick:()=>{i("move-motors")},size:"sm",children:t.jsx("i",{className:"fad fam-move-samplestage fa-fw fa-2x"})}),s&&t.jsx(N,{variant:a==="create"?"primary":"secondary",title:"Click on the scene to create a new scan ROI",onClick:()=>{i("create")},size:"sm",children:t.jsx("i",{className:"fa fam-roi-new fa-fw fa-lg"})})]})}function ts(e){const{tilingRoi:n,clearTilingRoi:o,mouseModeInteraction:s,tomoConfigId:a}=e,{mouseMode:i,setOrResetMouseMode:l}=s,r=i==="create-tiling-roi",c=g.useCallback(()=>{if(n===null)return;const m=de.getState().hardware,d=pe(m,a),{sampleStage:x}=d,h=(x==null?void 0:x.properties.detector_center)??[0,0],f=h[0]??0,y=h[1]??0;return{start_x:V(n.start.x+f,3),end_x:V(n.stop.x+f,3),start_y:V(n.start.y+f,3),end_y:V(n.stop.y+f,3),start_z:V(n.start.z+y,3),end_z:V(n.stop.z+y,3)}},[n,a]);return t.jsxs(Ee,{direction:"horizontal",children:[t.jsx("div",{className:"text-dark p-2",children:"Tiling:"}),t.jsxs(E,{className:e.className,children:[t.jsx(N,{variant:r?"primary":"secondary",title:"Initialize the location of the ROI",onClick:()=>{l("create-tiling-roi")},children:t.jsx("i",{className:"fa fam-roi-new fa-fw"})}),t.jsx(N,{variant:"secondary",title:"Initialize the location of the ROI",onClick:()=>{o()},disabled:n===null,children:t.jsx("i",{className:"fa fa-trash-can fa-fw"})}),t.jsx(_e,{button:t.jsxs("span",{className:"text-nowrap",children:[t.jsx("i",{className:"fa fa-plus",title:"Launch a new tiling scan"})," New Scan"]}),disabled:n===null,options:{tags:["tomo-tiling-roi"],providers:{metadata:{datacollections:{namespace:"tilingview"}}}},additionalFormData:c})]})]})}function ns(e){const{scanRoi:n,clearScanRoi:o,mouseModeInteraction:s,tomoConfigId:a}=e,{mouseMode:i,setOrResetMouseMode:l}=s,r=i==="create-tiling-roi",c=g.useCallback(()=>{if(n===null)return;const m=de.getState().hardware,d=pe(m,a),{sampleStage:x}=d,h=(x==null?void 0:x.properties.detector_center)??[0,0],f=h[0]??0,y=h[1]??0;return{x:V(n.x+f,3),y:V(n.y+f,3),z:V(n.z+y,3)}},[n,a]);return t.jsxs(Ee,{direction:"horizontal",children:[t.jsx("div",{className:"text-dark p-2",children:"Tomo:"}),t.jsxs(E,{className:e.className,children:[t.jsx(N,{variant:r?"primary":"secondary",title:"Initialize the location of the ROI",onClick:()=>{l("create-tiling-roi")},children:t.jsx("i",{className:"fa fam-roi-new fa-fw"})}),t.jsx(N,{variant:"secondary",title:"Initialize the location of the ROI",onClick:()=>{o()},disabled:n===null,children:t.jsx("i",{className:"fa fa-trash-can fa-fw"})}),t.jsx(_e,{button:t.jsxs("span",{className:"text-nowrap",children:[t.jsx("i",{className:"fa fa-plus",title:"Launch a new tiling scan"})," New Scan"]}),disabled:n===null,options:{tags:["tomo-tomo-roi"],providers:{metadata:{datacollections:{namespace:"tilingview"}}}},additionalFormData:c})]})]})}function os(e){const{zseriesRoi:n,clearZseriesRoi:o,mouseModeInteraction:s,tomoConfigId:a}=e,{mouseMode:i,setOrResetMouseMode:l}=s,r=i==="create-tiling-roi",c=g.useCallback(()=>{if(n===null)return;const m=de.getState().hardware,d=pe(m,a),{sampleStage:x,tomoDetector:h,detector:f}=d,y=(x==null?void 0:x.properties.detector_center)??[0,0],v=y[0]??0,b=y[1]??0,p=Math.sign(n.zstop-n.zstart),j=Ve(h,f);if(j===null)return;const M=j[1]*.5,S=n.zstart+b+p*M,C=n.zstop+b-p*M,D=C-S;return{x:V(n.x+v,3),y:V(n.y+v,3),z_start:V(S,3),z_stop:V(C,3),z_height:V(Math.abs(D)+j[1],3),z_direction:p>0?"Down":"Up"}},[n,a]);return t.jsxs(Ee,{direction:"horizontal",children:[t.jsx("div",{className:"text-dark p-2",children:"Zseries:"}),t.jsxs(E,{className:e.className,children:[t.jsx(N,{variant:r?"primary":"secondary",title:"Initialize the location of the ROI",onClick:()=>{l("create-tiling-roi")},children:t.jsx("i",{className:"fa fam-roi-new fa-fw"})}),t.jsx(N,{variant:"secondary",title:"Initialize the location of the ROI",onClick:()=>{o()},disabled:n===null,children:t.jsx("i",{className:"fa fa-trash-can fa-fw"})}),t.jsx(_e,{button:t.jsxs("span",{className:"text-nowrap",children:[t.jsx("i",{className:"fa fa-plus",title:"Launch a new tiling scan"})," New Scan"]}),disabled:n===null,options:{tags:["tomo-zseries-roi"],providers:{metadata:{datacollections:{namespace:"tilingview"}}}},additionalFormData:c})]})]})}function ss(e){const{editScanRoi:n,setEditScanRoi:o}=e,s=g.useRef(null),a=g.useRef(null),i=g.useRef(null);function l(r){o(c=>c===r?null:r)}return t.jsxs(t.Fragment,{children:[t.jsxs(E,{className:e.className,children:[t.jsx(N,{ref:s,variant:n==="tiling"?"primary":"secondary",title:"ROI for tiling scan",onClick:()=>{l("tiling")},children:t.jsx("i",{className:"fa fam-roi-rect-tile fa-fw fa-lg"})}),t.jsx(N,{ref:a,variant:n==="scan"?"primary":"secondary",title:"ROI for tomo scan",onClick:()=>{l("scan")},children:t.jsx("i",{className:"fa fam-roi-rect fa-fw fa-lg"})}),t.jsx(N,{ref:i,variant:n==="zseries"?"primary":"secondary",title:"ROI for zseries scan",onClick:()=>{l("zseries")},children:t.jsx("i",{className:"fa fam-roi-rect-tile-v fa-fw fa-lg"})})]}),t.jsx(Re,{show:n==="tiling",placement:"bottom",container:s.current,target:s.current,containerPadding:20,children:t.jsx(ce,{id:"popover-tiling-contained",children:t.jsx(ts,{...e,className:void 0})})}),t.jsx(Re,{show:n==="scan",placement:"bottom",container:a.current,target:a.current,containerPadding:20,children:t.jsx(ce,{id:"popover-scan-contained",children:t.jsx(ns,{...e,className:void 0})})}),t.jsx(Re,{show:n==="zseries",placement:"bottom",container:i.current,target:i.current,containerPadding:20,children:t.jsx(ce,{id:"popover-zseries-contained",children:t.jsx(os,{...e,className:void 0})})})]})}function is(e,n){if(n===void 0)return[];const o=[];return Object.keys(n).map(a=>[a,n[a].tomo_detector_id]).forEach(a=>{const[i,l]=a,r=re(e,l),c=re(e,`${l}.detector`);if(r===null||c===null){console.debug(`${l} not there`);return}if(!on(c)||!sn(c)||!r.properties.state||!r.properties.sample_pixel_size_mode)return;function u(){return!r||!r.online||r.properties.state==="OFFLINE"?"DETECTOR_OFFLINE":"READY"}const m=u();if(r.properties.sample_pixel_size_mode==="USER")r.properties.user_sample_pixel_size!==null&&o.push({detector:i,state:m,size:c.properties.size,userPixelSize:r.properties.user_sample_pixel_size});else{const x=re(e,`${l}.optic`);if(x===null){console.debug(`${r.properties.optic} not there`);return}if(!x.properties.available_magnifications){console.debug(`${r.properties.optic} no magnifications`);return}x.properties.available_magnifications.forEach(h=>{o.push({detector:i,state:m,size:r.properties.actual_size,autoPixelSize:{magnification:h,cameraPixelSize:r.properties.camera_pixel_size}})})}}),o}function as(){const e=nn(),n=de(o=>o.hardware);return g.useMemo(()=>is(n,e),[n,e])}function Tt(e,n){return[n[0]*e.size[0]*.001,n[1]*e.size[1]*.001]}function Ft(e){if(e.userPixelSize!==void 0)return[e.userPixelSize,e.userPixelSize];if(e.autoPixelSize!==void 0){const n=e.autoPixelSize.magnification,o=e.autoPixelSize.cameraPixelSize;return[o[0]/n,o[1]/n]}throw new Error("Unsupported TomoAvailableFieldOfView state")}function rs(e){const{eventKey:n,isSelected:o,data:s}=e,a=Ft(s),i=Tt(s,a);function l(){if(s.userPixelSize!==void 0)return"user";if(s.autoPixelSize!==void 0)return`×${s.autoPixelSize.magnification}`;throw new Error("Unsupported TomoAvailableFieldOfView state")}return t.jsxs(F.Item,{eventKey:n,children:[t.jsxs("div",{children:[s.detector," ",l()]}),t.jsxs("div",{className:"fw-bold",children:[i[0],"mm ",a[0],"µm"]})]})}function cs(e){const{as:n=void 0,onSelect:o,value:s,variant:a}=e,i=as();function l(u){if(u===null)return"No detector/optic selected";function m(){return u===null?"":u.magnification===null?"user":`×${u.magnification}`}return`${u.detector} ${m()} ${u.pixelSize[0]}µm ${u.fov[0]}mm`}const r=l(s);function c(u){var y;if(u===null){o(null);return}const m=Number.parseInt(u),d=i[m];d.size;const x=Ft(d),h=Tt(d,x),f={detector:d.detector,magnification:((y=d.autoPixelSize)==null?void 0:y.magnification)??null,fov:h,pixelSize:x};o(f)}return t.jsx(Yn,{as:n,title:r,id:"bg-vertical-dropdown-3",onSelect:c,variant:a,children:i.map((u,m)=>{var x;const d=s!==null&&u.detector===s.detector&&(((x=u.autoPixelSize)==null?void 0:x.magnification)??null)===s.magnification;return t.jsx(rs,{eventKey:m,isSelected:d,data:u},m)})})}function ls(e){return t.jsx(cs,{...e})}function Pe(e){return e<9?`0${e}`:e}function ds(e){const o=Date.now()-e.valueOf();if(o<50*1e3)return"Few seconds ago";if(o<80*1e3)return"1 minute ago";if(o<90*60*1e3)return`${Math.round(o/6e4)} minutes ago`;if(o<7*24*60*60*1e3){const s=new Date;if(e.getDate()===s.getDate())return`Today at ${e.getHours()}:${Pe(e.getMinutes())}`;const a=new Date(s);if(a.setDate(a.getDate()-1),e.getDate()===a.getDate())return`Yesterday at ${e.getHours()}:${Pe(e.getMinutes())}`;const i=new Date(s);if(i.setDate(i.getDate()-s.getDay()),i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),e>=i)return`${e.toLocaleString("default",{weekday:"long"})} at ${e.getHours()}:${Pe(e.getMinutes())}`}return e.toLocaleDateString()}function us(e){const{imageTiling:n,isSelected:o}=e,s=o?"fa fa-fw fa-dot-circle-o":"fa fa-fw fa-circle-o",a=n.status==="done"?"success":"warning",i=new Date(Date.parse(n.create_time));return t.jsxs(F.Item,{className:"d-flex",style:{alignItems:"center"},eventKey:n.id,active:o,children:[t.jsx("i",{className:s})," ",t.jsx("span",{className:"ms-2 me-auto pr-2",title:i.toLocaleString(),children:ds(i)})," ",t.jsx(bt,{className:"me-2",bg:a,children:n.status.toUpperCase()})," ",t.jsx(N,{size:"sm",variant:"danger",onClick:l=>{l.stopPropagation(),e.onDelete(n.id)},children:t.jsx("i",{className:"fa fa-fw fa-trash"})})]})}function ms(e){const{as:n=void 0,onSelect:o,selected:s,variant:a,tomovisService:i}=e,l=i.imageTilings;return t.jsxs(F,{className:`me-1 ${e.dropDirection==="up"?"dropup":""}`,as:n,onSelect:r=>{o(r)},onToggle:r=>{r&&i.updateImageTilings()},children:[t.jsxs(F.Toggle,{id:"dropdown-basic",variant:a,title:s?`Tiling selected: ${s}`:"No tiling selected",children:[t.jsx("i",{className:"fa fa-th fa-fw"}),(s===null||l.length===0)&&t.jsx("div",{className:"indicator",children:t.jsx("i",{className:"fa fa-xs fa-circle text-warning",title:"No tiling selected"})})]}),t.jsxs(F.Menu,{className:"dropdown-menu-center",children:[l.length===0&&t.jsx(F.Item,{disabled:!0,children:"No tiling available"}),l.map((r,c)=>{const u=s===r.id;return t.jsx(us,{isSelected:u,imageTiling:r,onDelete:m=>{i.deleteImageTiling(m),u&&o(null)}},c)})]})]})}const jt=q("daiquiri.components.tomo.tiling.ActualDetectorLocation");function pt(e){var I;const{detectorConfig:n,projRotation:o,clockWiseRotation:s}=e;if(Ct({statistics:(I=e.detectorArray)==null?void 0:I.statistics,...n}),e.detectorArray===null)return t.jsx(t.Fragment,{});const{displayArray:a,imagePosition:i,detectorSize:l,imagePixelSize:r,szPosition:c,imageSomegaPosition:u,detectorCenterY:m,detectorCenterZ:d}=e.detectorArray;if(c===null||l===null||r===null||u===null)return jt("Skipped: one of imagePosition, szPosition, detectorSize, imagePixelSize, imageSomegaPosition is missing."),t.jsx(t.Fragment,{});const x=(m==null?void 0:m.to("mm").scalar)??0,h=(d==null?void 0:d.to("mm").scalar)??0,f=c.to("mm").scalar,y=i?i.to("mm").scalar:0,v=u.scalar*(s?1:-1),b=r.to("mm").scalar,p=.01;function j(R,_){const $=(R-_)%360;return $<0?360+$:$}const M=j(v,o),S=M<p||M>360-p,C=M>180-p&&M<180+p;if(!S&&!C)return jt(`Skipped: rot ${v} does not match to the projRotation ${o}.`),t.jsx(t.Fragment,{});const D=S?-1:1;return t.jsx(Pn,{values:a,domain:n.scaleDomain,colorMap:n.colorMap,invertColorMap:n.invertColorMap,scaleType:n.scaleType,position:[-D*(y-x),f-h,2],scale:[D*b,b,1],size:l})}function xs(e){const{resetZoomEnabled:n,actions:o}=e;return t.jsxs(F,{as:E,children:[t.jsx(N,{title:"Reset zoom (sample stage overview)",variant:"secondary",disabled:!n,onClick:()=>{o.resetZoom()},children:t.jsx("i",{className:"fa fa-expand fa-fw fa-lg"})}),t.jsx(F.Toggle,{split:!0,id:"dropdown-split-basic",variant:"secondary"}),t.jsxs(F.Menu,{children:[t.jsx(F.Item,{onClick:()=>{o.setScale(1)},children:"×1 (overview)"}),t.jsx(F.Item,{onClick:()=>{o.setScale(2)},children:"×2"}),t.jsx(F.Item,{onClick:()=>{o.setScale(10)},children:"×10"}),t.jsx(F.Item,{onClick:()=>{o.setScale(100)},children:"×100"})]})]})}function fs(){const e=kn({name:"tomo/tilingcolormap",lut:"Greys"}),[n,o]=H("tomo/tilingview/layout-view","front-side"),[s,a]=H("tomo/tilingview/axes",!0),[i,l]=H("tomo/tilingview/colorbar-visible",!0),[r,c]=H("tomo/tilingview/crosshair",!1),[u,m]=H("tomo/tilingview/toolbarlocation","top"),[d,x]=H("tomo/tilingview/detectordisplayed",!1);return{layoutView:n,setLayoutView:o,colorbarVisible:i,setColorbarVisible:l,displayAxes:s,setDisplayAxes:a,crossHair:r,setCrossHair:c,toolbarLocation:u,setToolbarLocation:m,...e,isDetectorDisplayed:d,setDetectorDisplayed:x}}function gs(e,n){return e===n?"primary":"secondary"}function U(e){return t.jsx(N,{variant:gs(e.var,e.value),onClick:()=>{e.setter(e.value)},className:"text-nowrap",size:"sm",children:e.children})}function hs(e){const{as:n=void 0,variant:o="secondary",config:s}=e;return t.jsxs(F,{as:n,className:`${e.dropDirection==="up"?"dropup":""}`,children:[t.jsx(F.Toggle,{id:"dropdown-basic",variant:o,className:"d-flex align-items-center",children:t.jsx("i",{className:"fa fa-sliders fa-fw fa-lg"})}),t.jsx(F.Menu,{className:"dropdown-menu-center",children:t.jsx("div",{className:"ms-1 me-1",style:{minWidth:"300px"},children:t.jsxs(ve,{children:[t.jsxs(A,{children:[t.jsx(L,{className:"my-auto",children:"Display axes"}),t.jsx(L,{xs:7,children:t.jsxs(E,{children:[t.jsx(U,{var:s.displayAxes,value:!0,setter:s.setDisplayAxes,children:"Yes"}),t.jsx(U,{var:s.displayAxes,value:!1,setter:s.setDisplayAxes,children:"No"})]})})]}),t.jsxs(A,{className:"mt-1",children:[t.jsx(L,{className:"my-auto",children:"Layout"}),t.jsx(L,{xs:7,children:t.jsxs(E,{children:[t.jsx(U,{var:s.layoutView,value:"front",setter:s.setLayoutView,children:"Front"}),t.jsx(U,{var:s.layoutView,value:"side",setter:s.setLayoutView,children:"Side"}),t.jsx(U,{var:s.layoutView,value:"front-side",setter:s.setLayoutView,children:"Both"})]})})]}),t.jsxs(A,{className:"mt-1",children:[t.jsx(L,{className:"my-auto",children:"Color bar"}),t.jsx(L,{xs:7,children:t.jsxs(E,{children:[t.jsx(U,{var:s.colorbarVisible,value:!0,setter:s.setColorbarVisible,children:"Displayed"}),t.jsx(U,{var:s.colorbarVisible,value:!1,setter:s.setColorbarVisible,children:"Hide"})]})})]}),t.jsxs(A,{className:"mt-1",children:[t.jsx(L,{className:"my-auto",children:"Crosshair"}),t.jsx(L,{xs:7,children:t.jsxs(E,{children:[t.jsx(U,{var:s.crossHair,value:!0,setter:s.setCrossHair,children:"Yes"}),t.jsx(U,{var:s.crossHair,value:!1,setter:s.setCrossHair,children:"No"})]})})]}),t.jsxs(A,{className:"mt-1",children:[t.jsx(L,{className:"my-auto",children:"Toolbar"}),t.jsx(L,{xs:7,children:t.jsxs(E,{children:[t.jsx(U,{var:s.toolbarLocation,value:"top",setter:s.setToolbarLocation,children:"Top"}),t.jsx(U,{var:s.toolbarLocation,value:"bottom",setter:s.setToolbarLocation,children:"Bottom"})]})})]})]})})})]})}const ys=an()(rn(e=>({setFrontViewpoint:n=>{const{center:o,scale:s}=n;e({y:o.x,z:o.y,scale:s.x})},setSideViewpoint:n=>{const{center:o,scale:s}=n;e({x:o.x,z:o.y,scale:s.x})}}),{name:"tomotiling-viewpoint",storage:cn(()=>sessionStorage)}));function vs(){const{x:e,y:n,z:o,scale:s,setFrontViewpoint:a,setSideViewpoint:i}=ys();let l;Number.isFinite(n)&&Number.isFinite(o)&&Number.isFinite(s)&&(l={center:new k(n,o,0),scale:new k(s,s,1)});let r;return Number.isFinite(e)&&Number.isFinite(o)&&Number.isFinite(s)&&(r={center:new k(e,o,0),scale:new k(s,s,1)}),{frontViewpoint:l,setFrontViewpoint:a,sideViewpoint:r,setSideViewpoint:i}}function js(e){const{toolbarLocation:n}=e;return t.jsxs("div",{className:e.className,style:e.style,children:[n==="top"&&e.toolbar,e.children,n==="bottom"&&e.toolbar]})}q("daiquiri.components.tomo.TomoTilingtiling");function ps(){const e=g.useRef(null),n=g.useRef(null);function o(i,l){if(e.current){const{getCameraViewpoint:r,updateCameraViewpoint:c}=e.current,u=r();c({center:new k(u.center.x,i.y),scale:l})}}function s(i,l){if(n.current){const{getCameraViewpoint:r,updateCameraViewpoint:c}=n.current,u=r();c({center:new k(u.center.x,i.y),scale:l})}}const a=g.useMemo(()=>({resetZoom:()=>{var i,l;(i=e.current)==null||i.resetZoom(),(l=n.current)==null||l.resetZoom()},setScale:i=>{var l,r;(l=e.current)==null||l.setScale(1/i),(r=n.current)==null||r.setScale(1/i)}}),[e,n]);return{handleFrameFront:s,handleFrameSide:o,frontRef:e,sideRef:n,actions:a}}function Ss(e){const{actions:n,tasks:o,options:s}=e,{showrois:a=!0,showlaunchscan:i=!0,tomoconfig:l}=s,r=ln(),[c,u]=g.useState(null),m=zt(),d=fs(),x=dn(l??""),[h,f]=H("tomo/tilingroi/roi",null),[y,v]=H("tomo/scanroi/roi",null),[b,p]=H("tomo/zseriesroi/roi",null),[j,M]=H("tomo/tilingview/refreshperiod",30),{frontViewpoint:S,setFrontViewpoint:C,sideViewpoint:D,setSideViewpoint:I}=vs(),R=un(),{tomovis_url:_,tomovis_proxy_url:$}=R,B=Kn(_,$),z=Un(),P=eo(B,r,3e4),{apiFront:Q,apiSide:ne,histogram:ue,tilingBoxFront:Et,tilingBoxSide:Lt,invalidate:At,lazyRefresh:$e}=Jn(B,c),we=Rn(ue);Ct({statistics:we,...d}),g.useEffect(()=>{let W=null;return P.state==="READY"?$e():P.state==="PROCESSING"&&j&&(W=setInterval(()=>{$e()},j*1e3)),()=>{W&&clearInterval(W)}},[P.state,j]);const J=Cn("zoom"),{mouseMode:be,resetMouseMode:Ot}=J,Be=Fe(x),_t=g.useCallback(()=>Se(Be),[Be]),Ge=mn(`${l}.flat_motion`),[He,Ye]=yo({getCenter:_t}),Vt=Zn({sampleStageRefs:x}),ze=qn({detector:Vt,sampleStageRefs:x,profile:z.profile,normalization:z.scaleType,autoscale:z.autoscale,autoscaleMode:z.autoscaleMode,domain:z.scaleDomain,enabled:d.isDetectorDisplayed,minRefreshPeriod:.5}).data;g.useEffect(()=>{P.lastReadyImageTiling&&u(P.lastReadyImageTiling)},[P.lastReadyImageTiling]),g.useEffect(()=>{!m&&be==="move-motors"&&Ot()},[be,m]);const[me,$t]=H("tomo/tilingroi/fov",null),[Ce,Bt]=H("tomo/tilingmarker/selection","primary"),[Me,Gt]=g.useState(null),oe=ps(),Ue=g.useCallback((W,xe,We)=>{const Ht=de.getState().hardware,se=pe(Ht,l),{sampleStage:De}=se,Xe=(De==null?void 0:De.properties.detector_center)??[0,0],Qe=Xe[0]??0,Yt=Xe[1]??0,Je=se.sy?K(se.sy):0;function Ut(){return se.sampu===null||se.sampv===null?[void 0,void 0]:[W===null?void 0:new G(W-Je+Qe,"mm"),xe===null?void 0:new G(xe-Je+Qe,"mm")]}const[Zt,qt]=Ut();return{sz:We===null?void 0:new G(We+Yt,"mm"),sampu:Zt,sampv:qt}},[]),ee=d.toolbarLocation==="top"?"down":"up",Ze=xn((x==null?void 0:x.somega)??null),qe=Ze?St(Ze):!0;return t.jsx(js,{className:"w-100 h-100",style:{flex:"1 1 0%",display:"flex",flexDirection:"column"},toolbarLocation:d.toolbarLocation,toolbar:t.jsxs(Mn,{align:"center",style:{zIndex:1},children:[t.jsx(Dn,{mouseModeInteraction:J}),t.jsx(xs,{resetZoomEnabled:!0,actions:oe.actions}),t.jsx(ie,{}),t.jsx(Bn,{mouseModeInteraction:J,dropDirection:ee}),t.jsx(es,{mouseModeInteraction:J,showRoiTools:a,markerName:Ce,onSelectMarkerName:Bt,dropDirection:ee}),t.jsx(Wn,{variant:d.isDetectorDisplayed?"primary":"secondary",isInverted:z.invertColorMap,onSelectInvertion:z.setInvertColorMap,isDisplayed:d.isDetectorDisplayed,onSelectDisplayed:d.setDetectorDisplayed,lut:z.colorMap,onSelectLut:z.setColorMap,norm:z.scaleType,onSelectNorm:z.setScaleType,autoscale:z.autoscale,onSelectAutoscale:z.setAutoscale,autoscaleMode:z.autoscaleMode,onSelectAutoscaleMode:z.setAutoscaleMode,profile:z.profile,onSelectProfile:z.setProfile,array:ze,dropDirection:ee}),a&&t.jsx(ls,{value:me,onSelect:$t,variant:be==="create"?me===null?"danger":"primary":"secondary"}),t.jsx(ie,{}),t.jsx(Jo,{className:"me-1 d-none d-lg-block"}),i&&t.jsx(ss,{className:"d-none d-lg-block",mouseModeInteraction:J,editScanRoi:Me,setEditScanRoi:Gt,tomoConfigId:l,tilingRoi:h,clearTilingRoi:()=>{f(null)},zseriesRoi:b,clearZseriesRoi:()=>{p(null)},scanRoi:y,clearScanRoi:()=>{v(null)}}),t.jsx(ie,{}),t.jsx(Qo,{className:"me-1 d-none d-lg-block",tomovisRestService:B,tomovisService:P}),t.jsx(ms,{variant:"secondary",tomovisService:P,selected:c,onSelect:u,dropDirection:ee}),t.jsx(N,{variant:"secondary",disabled:c===null,title:P.state==="PROCESSING"?`Auto refresh the tiling every ${j.toFixed(1)} seconds`:"Reload current tiling",onClick:At,children:t.jsx("i",{className:`fa fa-rotate-right fa-solid ${P.state==="PROCESSING"?"fa-spin":""}`})}),t.jsx(ie,{}),t.jsx(Qn,{lut:d.colorMap,onSelectLut:d.setColorMap,norm:_n(d.scaleType),autoscale:d.autoscale,autoscaleMode:d.autoscaleMode,onSelectNorm:d.setScaleType,isInverted:d.invertColorMap,onSelectInvertion:d.setInvertColorMap,onSelectAutoscale:d.setAutoscale,onSelectAutoscaleMode:d.setAutoscaleMode,dropDirection:ee}),t.jsx(Tn,{disabled:we===void 0,...d}),t.jsx(Xn,{disabled:we===void 0,histogram:ue,...d}),t.jsx(ie,{}),t.jsx(hs,{config:d,dropDirection:ee})]}),children:t.jsxs("div",{style:{flex:"1 1 auto",display:"flex",margin:0,minHeight:0},children:[(d.layoutView==="front"||d.layoutView==="front-side")&&t.jsxs(vt,{config:d,projRotation:0,api:Q,tilingBox:Et,actions:n,computeSampleStageAtPlotLocation:Ue,tasks:o,sampleStage:x,operator:m,domain:d.scaleDomain,colorMap:d.colorMap,invertColorMap:d.invertColorMap,scaleType:d.scaleType,roiFov:me,markerName:Ce,mouseModeInteraction:J,markers:He,setMarker:Ye,tilingRoi:h,setTilingRoi:f,scanRoi:y,setScanRoi:v,zseriesRoi:b,setZseriesRoi:p,editScanRoi:Me,tomoFlatMotion:Ge,children:[d.isDetectorDisplayed&&t.jsx(pt,{clockWiseRotation:qe,projRotation:0,detectorArray:ze,detectorConfig:z}),t.jsx(ot,{ref:oe.frontRef,onVisViewpointChange:oe.handleFrameFront}),t.jsx(ct,{viewpoint:S,setViewpoint:C}),t.jsx(dt,{children:t.jsx(nt,{guides:d.crossHair?"both":void 0,renderTooltip:(W,xe)=>t.jsx(t.Fragment,{})})})]}),d.layoutView==="front-side"&&!d.displayAxes&&t.jsx("div",{style:{minWidth:"1em"},className:"p-2 bg-light"}),(d.layoutView==="side"||d.layoutView==="front-side")&&t.jsxs(vt,{config:d,projRotation:-90,api:ne,tilingBox:Lt,actions:n,computeSampleStageAtPlotLocation:Ue,tasks:o,sampleStage:x,operator:m,domain:d.scaleDomain,colorMap:d.colorMap,invertColorMap:d.invertColorMap,scaleType:d.scaleType,roiFov:me,markerName:Ce,mouseModeInteraction:J,markers:He,setMarker:Ye,tilingRoi:h,setTilingRoi:f,scanRoi:y,setScanRoi:v,zseriesRoi:b,setZseriesRoi:p,editScanRoi:Me,tomoFlatMotion:Ge,children:[d.isDetectorDisplayed&&t.jsx(pt,{clockWiseRotation:qe,projRotation:-90,detectorArray:ze,detectorConfig:z}),t.jsx(ot,{ref:oe.sideRef,onVisViewpointChange:oe.handleFrameSide}),t.jsx(ct,{viewpoint:D,setViewpoint:I}),t.jsx(dt,{children:t.jsx(nt,{guides:d.crossHair?"both":void 0,renderTooltip:(W,xe)=>t.jsx(t.Fragment,{})})})]}),d.colorbarVisible&&t.jsx(bn,{domain:d.scaleDomain,scaleType:d.scaleType,colorMap:d.colorMap,invertColorMap:d.invertColorMap,withBounds:!0})]})})}function ws(){return gn(e=>e.scanTasks)}function bs(e){const n=fn(),o=ws();return t.jsx(Ss,{...e,actions:n,tasks:o})}function oi(e){const{yamlNode:n,showrois:o,showlaunchscan:s,tomoconfig:a,...i}=e;hn(n,"tomoconfig",a),tt(n,"showrois",o),tt(n,"showlaunchscan",s),yn(n,i);const l={showrois:o,showlaunchscan:s,tomoconfig:a};return t.jsx(bs,{options:l})}export{oi as default};