@labelbee/lb-components 1.24.0-alpha.5 → 1.24.0-alpha.50

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 (150) hide show
  1. package/dist/_virtual/2DViewWorker.js +1 -1
  2. package/dist/assets/annotation/rectTool/three_points_rect.svg.js +1 -0
  3. package/dist/assets/annotation/rectTool/two_points_rect.svg.js +1 -0
  4. package/dist/components/DynamicResizer/DynamicResizer.js +1 -1
  5. package/dist/components/DynamicResizer/hooks/useDrag.js +1 -1
  6. package/dist/components/DynamicResizer/hooks/useDraggingAllowed.js +1 -0
  7. package/dist/components/DynamicResizer/hooks/useUpdateHeight.js +1 -1
  8. package/dist/components/DynamicResizer/utils/index.js +1 -0
  9. package/dist/components/LLMMultiWheelView/dialogView/index.js +1 -1
  10. package/dist/components/LLMMultiWheelView/index.js +1 -1
  11. package/dist/components/LLMMultiWheelView/sidebar/index.js +1 -1
  12. package/dist/components/LLMToolView/index.js +1 -1
  13. package/dist/components/LLMToolView/modelAPIView/index.js +1 -1
  14. package/dist/components/LLMToolView/questionView/components/audioView/index.js +1 -0
  15. package/dist/components/LLMToolView/questionView/components/header/index.js +1 -1
  16. package/dist/components/LLMToolView/questionView/index.js +1 -1
  17. package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  18. package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  19. package/dist/components/attributeList/index.js +1 -1
  20. package/dist/components/audioAnnotate/index.js +1 -1
  21. package/dist/components/audioPlayer/index.js +1 -1
  22. package/dist/components/longText/index.js +1 -1
  23. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  24. package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
  25. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  26. package/dist/components/pointCloudView/PointCloudContext.js +1 -1
  27. package/dist/components/pointCloudView/PointCloudListener.js +1 -1
  28. package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
  29. package/dist/components/pointCloudView/components/TitleButton/index.js +1 -1
  30. package/dist/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
  31. package/dist/components/pointCloudView/components/sideAndBackOverView/index.js +1 -1
  32. package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
  33. package/dist/components/pointCloudView/hooks/usePointCloudAttribute.js +1 -0
  34. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  35. package/dist/components/pointCloudView/index.js +1 -1
  36. package/dist/components/tagList/index.js +1 -1
  37. package/dist/components/videoPlayer/components/SpeedController/index.js +1 -1
  38. package/dist/components/videoPlayer/index.js +1 -1
  39. package/dist/constant/index.js +1 -1
  40. package/dist/index.css +112 -90
  41. package/dist/store/Actions.js +1 -1
  42. package/dist/store/annotation/actionCreators.js +1 -1
  43. package/dist/store/annotation/reducer.js +1 -1
  44. package/dist/store/toolConfig/pointCloudToolConfig.js +1 -1
  45. package/dist/types/components/DynamicResizer/DynamicResizer.d.ts +3 -3
  46. package/dist/types/components/DynamicResizer/hooks/useDrag.d.ts +24 -7
  47. package/dist/types/components/DynamicResizer/hooks/useDraggingAllowed.d.ts +12 -0
  48. package/dist/types/components/DynamicResizer/hooks/useUpdateHeight.d.ts +10 -21
  49. package/dist/types/components/DynamicResizer/types/interface.d.ts +14 -6
  50. package/dist/types/components/DynamicResizer/utils/index.d.ts +4 -0
  51. package/dist/types/components/LLMMultiWheelView/dialogView/index.d.ts +2 -0
  52. package/dist/types/components/LLMMultiWheelView/index.d.ts +2 -0
  53. package/dist/types/components/LLMToolView/questionView/components/audioView/index.d.ts +8 -0
  54. package/dist/types/components/LLMToolView/questionView/components/header/index.d.ts +3 -1
  55. package/dist/types/components/attributeList/components/limitPopover/index.d.ts +2 -2
  56. package/dist/types/components/longText/index.d.ts +1 -1
  57. package/dist/types/components/pointCloud2DRectOperationView/useUpdateRectList.d.ts +0 -1
  58. package/dist/types/components/pointCloudView/PointCloudContext.d.ts +4 -0
  59. package/dist/types/components/pointCloudView/PointCloudListener.d.ts +1 -0
  60. package/dist/types/components/pointCloudView/hooks/usePointCloudAttribute.d.ts +3 -0
  61. package/dist/types/components/pointCloudView/hooks/useRotate.d.ts +1 -2
  62. package/dist/types/components/pointCloudView/hooks/useRotateEdge.d.ts +1 -2
  63. package/dist/types/components/pointCloudView/index.d.ts +2 -0
  64. package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +1 -1
  65. package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
  66. package/dist/types/components/videoAnnotate/videoTextTool/index.d.ts +1 -1
  67. package/dist/types/components/videoPlayer/index.d.ts +1 -1
  68. package/dist/types/constant/index.d.ts +4 -2
  69. package/dist/types/store/Actions.d.ts +1 -0
  70. package/dist/types/store/annotation/actionCreators.d.ts +9 -1
  71. package/dist/types/store/annotation/map.d.ts +1 -0
  72. package/dist/types/store/annotation/reducer.d.ts +5 -1
  73. package/dist/types/store/annotation/types.d.ts +4 -2
  74. package/dist/types/store/toolConfig/types.d.ts +2 -0
  75. package/dist/types/utils/LLM.d.ts +6 -0
  76. package/dist/types/views/MainView/index.d.ts +2 -0
  77. package/dist/types/views/MainView/sidebar/GeneralOperation/ActionsConfirm.d.ts +3 -0
  78. package/dist/types/views/MainView/sidebar/GeneralOperation/index.d.ts +9 -0
  79. package/dist/types/views/MainView/sidebar/index.d.ts +2 -0
  80. package/dist/utils/LLM.js +1 -0
  81. package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
  82. package/dist/views/MainView/LLMMultiWheelLayout/index.js +1 -1
  83. package/dist/views/MainView/index.js +1 -1
  84. package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  85. package/dist/views/MainView/sidebar/GeneralOperation/index.js +1 -1
  86. package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  87. package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
  88. package/dist/views/MainView/sidebar/ToolIcons.js +1 -1
  89. package/dist/views/MainView/sidebar/index.js +1 -1
  90. package/es/_virtual/2DViewWorker.js +1 -1
  91. package/es/assets/annotation/rectTool/three_points_rect.svg.js +1 -0
  92. package/es/assets/annotation/rectTool/two_points_rect.svg.js +1 -0
  93. package/es/components/DynamicResizer/DynamicResizer.js +1 -1
  94. package/es/components/DynamicResizer/hooks/useDrag.js +1 -1
  95. package/es/components/DynamicResizer/hooks/useDraggingAllowed.js +1 -0
  96. package/es/components/DynamicResizer/hooks/useUpdateHeight.js +1 -1
  97. package/es/components/DynamicResizer/utils/index.js +1 -0
  98. package/es/components/LLMMultiWheelView/dialogView/index.js +1 -1
  99. package/es/components/LLMMultiWheelView/index.js +1 -1
  100. package/es/components/LLMMultiWheelView/sidebar/index.js +1 -1
  101. package/es/components/LLMToolView/index.js +1 -1
  102. package/es/components/LLMToolView/modelAPIView/index.js +1 -1
  103. package/es/components/LLMToolView/questionView/components/audioView/index.js +1 -0
  104. package/es/components/LLMToolView/questionView/components/header/index.js +1 -1
  105. package/es/components/LLMToolView/questionView/index.js +1 -1
  106. package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  107. package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  108. package/es/components/attributeList/index.js +1 -1
  109. package/es/components/audioAnnotate/index.js +1 -1
  110. package/es/components/audioPlayer/index.js +1 -1
  111. package/es/components/longText/index.js +1 -1
  112. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  113. package/es/components/pointCloudView/PointCloud2DView.js +1 -1
  114. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  115. package/es/components/pointCloudView/PointCloudContext.js +1 -1
  116. package/es/components/pointCloudView/PointCloudListener.js +1 -1
  117. package/es/components/pointCloudView/PointCloudTopView.js +1 -1
  118. package/es/components/pointCloudView/components/TitleButton/index.js +1 -1
  119. package/es/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
  120. package/es/components/pointCloudView/components/sideAndBackOverView/index.js +1 -1
  121. package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
  122. package/es/components/pointCloudView/hooks/usePointCloudAttribute.js +1 -0
  123. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  124. package/es/components/pointCloudView/index.js +1 -1
  125. package/es/components/tagList/index.js +1 -1
  126. package/es/components/videoPlayer/components/SpeedController/index.js +1 -1
  127. package/es/components/videoPlayer/index.js +1 -1
  128. package/es/constant/index.js +1 -1
  129. package/es/index.css +112 -90
  130. package/es/store/Actions.js +1 -1
  131. package/es/store/annotation/actionCreators.js +1 -1
  132. package/es/store/annotation/reducer.js +1 -1
  133. package/es/store/toolConfig/pointCloudToolConfig.js +1 -1
  134. package/es/utils/LLM.js +1 -0
  135. package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
  136. package/es/views/MainView/LLMMultiWheelLayout/index.js +1 -1
  137. package/es/views/MainView/index.js +1 -1
  138. package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  139. package/es/views/MainView/sidebar/GeneralOperation/index.js +1 -1
  140. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  141. package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
  142. package/es/views/MainView/sidebar/ToolIcons.js +1 -1
  143. package/es/views/MainView/sidebar/index.js +1 -1
  144. package/package.json +8 -8
  145. package/dist/components/DynamicResizer/assets/bottomToZero.svg.js +0 -1
  146. package/dist/components/DynamicResizer/assets/divider.svg.js +0 -1
  147. package/dist/components/DynamicResizer/assets/topToZero.svg.js +0 -1
  148. package/es/components/DynamicResizer/assets/bottomToZero.svg.js +0 -1
  149. package/es/components/DynamicResizer/assets/divider.svg.js +0 -1
  150. package/es/components/DynamicResizer/assets/topToZero.svg.js +0 -1
