@labelbee/lb-components 1.24.0-alpha.5 → 1.24.0-alpha.51
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.
- package/dist/_virtual/2DViewWorker.js +1 -1
- package/dist/assets/annotation/rectTool/three_points_rect.svg.js +1 -0
- package/dist/assets/annotation/rectTool/two_points_rect.svg.js +1 -0
- package/dist/components/DynamicResizer/DynamicResizer.js +1 -1
- package/dist/components/DynamicResizer/hooks/useDrag.js +1 -1
- package/dist/components/DynamicResizer/hooks/useDraggingAllowed.js +1 -0
- package/dist/components/DynamicResizer/hooks/useUpdateHeight.js +1 -1
- package/dist/components/DynamicResizer/utils/index.js +1 -0
- package/dist/components/LLMMultiWheelView/dialogView/index.js +1 -1
- package/dist/components/LLMMultiWheelView/index.js +1 -1
- package/dist/components/LLMMultiWheelView/sidebar/index.js +1 -1
- package/dist/components/LLMToolView/index.js +1 -1
- package/dist/components/LLMToolView/modelAPIView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/audioView/index.js +1 -0
- package/dist/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/dist/components/LLMToolView/questionView/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/dist/components/attributeList/index.js +1 -1
- package/dist/components/audioAnnotate/index.js +1 -1
- package/dist/components/audioPlayer/index.js +1 -1
- package/dist/components/longText/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/components/TitleButton/index.js +1 -1
- package/dist/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
- package/dist/components/pointCloudView/components/sideAndBackOverView/index.js +1 -1
- package/dist/components/pointCloudView/hooks/useConfig.js +1 -1
- package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudAttribute.js +1 -0
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/components/tagList/index.js +1 -1
- package/dist/components/videoPlayer/components/SpeedController/index.js +1 -1
- package/dist/components/videoPlayer/index.js +1 -1
- package/dist/constant/index.js +1 -1
- package/dist/index.css +112 -90
- package/dist/store/Actions.js +1 -1
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/store/toolConfig/pointCloudToolConfig.js +1 -1
- package/dist/types/components/DynamicResizer/DynamicResizer.d.ts +3 -3
- package/dist/types/components/DynamicResizer/hooks/useDrag.d.ts +24 -7
- package/dist/types/components/DynamicResizer/hooks/useDraggingAllowed.d.ts +12 -0
- package/dist/types/components/DynamicResizer/hooks/useUpdateHeight.d.ts +10 -21
- package/dist/types/components/DynamicResizer/types/interface.d.ts +14 -6
- package/dist/types/components/DynamicResizer/utils/index.d.ts +4 -0
- package/dist/types/components/LLMMultiWheelView/dialogView/index.d.ts +2 -0
- package/dist/types/components/LLMMultiWheelView/index.d.ts +2 -0
- package/dist/types/components/LLMToolView/questionView/components/audioView/index.d.ts +8 -0
- package/dist/types/components/LLMToolView/questionView/components/header/index.d.ts +3 -1
- package/dist/types/components/attributeList/components/limitPopover/index.d.ts +2 -2
- package/dist/types/components/longText/index.d.ts +1 -1
- package/dist/types/components/pointCloud2DRectOperationView/useUpdateRectList.d.ts +0 -1
- package/dist/types/components/pointCloudView/PointCloudContext.d.ts +4 -0
- package/dist/types/components/pointCloudView/PointCloudListener.d.ts +1 -0
- package/dist/types/components/pointCloudView/hooks/useConfig.d.ts +2 -1
- package/dist/types/components/pointCloudView/hooks/usePointCloudAttribute.d.ts +3 -0
- package/dist/types/components/pointCloudView/hooks/useRotate.d.ts +1 -2
- package/dist/types/components/pointCloudView/hooks/useRotateEdge.d.ts +1 -2
- package/dist/types/components/pointCloudView/index.d.ts +2 -0
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +1 -1
- package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
- package/dist/types/components/videoAnnotate/videoTextTool/index.d.ts +1 -1
- package/dist/types/components/videoPlayer/index.d.ts +1 -1
- package/dist/types/constant/index.d.ts +4 -2
- package/dist/types/store/Actions.d.ts +1 -0
- package/dist/types/store/annotation/actionCreators.d.ts +9 -1
- package/dist/types/store/annotation/map.d.ts +1 -0
- package/dist/types/store/annotation/reducer.d.ts +5 -1
- package/dist/types/store/annotation/types.d.ts +4 -2
- package/dist/types/store/toolConfig/types.d.ts +2 -0
- package/dist/types/utils/LLM.d.ts +6 -0
- package/dist/types/views/MainView/index.d.ts +2 -0
- package/dist/types/views/MainView/sidebar/GeneralOperation/ActionsConfirm.d.ts +3 -0
- package/dist/types/views/MainView/sidebar/GeneralOperation/index.d.ts +9 -0
- package/dist/types/views/MainView/sidebar/index.d.ts +2 -0
- package/dist/utils/LLM.js +1 -0
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/dist/views/MainView/LLMMultiWheelLayout/index.js +1 -1
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/dist/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/ToolIcons.js +1 -1
- package/dist/views/MainView/sidebar/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/assets/annotation/rectTool/three_points_rect.svg.js +1 -0
- package/es/assets/annotation/rectTool/two_points_rect.svg.js +1 -0
- package/es/components/DynamicResizer/DynamicResizer.js +1 -1
- package/es/components/DynamicResizer/hooks/useDrag.js +1 -1
- package/es/components/DynamicResizer/hooks/useDraggingAllowed.js +1 -0
- package/es/components/DynamicResizer/hooks/useUpdateHeight.js +1 -1
- package/es/components/DynamicResizer/utils/index.js +1 -0
- package/es/components/LLMMultiWheelView/dialogView/index.js +1 -1
- package/es/components/LLMMultiWheelView/index.js +1 -1
- package/es/components/LLMMultiWheelView/sidebar/index.js +1 -1
- package/es/components/LLMToolView/index.js +1 -1
- package/es/components/LLMToolView/modelAPIView/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/audioView/index.js +1 -0
- package/es/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/es/components/LLMToolView/questionView/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/es/components/attributeList/index.js +1 -1
- package/es/components/audioAnnotate/index.js +1 -1
- package/es/components/audioPlayer/index.js +1 -1
- package/es/components/longText/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/components/TitleButton/index.js +1 -1
- package/es/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
- package/es/components/pointCloudView/components/sideAndBackOverView/index.js +1 -1
- package/es/components/pointCloudView/hooks/useConfig.js +1 -1
- package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudAttribute.js +1 -0
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/index.js +1 -1
- package/es/components/tagList/index.js +1 -1
- package/es/components/videoPlayer/components/SpeedController/index.js +1 -1
- package/es/components/videoPlayer/index.js +1 -1
- package/es/constant/index.js +1 -1
- package/es/index.css +112 -90
- package/es/store/Actions.js +1 -1
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/store/toolConfig/pointCloudToolConfig.js +1 -1
- package/es/utils/LLM.js +1 -0
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/views/MainView/LLMMultiWheelLayout/index.js +1 -1
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/ToolIcons.js +1 -1
- package/es/views/MainView/sidebar/index.js +1 -1
- package/package.json +8 -8
- package/dist/components/DynamicResizer/assets/bottomToZero.svg.js +0 -1
- package/dist/components/DynamicResizer/assets/divider.svg.js +0 -1
- package/dist/components/DynamicResizer/assets/topToZero.svg.js +0 -1
- package/es/components/DynamicResizer/assets/bottomToZero.svg.js +0 -1
- package/es/components/DynamicResizer/assets/divider.svg.js +0 -1
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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{
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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};
|