@@ -0,0 +1 @@
1
+ import*as t from"react";var l,o,v,c,m,z;function a(){return a=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(h[n]=r[n])}return h},a.apply(null,arguments)}var i=function(e){return t.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),l||(l=t.createElement("path",{fill:"currentColor",d:"M17 5h-1.571V3H17zm-3.143 0h-1.571V3h1.571zm-3.143 0H9.143V3h1.571zM7.571 5H6V3h1.571z"})),o||(o=t.createElement("path",{fill:"currentColor",d:"M17 17h-2v-2h2zm0-4h-2v-2h2zm0-4h-2V7h2zm0-4h-2V3h2z"})),v||(v=t.createElement("path",{fill:"currentColor",d:"M17 17h-1.571v-2H17zm-3.143 0h-1.571v-2h1.571zm-3.143 0H9.143v-2h1.571zm-3.143 0H6v-2h1.571zM6 2H2v4h4zM18 2h-4v4h4zM6 14H2v4h4z"})),c||(c=t.createElement("path",{fill:"currentColor",d:"M18 14h-4v4h4z"})),m||(m=t.createElement("path",{fill:"#fff",d:"M5 6H3v9h2z"})),z||(z=t.createElement("path",{fill:"currentColor",d:"M3 6h2v9H3zM15 3v2H5V3zM15 15v2H5v-2zM15 6h2v9h-2z"})))};export{i as ReactComponent};
@@ -0,0 +1 @@
1
+ import*as t from"react";var l,o,v,c;function a(){return a=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(h[n]=r[n])}return h},a.apply(null,arguments)}var m=function(e){return t.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,fill:"none"},e),l||(l=t.createElement("path",{fill:"currentColor",d:"M17 5h-1.571V3H17zm-3.143 0h-1.571V3h1.571zm-3.143 0H9.143V3h1.571zM7.571 5H6V3h1.571z"})),o||(o=t.createElement("path",{fill:"currentColor",d:"M17 17h-2v-2h2zm0-4h-2v-2h2zm0-4h-2V7h2zm0-4h-2V3h2z"})),v||(v=t.createElement("path",{fill:"currentColor",d:"M17 17h-1.571v-2H17zm-3.143 0h-1.571v-2h1.571zm-3.143 0H9.143v-2h1.571zm-3.143 0H6v-2h1.571z"})),c||(c=t.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 2H2v4h1v11h11v1h4v-4h-1V3H6zm9 3H6v1H5v9h9v-1h1z",clipRule:"evenodd"})))};export{m as ReactComponent};
@@ -1 +1 @@
1
- import e,{useRef as f}from"react";import h from"./hooks/useDrag.js";const g=s=>{const{minTopHeight:i=0,minBottomHeight:a=0,defaultHeight:o=50,axis:c="y",children:t,localKey:n="dynamicResizerHeights",customDivider:m,isShortcutButton:l=!1}=s,r=f(null),{rendered:d,topStyle:u,bottomStyle:y}=h({containerRef:r,minTopHeight:i,minBottomHeight:a,defaultHeight:o,axis:c,localKey:n,customDivider:m,isShortcutButton:l});return e.createElement("div",{className:"dynamic-resizer-content",ref:r},e.createElement("div",{className:"dynamic-resizer-top",style:u},t[0]),d,e.createElement("div",{className:"dynamic-resizer-bottom",style:y},t[1]))};export{g as default};
1
+ import s,{useRef as b}from"react";import{Resizable as z}from"re-resizable";import g from"./hooks/useDrag.js";var h=Object.defineProperty,l=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,n=(t,e,r)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R=(t,e)=>{for(var r in e||(e={}))w.call(e,r)&&n(t,r,e[r]);if(l)for(var r of l(e))E.call(e,r)&&n(t,r,e[r]);return t};const N=({direction:t="vertical",children:e,defaultWidth:r,defaultHeight:i,minTopHeight:c,minBottomHeight:m,minLeftWidth:p,minRightWidth:f,localKey:u,enableEdges:y=["right","bottom"],disabled:d=!1,onResizeStart:_,onResize:v,onResizeStop:O})=>{const o=b(null),P=g({direction:t,containerRef:o,defaultHeight:i,defaultWidth:r,minTopHeight:c,minBottomHeight:m,minLeftWidth:p,minRightWidth:f,localKey:u,enableEdges:y,onResizeStart:_,onResize:v,onResizeStop:O}),a=d?{display:"contents"}:void 0;return s.createElement("div",{style:a,className:`dynamic-resizer-content ${t}`,ref:o},s.createElement(z,R({style:a},P),s.createElement("div",{style:a,className:"resizable-child"},e[0])),s.createElement("div",{style:a,className:"resizable-child-two"},e[1]))};export{N as default};
@@ -1 +1 @@
1
- import e,{useCallback as a,useMemo as b}from"react";import L from"react-draggable";import{useLocalStorageState as j}from"ahooks";import k from"./useUpdateHeight.js";import C from"../assets/topToZero.svg.js";import Z from"../assets/bottomToZero.svg.js";import P from"../assets/divider.svg.js";const F=({containerRef:t,minTopHeight:h=0,minBottomHeight:f=0,defaultHeight:E=50,axis:o,localKey:H,isShortcutButton:s=!1})=>{const l=H||"dynamicResizerHeights",{topHeight:i,position:d,bounds:m,topStyle:S,bottomStyle:T,updateELHeight:c,setTopHeightToZero:g,setBottomHeightToZero:n}=k(t,h,f,E,l),[U,p]=j(l),N=a(r=>{r.stopPropagation(),t.current&&t.current.classList.add("hide-scrollbar")},[t]),u=a((r,D)=>{r.stopPropagation(),c(D.y)},[c]),v=a(r=>{r.stopPropagation(),t.current&&t.current.classList.remove("hide-scrollbar"),p(i)},[t,p,i]),y=b(()=>s?e.createElement(e.Fragment,null,e.createElement("img",{src:C,className:"divider-top",draggable:"false",onClick:g}),e.createElement("div",{className:"divider-icon",draggable:"false"}),e.createElement("img",{src:Z,className:"divider-bottom",draggable:"false",onClick:n})):e.createElement(e.Fragment,null,e.createElement("img",{src:P,className:"divider-all",draggable:"false"}),e.createElement("div",{className:"divider-icon",draggable:"false"})),[s,g,n]);return{rendered:b(()=>{const r=e.createElement("div",{className:"divider"},y);return e.createElement(L,{axis:o,position:d,handle:".divider",onStart:N,onDrag:u,onStop:v,bounds:m},r)},[o,d,u,v,m]),topStyle:S,bottomStyle:T}};export{F as default};
1
+ import{useState as L,useEffect as P}from"react";import U from"./useUpdateHeight.js";import v from"./useDraggingAllowed.js";const C=({containerRef:e,direction:t,defaultHeight:h,defaultWidth:g,minTopHeight:l,minBottomHeight:n,minLeftWidth:c,minRightWidth:m,localKey:u,enableEdges:f,onResizeStart:s,onResize:i,onResizeStop:a})=>{const{width:p,height:z,minWidth:H,minHeight:b,maxWidth:D,maxHeight:y,updateHeight:W,updateWidth:w}=U({direction:t,containerRef:e,minTopHeight:l,minBottomHeight:n,defaultHeight:h,minLeftWidth:c,minRightWidth:m,defaultWidth:g,localKey:u}),x=v(t,f),[r,d]=L(!1),S=()=>{d(!0),s&&s()},j=()=>{i&&i()},A=(I,R,o)=>{d(!1),w(o.offsetWidth),W(o.offsetHeight),a&&a()};return P(()=>{e.current&&(r?e.current.classList.add("hide-scrollbar"):e.current.classList.remove("hide-scrollbar"))},[r,e.current]),{size:{width:p,height:z},onResizeStart:S,onResize:j,onResizeStop:A,enable:x,handleClasses:{right:"dynamic-right-handle",bottom:"dynamic-bottom-handle"},minWidth:H,maxWidth:D,minHeight:b,maxHeight:y}};export{C as default};
@@ -0,0 +1 @@
1
+ import{useMemo as s}from"react";const i=(r="vertical",o)=>{const t=(e,l)=>r===e&&(o==null?void 0:o.includes(l));return s(()=>{const e=t("vertical","top"),l=t("vertical","bottom"),n=t("horizontal","left"),a=t("horizontal","right");return{top:e,bottom:l,left:n,right:a,topLeft:!1,ropRight:!1,bottomLeft:!1,bottomRight:!1}},[r,o])};export{i as default};
@@ -1 +1 @@
1
- import{useState as r,useEffect as M,useMemo as c,useCallback as _}from"react";import{useLocalStorageState as U}from"ahooks";const b=1e-5,z=(t,m,v,d,S)=>{const[l,I]=r(0),[n,x]=r(0),[s,B]=r(0),[u,L]=r(0),[h,p]=U(S),[a,N]=r(!1);M(()=>{D(),N(!0)},[]),M(()=>{if(a){const o=P();H(o),p(o)}},[a]);const y=c(()=>({x:0,y:l}),[l]),Z=c(()=>{var o;return{top:s,bottom:(((o=t.current)==null?void 0:o.offsetHeight)||0)-u}},[s,t]),E=c(()=>({height:l+"px"}),[l]),k=c(()=>({height:n+"px"}),[n]),D=()=>{var o,i,e,g;if(t){let f=m,T=v;m>=(((o=t.current)==null?void 0:o.offsetHeight)||0)/2&&(f=(((i=t.current)==null?void 0:i.offsetHeight)||0)/2),v>=(((e=t.current)==null?void 0:e.offsetHeight)||0)/2&&(T=(((g=t.current)==null?void 0:g.offsetHeight)||0)/2),B(f||b),L(T)}},P=_(()=>{var o,i;let e=0;return h!=null?e=isNaN(Number(h))?0:Number(h):e=d,e<s&&(e=s),t&&e>=(((o=t==null?void 0:t.current)==null?void 0:o.offsetHeight)||0)&&(e=(((i=t.current)==null?void 0:i.offsetHeight)||0)/2),e||b},[t,l,s,h,d]),H=_(o=>{var i;if(t){const e=((i=t==null?void 0:t.current)==null?void 0:i.offsetHeight)||0,g=e-u;o>=s&&o<=g&&(I(o),x(e-o))}},[t,s,u]);return{topHeight:l,bottomHeight:n,position:y,bounds:Z,topStyle:E,bottomStyle:k,updateELHeight:H,setBottomHeightToZero:()=>{var o;if(t){const i=((o=t==null?void 0:t.current)==null?void 0:o.offsetHeight)||0;H(i-u||0),p(i-u||0)}},setTopHeightToZero:()=>{t&&(H(s||0),p(s||0))}}};export{z as default};
1
+ import{useState as a,useEffect as r,useCallback as n}from"react";import{useLocalStorageState as z}from"ahooks";import{adjustDefaultSize as D,calcMinSize as I,calcMaxSize as b}from"../utils/index.js";const Q=({containerRef:t,direction:e,defaultHeight:j=10,defaultWidth:k=10,minTopHeight:c=10,minBottomHeight:o=10,minLeftWidth:h=10,minRightWidth:d=10,localKey:v="dynamicResizerLocalKey"})=>{var g,H;const[W,w]=a(0),[x,A]=a(0),[_,y]=a(void 0),[C,E]=a(void 0),[L,U]=a(void 0),[m,q]=a(void 0),[F,G]=z(v+"width"),[J,K]=z(v+"height"),[u,M]=a(!1);r(()=>(M(!0),()=>{M(!1)}),[]),r(()=>{u&&N()},[u]),r(()=>{u&&e==="vertical"&&P()},[u,(g=t.current)==null?void 0:g.offsetHeight,c,o]),r(()=>{u&&e==="horizontal"&&O()},[u,(H=t.current)==null?void 0:H.offsetWidth,h,d]);const N=()=>{if(t==null?void 0:t.current){const l=t==null?void 0:t.current.offsetWidth,s=t==null?void 0:t.current.offsetHeight;let i=l,p=s;e==="vertical"?p=D(J,c,o,s,j):e==="horizontal"&&(i=D(F,h,d,l,k)),f(i),S(p)}},O=n(()=>{if(t==null?void 0:t.current){const l=t==null?void 0:t.current.offsetWidth;let s=l,i=l;s=I(h,l),i=b(d,l),y(s),U(i)}},[t,h,d]),P=n(()=>{if(t==null?void 0:t.current){const l=t==null?void 0:t.current.offsetHeight;let s=l,i=l;s=I(c,l),i=b(o,l),E(s),q(i)}},[t,c,o]),f=n(l=>{const s=e==="horizontal"?l:"100%";w(s),G(s)},[e,W]),S=n(l=>{const s=e==="vertical"?l:"100%";A(s),K(s)},[e,x]);return{width:W,height:x,minWidth:_,minHeight:C,maxWidth:L,maxHeight:m,updateWidth:f,updateHeight:S}};export{Q as default};
@@ -0,0 +1 @@
1
+ const p=t=>typeof t=="string"&&t.endsWith("%")&&!isNaN(parseFloat(t)),o=(t,s)=>{const f=parseFloat(t);return isNaN(f)?0:f/100*s},g=t=>typeof t=="number"&&t>0||p(t),b=(t,s)=>g(t)?typeof t=="string"&&p(t)?o(t,s):s-Number(t):s,n=(t,s)=>g(t)?typeof t=="string"&&p(t)?o(t,s):Number(t):0,h=(t,s,f,r=0,N)=>{if(!g(t))return N<r?N:Math.min(r,n(s,r));if(n(s,r)+n(f,r)>r)return r*.5;const a=n(s,r),u=r-n(f,r),M=typeof t=="string"&&p(t)?o(t,r):Number(t)||0;return Math.min(Math.max(M,a),u)};export{h as adjustDefaultSize,b as calcMaxSize,n as calcMinSize,g as isValidSize};
@@ -1 +1 @@
1
- import{getTextControlByConfig as I,RenderAnswer as N}from"../../LLMToolView/questionView/index.js";import{RenderQuestion as V}from"../../LLMToolView/questionView/components/header/index.js";import j from"../../LLMToolView/questionView/components/imgView/index.js";import x from"../../../store/LLMMultiWheel/index.js";import{classnames as h}from"../../../utils/index.js";import{Button as s}from"antd";import e from"react";import{useTranslation as M}from"react-i18next";var T=Object.defineProperty,q=Object.defineProperties,D=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,d=(o,t,r)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,S=(o,t)=>{for(var r in t||(t={}))F.call(t,r)&&d(o,r,t[r]);if(p)for(var r of p(t))C.call(t,r)&&d(o,r,t[r]);return o},b=(o,t)=>q(o,D(t));const A=o=>{const{id:t,answerList:r,question:u,index:f,name:w="",answerIsImg:v,questionIsImg:_,LLMConfig:g}=o,{t:n}=M(),{dataFormatType:i,selectedID:E,setSelectedID:y}=x(),a=f+1,L=w||`${n("Dialog")}${a}`;return e.createElement("div",{key:t,onClick:()=>y(t),className:h({dialog:!0,selected:t===E})},e.createElement("div",{className:"header"},e.createElement("span",{className:"order"},a),e.createElement("div",{className:"name"},e.createElement("div",{className:"show-name"},L),e.createElement("div",{className:"tips"},"\uFF08",n("SelectionOfAnnotation"),"\uFF09"))),e.createElement("div",{className:"dialog-question"},e.createElement(s,{type:"primary"},n("Title"),a),e.createElement("div",null,e.createElement(V,{question:u,dataFormatType:i,isImg:_}))),e.createElement("div",{className:"dialog-answer"},v?e.createElement(e.Fragment,null,e.createElement(s,{type:"primary"},n("Answer")),e.createElement(j,{answerList:r})):r==null?void 0:r.map((O,l)=>{const m=l+1,c=b(S({},O),{order:m}),P=I(c,g);return e.createElement("div",{key:l},e.createElement(s,{type:"primary"},n("Answer"),m),e.createElement(N,{i:c,isTextControl:P,dataFormatType:i}))})))};export{A as default};
1
+ import{getTextControlByConfig as x,RenderAnswer as A}from"../../LLMToolView/questionView/index.js";import N from"../../LLMToolView/questionView/components/audioView/index.js";import{RenderQuestion as M}from"../../LLMToolView/questionView/components/header/index.js";import T from"../../LLMToolView/questionView/components/imgView/index.js";import h from"../../../store/LLMMultiWheel/index.js";import{classnames as q}from"../../../utils/index.js";import{Button as a}from"antd";import e from"react";import{useTranslation as F}from"react-i18next";var D=Object.defineProperty,C=Object.defineProperties,S=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,p=(n,t,r)=>t in n?D(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,B=(n,t)=>{for(var r in t||(t={}))b.call(t,r)&&p(n,r,t[r]);if(d)for(var r of d(t))R.call(t,r)&&p(n,r,t[r]);return n},W=(n,t)=>C(n,S(t));const $=n=>{const{id:t,answerList:r,question:u,index:w,name:f="",answerIsImg:E,questionIsImg:g,questionIsAudio:v,answerIsAudio:_,LLMConfig:y}=n,{t:o}=F(),{dataFormatType:s,selectedID:L,setSelectedID:V}=h(),i=w+1,O=f||`${o("Dialog")}${i}`,I=()=>E?e.createElement(e.Fragment,null,e.createElement(a,{type:"primary"},o("Answer")),e.createElement(T,{answerList:r})):_?e.createElement(e.Fragment,null,e.createElement(a,{type:"primary"},o("Answer")),e.createElement(N,{answerList:r})):r==null?void 0:r.map((P,l)=>{const m=l+1,c=W(B({},P),{order:m}),j=x(c,y);return e.createElement("div",{key:l},e.createElement(a,{type:"primary"},o("Answer"),m),e.createElement(A,{i:c,isTextControl:j,dataFormatType:s}))});return e.createElement("div",{key:t,onClick:()=>V(t),className:q({dialog:!0,selected:t===L})},e.createElement("div",{className:"header"},e.createElement("span",{className:"order"},i),e.createElement("div",{className:"name"},e.createElement("div",{className:"show-name"},O),e.createElement("div",{className:"tips"},"\uFF08",o("SelectionOfAnnotation"),"\uFF09"))),e.createElement("div",{className:"dialog-question"},e.createElement(a,{type:"primary"},o("Title"),i),e.createElement("div",null,e.createElement(M,{question:u,dataFormatType:s,isImg:g,isAudio:v}))),e.createElement("div",{className:"dialog-answer"},I()))};export{$ as default};
@@ -1 +1 @@
1
- import i,{useEffect as M,useState as E}from"react";import{ELLMDataType as W}from"../../constant/index.js";import{getStepConfig as Y}from"../../store/annotation/reducer.js";import{LabelBeeContext as Z}from"../../store/ctx.js";import{jsonParser as ee}from"../../utils/index.js";import{connect as te}from"react-redux";import A from"../../store/LLMMultiWheel/index.js";import{LLMMultiWheelViewCls as $}from"../../views/MainView/LLMMultiWheelLayout/index.js";import{ToggleDataFormatType as ne}from"../LLMToolView/questionView/components/header/index.js";import oe from"./dialogView/index.js";import re from"../messageMaskLayer/index.js";import ie from"../../views/MainView/annotationTips/index.js";import{I18nextProvider as ae,useTranslation as se}from"react-i18next";import{LLMViewCls as le}from"../LLMToolView/questionView/index.js";import{Layout as ue}from"antd";import{i18n as F}from"@labelbee/lb-utils";var ce=Object.defineProperty,de=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,k=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))me.call(e,n)&&k(t,n,e[n]);if(N)for(var n of N(e))Le.call(e,n)&&k(t,n,e[n]);return t},h=(t,e)=>de(t,pe(e));const R=t=>{const{questionIsImg:e,answerIsImg:n,LLMConfig:l,dialogList:p,lang:u="cn"}=t,{dataFormatType:c,setDataFormatType:a}=A();return M(()=>{var o;u&&((o=F)==null||o.changeLanguage(u))},[u]),i.createElement(ae,{i18n:F},i.createElement("div",{className:`${$}`},i.createElement("div",{style:{display:"flex",justifyContent:"flex-end",margin:"10px"}},i.createElement(ne,{dataFormatType:c,setDataFormatType:a})),i.createElement("div",{className:`${$}-container`},p==null?void 0:p.map((o,d)=>i.createElement(oe,h(y({},o),{key:d,index:d,questionIsImg:e,answerIsImg:n,LLMConfig:l}))))))},U=({type:t,questionIndex:e,answerIndex:n,llmFile:l})=>{if(t==="question")return l==null?void 0:l.find((u,c)=>e===c);let p=null;return l==null||l.forEach((u,c)=>{var a;(a=u.answerList)==null||a.forEach((o,d)=>{c===e&&n===d&&(p=o)})}),p},fe=t=>{var e,n;const{annotation:l,tips:p,showTips:u,drawLayerSlot:c}=t,{imgIndex:a,imgList:o,stepList:d,step:x,toolInstance:v}=l,[g,B]=E(),{setSelectedID:Q,newAnswerListMap:I}=A(),[z,T]=E([]),j=((e=g==null?void 0:g.dataType)==null?void 0:e.prompt)===W.Picture,P=((n=g==null?void 0:g.dataType)==null?void 0:n.response)===W.Picture,{t:G}=se(),[,H]=E(0);return M(()=>{var r,m,L;if(!o[a])return;const w=(r=o[a])!=null?r:{},f=(L=(m=w==null?void 0:w.questionList)==null?void 0:m.textList)!=null?L:[];T(f),(f==null?void 0:f.length)&&Q(f[0].id)},[a]),M(()=>{var r,m;const L=(r=o[a])!=null?r:{},w=L==null?void 0:L.questionList,f=(m=L==null?void 0:L.llmFile)==null?void 0:m.textList,V=w==null?void 0:w.textList,J=V==null?void 0:V.map((s,b)=>{var D;return h(y({},s),{question:j&&U({type:"question",questionIndex:b,llmFile:f})||(s==null?void 0:s.question),answerList:(D=s==null?void 0:s.answerList)==null?void 0:D.map((_,O)=>{var S,q,C;const K=`${(S=s==null?void 0:s.id)!=null?S:""}-${(q=_==null?void 0:_.id)!=null?q:""}`,X=P?U({type:"answer",questionIndex:b,answerIndex:O,llmFile:f})||{}:{};return y(h(y({},_),{answer:_.answer,newAnswer:(C=I[K])!=null?C:_.answer,order:O+1}),X)})})});T(J)},[I,j,P]),M(()=>{var r;if(d&&x){const m=(r=Y(d,x))==null?void 0:r.config;B(ee(m))}},[d,x]),M(()=>{if(v)return v.on("validUpdated",()=>{H(r=>r+1)}),()=>{v.unbindAll("validUpdated")}},[v]),i.createElement(ue,{className:le},!(v==null?void 0:v.valid)&&i.createElement(re,{message:G("InvalidQuestionAndSkip")}),c==null?void 0:c({}),u===!0&&i.createElement(ie,{tips:p}),i.createElement(R,{questionIsImg:j,answerIsImg:P,LLMConfig:g,dialogList:z}))},ve=t=>({annotation:t.annotation});var ge=te(ve,null,null,{context:Z})(fe);export{R as LLMMultiWheelSourceView,ge as default};
1
+ import a,{useEffect as x,useState as b}from"react";import{ELLMDataType as I}from"../../constant/index.js";import{getStepConfig as ne}from"../../store/annotation/reducer.js";import{LabelBeeContext as oe}from"../../store/ctx.js";import{jsonParser as re}from"../../utils/index.js";import{connect as ie}from"react-redux";import k from"../../store/LLMMultiWheel/index.js";import{LLMMultiWheelViewCls as R}from"../../views/MainView/LLMMultiWheelLayout/index.js";import{ToggleDataFormatType as ae}from"../LLMToolView/questionView/components/header/index.js";import se from"./dialogView/index.js";import le from"../messageMaskLayer/index.js";import ue from"../../views/MainView/annotationTips/index.js";import{I18nextProvider as de,useTranslation as ce}from"react-i18next";import{LLMViewCls as pe}from"../LLMToolView/questionView/index.js";import{Layout as me}from"antd";import{i18n as U}from"@labelbee/lb-utils";var ve=Object.defineProperty,fe=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,Q=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,j=(t,e)=>{for(var n in e||(e={}))we.call(e,n)&&Q(t,n,e[n]);if(B)for(var n of B(e))ge.call(e,n)&&Q(t,n,e[n]);return t},q=(t,e)=>fe(t,Le(e));const z=t=>{const{questionIsImg:e,answerIsImg:n,questionIsAudio:s,answerIsAudio:p,LLMConfig:L,dialogList:d,lang:c="cn"}=t,{dataFormatType:w,setDataFormatType:o}=k();return x(()=>{var r;c&&((r=U)==null||r.changeLanguage(c))},[c]),a.createElement(de,{i18n:U},a.createElement("div",{className:`${R}`},a.createElement("div",{style:{display:"flex",justifyContent:"flex-end",margin:"10px"}},a.createElement(ae,{dataFormatType:w,setDataFormatType:o})),a.createElement("div",{className:`${R}-container`},d==null?void 0:d.map((r,g)=>a.createElement(se,q(j({},r),{key:g,index:g,questionIsImg:e,answerIsImg:n,questionIsAudio:s,answerIsAudio:p,LLMConfig:L}))))))},G=({type:t,questionIndex:e,answerIndex:n,llmFile:s})=>{if(t==="question")return s==null?void 0:s.find((L,d)=>e===d);let p=null;return s==null||s.forEach((L,d)=>{var c;(c=L.answerList)==null||c.forEach((w,o)=>{d===e&&n===o&&(p=w)})}),p},_e=t=>{var e,n,s,p;const{annotation:L,tips:d,showTips:c,drawLayerSlot:w}=t,{imgIndex:o,imgList:r,stepList:g,step:P,toolInstance:_}=L,[l,H]=b(),{setSelectedID:J,newAnswerListMap:D}=k(),[K,O]=b([]),E=((e=l==null?void 0:l.dataType)==null?void 0:e.prompt)===I.Picture,T=((n=l==null?void 0:l.dataType)==null?void 0:n.response)===I.Picture,h=((s=l==null?void 0:l.dataType)==null?void 0:s.prompt)===I.Audio,V=((p=l==null?void 0:l.dataType)==null?void 0:p.response)===I.Audio,{t:X}=ce(),[,Y]=b(0);return x(()=>{var i,m,v;if(!r[o])return;const M=(i=r[o])!=null?i:{},f=(v=(m=M==null?void 0:M.questionList)==null?void 0:m.textList)!=null?v:[];O(f),(f==null?void 0:f.length)&&J(f[0].id)},[o]),x(()=>{var i,m;if(!r[o])return;const v=(i=r[o])!=null?i:{},M=v==null?void 0:v.questionList,f=(m=v==null?void 0:v.llmFile)==null?void 0:m.textList,A=M==null?void 0:M.textList,Z=A==null?void 0:A.map((u,S)=>{var C;return q(j({},u),{question:(E||h)&&G({type:"question",questionIndex:S,llmFile:f})||(u==null?void 0:u.question),answerList:(C=u==null?void 0:u.answerList)==null?void 0:C.map((y,W)=>{var $,F,N;const ee=`${($=u==null?void 0:u.id)!=null?$:""}-${(F=y==null?void 0:y.id)!=null?F:""}`,te=T||V?G({type:"answer",questionIndex:S,answerIndex:W,llmFile:f})||{}:{};return j(q(j({},y),{answer:y.answer,newAnswer:(N=D[ee])!=null?N:y.answer,order:W+1}),te)})})});O(Z)},[D,E,h,T,V,r,o]),x(()=>{var i;if(g&&P){const m=(i=ne(g,P))==null?void 0:i.config;H(re(m))}},[g,P]),x(()=>{if(_)return _.on("validUpdated",()=>{Y(i=>i+1)}),()=>{_.unbindAll("validUpdated")}},[_]),a.createElement(me,{className:pe},!(_==null?void 0:_.valid)&&a.createElement(le,{message:X("InvalidQuestionAndSkip")}),w==null?void 0:w({}),c===!0&&a.createElement(ue,{tips:d}),a.createElement(z,{questionIsImg:E,answerIsImg:T,questionIsAudio:h,answerIsAudio:V,LLMConfig:l,dialogList:K}))},Me=t=>({annotation:t.annotation});var ye=ie(Me,null,null,{context:oe})(_e);export{z as LLMMultiWheelSourceView,ye as default};
@@ -1 +1 @@
1
- import r,{useState as T,useRef as It,useMemo as N,useEffect as $}from"react";import{LabelBeeContext as Vt}from"../../../store/ctx.js";import{connect as Nt}from"react-redux";import{prefix as $t}from"../../../constant/index.js";import{getStepConfig as Bt}from"../../../store/annotation/reducer.js";import{jsonParser as dt}from"../../../utils/index.js";import Wt,{getSorts as ct}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as Ft}from"react-i18next";import{useCustomToolInstance as kt}from"../../../hooks/annotation.js";import{isBoolean as qt,isString as Gt,isNumber as Kt,isObject as zt,isArray as Ut}from"lodash";import{PageForward as B}from"../../../store/annotation/actionCreators.js";import{cKeyCode as Qt,EToolName as Jt}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Ht,EmptyConfig as Xt}from"../../LLMToolView/sidebar/index.js";import Yt from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as pt}from"antd";import Zt from"../../LLMToolView/sidebar/components/answerList/index.js";import te from"../../../store/LLMMultiWheel/index.js";import ee from"../../../utils/StepUtils.js";import{getRenderDataByResult as ne,getTagResult as oe,getCurrentResultFromResultList as re}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as z}from"ahooks";import le from"../../LLMToolView/sidebar/components/answerSort/index.js";import ie from"../../tagList/components/overall/index.js";var se=Object.defineProperty,ae=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,ft=(p,d,m)=>d in p?se(p,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[d]=m,l=(p,d)=>{for(var m in d||(d={}))de.call(d,m)&&ft(p,m,d[m]);if(mt)for(var m of mt(d))ce.call(d,m)&&ft(p,m,d[m]);return p},u=(p,d)=>ae(p,ue(d));const pe=Qt.default,vt=`${$t}-sidebar`,me={sort:[],answerSort:{},textAttribute:[],tagList:{}},fe=p=>{var d,m,U,Q,J,H;const{annotation:Lt,dispatch:R,checkMode:gt}=p,{imgIndex:M,imgList:W,stepList:A,step:h,skipBeforePageTurning:D}=Lt,[c,xt]=T(),{t:S}=Ft(),o=(d=W[M])!=null?d:{},X=dt(o==null?void 0:o.result),{toolInstanceRef:L}=kt({basicInfo:X}),[F,wt]=T(!0),[O,Y]=T({}),[g,Z]=T(me),k=It(),[_,q]=T({}),{selectedID:P,setNewAnswerListMap:tt,newAnswerListMap:et}=te(),b=N(()=>O[P],[P,O]),y=!L.current.valid||gt;$(()=>{var t;if(A&&h){const e=(t=Bt(A,h))==null?void 0:t.config;xt(dt(e))}},[h,JSON.stringify(A)]),$(()=>{!o||M===-1||(L.current.setValid=nt,L.current.clearResult=St,nt(),ot())},[M,c,o==null?void 0:o.id]);const St=()=>{var t,e,n,i;ot((t=o==null?void 0:o.questionList)==null?void 0:t.textList),((e=k.current)==null?void 0:e.clearValue)&&((n=k.current)==null||n.clearValue());const{waitSorts:f}=ct({selectedSort:(i=x==null?void 0:x.sort)!=null?i:[],initSelected:[],modelList:j?V!=null?V:[]:[]});q(u(l({},_),{waitSorts:f,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;qt(n)&&(wt(n),L.current.valid=n,(e=L.current)==null||e.emit("validUpdated"))},_t=()=>{const t=ee.getCurrentStepInfo(h,A);return re(o==null?void 0:o.result,t.step)},x=N(()=>_t(),[h,A,o]),ot=z(t=>{var e,n,i,f,s,w,C;const a=x;let E=(e=o==null?void 0:o.questionList)==null?void 0:e.textList;((n=a==null?void 0:a.modelData)==null?void 0:n.length)&&L.current.valid&&(E=a==null?void 0:a.modelData),t&&(E=t,a.sort=[],a.textAttribute=[],a.answerSort=[]);let at={};E==null||E.forEach((v,Dt)=>{var ut;const Ot=ne(c,u(l({},v),{answerList:(ut=v==null?void 0:v.answerList)==null?void 0:ut.map((K,Pt)=>(tt(u(l({},et),{[`${v.id}-${K.id}`]:K.answer})),u(l({},K),{order:Pt+1})))}));at[v.id]=u(l({},Ot),{order:Dt+1,id:v.id})});const{waitSorts:jt,newSort:Ct}=ct({selectedSort:(i=x==null?void 0:x.sort)!=null?i:[],modelList:j?V!=null?V:[]:[]});q({waitSorts:jt,newSort:Ct});const Tt=((f=c==null?void 0:c.inputList)==null?void 0:f.filter(v=>v==null?void 0:v.isOverall))||[],Rt=oe(Tt,a==null?void 0:a.tagList);Z({sort:(s=a==null?void 0:a.sort)!=null?s:[],textAttribute:(w=a==null?void 0:a.textAttribute)!=null?w:[],answerSort:(C=a==null?void 0:a.answerSort)!=null?C:{},tagList:Rt}),Y(at)});$(()=>{bt()},[O,F,g]),$(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const bt=z(()=>{var t,e;const n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var s;const w=(s=O[f.id])!=null?s:{};return{id:f.id,answerList:w.answerList}}),i=u(l({},g),{modelData:n});L.current.exportData=()=>[[i],{valid:F}],L.current.currentPageResult=u(l({},i),{toolName:Jt.LLMMultiWheel,valid:F})}),rt=t=>{if(t.ctrlKey&&t.keyCode===pe.Enter){if(D){D(()=>R(B()));return}R(B())}},yt=z(({order:t,value:e,key:n})=>{const{answerList:i}=b,f=i==null?void 0:i.map(s=>{var w,C;if((s==null?void 0:s.order)===t){if(n==="textEdit"&&Gt(e))return tt(u(l({},et),{[`${P}-${(w=s==null?void 0:s.id)!=null?w:""}`]:e})),u(l({},s),{newAnswer:e});if(Kt(e))return u(l({},s),{score:e});if(zt(e)&&n){const a={[e==null?void 0:e.key]:e.value},E=(C=s[n])!=null?C:{};return u(l({},s),{[n]:l(l({},E),a)})}}return s});Y(s=>u(l({},s),{[P]:u(l({},b),{answerList:f})}))}),I=(t,e)=>{Z(n=>u(l({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:Et,dialogSort:j=!1,inputList:G=[],tagInputListConfigurable:st,enableSort:Mt=!1}=c||{},V=N(()=>{var t,e,n;return j?(n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map((i,f)=>u(l({},i),{title:f+1})))!=null?n:[]:[]},[o,j]);if(N(()=>Ht(c),[c]))return r.createElement(Xt,null);const At=st&&((m=G.filter(t=>!t.isOverall))==null?void 0:m.length)>0,ht=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||Et||At;return r.createElement("div",{className:`${vt}`},r.createElement("div",{className:`${vt}__content`},r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("GlobalAnnotation")),j&&r.createElement(le,{waitSortList:(_==null?void 0:_.waitSorts)||[],sortList:(_==null?void 0:_.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(i=>i.id));I("sort",e),q(u(l({},_),{newSort:t}))},disabeledAll:y,title:S("SortConversationQuality"),prefixId:"model"}),(c==null?void 0:c.text)&&r.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},r.createElement(Yt,{textAttribute:(U=g==null?void 0:g.textAttribute)!=null?U:[],textConfig:(c==null?void 0:c.text)&&Ut(c.text)?c==null?void 0:c.text:[],setText:t=>I("textAttribute",t),disabeledAll:y})),Mt&&r.createElement(Wt,{modelData:(J=(Q=o==null?void 0:o.questionList)==null?void 0:Q.textList)!=null?J:[],selectedAnswerSort:t=>I("answerSort",t),selectedSort:(H=x==null?void 0:x.answerSort)!=null?H:[],ref:k,disabeledAll:y,imgIndex:M}),st&&G.length&&r.createElement(ie,{inputList:G,selectedTags:(g==null?void 0:g.tagList)||{},updateValue:t=>{const{key:e,value:n}=t,i=(g==null?void 0:g.tagList)||{};I("tagList",u(l({},i),{[e]:n}))},disabeledAll:y}),b&&r.createElement(r.Fragment,null,r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("QualifiedAnnotation")),r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},r.createElement(pt,{type:"primary",danger:!0},S("Annotating")),r.createElement("div",{style:{padding:16}},S("Group"),"\uFF1A",b.order)),r.createElement("div",null,ht&&r.createElement(Zt,{list:(b==null?void 0:b.answerList)||[],LLMConfig:c,updateValue:yt,disabeledAll:y})))),r.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(W==null?void 0:W.length)-1!==M&&r.createElement(pt,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(D){D(()=>R(B()));return}R(B())},disabled:y},S("Save"))))},ve=p=>({annotation:p.annotation});var Le=Nt(ve,null,null,{context:Vt})(fe);export{Le as default};
1
+ import r,{useState as C,useRef as It,useMemo as N,useEffect as $}from"react";import{LabelBeeContext as Vt}from"../../../store/ctx.js";import{connect as Nt}from"react-redux";import{prefix as $t}from"../../../constant/index.js";import{getStepConfig as Bt}from"../../../store/annotation/reducer.js";import{jsonParser as ct}from"../../../utils/index.js";import Wt,{getSorts as pt}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as Ft}from"react-i18next";import{useCustomToolInstance as kt}from"../../../hooks/annotation.js";import{isBoolean as qt,isString as Gt,isNumber as Kt,isObject as zt,isArray as Ut}from"lodash";import{PageForward as B}from"../../../store/annotation/actionCreators.js";import{cKeyCode as Qt,EToolName as Jt}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Ht,EmptyConfig as Xt}from"../../LLMToolView/sidebar/index.js";import Yt from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as mt}from"antd";import Zt from"../../LLMToolView/sidebar/components/answerList/index.js";import te from"../../../store/LLMMultiWheel/index.js";import ee from"../../../utils/StepUtils.js";import{getRenderDataByResult as ne,getTagResult as oe,getCurrentResultFromResultList as re}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as z}from"ahooks";import le from"../../LLMToolView/sidebar/components/answerSort/index.js";import ie from"../../tagList/components/overall/index.js";var se=Object.defineProperty,ae=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,vt=(p,c,m)=>c in p?se(p,c,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[c]=m,l=(p,c)=>{for(var m in c||(c={}))de.call(c,m)&&vt(p,m,c[m]);if(ft)for(var m of ft(c))ce.call(c,m)&&vt(p,m,c[m]);return p},d=(p,c)=>ae(p,ue(c));const pe=Qt.default,Lt=`${$t}-sidebar`,me={sort:[],answerSort:{},textAttribute:[],tagList:{}},fe=p=>{var c,m,U,Q,J,H;const{annotation:gt,dispatch:R,checkMode:xt}=p,{imgIndex:M,imgList:W,stepList:A,step:T,skipBeforePageTurning:D}=gt,[i,wt]=C(),{t:S}=Ft(),o=(c=W[M])!=null?c:{},X=ct(o==null?void 0:o.result),{toolInstanceRef:L}=kt({basicInfo:X}),[F,St]=C(!0),[O,Y]=C({}),[g,Z]=C(me),k=It(),[_,q]=C({}),{selectedID:P,setNewAnswerListMap:tt,newAnswerListMap:et}=te(),b=N(()=>O[P],[P,O]),y=!L.current.valid||xt;$(()=>{var t;if(A&&T){const e=(t=Bt(A,T))==null?void 0:t.config;wt(ct(e))}},[T,JSON.stringify(A)]),$(()=>{!o||M===-1||(L.current.setValid=nt,L.current.clearResult=_t,nt(),ot())},[M,i,o==null?void 0:o.id]);const _t=()=>{var t,e,n,s;ot((t=o==null?void 0:o.questionList)==null?void 0:t.textList),((e=k.current)==null?void 0:e.clearValue)&&((n=k.current)==null||n.clearValue());const{waitSorts:f}=pt({selectedSort:(s=x==null?void 0:x.sort)!=null?s:[],initSelected:[],modelList:h?V!=null?V:[]:[]});q(d(l({},_),{waitSorts:f,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;qt(n)&&(St(n),L.current.valid=n,(e=L.current)==null||e.emit("validUpdated"))},bt=()=>{const t=ee.getCurrentStepInfo(T,A);return re(o==null?void 0:o.result,t.step)},x=N(()=>bt(),[T,A,o]),ot=z(t=>{var e,n,s,f,a,w,j;const u=x;let E=(e=o==null?void 0:o.questionList)==null?void 0:e.textList;((n=u==null?void 0:u.modelData)==null?void 0:n.length)&&L.current.valid&&(E=u==null?void 0:u.modelData),t&&(E=t,u.sort=[],u.textAttribute=[],u.answerSort=[]);let ut={};E==null||E.forEach((v,Dt)=>{var dt;const Ot=ne(i,d(l({},v),{answerList:(dt=v==null?void 0:v.answerList)==null?void 0:dt.map((K,Pt)=>((i==null?void 0:i.isTextEdit)&&tt(d(l({},et),{[`${v.id}-${K.id}`]:K.answer})),d(l({},K),{order:Pt+1})))}));ut[v.id]=d(l({},Ot),{order:Dt+1,id:v.id})});const{waitSorts:ht,newSort:jt}=pt({selectedSort:(s=x==null?void 0:x.sort)!=null?s:[],modelList:h?V!=null?V:[]:[]});q({waitSorts:ht,newSort:jt});const Ct=((f=i==null?void 0:i.inputList)==null?void 0:f.filter(v=>v==null?void 0:v.isOverall))||[],Rt=oe(Ct,u==null?void 0:u.tagList);Z({sort:(a=u==null?void 0:u.sort)!=null?a:[],textAttribute:(w=u==null?void 0:u.textAttribute)!=null?w:[],answerSort:(j=u==null?void 0:u.answerSort)!=null?j:{},tagList:Rt}),Y(ut)});$(()=>{yt()},[O,F,g]),$(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const yt=z(()=>{var t,e;const n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var a;const w=(a=O[f.id])!=null?a:{};return{id:f.id,answerList:w.answerList}}),s=d(l({},g),{modelData:n});L.current.exportData=()=>[[s],{valid:F}],L.current.currentPageResult=d(l({},s),{toolName:Jt.LLMMultiWheel,valid:F})}),rt=t=>{if(t.ctrlKey&&t.keyCode===pe.Enter){if(D){D(()=>R(B()));return}R(B())}},Et=z(({order:t,value:e,key:n})=>{const{answerList:s}=b,f=s==null?void 0:s.map(a=>{var w,j;if((a==null?void 0:a.order)===t){if(n==="textEdit"&&Gt(e)&&st)return tt(d(l({},et),{[`${P}-${(w=a==null?void 0:a.id)!=null?w:""}`]:e})),d(l({},a),{newAnswer:e});if(Kt(e))return d(l({},a),{score:e});if(zt(e)&&n){const u={[e==null?void 0:e.key]:e.value},E=(j=a[n])!=null?j:{};return d(l({},a),{[n]:l(l({},E),u)})}}return a});Y(a=>d(l({},a),{[P]:d(l({},b),{answerList:f})}))}),I=(t,e)=>{Z(n=>d(l({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:st,dialogSort:h=!1,inputList:G=[],tagInputListConfigurable:at,enableSort:Mt=!1}=i||{},V=N(()=>{var t,e,n;return h?(n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map((s,f)=>d(l({},s),{title:f+1})))!=null?n:[]:[]},[o,h]);if(N(()=>Ht(i),[i]))return r.createElement(Xt,null);const At=at&&((m=G.filter(t=>!t.isOverall))==null?void 0:m.length)>0,Tt=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||st||At;return r.createElement("div",{className:`${Lt}`},r.createElement("div",{className:`${Lt}__content`},r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("GlobalAnnotation")),h&&r.createElement(le,{waitSortList:(_==null?void 0:_.waitSorts)||[],sortList:(_==null?void 0:_.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(s=>s.id));I("sort",e),q(d(l({},_),{newSort:t}))},disabeledAll:y,title:S("SortConversationQuality"),prefixId:"model"}),(i==null?void 0:i.text)&&r.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},r.createElement(Yt,{textAttribute:(U=g==null?void 0:g.textAttribute)!=null?U:[],textConfig:(i==null?void 0:i.text)&&Ut(i.text)?i==null?void 0:i.text:[],setText:t=>I("textAttribute",t),disabeledAll:y})),Mt&&r.createElement(Wt,{modelData:(J=(Q=o==null?void 0:o.questionList)==null?void 0:Q.textList)!=null?J:[],selectedAnswerSort:t=>I("answerSort",t),selectedSort:(H=x==null?void 0:x.answerSort)!=null?H:[],ref:k,disabeledAll:y,imgIndex:M}),at&&G.length&&r.createElement(ie,{inputList:G,selectedTags:(g==null?void 0:g.tagList)||{},updateValue:t=>{const{key:e,value:n}=t,s=(g==null?void 0:g.tagList)||{};I("tagList",d(l({},s),{[e]:n}))},disabeledAll:y}),b&&r.createElement(r.Fragment,null,r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("QualifiedAnnotation")),r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},r.createElement(mt,{type:"primary",danger:!0},S("Annotating")),r.createElement("div",{style:{padding:16}},S("Group"),"\uFF1A",b.order)),r.createElement("div",null,Tt&&r.createElement(Zt,{list:(b==null?void 0:b.answerList)||[],LLMConfig:i,updateValue:Et,disabeledAll:y})))),r.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(W==null?void 0:W.length)-1!==M&&r.createElement(mt,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(D){D(()=>R(B()));return}R(B())},disabled:y},S("Save"))))},ve=p=>({annotation:p.annotation});var Le=Nt(ve,null,null,{context:Vt})(fe);export{Le as default};
@@ -1 +1 @@
1
- import a,{useContext as $,useState as v,useEffect as u}from"react";import{connect as U}from"react-redux";import{LabelBeeContext as B,LLMContext as K}from"../../store/ctx.js";import{message as W}from"antd";import{ELLMDataType as L,prefix as z}from"../../constant/index.js";import{Layout as G}from"antd/es";import H from"./questionView/index.js";import{useTranslation as J}from"react-i18next";import O from"../../views/MainView/annotationTips/index.js";import{getCurrentResultFromResultList as X}from"./utils/data.js";import{getStepConfig as Y}from"../../store/annotation/reducer.js";import{jsonParser as Z}from"../../utils/index.js";import ee from"../messageMaskLayer/index.js";const q=`${z}-LLMView`,te=g=>{var x;const{annotation:M,checkMode:T=!0,tips:A,showTips:E,drawLayerSlot:I}=g,{imgIndex:n,imgList:s,stepList:w,step:d,toolInstance:l}=M,{hoverKey:R,modelAPIResponse:P,setModelAPIResponse:_,newAnswerList:c}=$(K),[V,S]=v([]),[h,k]=v(""),[t,Q]=v(),{t:y}=J(),[,b]=v(0);return u(()=>{let e;if(!T)return e=setInterval(()=>{W.info(y("EfficientListening"))},1e3*60),()=>{e&&clearInterval(e)}},[]),u(()=>{if(l)return l.on("validUpdated",()=>{b(e=>e+1)}),()=>{l.unbindAll("validUpdated")}},[l]),u(()=>{var e,o,i,r,j,C;if(!s[n])return;const D=((e=t==null?void 0:t.dataType)==null?void 0:e.prompt)===L.Picture,F=((o=t==null?void 0:t.dataType)==null?void 0:o.response)===L.Picture,m=(i=s[n])==null?void 0:i.questionList,p=(r=s[n])==null?void 0:r.llmFile,N=D?p==null?void 0:p.question:m==null?void 0:m.question;k(N);let f=(m==null?void 0:m.answerList)||[];F&&(f=(p==null?void 0:p.answerList)||[]),((j=t==null?void 0:t.dataType)==null?void 0:j.response)===L.None&&(f=[]),((C=t==null?void 0:t.dataType)==null?void 0:C.response)===L.Text&&(c==null?void 0:c.length)>0&&(f=c),S(f)},[n,c,t,(x=s[n])==null?void 0:x.id]),u(()=>{var e;if(!s[n])return;const o=(e=s[n])!=null?e:{},i=X(o==null?void 0:o.result,d),r=(i==null?void 0:i.length)>0?i[0]:i;_((r==null?void 0:r.modelAPIResponse)||[])},[n]),u(()=>{var e;if(w&&d){const o=(e=Y(w,d))==null?void 0:e.config;Q(Z(o))}},[w,d]),a.createElement(G,{className:q},!(l==null?void 0:l.valid)&&a.createElement(ee,{message:y("InvalidQuestionAndSkip")}),I==null?void 0:I({}),a.createElement("div",{className:`${q}-question`},E===!0&&a.createElement(O,{tips:A}),a.createElement(H,{hoverKey:R,question:h,answerList:V,modelAPIResponse:P,setModelAPIResponse:_,checkMode:T,annotation:M,LLMConfig:t})))},ne=g=>({annotation:g.annotation});var oe=U(ne,null,null,{context:B})(te);export{oe as default};
1
+ import u,{useContext as W,useState as L,useEffect as d}from"react";import{connect as z}from"react-redux";import{LabelBeeContext as G,LLMContext as H}from"../../store/ctx.js";import{message as J}from"antd";import{ELLMDataType as r,prefix as O}from"../../constant/index.js";import{Layout as X}from"antd/es";import Y from"./questionView/index.js";import{useTranslation as Z}from"react-i18next";import ee from"../../views/MainView/annotationTips/index.js";import{getCurrentResultFromResultList as te}from"./utils/data.js";import{getStepConfig as ne}from"../../store/annotation/reducer.js";import{jsonParser as oe}from"../../utils/index.js";import ie from"../messageMaskLayer/index.js";const E=`${O}-LLMView`,se=g=>{var x;const{annotation:M,checkMode:T=!0,tips:R,showTips:P,drawLayerSlot:I}=g,{imgIndex:n,imgList:s,stepList:w,step:c,toolInstance:l}=M,{hoverKey:V,modelAPIResponse:h,setModelAPIResponse:_,newAnswerList:m}=W(H),[S,k]=L([]),[Q,b]=L(""),[e,D]=L(),{t:y}=Z(),[,F]=L(0);return d(()=>{let t;if(!T)return t=setInterval(()=>{J.info(y("EfficientListening"))},1e3*60),()=>{t&&clearInterval(t)}},[]),d(()=>{if(l)return l.on("validUpdated",()=>{F(t=>t+1)}),()=>{l.unbindAll("validUpdated")}},[l]),d(()=>{var t,o,i,a,A,j,q,C;if(!s[n])return;const N=((t=e==null?void 0:e.dataType)==null?void 0:t.prompt)===r.Picture,$=((o=e==null?void 0:e.dataType)==null?void 0:o.prompt)===r.Audio,U=((i=e==null?void 0:e.dataType)==null?void 0:i.response)===r.Picture,B=((a=e==null?void 0:e.dataType)==null?void 0:a.response)===r.Audio,p=(A=s[n])==null?void 0:A.questionList,v=(j=s[n])==null?void 0:j.llmFile,K=N||$?v==null?void 0:v.question:p==null?void 0:p.question;b(K);let f=(p==null?void 0:p.answerList)||[];(U||B)&&(f=(v==null?void 0:v.answerList)||[]),((q=e==null?void 0:e.dataType)==null?void 0:q.response)===r.None&&(f=[]),((C=e==null?void 0:e.dataType)==null?void 0:C.response)===r.Text&&(m==null?void 0:m.length)>0&&(f=m),k(f)},[n,m,e,(x=s[n])==null?void 0:x.id]),d(()=>{var t;if(!s[n])return;const o=(t=s[n])!=null?t:{},i=te(o==null?void 0:o.result,c),a=(i==null?void 0:i.length)>0?i[0]:i;_((a==null?void 0:a.modelAPIResponse)||[])},[n]),d(()=>{var t;if(w&&c){const o=(t=ne(w,c))==null?void 0:t.config;D(oe(o))}},[w,c]),u.createElement(X,{className:E},!(l==null?void 0:l.valid)&&u.createElement(ie,{message:y("InvalidQuestionAndSkip")}),I==null?void 0:I({}),u.createElement("div",{className:`${E}-question`},P===!0&&u.createElement(ee,{tips:R}),u.createElement(Y,{hoverKey:V,question:Q,answerList:S,modelAPIResponse:h,setModelAPIResponse:_,checkMode:T,annotation:M,LLMConfig:e})))},le=g=>({annotation:g.annotation});var re=z(le,null,null,{context:G})(se);export{re as default};
@@ -1 +1 @@
1
- import{Tag as F}from"antd";import p from"classnames";import t,{useState as L,useEffect as P,useCallback as x}from"react";import b from"../../../assets/annotation/LLMTool/loading.svg.js";import j from"../../markdownView/index.js";import{EDataFormatType as N}from"../../../constant/index.js";import{getStepConfig as R}from"../../../store/annotation/reducer.js";import{jsonParser as $}from"../../../utils/index.js";import{SyncOutlined as T,InfoCircleFilled as V}from"@ant-design/icons";import{LLMViewCls as v}from"../questionView/index.js";import{i18n as I}from"@labelbee/lb-utils";var S=(r,e,l)=>new Promise((o,m)=>{var d=n=>{try{i(l.next(n))}catch(s){m(s)}},w=n=>{try{i(l.throw(n))}catch(s){m(s)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(d,w);i((l=l.apply(r,e)).next())});const D=({dataFormatType:r,answer:e})=>r===N.Markdown?t.createElement(j,{value:e}):t.createElement("span",null,e),G=(r,e)=>{var l;return(l=e.find(o=>o.id===r))==null?void 0:l.answer},q=r=>{var e;const{annotation:l={},checkMode:o,dataFormatType:m,modelAPIResponse:d,question:w,setModelAPIResponse:i}=r,{stepList:n,step:s,toolInstance:E}=l,[_,M]=L(),[c,A]=L([]),{enableModelAPI:u=!1,modelAPIConfigList:f=[]}=_||{};P(()=>{E&&(E.loading=(c==null?void 0:c.length)>0)},[c]);const g=x(a=>{i==null||i(y=>{let h=!1;const C=y.map(k=>k.id===a.id?(h=!0,a):k);return h||C.push(a),C})},[d]);return P(()=>{var a;if(n&&s){const y=(a=R(n,s))==null?void 0:a.config;M($(y))}},[n,s]),u?(e=f==null?void 0:f.map)==null?void 0:e.call(f,a=>t.createElement(z,{dataFormatType:m,config:a,modelAPIResponse:d,key:a==null?void 0:a.id,toolInstance:E,setLoadingModelIDs:A,question:w,updateModelAPIResponse:g,checkMode:o})):null},B=()=>t.createElement("div",{className:p({[`${v}__loading`]:!0})},I.t("AnswersAreBeingGenerated"),t.createElement("img",{src:b})),O=()=>t.createElement("span",{className:p({[`${v}__failed`]:!0})},I.t("AnswerGenerationFailedPleaseTryAgainLater")," ",t.createElement(V,null)),z=({dataFormatType:r,config:e,modelAPIResponse:l,toolInstance:o,setLoadingModelIDs:m,question:d,updateModelAPIResponse:w,checkMode:i})=>{const[n,s]=L(!1),[E,_]=L(!1),M=G(e==null?void 0:e.id,l),c=u=>{s(u),m(f=>u?[...f,e==null?void 0:e.id]:f.filter(g=>g!==(e==null?void 0:e.id)))},A=()=>S(void 0,null,function*(){c(!0),_(!1);try{const u=yield o==null?void 0:o.getAPIAnswer(e,d);w({id:e==null?void 0:e.id,answer:u,name:e==null?void 0:e.name})}catch(u){_(!0)}finally{c(!1)}});return P(()=>{_(!1)},[d]),t.createElement("div",{className:p({[`${v}__content`]:!0}),key:e==null?void 0:e.id},t.createElement(F,{style:{color:"#666FFF",background:"#eeefff",height:"20px",padding:"0px 8px",border:"none"}},e==null?void 0:e.name),t.createElement("div",{className:p({[`${v}__answer`]:!0})},!n&&M&&t.createElement(D,{dataFormatType:r,answer:M}),t.createElement("div",{className:p({[`${v}__message`]:!0})},n?t.createElement(B,null):E&&t.createElement(O,null)),!n&&!i&&t.createElement("div",{className:p({[`${v}__footer`]:!0})},t.createElement("span",{onClick:A},I.t("ReGenerate"),t.createElement(T,null)))))};export{q as default};
1
+ import{Tag as j}from"antd";import p from"classnames";import t,{useState as w,useEffect as P,useCallback as b}from"react";import N from"../../../assets/annotation/LLMTool/loading.svg.js";import k from"../../markdownView/index.js";import{EDataFormatType as F}from"../../../constant/index.js";import{getStepConfig as R}from"../../../store/annotation/reducer.js";import{jsonParser as $}from"../../../utils/index.js";import{SyncOutlined as V,InfoCircleFilled as S}from"@ant-design/icons";import{LLMViewCls as v}from"../questionView/index.js";import{i18n as I}from"@labelbee/lb-utils";import{convertLatexFormat as T}from"../../../utils/LLM.js";var D=(r,e,l)=>new Promise((o,m)=>{var d=n=>{try{i(l.next(n))}catch(s){m(s)}},L=n=>{try{i(l.throw(n))}catch(s){m(s)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(d,L);i((l=l.apply(r,e)).next())});const G=({dataFormatType:r,answer:e})=>r===F.Markdown?t.createElement(k,{value:e}):r===F.Latex?t.createElement(k,{value:T(e)}):t.createElement("span",null,e),q=(r,e)=>{var l;return(l=e.find(o=>o.id===r))==null?void 0:l.answer},B=r=>{var e;const{annotation:l={},checkMode:o,dataFormatType:m,modelAPIResponse:d,question:L,setModelAPIResponse:i}=r,{stepList:n,step:s,toolInstance:E}=l,[M,_]=w(),[c,A]=w([]),{enableModelAPI:u=!1,modelAPIConfigList:f=[]}=M||{};P(()=>{E&&(E.loading=(c==null?void 0:c.length)>0)},[c]);const g=b(a=>{i==null||i(y=>{let h=!1;const C=y.map(x=>x.id===a.id?(h=!0,a):x);return h||C.push(a),C})},[d]);return P(()=>{var a;if(n&&s){const y=(a=R(n,s))==null?void 0:a.config;_($(y))}},[n,s]),u?(e=f==null?void 0:f.map)==null?void 0:e.call(f,a=>t.createElement(H,{dataFormatType:m,config:a,modelAPIResponse:d,key:a==null?void 0:a.id,toolInstance:E,setLoadingModelIDs:A,question:L,updateModelAPIResponse:g,checkMode:o})):null},O=()=>t.createElement("div",{className:p({[`${v}__loading`]:!0})},I.t("AnswersAreBeingGenerated"),t.createElement("img",{src:N})),z=()=>t.createElement("span",{className:p({[`${v}__failed`]:!0})},I.t("AnswerGenerationFailedPleaseTryAgainLater")," ",t.createElement(S,null)),H=({dataFormatType:r,config:e,modelAPIResponse:l,toolInstance:o,setLoadingModelIDs:m,question:d,updateModelAPIResponse:L,checkMode:i})=>{const[n,s]=w(!1),[E,M]=w(!1),_=q(e==null?void 0:e.id,l),c=u=>{s(u),m(f=>u?[...f,e==null?void 0:e.id]:f.filter(g=>g!==(e==null?void 0:e.id)))},A=()=>D(void 0,null,function*(){c(!0),M(!1);try{const u=yield o==null?void 0:o.getAPIAnswer(e,d);L({id:e==null?void 0:e.id,answer:u,name:e==null?void 0:e.name})}catch(u){M(!0)}finally{c(!1)}});return P(()=>{M(!1)},[d]),t.createElement("div",{className:p({[`${v}__content`]:!0}),key:e==null?void 0:e.id},t.createElement(j,{style:{color:"#666FFF",background:"#eeefff",height:"20px",padding:"0px 8px",border:"none"}},e==null?void 0:e.name),t.createElement("div",{className:p({[`${v}__answer`]:!0})},!n&&_&&t.createElement(G,{dataFormatType:r,answer:_}),t.createElement("div",{className:p({[`${v}__message`]:!0})},n?t.createElement(O,null):E&&t.createElement(z,null)),!n&&!i&&t.createElement("div",{className:p({[`${v}__footer`]:!0})},t.createElement("span",{onClick:A},I.t("ReGenerate"),t.createElement(V,null)))))};export{B as default};
@@ -0,0 +1 @@
1
+ import t from"react";import{Tag as c}from"antd";import{prefix as m}from"../../../../../constant/index.js";import s from"classnames";const n=`${m}-LLMView`,u=t.memo(({url:r})=>t.createElement("audio",{controls:!0},t.createElement("source",{src:r,type:"audio/mpeg"}))),d=r=>{const{answerList:l,hoverKey:o}=r;return t.createElement("div",null,(l==null?void 0:l.length)>0&&l.map((e,a)=>t.createElement("div",{key:a,className:s({[`${n}__content`]:!0,[`${n}__contentActive`]:o===(e==null?void 0:e.order)})},t.createElement(c,{className:`${n}-tag`},e==null?void 0:e.order),t.createElement("div",null,t.createElement(u,{key:e==null?void 0:e.url,url:e==null?void 0:e.url})))))};export{d as default};
@@ -1 +1 @@
1
- import e from"react";import{useTranslation as u}from"react-i18next";import{Resizable as f}from"re-resizable";import{Radio as i,Image as g}from"antd";import{EDataFormatType as m,prefix as E}from"../../../../../constant/index.js";import{FileTextOutlined as x}from"@ant-design/icons";import w from"../../../../markdownView/index.js";import{isString as y,isObject as T}from"lodash";import{i18n as b}from"@labelbee/lb-utils";import h from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import v from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";const s=`${E}-LLMView`,c=({question:t,dataFormatType:n,isImg:a})=>{const r=y(t)?t:"",o=b.language==="en"?v:h;if(a){const l=T(t)?t==null?void 0:t.url:"";return e.createElement(g,{src:l||o,fallback:o})}return e.createElement("div",{style:{whiteSpace:"pre-wrap"}},n===m.Markdown?e.createElement(w,{value:r}):r)},F=t=>{const{question:n,dataFormatType:a,setDataFormatType:r,isImg:o}=t,l=300,{t:p}=u();return e.createElement(f,{defaultSize:{width:"100%",height:l},minHeight:l,enable:{bottom:!0},style:{padding:"26px 32px",borderBottom:"1px solid #EBEBEB",overflow:"hidden"}},e.createElement("div",{className:`${s}__title`,style:{display:"flex",justifyContent:"space-between"}},p("Title"),e.createElement(d,{dataFormatType:a,setDataFormatType:r})),e.createElement("div",{className:`${s}__headerContent`},e.createElement(c,{question:n,dataFormatType:a,isImg:o})))},d=t=>{const{dataFormatType:n,setDataFormatType:a}=t;return e.createElement("span",{style:{display:"flex"}},e.createElement(i.Group,{value:n,onChange:r=>{a(r.target.value)}},e.createElement(i.Button,{value:m.Default,style:{textAlign:"center",width:"52px"}},"</>"),e.createElement(i.Button,{value:m.Markdown,style:{textAlign:"center",width:"52px"}},e.createElement(x,null))),e.createElement("span",{style:{marginLeft:"8px",width:"4px",background:"#1890ff"}}))};export{c as RenderQuestion,d as ToggleDataFormatType,F as default};
1
+ import e from"react";import{useTranslation as x}from"react-i18next";import{Resizable as w}from"re-resizable";import{Radio as s,Image as y,Empty as c}from"antd";import{EDataFormatType as i,prefix as v}from"../../../../../constant/index.js";import{FileTextOutlined as L,FileMarkdownOutlined as T}from"@ant-design/icons";import d from"../../../../markdownView/index.js";import{isString as h,isObject as u}from"lodash";import{i18n as F}from"@labelbee/lb-utils";import b from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import M from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";import{convertLatexFormat as _}from"../../../../../utils/LLM.js";const p=`${v}-LLMView`,E=({question:t,dataFormatType:n,isImg:r,isAudio:l})=>{const o=h(t)?t:"",m=F.language==="en"?M:b;if(r){const a=u(t)?t==null?void 0:t.url:"";return e.createElement(y,{src:a||m,fallback:m})}if(l){const a=u(t)?t==null?void 0:t.url:"";return a?e.createElement("audio",{controls:!0},e.createElement("source",{src:a,type:"audio/mpeg"})):e.createElement(c,{image:c.PRESENTED_IMAGE_SIMPLE})}return e.createElement("div",{style:{whiteSpace:"pre-wrap"}},(()=>{switch(n){case i.Markdown:return e.createElement(d,{value:o});case i.Latex:return e.createElement(d,{value:_(o)});default:return o}})())},j=t=>{const{question:n,dataFormatType:r,setDataFormatType:l,isImg:o,isAudio:m}=t,a=300,{t:g}=x();return e.createElement(w,{defaultSize:{width:"100%",height:a},minHeight:a,enable:{bottom:!0},style:{padding:"26px 32px",borderBottom:"1px solid #EBEBEB",overflow:"hidden"}},e.createElement("div",{className:`${p}__title`,style:{display:"flex",justifyContent:"space-between"}},g("Title"),e.createElement(f,{dataFormatType:r,setDataFormatType:l})),e.createElement("div",{className:`${p}__headerContent`},e.createElement(E,{question:n,dataFormatType:r,isImg:o,isAudio:m})))},f=t=>{const{dataFormatType:n,setDataFormatType:r}=t;return e.createElement("span",{style:{display:"flex"}},e.createElement(s.Group,{value:n,onChange:l=>{r(l.target.value)}},e.createElement(s.Button,{value:i.Default,style:{textAlign:"center",width:"52px"}},"</>"),e.createElement(s.Button,{value:i.Markdown,style:{textAlign:"center",width:"52px"}},e.createElement(L,null)),e.createElement(s.Button,{value:i.Latex,style:{textAlign:"center",width:"52px"}},e.createElement(T,null))),e.createElement("span",{style:{marginLeft:"8px",width:"4px",background:"#1890ff"}}))};export{E as RenderQuestion,f as ToggleDataFormatType,j as default};
@@ -1 +1 @@
1
- import n,{useState as M,useEffect as O}from"react";import{Tag as S}from"antd";import{prefix as N,EDataFormatType as u,ELLMDataType as p}from"../../../constant/index.js";import $ from"classnames";import{I18nextProvider as k,useTranslation as C}from"react-i18next";import{i18n as v}from"@labelbee/lb-utils";import D from"../../markdownView/index.js";import L from"../modelAPIView/index.js";import R from"../../diffMatchPatchComponent/index.js";import F from"./components/header/index.js";import W from"./components/imgView/index.js";import{isString as q}from"lodash";var B=Object.defineProperty,w=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,f=(e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,K=(e,t)=>{for(var r in t||(t={}))H.call(t,r)&&f(e,r,t[r]);if(w)for(var r of w(t))Q.call(t,r)&&f(e,r,t[r]);return e};const a=`${N}-LLMView`,_=({i:e,dataFormatType:t,isTextControl:r})=>{var l;return t===u.Markdown?n.createElement(D,{value:(l=e==null?void 0:e.newAnswer)!=null?l:e==null?void 0:e.answer}):r?n.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},n.createElement(R,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):n.createElement("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"break-word"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},E=(e,t)=>{var r;return(t==null?void 0:t.isTextEdit)?!!((r=((t==null?void 0:t.textEdit)||[]).filter(s=>(s==null?void 0:s.title)===e.order)[0])==null?void 0:r.textControl):!1},z=e=>{var t,r;const{hoverKey:l,answerList:s,question:m,lang:c,modelAPIResponse:x,setModelAPIResponse:g,checkMode:y=!0,LLMConfig:i,answerHeaderSlot:P}=e,[d,h]=M(u.Default),I=((t=i==null?void 0:i.dataType)==null?void 0:t.prompt)===p.Picture,A=((r=i==null?void 0:i.dataType)==null?void 0:r.response)===p.Picture,{t:T}=C();O(()=>{var o;c&&((o=v)==null||o.changeLanguage(c))},[]);const V=n.createElement("div",null,s.map((o,b)=>{const j=E(o,i);return n.createElement("div",{className:$({[`${a}__content`]:!0,[`${a}__contentActive`]:l===(o==null?void 0:o.order)}),key:b},n.createElement(S,{className:`${a}-tag`},o==null?void 0:o.order),n.createElement(_,{i:o,isTextControl:j,dataFormatType:d}))}),q(m)&&n.createElement(L,{dataFormatType:d,modelAPIResponse:x,question:m,setModelAPIResponse:g,checkMode:y,annotation:e.annotation}));return n.createElement("div",{className:a},n.createElement(F,{question:m,dataFormatType:d,setDataFormatType:h,isImg:I}),n.createElement("div",{className:`${a}__textBox`},n.createElement("div",{className:`${a}__title`},T("Answer")," ",P),A?n.createElement(W,{hoverKey:l,answerList:s}):V))},G=e=>n.createElement(k,{i18n:v},n.createElement(z,K({},e)));export{a as LLMViewCls,_ as RenderAnswer,G as default,E as getTextControlByConfig};
1
+ import n,{useState as $,useEffect as k}from"react";import{Tag as D}from"antd";import{prefix as R,EDataFormatType as v,ELLMDataType as d}from"../../../constant/index.js";import q from"classnames";import{I18nextProvider as F,useTranslation as W}from"react-i18next";import{i18n as f}from"@labelbee/lb-utils";import _ from"../../markdownView/index.js";import B from"../modelAPIView/index.js";import H from"../../diffMatchPatchComponent/index.js";import Q from"./components/header/index.js";import K from"./components/imgView/index.js";import{isString as z}from"lodash";import G from"./components/audioView/index.js";import{convertLatexFormat as J}from"../../../utils/LLM.js";var U=Object.defineProperty,E=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,x=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Z=(e,t)=>{for(var r in t||(t={}))X.call(t,r)&&x(e,r,t[r]);if(E)for(var r of E(t))Y.call(t,r)&&x(e,r,t[r]);return e};const i=`${R}-LLMView`,g=({i:e,dataFormatType:t,isTextControl:r})=>{var s,l;return t===v.Markdown?n.createElement(_,{value:(s=e==null?void 0:e.newAnswer)!=null?s:e==null?void 0:e.answer}):t===v.Latex?n.createElement(_,{value:J((l=e==null?void 0:e.newAnswer)!=null?l:e==null?void 0:e.answer)}):r?n.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},n.createElement(H,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):n.createElement("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"break-word"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},y=(e,t)=>{var r;return(t==null?void 0:t.isTextEdit)?!!((r=((t==null?void 0:t.textEdit)||[]).filter(l=>(l==null?void 0:l.title)===e.order)[0])==null?void 0:r.textControl):!1},ee=e=>{var t,r,s,l;const{hoverKey:m,answerList:u,question:c,lang:w,modelAPIResponse:A,setModelAPIResponse:P,checkMode:I=!0,LLMConfig:o,answerHeaderSlot:h}=e,[p,V]=$(v.Default),T=((t=o==null?void 0:o.dataType)==null?void 0:t.prompt)===d.Picture,j=((r=o==null?void 0:o.dataType)==null?void 0:r.response)===d.Picture,b=((s=o==null?void 0:o.dataType)==null?void 0:s.prompt)===d.Audio,M=((l=o==null?void 0:o.dataType)==null?void 0:l.response)===d.Audio,{t:L}=W();k(()=>{var a;w&&((a=f)==null||a.changeLanguage(w))},[]);const O=n.createElement("div",null,u.map((a,N)=>{const C=y(a,o);return n.createElement("div",{className:q({[`${i}__content`]:!0,[`${i}__contentActive`]:m===(a==null?void 0:a.order)}),key:N},n.createElement(D,{className:`${i}-tag`},a==null?void 0:a.order),n.createElement(g,{i:a,isTextControl:C,dataFormatType:p}))}),z(c)&&n.createElement(B,{dataFormatType:p,modelAPIResponse:A,question:c,setModelAPIResponse:P,checkMode:I,annotation:e.annotation})),S=()=>M?n.createElement(G,{hoverKey:m,answerList:u}):j?n.createElement(K,{hoverKey:m,answerList:u}):O;return n.createElement("div",{className:i},n.createElement(Q,{question:c,dataFormatType:p,setDataFormatType:V,isImg:T,isAudio:b}),n.createElement("div",{className:`${i}__textBox`},n.createElement("div",{className:`${i}__title`},L("Answer")," ",h),S()))},te=e=>n.createElement(F,{i18n:f},n.createElement(ee,Z({},e)));export{i as LLMViewCls,g as RenderAnswer,te as default,y as getTextControlByConfig};
@@ -1,2 +1,2 @@
1
- import e,{useEffect as j}from"react";import{Form as m,Popover as C,Input as N,message as S}from"antd";import{useTranslation as A}from"react-i18next";import{InfoCircleOutlined as B}from"@ant-design/icons";import M from"../../../../markdownView/index.js";import O from"../../../../latexEditor/index.js";import c from"./index.module.scss.js";import R from"../../../../longText/index.js";const k=w=>{const{disabeledAll:x,newAnswer:E,textEditObject:b,updateValue:f,answerIndex:g}=w,{max:a,min:u,isLaText:v,tip:h}=b,{TextArea:y}=N,[l]=m.useForm(),{t:o}=A(),T=o("LeastCharacterError",{num:u});j(()=>{l.setFieldsValue({value:E}),x||l.validateFields()},[E]);const V=n=>{var t,d;const I=`inputTextarea_${g}`,r=document.getElementById(I),s=r.value||"",p=(t=r==null?void 0:r.selectionStart)!=null?t:s.length,_=(d=r.selectionEnd)!=null?d:s.length,F=s.substring(0,p),L=s.substring(_,s.length),i=F+n+L;if(a&&(i==null?void 0:i.length)>a){S.error(o("MaximumCharacterError",{num:a}));return}r.value=i,l.setFieldsValue({value:i}),f(i),r.selectionStart=p+n.length,r.selectionEnd=p+n.length,r.focus()};return e.createElement(m,{form:l,onValuesChange:(n,t)=>{const d=t.value;f(d)},className:c.form},e.createElement(m.Item,{name:"title",style:{marginBottom:0},label:e.createElement(e.Fragment,null,o("AnswerTextEdit"),e.createElement(C,{placement:"bottom",content:o("ShowEditingResultDifferencesInTextModeOnly")},e.createElement(B,{style:{margin:"0px 4px",cursor:"pointer"}}))),colon:!1,required:!!u}),e.createElement("div",{className:c.tip},e.createElement(R,{text:h!=null?h:"",overflowMaxLines:3,openByText:!0})),v&&e.createElement(O,{onSelectLatex:V,disabled:x}),e.createElement(m.Item,{name:"value",style:{marginBottom:24},rules:[{validator:(n,t="")=>u&&(t==null?void 0:t.length)<Number(u)?Promise.reject(T):Promise.resolve()}]},e.createElement(y,{maxLength:a,autoSize:{minRows:4,maxRows:10},allowClear:!0,disabled:x,showCount:!!a,style:{width:"100%"},id:`inputTextarea_${g}`})),v&&e.createElement(m.Item,{shouldUpdate:!0,noStyle:!0},()=>{const n=l.getFieldValue("value")||"",t=n.replace(/\n/g,`
2
- `);return e.createElement("div",{className:c.outputDisplay},e.createElement("div",{className:c.title},o("OutputDisplay")),e.createElement("div",{className:c.content},n?e.createElement(M,{value:t}):""))}))};export{k as default};
1
+ import e,{useEffect as j}from"react";import{Form as m,Popover as C,Input as N,message as S}from"antd";import{useTranslation as M}from"react-i18next";import{InfoCircleOutlined as A}from"@ant-design/icons";import B from"../../../../markdownView/index.js";import O from"../../../../latexEditor/index.js";import c from"./index.module.scss.js";import R from"../../../../longText/index.js";import{convertLatexFormat as k}from"../../../../../utils/LLM.js";const D=w=>{const{disabeledAll:x,newAnswer:E,textEditObject:b,updateValue:f,answerIndex:g}=w,{max:a,min:u,isLaText:v,tip:h}=b,{TextArea:y}=N,[l]=m.useForm(),{t:o}=M(),T=o("LeastCharacterError",{num:u});j(()=>{l.setFieldsValue({value:E}),x||l.validateFields()},[E]);const L=n=>{var t,d;const V=`inputTextarea_${g}`,r=document.getElementById(V),s=r.value||"",p=(t=r==null?void 0:r.selectionStart)!=null?t:s.length,F=(d=r.selectionEnd)!=null?d:s.length,I=s.substring(0,p),_=s.substring(F,s.length),i=I+n+_;if(a&&(i==null?void 0:i.length)>a){S.error(o("MaximumCharacterError",{num:a}));return}r.value=i,l.setFieldsValue({value:i}),f(i),r.selectionStart=p+n.length,r.selectionEnd=p+n.length,r.focus()};return e.createElement(m,{form:l,onValuesChange:(n,t)=>{const d=t.value;f(d)},className:c.form},e.createElement(m.Item,{name:"title",style:{marginBottom:0},label:e.createElement(e.Fragment,null,o("AnswerTextEdit"),e.createElement(C,{placement:"bottom",content:o("ShowEditingResultDifferencesInTextModeOnly")},e.createElement(A,{style:{margin:"0px 4px",cursor:"pointer"}}))),colon:!1,required:!!u}),e.createElement("div",{className:c.tip},e.createElement(R,{text:h!=null?h:"",overflowMaxLines:3,openByText:!0})),v&&e.createElement(O,{onSelectLatex:L,disabled:x}),e.createElement(m.Item,{name:"value",style:{marginBottom:24},rules:[{validator:(n,t="")=>u&&(t==null?void 0:t.length)<Number(u)?Promise.reject(T):Promise.resolve()}]},e.createElement(y,{maxLength:a,autoSize:{minRows:4,maxRows:10},allowClear:!0,disabled:x,showCount:!!a,style:{width:"100%"},id:`inputTextarea_${g}`})),v&&e.createElement(m.Item,{shouldUpdate:!0,noStyle:!0},()=>{const n=l.getFieldValue("value")||"",t=n.replace(/\n/g,`
2
+ `);return e.createElement("div",{className:c.outputDisplay},e.createElement("div",{className:c.title},o("OutputDisplay")),e.createElement("div",{className:c.content},n?e.createElement(B,{value:k(t)}):""))}))};export{D as default};
@@ -1,2 +1,2 @@
1
- import t,{useEffect as V}from"react";import{Form as g,Input as j,message as F}from"antd";import L from"classnames";import{useTranslation as N}from"react-i18next";import S from"../../../../latexEditor/index.js";import E from"./index.module.scss.js";import C from"../../../../markdownView/index.js";import B from"../../../../longText/index.js";var D=Object.defineProperty,A=Object.defineProperties,R=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,P=(a,e,r)=>e in a?D(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,$=(a,e)=>{for(var r in e||(e={}))k.call(e,r)&&P(a,r,e[r]);if(b)for(var r of b(e))M.call(e,r)&&P(a,r,e[r]);return a},q=(a,e)=>A(a,R(e));const z=a=>{const{disabeledAll:e,textConfig:r,textAttribute:w,setText:T}=a,{TextArea:I}=j,[v]=g.useForm(),{t:y}=N();V(()=>{const s=r.map((c,n)=>{var d;const m=(w==null?void 0:w.filter(o=>(o==null?void 0:o.textId)===(c==null?void 0:c.textId)))||[];return q($({},c),{value:(d=m[0])==null?void 0:d.value})});v.setFieldsValue({text:s})},[r,w]);const O=({newText:s,fieldName:c,max:n})=>{var d,m;const o=`textInput_${c}`,l=document.getElementById(o),u=l.value||"",f=(d=l==null?void 0:l.selectionStart)!=null?d:u.length,p=(m=l.selectionEnd)!=null?m:u.length,_=u.substring(0,f),x=u.substring(p,u.length),i=_+s+x;if(n&&(i==null?void 0:i.length)>n){F.error(y("MaximumCharacterError",{num:n}));return}l.value=i,v.setFields([{name:["text",c,"value"],value:i,errors:[]}]),h(),l.selectionStart=f+s.length,l.selectionEnd=f+s.length,l.focus()},h=()=>{const s=v.getFieldValue("text");T(s)};return t.createElement(g,{form:v},t.createElement(g.List,{name:"text"},(s,c)=>t.createElement(t.Fragment,null,s.map((n,d)=>{const{max:m,min:o,title:l,tip:u,isLaText:f}=r[n.name]||{},p=l,_=y("LeastCharacterError",{num:o});return t.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:"16px"},key:d},p&&t.createElement(g.Item,{name:[n.name,"title"],extra:t.createElement(B,{text:u!=null?u:"",overflowMaxLines:3,openByText:!0}),className:E.textTitle,required:!!o,label:" ",colon:!1},l,p&&t.createElement("span",{className:L({clearText:!0,clearText__disabled:e}),style:{verticalAlign:"initial"},onClick:()=>{e||(v.setFields([{name:["text",n.name,"value"],value:void 0,errors:o?[_]:[]}]),h())}})),f&&p&&t.createElement(S,{onSelectLatex:x=>O({newText:x,fieldName:n.name,max:m}),disabled:e}),p&&t.createElement(g.Item,{name:[n.name,"value"],style:{marginBottom:24},rules:[{validator:(x,i)=>o&&(i==null?void 0:i.length)<Number(o)?Promise.reject(_):Promise.resolve()}],initialValue:void 0},t.createElement(I,{maxLength:m,disabled:e,showCount:!!m,autoSize:{minRows:4,maxRows:10},style:{width:"100%"},id:`textInput_${n.name}`,onChange:()=>h()})),f&&p&&t.createElement(g.Item,{shouldUpdate:!0,noStyle:!0},()=>{const x=v.getFieldValue(["text",n.name,"value"])||"",i=x.replace(/\n/g,`
2
- `);return t.createElement("div",{className:E.outputDisplay},t.createElement("div",{className:E.title},y("OutputDisplay")),t.createElement("div",{className:E.content},x?t.createElement(C,{value:i}):""))}))}))))};export{z as default};
1
+ import t,{useEffect as L}from"react";import{Form as g,Input as j,message as V}from"antd";import F from"classnames";import{useTranslation as N}from"react-i18next";import S from"../../../../latexEditor/index.js";import E from"./index.module.scss.js";import C from"../../../../markdownView/index.js";import B from"../../../../longText/index.js";import{convertLatexFormat as D}from"../../../../../utils/LLM.js";var A=Object.defineProperty,M=Object.defineProperties,R=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,P=(a,e,r)=>e in a?A(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,q=(a,e)=>{for(var r in e||(e={}))k.call(e,r)&&P(a,r,e[r]);if(b)for(var r of b(e))$.call(e,r)&&P(a,r,e[r]);return a},z=(a,e)=>M(a,R(e));const U=a=>{const{disabeledAll:e,textConfig:r,textAttribute:w,setText:T}=a,{TextArea:I}=j,[v]=g.useForm(),{t:y}=N();L(()=>{const s=r.map((c,n)=>{var d;const m=(w==null?void 0:w.filter(o=>(o==null?void 0:o.textId)===(c==null?void 0:c.textId)))||[];return z(q({},c),{value:(d=m[0])==null?void 0:d.value})});v.setFieldsValue({text:s})},[r,w]);const O=({newText:s,fieldName:c,max:n})=>{var d,m;const o=`textInput_${c}`,l=document.getElementById(o),u=l.value||"",f=(d=l==null?void 0:l.selectionStart)!=null?d:u.length,p=(m=l.selectionEnd)!=null?m:u.length,_=u.substring(0,f),x=u.substring(p,u.length),i=_+s+x;if(n&&(i==null?void 0:i.length)>n){V.error(y("MaximumCharacterError",{num:n}));return}l.value=i,v.setFields([{name:["text",c,"value"],value:i,errors:[]}]),h(),l.selectionStart=f+s.length,l.selectionEnd=f+s.length,l.focus()},h=()=>{const s=v.getFieldValue("text");T(s)};return t.createElement(g,{form:v},t.createElement(g.List,{name:"text"},(s,c)=>t.createElement(t.Fragment,null,s.map((n,d)=>{const{max:m,min:o,title:l,tip:u,isLaText:f}=r[n.name]||{},p=l,_=y("LeastCharacterError",{num:o});return t.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:"16px"},key:d},p&&t.createElement(g.Item,{name:[n.name,"title"],extra:t.createElement(B,{text:u!=null?u:"",overflowMaxLines:3,openByText:!0}),className:E.textTitle,required:!!o,label:" ",colon:!1},l,p&&t.createElement("span",{className:F({clearText:!0,clearText__disabled:e}),style:{verticalAlign:"initial"},onClick:()=>{e||(v.setFields([{name:["text",n.name,"value"],value:void 0,errors:o?[_]:[]}]),h())}})),f&&p&&t.createElement(S,{onSelectLatex:x=>O({newText:x,fieldName:n.name,max:m}),disabled:e}),p&&t.createElement(g.Item,{name:[n.name,"value"],style:{marginBottom:24},rules:[{validator:(x,i)=>o&&(i==null?void 0:i.length)<Number(o)?Promise.reject(_):Promise.resolve()}],initialValue:void 0},t.createElement(I,{maxLength:m,disabled:e,showCount:!!m,autoSize:{minRows:4,maxRows:10},style:{width:"100%"},id:`textInput_${n.name}`,onChange:()=>h()})),f&&p&&t.createElement(g.Item,{shouldUpdate:!0,noStyle:!0},()=>{const x=v.getFieldValue(["text",n.name,"value"])||"",i=x.replace(/\n/g,`
2
+ `);return t.createElement("div",{className:E.outputDisplay},t.createElement("div",{className:E.title},y("OutputDisplay")),t.createElement("div",{className:E.content},x?t.createElement(C,{value:D(i)}):""))}))}))))};export{U as default};
@@ -1 +1 @@
1
- import K from"../../assets/attributeIcon/icon_eyeLock_a.svg.js";import B from"../../assets/attributeIcon/icon_eyeLock_h.svg.js";import{COLORS_ARRAY as b,NULL_COLOR as F}from"../../data/Style.js";import{ColorTag as G}from"../colorTag/index.js";import{Radio as y}from"antd/es";import n,{useState as C,useEffect as H}from"react";import{Popover as M,message as W}from"antd";import Y from"../colorPalette/index.js";import{CloseOutlined as $}from"@ant-design/icons";import{useTranslation as q}from"react-i18next";import J from"./components/limitPopover/index.js";import E from"lodash";import{CommonToolUtils as Q,MathUtils as s}from"@labelbee/lb-annotation";const R=[F].concat(b),X=n.forwardRef((e,_)=>{const w=n.useRef(),{t:g}=q(),A=e.list||[],[P,m]=C(!1),[T,D]=C(void 0),[c,I]=C([]);let d=[...R];e.forbidDefault===!0&&(d=d.slice(1));let k="sensebee-radio-group";e.noHeightLimit&&(k="sensebee-radio-group-no-limit-height");const L=t=>{var l,u;if(!Q.hotkeyFilter(t)||(e==null?void 0:e.forbidColor))return;let o=t.keyCode;e.forbidDefault===!0&&(o=o-1);let i;if(s.isInRange(t.keyCode,[48,57])&&(i=e.list[o-48]),s.isInRange(t.keyCode,[96,105])&&(i=e.list[o-96]),t.shiftKey&&i){if(!(e==null?void 0:e.attributeLockChange))return;f(t,i),t.preventDefault();return}(s.isInRange(t.keyCode,[48,57])||s.isInRange(t.keyCode,[96,105]))&&((u=e==null?void 0:e.attributeChanged)==null||u.call(e,(l=i==null?void 0:i.value)!=null?l:""))};H(()=>(window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)));const O=(t,l)=>{e.updateColorConfig&&e.updateColorConfig(t,l)},S=(t,l)=>{if(t.shiftKey&&(e==null?void 0:e.attributeLockChange)){f(t,l);return}e.attributeChanged(t.target.value)},j=E.debounce(S,100),f=(t,l)=>{var u;if(e==null?void 0:e.forbidColor)return;const o=c.includes(l.value);let i=E.cloneDeep(c);o?i=i.filter(a=>a!==l.value):i.push(l.value),I(i),(u=e==null?void 0:e.attributeLockChange)==null||u.call(e,i),o||W.success(g("AttributeLockNotify",{label:l.label})),t.preventDefault()};return n.createElement("div",{className:k,style:e.style},n.createElement(y.Group,{name:"radiogroup",defaultValue:e==null?void 0:e.selectedAttribute,value:e==null?void 0:e.selectedAttribute,ref:_},A.map((t,l)=>{var u,o,i;let a=(u=e==null?void 0:e.num)!=null?u:l;const N=(t==null?void 0:t.value)===(e==null?void 0:e.selectedAttribute);e.forbidDefault===!0&&typeof a=="number"&&a++,typeof a=="number"&&a<=9&&a>=0||(a="-");let v=l>8&&!e.forbidDefault?b[(l-1)%b.length]:d[l%d.length];(t==null?void 0:t.color)&&(v=t.color);const{defaultSize:z,logicalCondition:h,sizeRange:U}=((o=t==null?void 0:t.limit)==null?void 0:o.sizeLimit)||{},V=((i=t==null?void 0:t.limit)==null?void 0:i.positionLimit)||z||U||(h==null?void 0:h.length)>0,x=N&&V&&e.forbidShowLimitPopover!==!0;return n.createElement(y,{value:t.value,ref:w,key:t.label+l,onClick:r=>j(r,t)},n.createElement("span",{className:"sensebee-radio-label",title:t.label},!(e==null?void 0:e.forbidColor)&&n.createElement(M,{content:n.createElement(Y,{defaultColor:v,setColor:r=>O(t.value,r)}),title:n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},n.createElement("span",null,g("Palette")),n.createElement($,{onClick:()=>m(!1)})),visible:P&&T===l,onVisibleChange:r=>{!r||m(r)}},n.createElement(G,{color:v,style:{cursor:"pointer",marginRight:"8px"},onClick:()=>{(e==null?void 0:e.enableColorPicker)&&(D(l),m(!0))}})),t.label),!(e==null?void 0:e.forbidColor)&&(e==null?void 0:e.attributeLockChange)&&n.createElement("img",{onClick:r=>f(r,t),src:c.includes(t.value)?K:B,style:{display:c.includes(t.value)?"inline-block":""},className:"sensebee-radio-icon"}),x&&n.createElement(J,{limit:t.limit,updateSize:e==null?void 0:e.updateSize}),n.createElement("span",{className:"sensebee-radio-num"},a))})))});export{R as ATTRIBUTE_COLORS,X as default};
1
+ import B from"../../assets/attributeIcon/icon_eyeLock_a.svg.js";import F from"../../assets/attributeIcon/icon_eyeLock_h.svg.js";import{COLORS_ARRAY as b,NULL_COLOR as G}from"../../data/Style.js";import{ColorTag as H}from"../colorTag/index.js";import{Radio as y}from"antd/es";import n,{useState as C,useEffect as M}from"react";import{Popover as W,message as Y}from"antd";import $ from"../colorPalette/index.js";import{CloseOutlined as q}from"@ant-design/icons";import{useTranslation as J}from"react-i18next";import Q from"./components/limitPopover/index.js";import X from"lodash";import{CommonToolUtils as Z,MathUtils as s}from"@labelbee/lb-annotation";import{useDebounceFn as E}from"ahooks";const R=[G].concat(b),p=n.forwardRef((e,_)=>{const w=n.useRef(),{t:g}=J(),A=e.list||[],[D,m]=C(!1),[P,T]=C(void 0),[c,I]=C([]);let d=[...R];e.forbidDefault===!0&&(d=d.slice(1));let k="sensebee-radio-group";e.noHeightLimit&&(k="sensebee-radio-group-no-limit-height");const O=t=>{var l,u;if(!Z.hotkeyFilter(t)||(e==null?void 0:e.forbidColor))return;let o=t.keyCode;e.forbidDefault===!0&&(o=o-1);let i;if(s.isInRange(t.keyCode,[48,57])&&(i=e.list[o-48]),s.isInRange(t.keyCode,[96,105])&&(i=e.list[o-96]),t.shiftKey&&i){if(!(e==null?void 0:e.attributeLockChange))return;f(t,i),t.preventDefault();return}(s.isInRange(t.keyCode,[48,57])||s.isInRange(t.keyCode,[96,105]))&&((u=e==null?void 0:e.attributeChanged)==null||u.call(e,(l=i==null?void 0:i.value)!=null?l:""))},{run:L}=E(O,{wait:200});M(()=>(window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)));const S=(t,l)=>{e.updateColorConfig&&e.updateColorConfig(t,l)},j=(t,l)=>{if(t.shiftKey&&(e==null?void 0:e.attributeLockChange)){f(t,l);return}e.attributeChanged(t.target.value)},{run:N}=E(j,{wait:100}),f=(t,l)=>{var u;if(e==null?void 0:e.forbidColor)return;const o=c.includes(l.value);let i=X.cloneDeep(c);o?i=i.filter(a=>a!==l.value):i.push(l.value),I(i),(u=e==null?void 0:e.attributeLockChange)==null||u.call(e,i),o||Y.success(g("AttributeLockNotify",{label:l.label})),t.preventDefault()};return n.createElement("div",{className:k,style:e.style},n.createElement(y.Group,{name:"radiogroup",defaultValue:e==null?void 0:e.selectedAttribute,value:e==null?void 0:e.selectedAttribute,ref:_},A.map((t,l)=>{var u,o,i;let a=(u=e==null?void 0:e.num)!=null?u:l;const z=(t==null?void 0:t.value)===(e==null?void 0:e.selectedAttribute);e.forbidDefault===!0&&typeof a=="number"&&a++,typeof a=="number"&&a<=9&&a>=0||(a="-");let v=l>8&&!e.forbidDefault?b[(l-1)%b.length]:d[l%d.length];(t==null?void 0:t.color)&&(v=t.color);const{defaultSize:U,logicalCondition:h,sizeRange:V}=((o=t==null?void 0:t.limit)==null?void 0:o.sizeLimit)||{},x=((i=t==null?void 0:t.limit)==null?void 0:i.positionLimit)||U||V||(h==null?void 0:h.length)>0,K=z&&x&&e.forbidShowLimitPopover!==!0;return n.createElement(y,{value:t.value,ref:w,key:t.label+l,onClick:r=>N(r,t)},n.createElement("span",{className:"sensebee-radio-label",title:t.label},!(e==null?void 0:e.forbidColor)&&n.createElement(W,{content:n.createElement($,{defaultColor:v,setColor:r=>S(t.value,r)}),title:n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},n.createElement("span",null,g("Palette")),n.createElement(q,{onClick:()=>m(!1)})),visible:D&&P===l,onVisibleChange:r=>{!r||m(r)}},n.createElement(H,{color:v,style:{cursor:"pointer",marginRight:"8px"},onClick:()=>{(e==null?void 0:e.enableColorPicker)&&(T(l),m(!0))}})),t.label),!(e==null?void 0:e.forbidColor)&&(e==null?void 0:e.attributeLockChange)&&n.createElement("img",{onClick:r=>f(r,t),src:c.includes(t.value)?B:F,style:{display:c.includes(t.value)?"inline-block":""},className:"sensebee-radio-icon"}),K&&n.createElement(Q,{limit:t.limit,updateSize:e==null?void 0:e.updateSize}),n.createElement("span",{className:"sensebee-radio-num"},a))})))});export{R as ATTRIBUTE_COLORS,p as default};
@@ -1 +1 @@
1
- import r,{useState as M,useEffect as V,useMemo as re}from"react";import{AudioPlayer as Oe}from"../audioPlayer/index.js";import{getClassName as ke}from"../../utils/dom.js";import Ne from"../predictTracking/previewResult/index.js";import{Layout as ae}from"antd/es";import{Spin as De}from"antd";import{prefix as $e}from"../../constant/index.js";import{cKeyCode as Me,CommonToolUtils as B,EventBus as ue,uuid as Ve,TagUtils as Be,cTool as Fe}from"@labelbee/lb-annotation";import U from"./index.module.scss.js";import Ke from"./tagResultShow/index.js";import{AudioClipProvider as We,DEFAULT_CLIP_TEXT_CONFIG_ITEM as Ue,useAudioClipStore as Xe}from"./audioContext/index.js";import ze from"./textInput/index.js";import{connect as Ge}from"react-redux";import{a2MapStateToProps as qe}from"../../store/annotation/map.js";import{LabelBeeContext as He}from"../../store/ctx.js";import{jsonParser as Je}from"../../utils/index.js";import{useCustomToolInstance as Qe}from"../../hooks/annotation.js";import{sidebarCls as Z}from"../../views/MainView/sidebar/index.js";import Ye from"./audioSide/labelSidebar/index.js";import Ze from"./audioSide/clipSidebar/index.js";import et from"../../assets/annotation/audio/tag.svg.js";import tt from"../../assets/annotation/audio/tagA.svg.js";import ot from"../../assets/annotation/audio/clip.svg.js";import nt from"../../assets/annotation/audio/clipA.svg.js";import{isImageValue as it}from"../../utils/audio.js";import lt from"./utils/dataTransform.js";import{useMemoizedFn as ce}from"ahooks";var st=Object.defineProperty,rt=Object.defineProperties,at=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,fe=(o,n,a)=>n in o?st(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a,R=(o,n)=>{for(var a in n||(n={}))ut.call(n,a)&&fe(o,a,n[a]);if(de)for(var a of de(n))ct.call(n,a)&&fe(o,a,n[a]);return o},F=(o,n)=>rt(o,at(n));const{EAudioToolName:dt}=Fe,me=Me.default,{Sider:ft,Content:mt}=ae,pe=`${$e}-layout`,pt=({setSideTab:o,sideTab:n})=>{const a=[{tab:"tag",commonSvg:et,selectedSvg:tt},{tab:"clip",commonSvg:ot,selectedSvg:nt}];return r.createElement("div",{className:U.toggleAudioOption},a.map((m,y)=>{const{tab:d,selectedSvg:_,commonSvg:T}=m;return r.createElement("div",{key:y,className:U.option},r.createElement("img",{className:U.icon,src:n===d?_:T,onClick:()=>{n!==d&&o(d)}}))}))},gt=({result:o,inputDisabled:n,updateText:a,configList:m,autofocus:y,preContext:d,isCheck:_,clipAttributeConfigurable:T,clipTextConfigurable:k,textConfigurable:b,updateRegion:E,clipAttributeList:f,clipTextList:p})=>r.createElement(ze,{isCheck:_,result:o==null?void 0:o.value,textInputDisabled:n,textID:(o==null?void 0:o.id)||0,updateText:a,configList:m,autofocus:!n&&y,preContext:d,regions:o==null?void 0:o.regions,clipAttributeConfigurable:T,clipTextConfigurable:k,textConfigurable:b,updateRegion:E,clipAttributeList:f,clipTextList:p}),vt=o=>{var n,a;const{sider:m,config:y,result:d,updateTagResult:_,updateRegion:T,isEdit:k,tagConfigurable:b,clipConfigurable:E}=o;let f=(y==null?void 0:y.inputList)||[],p=(n=d==null?void 0:d.tag)!=null?n:{},u=(a=d==null?void 0:d.regions)!=null?a:[];const[X,w]=M([]),[x,g]=M("tag");V(()=>{if(!b&&E){g("clip");return}g("tag")},[b,E]),V(()=>(window.addEventListener("keydown",N),()=>{window.removeEventListener("keydown",N)}));const N=t=>{if(b&&E)switch(t.keyCode){case me.L:g("tag");break;case me.X:g("clip");break}if(x==="tag"){if(!B.hotkeyFilter(t))return;B.isMoveKey(t==null?void 0:t.keyCode)&&t.preventDefault();let i=t.keyCode;if(i&&(i<=57&&i>=49||i<=105&&i>=97)){i>57?i=i-97:i=i-49;const h=X.slice();f.length===1?(L(0,i),w([0,i]),setTimeout(()=>{w([])},500)):h.length===1?(L(h[0],i),w([h[0],i]),setTimeout(()=>{w([])},500)):w([i])}}},L=(t,i)=>{if(t<f.length&&f[t].subSelected&&i<f[t].subSelected.length){const h=f[t].value,s=f[t].isMulti;let j=f[t].subSelected[i].value,z=0;const K=p;for(const S in p)if(S===f[t].value){if(z++,s===!0){const I=K[S].split(";").filter(q=>q!==""),v=I.indexOf(j);v===-1?I.push(j):I.splice(v,1),j=I.join(";")}j===""?delete K[S]:K[S]=j}z===0&&Object.assign(p,{[h]:j}),_(p)}},P=t=>{delete p[t],_(p)},D=b&&E&&r.createElement(pt,{setSideTab:g,sideTab:x}),A=x==="tag"&&r.createElement(Ye,{labelInfoSet:b?f:[],labelSelectedList:X,setLabel:L,tagResult:p,clearResult:P,isEdit:k,withPanelTab:!1}),$=x==="clip"&&r.createElement(Ze,{regions:u,updateRegion:T,useAudioClipStore:Xe});return m?typeof m=="function"?r.createElement("div",{className:`${Z}`},m({toggleAudioOption:D,labelSidebar:A,clipSidebar:$})):m:r.createElement("div",{className:`${Z}`},r.createElement("div",{className:`${Z}__content`},D,A,$))},bt=o=>{var n,a,m,y,d,_,T,k,b;const E=(a=(n=o.style)==null?void 0:n.sider)==null?void 0:a.width,{step:f,stepList:p,audioContext:u,sider:X,drawLayerSlot:w,imgList:x,imgIndex:g,currentData:N,config:L,stepInfo:P,checkMode:D}=o,A=B.getCurrentStepToolAndConfig(f,p),$=Je(N.result),{toolInstanceRef:t}=Qe({basicInfo:$}),[i,h]=M(!0),[s,j]=M(null),[z,K]=M(0),[S,I]=M(!0),v=e=>{if(!e)return;const l=lt.fixData(e);j(l)};V(()=>{h(!0)},[g]),V(()=>{i===!1&&Re()},[i]),V(()=>{ge()},[]),V(()=>{t.current.exportData=()=>[[s],{duration:z,valid:S}],t.current.setResult=Pe,t.current.clearResult=Ae,t.current.currentPageResult=s==null?void 0:s.regions,t.current.emit("updatePageNumber"),t.current.setSelectedRegion=q,t.current.setValid=Ie},[s,S]);const q=e=>{ue.emit("setSelectedRegion",{id:e,isLoopStatus:!0,playImmediately:!0})},ge=()=>{t.current.emit=e=>{const l=t.current.fns.get(e);l&&l.forEach(c=>{c&&(c==null||c())})},t.current.fns=new Map,t.current.singleOn=(e,l)=>{t.current.fns.set(e,[l])},t.current.on=(e,l)=>{t.current.singleOn(e,l)},t.current.unbindAll=e=>{t.current.fns.delete(e)}},H=re(()=>{const e=$[`step_${P==null?void 0:P.step}`];return(e==null?void 0:e.result)||[]},[L,$,P]),{tagConfigurable:ee,textConfigurable:J=!0,clipConfigurable:te=!1,clipAttributeConfigurable:oe=!1,clipAttributeList:ne=[],clipTextConfigurable:G=!1,subAttributeList:ve=[],secondaryAttributeConfigurable:be=!1,inputList:Se=[],configList:ye=[],clipTextList:ie=Ue}=re(()=>{if(A)return B.jsonParser(A==null?void 0:A.config)},[A]),_e={clipConfigurable:te,clipAttributeConfigurable:oe,clipAttributeList:ne,clipTextConfigurable:G,subAttributeList:ve,secondaryAttributeConfigurable:be,clipTextList:ie},Ee=(y=(m=B.jsonParser(N.result))==null?void 0:m.duration)!=null?y:0,xe=S?Ee:0,Ce=!S||i||![J,G].includes(!0)||D;let le={};if(g!==-1&&(x==null?void 0:x.length)){const e=(d=x[g])==null?void 0:d.preResult,l=(u==null?void 0:u.isEdit)?(_=u==null?void 0:u.stepConfig)==null?void 0:_.loadPreStep:P==null?void 0:P.loadPreStep;if(e&&l){const c=B.jsonParser(e),C=(k=(T=c==null?void 0:c.config)==null?void 0:T.context)!=null?k:{};Object.keys(C).forEach(O=>{O&&C[O]&&(le[O]={visible:!0,content:C[O],type:O})})}}const Re=()=>{(H==null?void 0:H.length)>0?v(H[0]):v({id:Ve(),sourceID:"",value:se(),tag:Te(),regions:[]});const e=it(x[g].result||"[]");I(e)},se=(e=!0)=>{const l={};let c=L.configList||[];return c.length>0&&c.forEach(C=>{l[C.key]=e&&C.default||""}),l},Te=()=>Be.getDefaultResultByConfig(L.inputList||[]),Le=({duration:e,hasError:l})=>{(u==null?void 0:u.onLoaded)&&(u==null||u.onLoaded()),h(!1),K(e)},he=ce(e=>{v(F(R({},s||{}),{regions:((s==null?void 0:s.regions)||[]).filter(l=>l.id!==e)}))}),Q=ce(e=>{var l;const c=(l=s==null?void 0:s.regions)!=null?l:[],{id:C}=e,O=c.find(W=>W.id===C);let Y=[];O?Y=c.map(W=>C===W.id?R(R({},W),e):W):Y=[...c,e],v(F(R({},s),{regions:Y}))}),je=(e,l)=>{const c=F(R({},s),{value:F(R({},s.value),{[l]:e})});v(c)},we=e=>{const l=F(R({},s),{tag:e});v(l)},Pe=e=>{v(e)},Ae=()=>{const e=F(R({},s),{value:se(),tag:{},regions:[]});v(e),ue.emit("clearRegions")},Ie=e=>{I(e)};return r.createElement(We,null,r.createElement(De,{spinning:i,wrapperClassName:"audio-tool-spinner"},r.createElement(ae,{className:ke("layout","container"),style:{height:"100%",userSelect:"none"}},o==null?void 0:o.leftSider,r.createElement(mt,{className:`${pe}__content`},r.createElement("div",{className:U.containerWrapper},r.createElement("div",{className:U.audioWrapper},ee&&r.createElement(Ke,{result:s==null?void 0:s.tag,labelInfoSet:Se,hasPromptLayer:!!(u==null?void 0:u.promptLayer)}),u==null?void 0:u.promptLayer,r.createElement(Oe,R({context:{isEdit:u==null?void 0:u.isEdit,count:xe,toolName:dt.AudioTextTool,imgIndex:g},drawLayerSlot:w,fileData:N,onLoaded:Le,invalid:!S,updateRegion:Q,removeRegion:he,regions:s==null?void 0:s.regions,activeToolPanel:u==null?void 0:u.activeToolPanel,footer:o.footer,isCheck:D},_e))),(J||G)&&r.createElement(gt,{preContext:le,result:s,inputDisabled:Ce,updateText:je,updateRegion:Q,configList:ye,autofocus:!1,textConfigurable:J,clipTextConfigurable:G,clipAttributeList:ne,clipAttributeConfigurable:oe,clipTextList:ie,isCheck:D}))),r.createElement(ft,{className:`${pe}__side`,width:E!=null?E:240,style:(b=o.style)==null?void 0:b.sider},r.createElement(vt,{sider:X,config:L,result:s,updateTagResult:we,updateRegion:Q,isEdit:u==null?void 0:u.isEdit,tagConfigurable:ee,clipConfigurable:te})),r.createElement(Ne,null))))};var St=Ge(qe,null,null,{context:He})(bt);export{St as default};
1
+ import s,{useState as N,useEffect as D,useMemo as ae}from"react";import{AudioPlayer as Oe}from"../audioPlayer/index.js";import{getClassName as ke}from"../../utils/dom.js";import Ne from"../predictTracking/previewResult/index.js";import{Layout as ue}from"antd/es";import{Spin as De}from"antd";import{prefix as $e}from"../../constant/index.js";import{cKeyCode as Me,CommonToolUtils as $,EventBus as ce,uuid as Ve,TagUtils as Be,cTool as Fe}from"@labelbee/lb-annotation";import K from"./index.module.scss.js";import Ke from"./tagResultShow/index.js";import{AudioClipProvider as We,DEFAULT_CLIP_TEXT_CONFIG_ITEM as Ue,useAudioClipStore as Xe}from"./audioContext/index.js";import ze from"./textInput/index.js";import{connect as Ge}from"react-redux";import{a2MapStateToProps as qe}from"../../store/annotation/map.js";import{LabelBeeContext as He}from"../../store/ctx.js";import{jsonParser as Je}from"../../utils/index.js";import{useCustomToolInstance as Qe}from"../../hooks/annotation.js";import{sidebarCls as ee}from"../../views/MainView/sidebar/index.js";import Ye from"./audioSide/labelSidebar/index.js";import Ze from"./audioSide/clipSidebar/index.js";import et from"../../assets/annotation/audio/tag.svg.js";import tt from"../../assets/annotation/audio/tagA.svg.js";import ot from"../../assets/annotation/audio/clip.svg.js";import nt from"../../assets/annotation/audio/clipA.svg.js";import{isImageValue as it}from"../../utils/audio.js";import lt from"./utils/dataTransform.js";import{useMemoizedFn as de}from"ahooks";var st=Object.defineProperty,rt=Object.defineProperties,at=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,me=(t,i,u)=>i in t?st(t,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[i]=u,L=(t,i)=>{for(var u in i||(i={}))ut.call(i,u)&&me(t,u,i[u]);if(fe)for(var u of fe(i))ct.call(i,u)&&me(t,u,i[u]);return t},M=(t,i)=>rt(t,at(i));const{EAudioToolName:dt}=Fe,pe=Me.default,{Sider:ft,Content:mt}=ue,ge=`${$e}-layout`,pt=({setSideTab:t,sideTab:i})=>{const u=[{tab:"tag",commonSvg:et,selectedSvg:tt},{tab:"clip",commonSvg:ot,selectedSvg:nt}];return s.createElement("div",{className:K.toggleAudioOption},u.map((g,_)=>{const{tab:f,selectedSvg:E,commonSvg:h}=g;return s.createElement("div",{key:_,className:K.option},s.createElement("img",{className:K.icon,src:i===f?E:h,onClick:()=>{i!==f&&t(f)}}))}))},gt=({result:t,inputDisabled:i,updateText:u,configList:g,autofocus:_,preContext:f,isCheck:E,clipAttributeConfigurable:h,clipTextConfigurable:O,textConfigurable:v,updateRegion:x,clipAttributeList:V,clipTextList:m})=>s.createElement(ze,{isCheck:E,result:t==null?void 0:t.value,textInputDisabled:i,textID:(t==null?void 0:t.id)||0,updateText:u,configList:g,autofocus:!i&&_,preContext:f,regions:t==null?void 0:t.regions,clipAttributeConfigurable:h,clipTextConfigurable:O,textConfigurable:v,updateRegion:x,clipAttributeList:V,clipTextList:m}),vt=t=>{var i,u;const{sider:g,config:_,result:f,updateTagResult:E,updateRegion:h,isEdit:O,tagConfigurable:v,clipConfigurable:x,valid:V}=t;let m=(_==null?void 0:_.inputList)||[],o=(i=f==null?void 0:f.tag)!=null?i:{},G=(u=f==null?void 0:f.regions)!=null?u:[];const[W,b]=N([]),[S,C]=N("tag");D(()=>{if(!v&&x){C("clip");return}C("tag")},[v,x]),D(()=>(window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}));const w=r=>{if(v&&x)switch(r.keyCode){case pe.L:C("tag");break;case pe.X:C("clip");break}if(S==="tag"){if(!$.hotkeyFilter(r))return;$.isMoveKey(r==null?void 0:r.keyCode)&&r.preventDefault();let a=r.keyCode;if(a&&(a<=57&&a>=49||a<=105&&a>=97)){a>57?a=a-97:a=a-49;const n=W.slice();m.length===1?(R(0,a),b([0,a]),setTimeout(()=>{b([])},500)):n.length===1?(R(n[0],a),b([n[0],a]),setTimeout(()=>{b([])},500)):b([a])}}},R=(r,a)=>{if(r<m.length&&m[r].subSelected&&a<m[r].subSelected.length){const n=m[r].value,q=m[r].isMulti;let j=m[r].subSelected[a].value,U=0;const y=o;for(const A in o)if(A===m[r].value){if(U++,q===!0){const p=y[A].split(";").filter(H=>H!==""),X=p.indexOf(j);X===-1?p.push(j):p.splice(X,1),j=p.join(";")}j===""?delete y[A]:y[A]=j}U===0&&Object.assign(o,{[n]:j}),E(o)}},B=r=>{delete o[r],E(o)},P=v&&x&&s.createElement(pt,{setSideTab:C,sideTab:S}),k=S==="tag"&&s.createElement(Ye,{labelInfoSet:v?m:[],labelSelectedList:W,setLabel:R,tagResult:o,clearResult:B,isEdit:O,withPanelTab:!1}),c=S==="clip"&&s.createElement(Ze,{regions:G,updateRegion:h,useAudioClipStore:Xe});return g?typeof g=="function"?s.createElement("div",{className:`${ee}`},g({toggleAudioOption:P,labelSidebar:k,clipSidebar:c,valid:V})):g:s.createElement("div",{className:`${ee}`},s.createElement("div",{className:`${ee}__content`},P,k,c))},bt=t=>{var i,u,g,_,f,E,h,O,v;const x=(u=(i=t.style)==null?void 0:i.sider)==null?void 0:u.width,{step:V,stepList:m,audioContext:o,sider:G,drawLayerSlot:W,imgList:b,imgIndex:S,currentData:C,config:w,stepInfo:R,checkMode:B}=t,P=$.getCurrentStepToolAndConfig(V,m),k=Je(C.result),{toolInstanceRef:c}=Qe({basicInfo:k}),[r,a]=N(!0),[n,q]=N(null),[j,U]=N(0),[y,A]=N(!0),p=e=>{if(!e)return;const l=lt.fixData(e);q(l)};D(()=>{a(!0)},[S]),D(()=>{r===!1&&Re()},[r]),D(()=>{H()},[]),D(()=>{c.current.exportData=()=>[[n],{duration:j,valid:y}],c.current.setResult=Pe,c.current.clearResult=Ae,c.current.currentPageResult=n==null?void 0:n.regions,c.current.emit("updatePageNumber"),c.current.setSelectedRegion=X,c.current.setValid=Ie},[n,y]);const X=e=>{ce.emit("setSelectedRegion",{id:e,isLoopStatus:!0,playImmediately:!0})},H=()=>{c.current.emit=e=>{const l=c.current.fns.get(e);l&&l.forEach(d=>{d&&(d==null||d())})},c.current.fns=new Map,c.current.singleOn=(e,l)=>{c.current.fns.set(e,[l])},c.current.on=(e,l)=>{c.current.singleOn(e,l)},c.current.unbindAll=e=>{c.current.fns.delete(e)}},J=ae(()=>{const e=k[`step_${R==null?void 0:R.step}`];return(e==null?void 0:e.result)||[]},[w,k,R]),{tagConfigurable:te,textConfigurable:Q=!0,clipConfigurable:oe=!1,clipAttributeConfigurable:ne=!1,clipAttributeList:ie=[],clipTextConfigurable:z=!1,subAttributeList:ve=[],secondaryAttributeConfigurable:be=!1,inputList:Se=[],configList:ye=[],clipTextList:le=Ue}=ae(()=>{if(P)return $.jsonParser(P==null?void 0:P.config)},[P]),_e={clipConfigurable:oe,clipAttributeConfigurable:ne,clipAttributeList:ie,clipTextConfigurable:z,subAttributeList:ve,secondaryAttributeConfigurable:be,clipTextList:le},Ee=(_=(g=$.jsonParser(C.result))==null?void 0:g.duration)!=null?_:0,xe=y?Ee:0,Ce=!y||r||![Q,z].includes(!0)||B;let se={};if(S!==-1&&(b==null?void 0:b.length)){const e=(f=b[S])==null?void 0:f.preResult,l=(o==null?void 0:o.isEdit)?(E=o==null?void 0:o.stepConfig)==null?void 0:E.loadPreStep:R==null?void 0:R.loadPreStep;if(e&&l){const d=$.jsonParser(e),T=(O=(h=d==null?void 0:d.config)==null?void 0:h.context)!=null?O:{};Object.keys(T).forEach(I=>{I&&T[I]&&(se[I]={visible:!0,content:T[I],type:I})})}}const Re=()=>{(J==null?void 0:J.length)>0?p(J[0]):p({id:Ve(),sourceID:"",value:re(),tag:Te(),regions:[]});const e=it(b[S].result||"[]");A(e)},re=(e=!0)=>{const l={};let d=w.configList||[];return d.length>0&&d.forEach(T=>{l[T.key]=e&&T.default||""}),l},Te=()=>Be.getDefaultResultByConfig(w.inputList||[]),Le=({duration:e,hasError:l})=>{(o==null?void 0:o.onLoaded)&&(o==null||o.onLoaded()),a(!1),U(e)},he=de(e=>{p(M(L({},n||{}),{regions:((n==null?void 0:n.regions)||[]).filter(l=>l.id!==e)}))}),Y=de(e=>{var l;const d=(l=n==null?void 0:n.regions)!=null?l:[],{id:T}=e,I=d.find(F=>F.id===T);let Z=[];I?Z=d.map(F=>T===F.id?L(L({},F),e):F):Z=[...d,e],p(M(L({},n),{regions:Z}))}),je=(e,l)=>{const d=M(L({},n),{value:M(L({},n.value),{[l]:e})});p(d)},we=e=>{const l=M(L({},n),{tag:e});p(l)},Pe=e=>{p(e)},Ae=()=>{const e=M(L({},n),{value:re(),tag:{},regions:[]});p(e),ce.emit("clearRegions")},Ie=e=>{A(e)};return s.createElement(We,null,s.createElement(De,{spinning:r,wrapperClassName:"audio-tool-spinner"},s.createElement(ue,{className:ke("layout","container"),style:{height:"100%",userSelect:"none"}},t==null?void 0:t.leftSider,s.createElement(mt,{className:`${ge}__content`},s.createElement("div",{className:K.containerWrapper},s.createElement("div",{className:K.audioWrapper},te&&s.createElement(Ke,{result:n==null?void 0:n.tag,labelInfoSet:Se,hasPromptLayer:!!(o==null?void 0:o.promptLayer)}),o==null?void 0:o.promptLayer,s.createElement(Oe,L({context:{isEdit:o==null?void 0:o.isEdit,count:xe,toolName:dt.AudioTextTool,imgIndex:S},drawLayerSlot:W,fileData:C,onLoaded:Le,invalid:!y,updateRegion:Y,removeRegion:he,regions:n==null?void 0:n.regions,activeToolPanel:o==null?void 0:o.activeToolPanel,footer:t.footer,isCheck:B},_e))),(Q||z)&&s.createElement(gt,{preContext:se,result:n,inputDisabled:Ce,updateText:je,updateRegion:Y,configList:ye,autofocus:!1,textConfigurable:Q,clipTextConfigurable:z,clipAttributeList:ie,clipAttributeConfigurable:ne,clipTextList:le,isCheck:B}))),s.createElement(ft,{className:`${ge}__side`,width:x!=null?x:240,style:(v=t.style)==null?void 0:v.sider},s.createElement(vt,{sider:G,config:w,result:n,updateTagResult:we,updateRegion:Y,isEdit:o==null?void 0:o.isEdit,tagConfigurable:te,clipConfigurable:oe,valid:y})),s.createElement(Ne,null))))};var St=Ge(qe,null,null,{context:He})(bt);export{St as default};
@@ -1 +1 @@
1
- import i,{useState as v,useRef as U,useMemo as ar,useEffect as P}from"react";import{getWebPcm2WavBase64 as ur}from"../audioAnnotate/utils/getWebPcm2Wac.js";import cr,{debounce as dr,sortBy as mr}from"lodash";import{PauseOutlined as fr,CaretRightOutlined as pr}from"@ant-design/icons";import{cKeyCode as vr,cTool as gr,EventBus as E,TagUtils as br}from"@labelbee/lb-annotation";import{i18n as Je}from"@labelbee/lb-utils";import{Button as yr}from"antd";import _r from"../invalidPage/index.js";import Er from"../imageError/index.js";import{classnames as V}from"../../utils/index.js";import Sr,{EPlayerType as hr}from"../videoPlayer/components/SpeedController/index.js";import Rr from"@labelbee/wavesurfer";import Pr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import Cr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import Tr,{audioZoomInfo as me}from"./zoomSlider/index.js";import wr from"./labelDisplayToggle/index.js";import Ar from"./clipRegion/index.js";import{useAudioClipStore as jr}from"../audioAnnotate/audioContext/index.js";import{useLatest as X,useUpdate as xr,useDeepCompareEffect as Qe,useThrottleFn as et}from"ahooks";import Dr from"./useAudioScroll/index.js";import y from"./index.module.scss.js";import{getAttributeColor as Lr,formatTime as tt,timeFormat as rt,dispatchResizeEvent as Ir,precisionMinus as nt,isDoubleClick as Mr,getCanMoveRange as kr}from"../../utils/audio.js";import Br from"./progressDot/index.js";import Or from"./clipTip/index.js";import Wr from"./useSwitchHotkey/index.js";import Nr from"./useAudioCombine/index.js";import zr from"./useAudioSegment/index.js";import Fr from"./combineTip/index.js";import $r from"./segmentTip/index.js";import Hr from"../../views/MainView/toolFooter/index.js";import{decimalReserved as Z}from"../videoPlayer/utils.js";import{I18nextProvider as Ur}from"react-i18next";import Vr from"../../hooks/useSize.js";var Xr=Object.defineProperty,Zr=Object.defineProperties,qr=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Gr=Object.prototype.propertyIsEnumerable,it=(f,u,d)=>u in f?Xr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):f[u]=d,fe=(f,u)=>{for(var d in u||(u={}))Kr.call(u,d)&&it(f,d,u[d]);if(ot)for(var d of ot(u))Gr.call(u,d)&&it(f,d,u[d]);return f},lt=(f,u)=>Zr(f,qr(u));const{EToolName:st}=gr,q=vr.default,at=.1,ut=i.createContext({count:0,isEdit:!1,toolName:st.Empty,imgIndex:0}),ct=({fileData:f={},onLoaded:u,context:d,invalid:dt,height:mt,hideError:ft,onError:pe,updateRegion:L,removeRegion:$,regions:A=[],activeToolPanel:pt,clipConfigurable:vt,clipTextConfigurable:ve,clipAttributeList:gt,clipAttributeConfigurable:ge,secondaryAttributeConfigurable:bt,subAttributeList:yt,isCheck:S,hoverRegionId:K,footer:_t,drawLayerSlot:be,clipTextList:Et,lang:ye})=>{var _e,Ee;const{url:H,path:Se}=f,[G,Y]=v(!1),[he,J]=v(!1),[j,St]=v(0),[ht,Re]=v(!1),[C,Pe]=v(0),o=U(null),x=U(null),Ce=U(j),Q=e=>{Ce.current=e,St(e)},[Te,Rt]=v(0),[k,Pt]=v(me.defaultValue),h=U(null),[we,Ct]=v({}),{audioClipState:ee,setAudioClipState:B}=jr(),[te,re]=v(!1),c=X(ee),Ae=X(we);X(G);const I=X(A),je=xr(),[xe,Tt]=v([]),[De,wt]=v({}),[At,Le]=v(""),[Ie,jt]=v({start:0,end:0}),xt=Vr(h),Dt=ar(()=>A.filter(e=>{const{start:t,end:r}=Ie;return e.start>=t&&e.start<=r||e.end>=t&&e.end<=r||e.id===At}),[A,Ie]),Lt=dr(()=>{E.emit("audioZoom")},500),Me=e=>{e<me.min||e>me.max||(Pt(e),Ir(),Lt())};Dr({container:h.current,target:document.querySelector(`[data-id=${(Ee=(_e=c.current)==null?void 0:_e.selectedRegion)==null?void 0:Ee.id}]`),clipping:te,zoom:k,zoomHandler:Me});const O=()=>{let e=I.current;const{attributeLockList:t}=c.current;t.length&&(e=e.filter(r=>t.includes(r.attribute))),oe(),e.forEach(r=>{var n;(n=o.current)==null||n.addRegion(lt(fe({},r),{drag:!S,resize:!S,color:"rgba(0, 0, 0, 0)"}))}),je()},g=e=>{var t,r,n,l,a,p,b;const{id:s,loop:m=!0,playImmediately:_=!1,isLoopStatus:z}=e,M=!1;if(s){const D=(n=(r=(t=o.current)==null?void 0:t.regions)==null?void 0:r.list)!=null?n:{};Object.entries(D).forEach(([,w])=>{const{id:F}=w;s===F?w.select():w.cancelSelect()}),B({selectedRegion:{id:s,loop:M},selectedAttribute:(p=(a=(l=I.current)==null?void 0:l.find(w=>w.id===s))==null?void 0:a.attribute)!=null?p:""}),_&&((b=W(s))==null||b.play())}else B({selectedRegion:{}})},{combineInstance:It}=Nr({waveRef:o,sortByStartRegions:xe,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:g}),{segmentInstance:Mt,onRegionMouseMove:kt,segmentTimeTip:Bt}=zr({waveRef:o,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:g}),ke={clipTextConfigurable:ve,clipAttributeList:gt,clipAttributeConfigurable:ge,clipConfigurable:vt,secondaryAttributeConfigurable:bt,subAttributeList:yt,clipTextList:Et};P(()=>{var e;ye&&((e=Je)==null||e.changeLanguage(ye))},[]),P(()=>{B({selectedAttribute:""})},[ge]),P(()=>{ne()},[ee.selectedAttribute]),P(()=>{O()},[ee.attributeLockList]),Qe(()=>{B(ke),setTimeout(()=>{Be()})},[ke]),Qe(()=>{Tt(mr(A,["start"])),wt(A.reduce((e,t)=>{const{id:r}=t;return lt(fe({},e),{[r]:t})},{})),S&&O()},[A]),P(()=>{g(K?{id:K,loop:!1,playImmediately:!0}:{})},[K]);const Be=()=>{var e,t;c.current.clipConfigurable?(!S&&o.current&&((e=o.current)==null||e.enableDragSelection({slop:5})),O()):((t=o.current)==null||t.disableDragSelection(),oe()),ne()},ne=()=>{var e,t,r,n,l;let a="";c.current.clipConfigurable?a=Lr(c.current.selectedAttribute,(e=c.current.clipAttributeList)!=null?e:[]):a="transparent",((r=(t=o==null?void 0:o.current)==null?void 0:t.cursor)==null?void 0:r.cursor)&&((l=(n=o==null?void 0:o.current)==null?void 0:n.cursor)==null||l.setStyle({border:`2px dashed ${a}`}))},W=e=>{var t,r,n;return((n=(r=(t=o.current)==null?void 0:t.regions)==null?void 0:r.list)!=null?n:{})[e]},Oe=()=>{var e,t;if(H){const r=((t=(e=Se==null?void 0:Se.split("."))==null?void 0:e.pop())==null?void 0:t.toLowerCase())==="pcm";Re(!1),r?ur(H).then(n=>{We(n)}):We(H)}},We=e=>{var t;e&&(J(!0),Q(0),Pe(0),(t=o==null?void 0:o.current)==null||t.load(e))},oe=()=>{var e;(e=o.current)==null||e.clearRegions()},ie=e=>{const t=W(e);t&&(re(!1),t==null||t.remove(),$==null||$(e),g({}))},{run:Ne}=et(g,{wait:100});Wr({sortByStartRegions:xe,setSelectedRegion:g});const Ot=e=>{const{start:t,end:r}=Ae.current;return(t||r)&&e.update(Ae.current),e},Wt=({action:e,id:t,eventDownTime:r})=>{var n,l;if(!c.current.clipConfigurable)return;t&&g({id:t});const a=W((t!=null?t:(n=c.current.selectedRegion)==null?void 0:n.id)||""),p=[];(e==="create"?I.current:(l=I.current)==null?void 0:l.filter(m=>m.id!==a.id)).forEach(m=>{const{start:_,end:z,attribute:M}=m;M===c.current.selectedAttribute&&[_,z].forEach(D=>{p.includes(D)||p.push(D)})});const s=kr(p.sort((m,_)=>m-_),r);o.current.range=s},Nt=e=>{ne(),setTimeout(()=>{re(!1)});const t=Ot(e),{id:r,start:n,end:l}=t;g({id:r,playImmediately:!0});const a={id:r,start:Z(n,3),end:Z(l,3)};L==null||L(a),je()},zt=()=>{const e=Rr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:mt||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[Pr.create({regions:A,dragSelection:{slop:5},canMove:!1}),Cr.create({opacity:1,customStyle:{border:"2px dashed transparent"}})]}),t=()=>{var r;Q(((r=o==null?void 0:o.current)==null?void 0:r.getCurrentTime())||0)};e.on("ready",()=>{var r;const n=((r=o==null?void 0:o.current)==null?void 0:r.getDuration())||0;Pe(n),t(),u==null||u({duration:Math.round(n)}),J(!1),N(),E.on("setCurrentTimeByPosition",se),E.on("clearRegions",oe),E.on("removeRegionById",ie),E.on("setSelectedRegion",Ne),e.on("regions-eventDown",Wt),Be()}),e.on("audioprocess",()=>{t()}),e.on("play",()=>{Y(!0)}),e.on("pause",()=>{Y(!1)}),e.on("finish",()=>{Y(!1)}),e.on("seek",()=>{t()}),e.on("error",()=>{Re(!0),J(!1),u==null||u({hasError:!0}),pe==null||pe()}),e.on("region-created",r=>{var n;const{id:l,start:a,end:p}=r;if(I.current.find(s=>s.id===l))return;Le(l);const b={id:l,start:Z(a,3),end:Z(p,3),attribute:c.current.selectedAttribute,text:""};if(c.current.secondaryAttributeConfigurable){const s=br.getDefaultResultByConfig((n=c.current.subAttributeList)!=null?n:[]);b.subAttribute=s!=null?s:{}}ve&&c.current.clipTextList.forEach((m,_)=>{_===0?Object.assign(b,{text:m==null?void 0:m.default}):Object.assign(b,{[m.key]:m==null?void 0:m.default})}),L==null||L(b)}),e.on("region-updated",(r,n)=>{var l,a,p,b,s,m,_,z,M,D;const w=n==null?void 0:n.action;B({combined:!1,segment:!1}),w==="resize"&&((a=(l=o==null?void 0:o.current)==null?void 0:l.cursor)==null||a.setStyle({borderStyle:"solid"})),w==="drag"&&((b=(p=o==null?void 0:o.current)==null?void 0:p.cursor)==null||b.setStyle({borderColor:"transparent"}));const F={},ae=[],ue={},Qt=(s=I.current)==null?void 0:s.filter(R=>R.id!==r.id),er=(z=(_=(m=o.current)==null?void 0:m.regions)==null?void 0:_.list)!=null?z:{};Qt.forEach(R=>{var Ke,Ge;const{element:ce}=(Ke=er[R.id])!=null?Ke:{},{start:nr,end:or}=R;if(ce){const{x:Ye,width:ir}=((Ge=ce.getBoundingClientRect)==null?void 0:Ge.call(ce))||{},lr=Ye+ir;[Ye,lr].forEach((de,sr)=>{ae.includes(de)||(ae.push(de),ue[de]=sr===0?nr:or)})}});const{x:qe,width:tr}=((D=(M=r.element).getBoundingClientRect)==null?void 0:D.call(M))||{},rr=qe+tr;ae.forEach(R=>{Math.abs(nt(R,qe))<5&&(F.start=ue[R]),Math.abs(nt(R,rr))<5&&(F.end=ue[R])}),Ct(F),Ne({id:r.id}),re(!0)}),e.on("region-update-end",r=>{Nt(r),Le("")}),e.on("region-contextmenu",(r,n)=>{if(!S){if(n.preventDefault(),n.stopPropagation(),Mr(n)){ie(r.id);return}g({id:r.id,playImmediately:!0})}}),e.on("region-click",(r,n,l)=>{if(!S){if(n.preventDefault(),n.stopPropagation(),c.current.combined){It(r);return}if(c.current.segment){Mt(r,l);return}g({id:r.id,playImmediately:!0})}}),e.on("region-mousemove",kt),o.current=e},Ft=G?i.createElement(fr,null):i.createElement(pr,null),ze=e=>e?`${parseFloat((e/C*100).toFixed(4))}%`:"0%",Fe=ze(j),$t=ze(Te),T=()=>{if(!he)return o==null?void 0:o.current},Ht=()=>{var e;(e=T())==null||e.skipForward(at)},Ut=()=>{var e;(e=T())==null||e.skipBackward(at)},N=()=>{var e;(e=T())==null||e.playPause()},$e=e=>{var t;switch(e.keyCode){case q.Right:Ht();break;case q.Left:Ut();break;case q.Space:e.preventDefault(),N();break;case q.Delete:if(!S){const{id:r}=((t=c.current)==null?void 0:t.selectedRegion)||{};r&&ie(r)}break}},Vt=e=>{se(e)},He=cr.throttle(Vt,50);let le=!1;const Ue=()=>{le&&(N(),le=!1),document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",Ue)},Xt=e=>{se(e),G&&(le=!0,N()),document.addEventListener("mousemove",He),document.addEventListener("mouseup",Ue)},Zt=()=>{Oe()};P(()=>(zt(),()=>{var e;(e=o==null?void 0:o.current)==null||e.destroy(),o.current=null,E.unbindAll("setCurrentTimeByPosition"),E.unbindAll("clearRegions"),E.unbindAll("removeRegionById"),E.unbindAll("setSelectedRegion")}),[]);const qt=e=>{var t,r,n;(t=T())==null||t.playPause(),(r=T())==null||r.setPlaybackRate(e),(n=T())==null||n.playPause()};P(()=>(document.addEventListener("keydown",$e),()=>{document.removeEventListener("keydown",$e)})),P(()=>{g({}),Oe()},[H]),P(()=>{Ve()},[xt,C,k]);const Kt=()=>{if(h.current&&C){const e=h.current.scrollLeft,t=h.current.clientWidth,r=e/h.current.scrollWidth*C,n=(e+t)/h.current.scrollWidth*C;jt({start:r,end:n})}},{run:Ve}=et(Kt,{wait:300}),Xe=e=>{var t,r,n,l;if((o==null?void 0:o.current)&&(x==null?void 0:x.current)){const a=(r=(t=o==null?void 0:o.current)==null?void 0:t.getDuration())!=null?r:0,p=(n=x==null?void 0:x.current)==null?void 0:n.getBoundingClientRect();let s=(e.clientX-p.left)/(((l=x==null?void 0:x.current)==null?void 0:l.clientWidth)||0)*a;return s>a&&(s=a),s}return 0},se=e=>{var t;const r=Xe(e);(t=o==null?void 0:o.current)==null||t.skip(r-Ce.current),Q(r)},Gt=e=>{Rt(Xe(e))},Yt=C?Math.max(C-j,0):0,Jt=(d==null?void 0:d.toolName)!==st.Empty&&(d==null?void 0:d.isEdit)!==!0&&(pt==="remark"||S),Ze=i.createElement("div",{className:y.audioPlayer},ht&&!ft&&i.createElement(Er,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:Zt,backgroundColor:"#ffffffbb"}),i.createElement(Or,{getRegionInstanceById:W,clipping:te}),i.createElement(Fr,{container:h.current}),i.createElement($r,{segmentTimeTip:Bt}),i.createElement("div",{className:y.waveformContainer,ref:h,onScroll:()=>Ve()},i.createElement("div",{id:"waveform",style:{width:`${k*100}%`},className:V({[y.waveform]:!0,"bee-audio-combined":c.current.combined,"bee-audio-clip":c.current.clipConfigurable})},dt&&i.createElement(_r,{isAudio:!0}),i.createElement("div",{ref:x,className:y.progress,onMouseDown:Xt,onMouseMove:Gt},i.createElement("div",{className:V({[y.radioTooltip]:!0}),style:{left:Fe}},tt(j)),i.createElement("div",{className:V({[y.radioTooltip]:!0,[y.mouseTooltip]:!0}),style:{left:$t}},tt(Te)),i.createElement(Br,{playPercentage:Fe})),Jt&&(be==null?void 0:be({currentTime:j,remainingTime:Yt,audioPlayer:T()})))),i.createElement("div",{className:y.controlBar},i.createElement(yr,{type:"link",icon:Ft,onClick:()=>{N()},className:V({[y.playButton]:!0,[y.playButtonDisabled]:he})}),i.createElement("span",{className:y.time},`${rt(j,"ss.SSS")} / -${rt(C-j,"ss.SSS")}`),i.createElement(Sr,{playerType:hr.Audio,onChange:e=>{qt(e)}}),i.createElement(Tr,{onChange:e=>{var t;(t=T())==null||t.pause(),Me(e)},zoom:k}),i.createElement(wr,{EventBus:E})));return d?i.createElement(ut.Provider,{value:d},Ze,Dt.map(e=>{const{id:t}=e,r=document.querySelector(`[data-id=${t}]`);return r?i.createElement(Ar,{el:r,key:t,region:e,edgeAdsorption:we,clipping:te,zoom:k,instance:W(t),isCheck:S}):null}),i.createElement(Hr,{footer:_t})):Ze},Yr=f=>i.createElement(Ur,{i18n:Je},i.createElement(ct,fe({},f)));export{ct as AudioPlayer,ut as AudioPlayerContext,Yr as WrapAudioPlayer};
1
+ import i,{useState as v,useRef as U,useMemo as ar,useEffect as P}from"react";import{getWebPcm2WavBase64 as ur}from"../audioAnnotate/utils/getWebPcm2Wac.js";import cr,{debounce as dr,sortBy as mr}from"lodash";import{PauseOutlined as fr,CaretRightOutlined as pr}from"@ant-design/icons";import{cKeyCode as vr,cTool as gr,EventBus as E,TagUtils as br}from"@labelbee/lb-annotation";import{i18n as Je}from"@labelbee/lb-utils";import{Button as yr}from"antd";import _r from"../invalidPage/index.js";import Er from"../imageError/index.js";import{classnames as V}from"../../utils/index.js";import Sr,{EPlayerType as hr}from"../videoPlayer/components/SpeedController/index.js";import Rr from"@labelbee/wavesurfer";import Pr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import Cr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import Tr,{audioZoomInfo as me}from"./zoomSlider/index.js";import wr from"./labelDisplayToggle/index.js";import Ar from"./clipRegion/index.js";import{useAudioClipStore as jr}from"../audioAnnotate/audioContext/index.js";import{useLatest as X,useUpdate as xr,useDeepCompareEffect as Qe,useThrottleFn as et}from"ahooks";import Dr from"./useAudioScroll/index.js";import y from"./index.module.scss.js";import{getAttributeColor as Lr,formatTime as tt,timeFormat as rt,dispatchResizeEvent as Ir,precisionMinus as nt,isDoubleClick as Mr,getCanMoveRange as kr}from"../../utils/audio.js";import Br from"./progressDot/index.js";import Or from"./clipTip/index.js";import Wr from"./useSwitchHotkey/index.js";import Nr from"./useAudioCombine/index.js";import zr from"./useAudioSegment/index.js";import Fr from"./combineTip/index.js";import $r from"./segmentTip/index.js";import Hr from"../../views/MainView/toolFooter/index.js";import{decimalReserved as Z}from"../videoPlayer/utils.js";import{I18nextProvider as Ur}from"react-i18next";import Vr from"../../hooks/useSize.js";var Xr=Object.defineProperty,Zr=Object.defineProperties,qr=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Gr=Object.prototype.propertyIsEnumerable,it=(f,u,d)=>u in f?Xr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):f[u]=d,fe=(f,u)=>{for(var d in u||(u={}))Kr.call(u,d)&&it(f,d,u[d]);if(ot)for(var d of ot(u))Gr.call(u,d)&&it(f,d,u[d]);return f},lt=(f,u)=>Zr(f,qr(u));const{EToolName:st}=gr,q=vr.default,at=.1,ut=i.createContext({count:0,isEdit:!1,toolName:st.Empty,imgIndex:0}),ct=({fileData:f={},onLoaded:u,context:d,invalid:dt,height:mt,hideError:ft,onError:pe,updateRegion:L,removeRegion:$,regions:A=[],activeToolPanel:pt,clipConfigurable:vt,clipTextConfigurable:ve,clipAttributeList:gt,clipAttributeConfigurable:ge,secondaryAttributeConfigurable:bt,subAttributeList:yt,isCheck:S,hoverRegionId:K,footer:_t,drawLayerSlot:be,clipTextList:Et,lang:ye})=>{var _e,Ee;const{url:H,path:Se}=f,[G,Y]=v(!1),[he,J]=v(!1),[j,St]=v(0),[ht,Re]=v(!1),[C,Pe]=v(0),o=U(null),x=U(null),Ce=U(j),Q=e=>{Ce.current=e,St(e)},[Te,Rt]=v(0),[k,Pt]=v(me.defaultValue),h=U(null),[we,Ct]=v({}),{audioClipState:ee,setAudioClipState:B}=jr(),[te,re]=v(!1),c=X(ee),Ae=X(we);X(G);const I=X(A),je=xr(),[xe,Tt]=v([]),[De,wt]=v({}),[At,Le]=v(""),[Ie,jt]=v({start:0,end:0}),xt=Vr(h),Dt=ar(()=>A.filter(e=>{const{start:t,end:r}=Ie;return e.start>=t&&e.start<=r||e.end>=t&&e.end<=r||e.id===At}),[A,Ie]),Lt=dr(()=>{E.emit("audioZoom")},500),Me=e=>{e<me.min||e>me.max||(Pt(e),Ir(),Lt())};Dr({container:h.current,target:document.querySelector(`[data-id=${(Ee=(_e=c.current)==null?void 0:_e.selectedRegion)==null?void 0:Ee.id}]`),clipping:te,zoom:k,zoomHandler:Me});const O=()=>{let e=I.current;const{attributeLockList:t}=c.current;t.length&&(e=e.filter(r=>t.includes(r.attribute))),oe(),e.forEach(r=>{var n;(n=o.current)==null||n.addRegion(lt(fe({},r),{drag:!S,resize:!S,color:"rgba(0, 0, 0, 0)"}))}),je()},g=e=>{var t,r,n,l,a,p,b;const{id:s,loop:m=!0,playImmediately:_=!1,isLoopStatus:z}=e,M=!1;if(s){const D=(n=(r=(t=o.current)==null?void 0:t.regions)==null?void 0:r.list)!=null?n:{};Object.entries(D).forEach(([,w])=>{const{id:F}=w;s===F?w.select():w.cancelSelect()}),B({selectedRegion:{id:s,loop:M},selectedAttribute:(p=(a=(l=I.current)==null?void 0:l.find(w=>w.id===s))==null?void 0:a.attribute)!=null?p:""}),_&&((b=W(s))==null||b.play())}else B({selectedRegion:{}})},{combineInstance:It}=Nr({waveRef:o,sortByStartRegions:xe,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:g}),{segmentInstance:Mt,onRegionMouseMove:kt,segmentTimeTip:Bt}=zr({waveRef:o,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:g}),ke={clipTextConfigurable:ve,clipAttributeList:gt,clipAttributeConfigurable:ge,clipConfigurable:vt,secondaryAttributeConfigurable:bt,subAttributeList:yt,clipTextList:Et};P(()=>{var e;ye&&((e=Je)==null||e.changeLanguage(ye))},[]),P(()=>{B({selectedAttribute:""})},[ge]),P(()=>{ne()},[ee.selectedAttribute]),P(()=>{O()},[ee.attributeLockList]),Qe(()=>{B(ke),setTimeout(()=>{Be()})},[ke]),Qe(()=>{Tt(mr(A,["start"])),wt(A.reduce((e,t)=>{const{id:r}=t;return lt(fe({},e),{[r]:t})},{})),S&&O()},[A]),P(()=>{g(K?{id:K,loop:!1,playImmediately:!0}:{})},[K]);const Be=()=>{var e,t;c.current.clipConfigurable?(!S&&o.current&&((e=o.current)==null||e.enableDragSelection({slop:5})),O()):((t=o.current)==null||t.disableDragSelection(),oe()),ne()},ne=()=>{var e,t,r,n,l;let a="";c.current.clipConfigurable?a=Lr(c.current.selectedAttribute,(e=c.current.clipAttributeList)!=null?e:[]):a="transparent",((r=(t=o==null?void 0:o.current)==null?void 0:t.cursor)==null?void 0:r.cursor)&&((l=(n=o==null?void 0:o.current)==null?void 0:n.cursor)==null||l.setStyle({border:`2px dashed ${a}`}))},W=e=>{var t,r,n;return((n=(r=(t=o.current)==null?void 0:t.regions)==null?void 0:r.list)!=null?n:{})[e]},Oe=()=>{var e,t;if(H){const r=((t=(e=Se==null?void 0:Se.split("."))==null?void 0:e.pop())==null?void 0:t.toLowerCase())==="pcm";Re(!1),r?ur(H).then(n=>{We(n)}):We(H)}},We=e=>{var t;e&&(J(!0),Q(0),Pe(0),(t=o==null?void 0:o.current)==null||t.load(e))},oe=()=>{var e;(e=o.current)==null||e.clearRegions()},ie=e=>{const t=W(e);t&&(re(!1),t==null||t.remove(),$==null||$(e),g({}))},{run:Ne}=et(g,{wait:100});Wr({sortByStartRegions:xe,setSelectedRegion:g});const Ot=e=>{const{start:t,end:r}=Ae.current;return(t||r)&&e.update(Ae.current),e},Wt=({action:e,id:t,eventDownTime:r})=>{var n,l;if(!c.current.clipConfigurable)return;t&&g({id:t});const a=W((t!=null?t:(n=c.current.selectedRegion)==null?void 0:n.id)||""),p=[];(e==="create"?I.current:(l=I.current)==null?void 0:l.filter(m=>m.id!==a.id)).forEach(m=>{const{start:_,end:z,attribute:M}=m;M===c.current.selectedAttribute&&[_,z].forEach(D=>{p.includes(D)||p.push(D)})});const s=kr(p.sort((m,_)=>m-_),r);o.current.range=s},Nt=e=>{ne(),setTimeout(()=>{re(!1)});const t=Ot(e),{id:r,start:n,end:l}=t;g({id:r,playImmediately:!0});const a={id:r,start:Z(n,3),end:Z(l,3)};L==null||L(a),je()},zt=()=>{const e=Rr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:mt||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[Pr.create({regions:A,dragSelection:{slop:5},canMove:!1}),Cr.create({opacity:1,customStyle:{border:"2px dashed transparent"}})]}),t=()=>{var r;Q(((r=o==null?void 0:o.current)==null?void 0:r.getCurrentTime())||0)};e.on("ready",()=>{var r;const n=((r=o==null?void 0:o.current)==null?void 0:r.getDuration())||0;Pe(n),t(),u==null||u({duration:Math.round(n)}),J(!1),N(),E.on("setCurrentTimeByPosition",se),E.on("clearRegions",oe),E.on("removeRegionById",ie),E.on("setSelectedRegion",Ne),e.on("regions-eventDown",Wt),Be()}),e.on("audioprocess",()=>{t()}),e.on("play",()=>{Y(!0)}),e.on("pause",()=>{Y(!1)}),e.on("finish",()=>{Y(!1)}),e.on("seek",()=>{t()}),e.on("error",()=>{Re(!0),J(!1),u==null||u({hasError:!0}),pe==null||pe()}),e.on("region-created",r=>{var n;const{id:l,start:a,end:p}=r;if(I.current.find(s=>s.id===l))return;Le(l);const b={id:l,start:Z(a,3),end:Z(p,3),attribute:c.current.selectedAttribute,text:""};if(c.current.secondaryAttributeConfigurable){const s=br.getDefaultResultByConfig((n=c.current.subAttributeList)!=null?n:[]);b.subAttribute=s!=null?s:{}}ve&&c.current.clipTextList.forEach((m,_)=>{_===0?Object.assign(b,{text:m==null?void 0:m.default}):Object.assign(b,{[m.key]:m==null?void 0:m.default})}),L==null||L(b)}),e.on("region-updated",(r,n)=>{var l,a,p,b,s,m,_,z,M,D;const w=n==null?void 0:n.action;B({combined:!1,segment:!1}),w==="resize"&&((a=(l=o==null?void 0:o.current)==null?void 0:l.cursor)==null||a.setStyle({borderStyle:"solid"})),w==="drag"&&((b=(p=o==null?void 0:o.current)==null?void 0:p.cursor)==null||b.setStyle({borderColor:"transparent"}));const F={},ae=[],ue={},Qt=(s=I.current)==null?void 0:s.filter(R=>R.id!==r.id),er=(z=(_=(m=o.current)==null?void 0:m.regions)==null?void 0:_.list)!=null?z:{};Qt.forEach(R=>{var Ke,Ge;const{element:ce}=(Ke=er[R.id])!=null?Ke:{},{start:nr,end:or}=R;if(ce){const{x:Ye,width:ir}=((Ge=ce.getBoundingClientRect)==null?void 0:Ge.call(ce))||{},lr=Ye+ir;[Ye,lr].forEach((de,sr)=>{ae.includes(de)||(ae.push(de),ue[de]=sr===0?nr:or)})}});const{x:qe,width:tr}=((D=(M=r.element).getBoundingClientRect)==null?void 0:D.call(M))||{},rr=qe+tr;ae.forEach(R=>{Math.abs(nt(R,qe))<5&&(F.start=ue[R]),Math.abs(nt(R,rr))<5&&(F.end=ue[R])}),Ct(F),Ne({id:r.id}),re(!0)}),e.on("region-update-end",r=>{Nt(r),Le("")}),e.on("region-contextmenu",(r,n)=>{if(!S){if(n.preventDefault(),n.stopPropagation(),Mr(n)){ie(r.id);return}g({id:r.id,playImmediately:!0})}}),e.on("region-click",(r,n,l)=>{if(!S){if(n.preventDefault(),n.stopPropagation(),c.current.combined){It(r);return}if(c.current.segment){Mt(r,l);return}g({id:r.id,playImmediately:!0})}}),e.on("region-mousemove",kt),o.current=e},Ft=G?i.createElement(fr,null):i.createElement(pr,null),ze=e=>e?`${parseFloat((e/C*100).toFixed(4))}%`:"0%",Fe=ze(j),$t=ze(Te),T=()=>{if(!he)return o==null?void 0:o.current},Ht=()=>{var e;(e=T())==null||e.skipForward(at)},Ut=()=>{var e;(e=T())==null||e.skipBackward(at)},N=()=>{var e;(e=T())==null||e.playPause()},$e=e=>{var t;switch(e.keyCode){case q.Right:Ht();break;case q.Left:Ut();break;case q.Space:e.preventDefault(),N();break;case q.Delete:if(!S){const{id:r}=((t=c.current)==null?void 0:t.selectedRegion)||{};r&&ie(r)}break}},Vt=e=>{se(e)},He=cr.throttle(Vt,50);let le=!1;const Ue=()=>{le&&(N(),le=!1),document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",Ue)},Xt=e=>{se(e),G&&(le=!0,N()),document.addEventListener("mousemove",He),document.addEventListener("mouseup",Ue)},Zt=()=>{Oe()};P(()=>(zt(),()=>{var e;(e=o==null?void 0:o.current)==null||e.destroy(),o.current=null,E.unbindAll("setCurrentTimeByPosition"),E.unbindAll("clearRegions"),E.unbindAll("removeRegionById"),E.unbindAll("setSelectedRegion")}),[]);const qt=e=>{var t,r,n;(t=T())==null||t.playPause(),(r=T())==null||r.setPlaybackRate(e),(n=T())==null||n.playPause()};P(()=>(document.addEventListener("keydown",$e),()=>{document.removeEventListener("keydown",$e)})),P(()=>{g({}),Oe()},[H]),P(()=>{Ve()},[xt,C,k]);const Kt=()=>{if(h.current&&C){const e=h.current.scrollLeft,t=h.current.clientWidth,r=e/h.current.scrollWidth*C,n=(e+t)/h.current.scrollWidth*C;jt({start:r,end:n})}},{run:Ve}=et(Kt,{wait:300}),Xe=e=>{var t,r,n,l;if((o==null?void 0:o.current)&&(x==null?void 0:x.current)){const a=(r=(t=o==null?void 0:o.current)==null?void 0:t.getDuration())!=null?r:0,p=(n=x==null?void 0:x.current)==null?void 0:n.getBoundingClientRect();let s=(e.clientX-p.left)/(((l=x==null?void 0:x.current)==null?void 0:l.clientWidth)||0)*a;return s>a&&(s=a),s}return 0},se=e=>{var t;const r=Xe(e);(t=o==null?void 0:o.current)==null||t.skip(r-Ce.current),Q(r)},Gt=e=>{Rt(Xe(e))},Yt=C?Math.max(C-j,0):0,Jt=(d==null?void 0:d.toolName)!==st.Empty&&(d==null?void 0:d.isEdit)!==!0&&(pt==="remark"||S),Ze=i.createElement("div",{className:y.audioPlayer},ht&&!ft&&i.createElement(Er,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:Zt,backgroundColor:"#ffffffbb"}),i.createElement(Or,{getRegionInstanceById:W,clipping:te}),i.createElement(Fr,{container:h.current}),i.createElement($r,{segmentTimeTip:Bt}),i.createElement("div",{className:y.waveformContainer,ref:h,onScroll:()=>Ve()},i.createElement("div",{id:"waveform",style:{width:`${k*100}%`},className:V({[y.waveform]:!0,"bee-audio-combined":c.current.combined,"bee-audio-clip":c.current.clipConfigurable})},dt&&i.createElement(_r,{isAudio:!0}),i.createElement("div",{ref:x,className:y.progress,onMouseDown:Xt,onMouseMove:Gt},i.createElement("div",{className:V({[y.radioTooltip]:!0}),style:{left:Fe}},tt(j)),i.createElement("div",{className:V({[y.radioTooltip]:!0,[y.mouseTooltip]:!0}),style:{left:$t}},tt(Te)),i.createElement(Br,{playPercentage:Fe})),Jt&&(be==null?void 0:be({currentTime:j,remainingTime:Yt,audioPlayer:T()})))),i.createElement("div",{className:y.controlBar},i.createElement(yr,{type:"link",icon:Ft,onClick:()=>{N()},className:V({[y.playButton]:!0,[y.playButtonDisabled]:he})}),i.createElement("span",{className:y.time},`${rt(j,"ss.SSS")} / -${rt(C-j,"ss.SSS")}`),i.createElement(Sr,{playerType:hr.Audio,onChange:e=>{qt(e)}}),i.createElement(Tr,{onChange:e=>{var t;(t=T())==null||t.pause(),Me(e)},zoom:k}),i.createElement(wr,{EventBus:E})));return d?i.createElement(ut.Provider,{value:d},Ze,Dt.map(e=>{const{id:t}=e,r=document.querySelector(`[data-id="${t}"]`);return r?i.createElement(Ar,{el:r,key:t,region:e,edgeAdsorption:we,clipping:te,zoom:k,instance:W(t),isCheck:S}):null}),i.createElement(Hr,{footer:_t})):Ze},Yr=f=>i.createElement(Ur,{i18n:Je},i.createElement(ct,fe({},f)));export{ct as AudioPlayer,ut as AudioPlayerContext,Yr as WrapAudioPlayer};
@@ -1 +1 @@
1
- import l,{forwardRef as h,useRef as E,useMemo as S}from"react";import{Tooltip as T,Popover as x}from"antd";import{useSize as j}from"ahooks";import{prefix as L}from"../../constant/index.js";import{SearchOutlined as C}from"@ant-design/icons";var M=Object.defineProperty,N=Object.defineProperties,R=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,b=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,f=(t,e)=>{for(var r in e||(e={}))g.call(e,r)&&b(t,r,e[r]);if(v)for(var r of v(e))P.call(e,r)&&b(t,r,e[r]);return t},W=(t,e)=>N(t,R(e)),$=(t,e)=>{var r={};for(var n in t)g.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&v)for(var n of v(t))e.indexOf(n)<0&&P.call(t,n)&&(r[n]=t[n]);return r};const u=`${L}-longText`,_=h((t,e)=>{var r=t,{text:n,overflowMaxLines:p,style:i}=r,m=$(r,["text","overflowMaxLines","style"]);const a={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},o={display:"-webkit-box",WebkitLineClamp:p,WebkitBoxOrient:"vertical",overflow:"hidden"},d=p>1?o:a,c=f(f({},d),i!=null?i:{});return l.createElement("div",f({style:c,ref:e},m),n)}),k=t=>{const{text:e,placement:r="bottom",icon:n=l.createElement(C,null),openByText:p,style:i,isToolTips:m,overflowMaxLines:a=1}=t,o=E(null),d=j(o),c=S(()=>{var s,y,O,w;return a>1?o.current&&((s=o.current)==null?void 0:s.clientHeight)<((y=o.current)==null?void 0:y.scrollHeight):o.current&&((O=o.current)==null?void 0:O.clientWidth)<((w=o.current)==null?void 0:w.scrollWidth)},[d]);if(p){let s={placement:r,overlayClassName:`${u}-popover`,content:e,key:`${c}`};return c||Object.assign(s,{open:!1}),m?l.createElement(T,W(f({},s),{title:e}),l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e})):l.createElement(x,f({},s),l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e}))}return l.createElement("div",{className:u,style:i},l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e}),c&&l.createElement(x,{placement:r,overlayClassName:`${u}-popover`,content:e},n))};export{k as default};
1
+ import o,{forwardRef as T,useRef as j,useMemo as L}from"react";import{Tooltip as E,Popover as y}from"antd";import{useSize as C}from"ahooks";import{prefix as W}from"../../constant/index.js";import{SearchOutlined as M}from"@ant-design/icons";var N=Object.defineProperty,R=Object.defineProperties,$=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,h=(t,e,r)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))P.call(e,r)&&h(t,r,e[r]);if(d)for(var r of d(e))b.call(e,r)&&h(t,r,e[r]);return t},S=(t,e)=>R(t,$(e)),k=(t,e)=>{var r={};for(var l in t)P.call(t,l)&&e.indexOf(l)<0&&(r[l]=t[l]);if(t!=null&&d)for(var l of d(t))e.indexOf(l)<0&&b.call(t,l)&&(r[l]=t[l]);return r};const w=`${W}-longText`,m=T((t,e)=>{var r=t,{text:l,overflowMaxLines:v,style:i}=r,u=k(r,["text","overflowMaxLines","style"]);const s={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},f={display:"-webkit-box",WebkitLineClamp:v,WebkitBoxOrient:"vertical",overflow:"hidden"},n=v>1?f:s,_=c(c({},n),i!=null?i:{});return o.createElement("div",c({style:_,ref:e},u),l)}),D=t=>{const{text:e,placement:r="bottom",icon:l=o.createElement(M,null),openByText:v,style:i,isToolTips:u,overflowMaxLines:s=1,maxWordCount:f}=t,n=j(null),_=C(n),x=L(()=>{var a,p,O,g;return s>1?n.current&&((a=n.current)==null?void 0:a.clientHeight)<((p=n.current)==null?void 0:p.scrollHeight):n.current&&((O=n.current)==null?void 0:O.clientWidth)<((g=n.current)==null?void 0:g.scrollWidth)},[_]);if(f){if(e.length>f){const a=e.substring(0,f)+"...",p={placement:r,content:e};return u?o.createElement(E,S(c({},p),{title:e}),o.createElement(m,{overflowMaxLines:s,style:i,ref:n,text:a})):o.createElement(y,c({},p),o.createElement(m,{overflowMaxLines:s,style:i,ref:n,text:a}))}return o.createElement("span",null,e)}if(v){let a={placement:r,overlayClassName:`${w}-popover`,content:e,key:`${x}`};return x||Object.assign(a,{open:!1}),u?o.createElement(E,S(c({},a),{title:e}),o.createElement(m,{overflowMaxLines:s,style:i,ref:n,text:e})):o.createElement(y,c({},a),o.createElement(m,{overflowMaxLines:s,style:i,ref:n,text:e}))}return o.createElement("div",{className:w,style:i},o.createElement(m,{overflowMaxLines:s,style:i,ref:n,text:e}),x&&o.createElement(y,{placement:r,overlayClassName:`${w}-popover`,content:e},l))};export{D as default};
@@ -1 +1 @@
1
- import{useLatest as oe,useMemoizedFn as Z,useDebounceEffect as Ie}from"ahooks";import{Spin as he}from"antd/es";import q,{useContext as De,useRef as J,useState as O,useMemo as _e,useCallback as be,useEffect as p}from"react";import{connect as Ce}from"react-redux";import{usePointCloudViews as we}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as xe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as Pe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Se,ImgUtils as Le}from"@labelbee/lb-annotation";import{ImgPosUtils as Oe}from"@labelbee/lb-utils";import{selectSpecifiedRectsFromTopViewSelectedIds as Ve}from"./util.js";import{useUpdateRectList as Ee}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as Be}from"../../hooks/useToolStyle.js";import Ne from"../../store/toolConfig/index.js";var ke=Object.defineProperty,Ue=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,le=(a,c,s)=>c in a?ke(a,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[c]=s,v=(a,c)=>{for(var s in c||(c={}))Ae.call(c,s)&&le(a,s,c[s]);if(ie)for(var s of ie(c))Me.call(c,s)&&le(a,s,c[s]);return a},C=(a,c)=>Ue(a,ze(c)),$=(a,c,s)=>new Promise((f,g)=>{var _=u=>{try{b(s.next(u))}catch(R){g(R)}},V=u=>{try{b(s.throw(u))}catch(R){g(R)}},b=u=>u.done?f(u.value):Promise.resolve(u.value).then(_,V);b((s=s.apply(a,c)).next())});const Te=a=>{var c,s;const{mappingData:f,size:g,config:_,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:u}=a,{selectBoxVisibleSwitch:R}=Ne(),E=(c=f==null?void 0:f.url)!=null?c:"",w=(s=f==null?void 0:f.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:B,defaultAttribute:N,rectList:k,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:U,selectedID:x}=De(xe),{value:z}=Be(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=we(),A=q.useRef(null),n=J(null),G=Z(fe),y=Z(pe),P=J(null),[me,K]=O(!0),[Q,W]=O(""),[ve,M]=O(!1),[ge,S]=O(!0),I=_e(()=>k==null?void 0:k.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,k]),X=J(I),L=oe(f==null?void 0:f.path),T=be(e=>$(void 0,null,function*(){try{const o=ae.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),i=t.filter(l=>r.has(l.id)).map(l=>l.id);U(i)}return t}catch(o){}}),[U]),Y=e=>{const{boxID:o}=e;if(S(!1),!u&&o){T(()=>{const t=G==null?void 0:G(e);return t?(P.current=t,B(t),t):null});return}se(e,!0)},ee=e=>{L.current&&ce(C(v({},e),{imageName:L.current}))},te=e=>{if(e.length===0)return;if(!u){const t=e.find(r=>r.boxID);if(t){T(()=>{const r=y==null?void 0:y(t);return r?(P.current=r,B(r),h(),r):null});return}}const o=e.find(t=>t.extId);o&&T(()=>{const{imageName:t,extId:r}=o,i=y==null?void 0:y({boxID:r,imageName:t});return i?(P.current=i,B(i),i):null}),ue(e)},Re=Z(()=>{let e=[];return j.forEach(o=>{const{rects:t=[],id:r,attribute:i,trackID:l}=o,d=t.find(F=>F.imageName===L.current),D=r+"_"+L.current;d&&(e=[...e,C(v({},d),{boxID:r,id:D,attribute:i,order:l})])}),e}),h=Ee(()=>{var e,o,t,r,i;const l=u?[]:Re(),d=(e=n.current)==null?void 0:e.selectedRectID,D=m.slice(0),F=R?Ve(D,l,I):[...l,...I];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(H=>d?m.includes(H.boxID)&&!d.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(t=n.current)==null||t.setResult(F),Q?((r=n.current)==null||r.setSelectedRectID(Q),W("")):ve&&d&&((i=n.current)==null||i.setSelectedRectID(d),M(!1))}),re=({targetId:e,id:o})=>{S(!1),U(e),W(o)};return p(()=>{if(A.current){const e=new Se({container:A.current,size:g,config:C(v({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",Y),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,t,r,i,l;(o=n.current)==null||o.unbind("updateDragResult",Y),(t=n.current)==null||t.unbind("afterAddingDrawingRect",ee),(r=n.current)==null||r.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(l=n.current)==null||l.destroy()}}},[]),p(()=>{const e=t=>$(void 0,null,function*(){try{return yield Le.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>$(void 0,null,function*(){var t;K(!0);let r=yield e(E);!r&&w&&(r=yield e(w)),r&&((t=n.current)==null||t.setImgNode(r),b(r)),K(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&h()},[j]),p(()=>{var e,o;const t=I.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,N),t&&de(r=>{var i;const l=[];let d=null;return r.forEach(D=>{D.id!==n.current.selectedRectID?l.push(D):d=D}),t.extId===void 0&&(d=(i=n.current)==null?void 0:i.selectedRect),[...l,C(v({},d||{}),{attribute:N})]}),M(!0),h()},[N]),p(()=>{const e=X.current;je.isEqual(e,I)||(M(!0),h(),X.current=I)},[I]),p(()=>{h()},[u]),p(()=>{var e,o,t,r;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},l=C(v({},i),{attributeList:(t=_.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(l))},[_.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),h()},[m]),Ie(()=>{if(!x||!ge){S(!0),u&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,i=e.find(d=>d.boxID===x||d.extId===x),l=Oe.getBasicRecPos(r,i,o,.5);if(!l){S(!0);return}u&&n.current.setHoverRectID(i.id),n.current.setCurrentPos(l.currentPos),n.current.setZoom(l.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[x],{wait:200}),p(()=>{const{hiddenText:e}=z||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=v(v({},o.style),z);o.setStyle(t)},[z]),p(()=>{h()},[R]),q.createElement(he,{spinning:me},q.createElement("div",{ref:A,style:v({position:"relative"},g)}))};var Fe=Ce(ye,null,null,{context:Pe})(Te);export{Fe as default};
1
+ import{useLatest as ce,useMemoizedFn as Z,useDebounceEffect as _e}from"ahooks";import{Spin as be}from"antd/es";import q,{useContext as Ce,useRef as J,useState as O,useMemo as we,useCallback as ye,useEffect as p}from"react";import{connect as xe}from"react-redux";import{usePointCloudViews as Pe}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as Se}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as Le}from"../../store/annotation/map.js";import{LabelBeeContext as Oe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Ve,ImgUtils as Ee}from"@labelbee/lb-annotation";import{ImgPosUtils as je}from"@labelbee/lb-utils";import{selectSpecifiedRectsFromTopViewSelectedIds as Be}from"./util.js";import{useUpdateRectList as Ne}from"./useUpdateRectList.js";import ke from"lodash";import{useToolStyleContext as Ue}from"../../hooks/useToolStyle.js";import Ae from"../../store/toolConfig/index.js";var Te=Object.defineProperty,ze=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,Fe=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable,se=(a,l,s)=>l in a?Te(a,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[l]=s,v=(a,l)=>{for(var s in l||(l={}))Fe.call(l,s)&&se(a,s,l[s]);if(le)for(var s of le(l))He.call(l,s)&&se(a,s,l[s]);return a},C=(a,l)=>ze(a,Me(l)),$=(a,l,s)=>new Promise((f,g)=>{var _=u=>{try{b(s.next(u))}catch(R){g(R)}},V=u=>{try{b(s.throw(u))}catch(R){g(R)}},b=u=>u.done?f(u.value):Promise.resolve(u.value).then(_,V);b((s=s.apply(a,l)).next())});const Ze=a=>{var l,s;const{mappingData:f,size:g,config:_,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:u}=a,{selectBoxVisibleSwitch:R,attrChangeTrigger:G}=Ae(),E=(l=f==null?void 0:f.url)!=null?l:"",w=(s=f==null?void 0:f.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:B,defaultAttribute:N,rectList:k,addRectIn2DView:ue,updateRectIn2DView:de,removeRectIn2DView:ae,updateRectListByReducer:fe,selectedIDs:m,setSelectedIDs:U,selectedID:y}=Ce(Se),{value:A}=Ue(),pe=ce(m),{update2DViewRect:me,remove2DViewRect:ve}=Pe(),T=q.useRef(null),n=J(null),K=Z(me),x=Z(ve),P=J(null),[ge,Q]=O(!0),[W,X]=O(""),[Re,z]=O(!1),[Ie,S]=O(!0),I=we(()=>k==null?void 0:k.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,k]),Y=J(I),L=ce(f==null?void 0:f.path),M=ye(e=>$(void 0,null,function*(){try{const o=pe.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),i=t.filter(c=>r.has(c.id)).map(c=>c.id);U(i)}return t}catch(o){}}),[U]),ee=e=>{const{boxID:o}=e;if(S(!1),!u&&o){M(()=>{const t=K==null?void 0:K(e);return t?(P.current=t,B(t),t):null});return}de(e,!0)},te=e=>{L.current&&ue(C(v({},e),{imageName:L.current}))},re=e=>{if(e.length===0)return;if(!u){const t=e.find(r=>r.boxID);if(t){M(()=>{const r=x==null?void 0:x(t);return r?(P.current=r,B(r),h(),r):null});return}}const o=e.find(t=>t.extId);o&&M(()=>{const{imageName:t,extId:r}=o,i=x==null?void 0:x({boxID:r,imageName:t});return i?(P.current=i,B(i),i):null}),ae(e)},he=Z(()=>{let e=[];return j.forEach(o=>{const{rects:t=[],id:r,attribute:i,trackID:c}=o,d=t.find(F=>F.imageName===L.current),D=r+"_"+L.current;d&&(e=[...e,C(v({},d),{boxID:r,id:D,attribute:i,order:c})])}),e}),h=Ne(()=>{var e,o,t,r,i;const c=u?[]:he(),d=(e=n.current)==null?void 0:e.selectedRectID,D=m.slice(0),F=R?Be(D,c,I):[...c,...I];let ie=[];!R&&(m==null?void 0:m.length)&&(ie=c.filter(H=>d?m.includes(H.boxID)&&!d.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ie),(t=n.current)==null||t.setResult(F),W?((r=n.current)==null||r.setSelectedRectID(W),X("")):Re&&d&&((i=n.current)==null||i.setSelectedRectID(d),z(!1))}),ne=({targetId:e,id:o})=>{S(!1),De(e),X(o)},De=e=>{(Array.isArray(m)?m:[]).includes(e)||U(e)},oe=()=>{var e,o;const t=I.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,N),t&&fe(r=>{var i;const c=[];let d=null;return r.forEach(D=>{D.id!==n.current.selectedRectID?c.push(D):d=D}),t.extId===void 0&&(d=(i=n.current)==null?void 0:i.selectedRect),[...c,C(v({},d||{}),{attribute:N})]}),z(!0),h()};return p(()=>{if(T.current){const e=new Ve({container:T.current,size:g,config:C(v({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",ee),n.current.on("afterAddingDrawingRect",te),n.current.on("deleteSelectedRects",re),n.current.on("onRightClick",ne),()=>{var o,t,r,i,c;(o=n.current)==null||o.unbind("updateDragResult",ee),(t=n.current)==null||t.unbind("afterAddingDrawingRect",te),(r=n.current)==null||r.unbind("deleteSelectedRects",re),(i=n.current)==null||i.unbind("onRightClick",ne),(c=n.current)==null||c.destroy()}}},[]),p(()=>{const e=t=>$(void 0,null,function*(){try{return yield Ee.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>$(void 0,null,function*(){var t;Q(!0);let r=yield e(E);!r&&w&&(r=yield e(w)),r&&((t=n.current)==null||t.setImgNode(r),b(r)),Q(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&h()},[j]),p(()=>{oe()},[N]),p(()=>{G&&oe()},[G]),p(()=>{const e=Y.current;ke.isEqual(e,I)||(z(!0),h(),Y.current=I)},[I]),p(()=>{h()},[u]),p(()=>{var e,o,t,r;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},c=C(v({},i),{attributeList:(t=_.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(c))},[_.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),h()},[m]),_e(()=>{if(!y||!Ie){S(!0),u&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,i=e.find(d=>d.boxID===y||d.extId===y),c=je.getBasicRecPos(r,i,o,.5);if(!c){S(!0);return}u&&n.current.setHoverRectID(i.id),n.current.setCurrentPos(c.currentPos),n.current.setZoom(c.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[y],{wait:200}),p(()=>{const{hiddenText:e}=A||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=v(v({},o.style),A);o.setStyle(t)},[A]),p(()=>{h()},[R]),q.createElement(be,{spinning:ge},q.createElement("div",{ref:T,style:v({position:"relative"},g)}))};var qe=xe(Le,null,null,{context:Oe})(Ze);export{qe as default};