@labelbee/lb-components 1.23.0-alpha.99 → 1.23.1-alpha.1
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/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/dist/components/AnnotationView/index.js +1 -1
- package/dist/components/LLMMultiWheelView/dialogView/index.js +1 -0
- package/dist/components/LLMMultiWheelView/index.js +1 -0
- package/dist/components/LLMMultiWheelView/sidebar/index.js +1 -0
- package/dist/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -0
- package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/index.js +1 -1
- package/dist/components/attributeList/index.js +1 -1
- package/dist/components/audioPlayer/index.js +1 -1
- package/dist/components/audioPlayer/useAudioScroll/index.js +1 -1
- package/dist/components/markdownView/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudSegmentListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/components/predictTracking/predictTrackingIcon/index.js +1 -1
- package/dist/components/predictTracking/previewResult/index.js +1 -1
- package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/dist/data/enums/ToolType.js +1 -1
- package/dist/index.css +71 -4
- package/dist/index.js +1 -1
- package/dist/store/LLMMultiWheel/index.js +1 -0
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/store/ctx.js +1 -1
- package/dist/store/toolConfig/baseToolConfig.js +1 -0
- package/dist/store/toolConfig/index.js +1 -0
- package/dist/store/toolConfig/pointCloudToolConfig.js +1 -0
- package/dist/types/App.d.ts +1 -0
- package/dist/types/components/AnnotationView/hooks/useFilterAnnotations.d.ts +2 -0
- package/dist/types/components/AnnotationView/index.d.ts +9 -0
- package/dist/types/components/LLMMultiWheelView/dialogView/index.d.ts +15 -0
- package/dist/types/components/LLMMultiWheelView/index.d.ts +21 -0
- package/dist/types/components/LLMMultiWheelView/sidebar/index.d.ts +8 -0
- package/dist/types/components/LLMMultiWheelView/types.d.ts +62 -0
- package/dist/types/components/LLMToolView/questionView/components/header/index.d.ts +15 -0
- package/dist/types/components/LLMToolView/questionView/index.d.ts +7 -0
- package/dist/types/components/LLMToolView/sidebar/components/answerSort/index.d.ts +3 -0
- package/dist/types/components/LLMToolView/sidebar/components/modelAnswerSort/index.d.ts +30 -0
- package/dist/types/components/LLMToolView/sidebar/components/textInputBox/index.d.ts +2 -2
- package/dist/types/components/LLMToolView/sidebar/index.d.ts +10 -0
- package/dist/types/components/LLMToolView/types.d.ts +6 -2
- package/dist/types/components/LLMToolView/utils/data.d.ts +1 -0
- package/dist/types/components/pointCloudView/PointCloudListener.d.ts +1 -0
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +23 -1
- package/dist/types/components/pointCloudView/hooks/useUpdatePointCloudColor.d.ts +4 -0
- package/dist/types/components/pointCloudView/index.d.ts +1 -0
- package/dist/types/data/enums/ToolType.d.ts +2 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/store/LLMMultiWheel/index.d.ts +15 -0
- package/dist/types/store/annotation/actionCreators.d.ts +1 -1
- package/dist/types/store/ctx.d.ts +7 -0
- package/dist/types/store/toolConfig/baseToolConfig.d.ts +4 -0
- package/dist/types/store/toolConfig/index.d.ts +3 -0
- package/dist/types/store/toolConfig/pointCloudToolConfig.d.ts +4 -0
- package/dist/types/store/toolConfig/types.d.ts +10 -0
- package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +2 -1
- package/dist/types/views/MainView/LLMMultiWheelLayout/index.d.ts +9 -0
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.d.ts +3 -0
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.d.ts +3 -0
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/dist/views/MainView/LLMMultiWheelLayout/index.js +1 -0
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.module.scss.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.module.scss.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/index.js +1 -1
- package/dist/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/es/components/AnnotationView/index.js +1 -1
- package/es/components/LLMMultiWheelView/dialogView/index.js +1 -0
- package/es/components/LLMMultiWheelView/index.js +1 -0
- package/es/components/LLMMultiWheelView/sidebar/index.js +1 -0
- package/es/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/es/components/LLMToolView/questionView/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -0
- package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/es/components/LLMToolView/sidebar/index.js +1 -1
- package/es/components/attributeList/index.js +1 -1
- package/es/components/audioPlayer/index.js +1 -1
- package/es/components/audioPlayer/useAudioScroll/index.js +1 -1
- package/es/components/markdownView/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/PointCloudSegmentListener.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/es/components/pointCloudView/index.js +1 -1
- package/es/components/predictTracking/predictTrackingIcon/index.js +1 -1
- package/es/components/predictTracking/previewResult/index.js +1 -1
- package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/es/data/enums/ToolType.js +1 -1
- package/es/index.css +71 -4
- package/es/index.js +1 -1
- package/es/store/LLMMultiWheel/index.js +1 -0
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/store/ctx.js +1 -1
- package/es/store/toolConfig/baseToolConfig.js +1 -0
- package/es/store/toolConfig/index.js +1 -0
- package/es/store/toolConfig/pointCloudToolConfig.js +1 -0
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/views/MainView/LLMMultiWheelLayout/index.js +1 -0
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.module.scss.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.module.scss.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/index.js +1 -1
- package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as u}from"react";const a=(n=[],t,r)=>u(()=>r&&(t==null?void 0:t.length)?n.filter(o=>t.includes(o.annotation.id)):n,[n,t,r]);export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import w,{useState as
|
|
1
|
+
import w,{useState as Q,useRef as y,useContext as W,useImperativeHandle as X,useEffect as c,useCallback as D}from"react";import{ViewOperation as Y,ImgUtils as ee}from"@labelbee/lb-annotation";import{Spin as te}from"antd/es";import ne from"../../hooks/useRefCache.js";import re from"../measureCanvas/index.js";import{PointCloudContext as oe}from"../pointCloudView/PointCloudContext.js";import ie from"./hooks/useFilterAnnotations.js";import ae from"../../store/toolConfig/index.js";var le=Object.defineProperty,N=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,T=(n,r,o)=>r in n?le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,R=(n,r)=>{for(var o in r||(r={}))ue.call(r,o)&&T(n,o,r[o]);if(N)for(var o of N(r))ce.call(r,o)&&T(n,o,r[o]);return n},B=(n,r,o)=>new Promise((v,d)=>{var s=u=>{try{f(o.next(u))}catch(m){d(m)}},I=u=>{try{f(o.throw(u))}catch(m){d(m)}},f=u=>u.done?v(u.value):Promise.resolve(u.value).then(s,I);f((o=o.apply(n,r)).next())});const x={width:455,height:100},se=n=>{if(!n)return x;if(n.width&&n.height)return n;const r=R({},n);return r.width||(r.width=x.width),r.height||(r.height=x.height),r},de=(n,r)=>{var o,v;const{src:d,fallbackSrc:s,annotations:I=[],style:f={stroke:"blue",thickness:3},zoomChange:u,backgroundStyle:m={},onChange:P,showLoading:F=!1,globalStyle:M,afterImgOnLoad:U,measureVisible:S,onRightClick:g,pointCloudBoxList:A=[],hiddenText:E=!1,renderToolName:Z}=n,p=se(n.size),[H,k]=Q(!1),z=y(null),e=y(),L=ne(U),h=y([]),_=y(!0),{selectedIDs:$}=W(oe),{selectBoxVisibleSwitch:q}=ae(),C=ie(I,$,q);X(r,()=>{const t=e.current;return t?{zoomIn:()=>t.zoomChanged(!0),zoomOut:()=>t.zoomChanged(!1),initImgPos:()=>t.initImgPos(),toolInstance:t}:{}},[e.current]),c(()=>(z.current&&(e.current=new Y({container:z.current,size:p,style:f,annotations:C,config:"{}",zoomInfo:n.zoomInfo,staticMode:n.staticMode,renderToolName:Z}),e.current.init(),g&&e.current.on("onRightClick",g)),()=>{var t,a;g&&((t=e.current)==null||t.unbind("onRightClick",g)),(a=e.current)==null||a.destroy()}),[S]);const O=D(t=>B(void 0,null,function*(){var a,i;try{const l=yield ee.load(t);return(a=e.current)==null||a.setImgNode(l),(i=L.current)==null||i.call(L,l),null}catch(l){return console.error("Error loading image:",l),l}}),[]),j=D(t=>B(void 0,null,function*(){var a,i;if(k(!0),(a=e.current)==null||a.setLoading(!0),(yield O(t))&&s){const b=yield O(s);b&&console.error("Error loading fallback image:",b)}(i=e.current)==null||i.setLoading(!1),k(!1)}),[O,s]);c(()=>{e.current&&j(d)},[d,S,s,j]),c(()=>{(e==null?void 0:e.current)&&e.current.setPointCloudBoxList(A)},[A]),c(()=>{var t;(e==null?void 0:e.current)&&((t=e.current)==null||t.setHiddenText(E))},[E]),c(()=>{if(_.current===!1){h.current.push(C);return}const t=()=>{_.current=!0,h.current=[]},a=()=>{var i;const l=h.current.length;if(l>0){const b=h.current[l-1];h.current=[],(i=e.current)==null||i.updateData(b).then(a).catch(t)}else _.current=!0};e.current&&(_.current=!1,e.current.updateData(C).then(a).catch(t))},[C]),c(()=>{const t=e.current;(t==null?void 0:t.setSize)&&(t.setSize(p),t.initPosition())},[(o=n.size)==null?void 0:o.width,(v=n.size)==null?void 0:v.height]),c(()=>{var t,a;return e.current&&((t=e.current)==null||t.on("onChange",(...i)=>{P==null||P.apply(null,i)}),(a=e.current)==null||a.on("renderZoom",i=>{u&&u(i)})),()=>{var i,l;(i=e.current)==null||i.unbindAll("onChange"),(l=e.current)==null||l.unbindAll("renderZoom")}},[u,P]);const G=w.createElement("div",{ref:z,style:R(R({position:"relative"},p),m)}),{imgNode:V,zoom:J,currentPos:K}=e.current||{};return w.createElement(te,{spinning:F||H,delay:300,style:M},S&&V?w.createElement(re,{size:p,imgNode:V,zoom:J,currentPos:K}):G)};var fe=w.forwardRef(de);export{fe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getTextControlByConfig as I,RenderAnswer as N}from"../../LLMToolView/questionView/index.js";import{RenderQuestion as V}from"../../LLMToolView/questionView/components/header/index.js";import j from"../../LLMToolView/questionView/components/imgView/index.js";import x from"../../../store/LLMMultiWheel/index.js";import{classnames as h}from"../../../utils/index.js";import{Button as s}from"antd";import e from"react";import{useTranslation as M}from"react-i18next";var T=Object.defineProperty,q=Object.defineProperties,D=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,d=(o,t,r)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,S=(o,t)=>{for(var r in t||(t={}))F.call(t,r)&&d(o,r,t[r]);if(p)for(var r of p(t))C.call(t,r)&&d(o,r,t[r]);return o},b=(o,t)=>q(o,D(t));const A=o=>{const{id:t,answerList:r,question:u,index:f,name:w="",answerIsImg:v,questionIsImg:_,LLMConfig:g}=o,{t:n}=M(),{dataFormatType:i,selectedID:E,setSelectedID:y}=x(),a=f+1,L=w||`${n("Dialog")}${a}`;return e.createElement("div",{key:t,onClick:()=>y(t),className:h({dialog:!0,selected:t===E})},e.createElement("div",{className:"header"},e.createElement("span",{className:"order"},a),e.createElement("div",{className:"name"},e.createElement("div",{className:"show-name"},L),e.createElement("div",{className:"tips"},"\uFF08",n("SelectionOfAnnotation"),"\uFF09"))),e.createElement("div",{className:"dialog-question"},e.createElement(s,{type:"primary"},n("Title"),a),e.createElement("div",null,e.createElement(V,{question:u,dataFormatType:i,isImg:_}))),e.createElement("div",{className:"dialog-answer"},v?e.createElement(e.Fragment,null,e.createElement(s,{type:"primary"},n("Answer")),e.createElement(j,{answerList:r})):r==null?void 0:r.map((O,l)=>{const m=l+1,c=b(S({},O),{order:m}),P=I(c,g);return e.createElement("div",{key:l},e.createElement(s,{type:"primary"},n("Answer"),m),e.createElement(N,{i:c,isTextControl:P,dataFormatType:i}))})))};export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i,{useEffect as M,useState as E}from"react";import{ELLMDataType as W}from"../../constant/index.js";import{getStepConfig as Y}from"../../store/annotation/reducer.js";import{LabelBeeContext as Z}from"../../store/ctx.js";import{jsonParser as ee}from"../../utils/index.js";import{connect as te}from"react-redux";import A from"../../store/LLMMultiWheel/index.js";import{LLMMultiWheelViewCls as $}from"../../views/MainView/LLMMultiWheelLayout/index.js";import{ToggleDataFormatType as ne}from"../LLMToolView/questionView/components/header/index.js";import oe from"./dialogView/index.js";import re from"../messageMaskLayer/index.js";import ie from"../../views/MainView/annotationTips/index.js";import{I18nextProvider as ae,useTranslation as se}from"react-i18next";import{LLMViewCls as le}from"../LLMToolView/questionView/index.js";import{Layout as ue}from"antd";import{i18n as F}from"@labelbee/lb-utils";var ce=Object.defineProperty,de=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,k=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))me.call(e,n)&&k(t,n,e[n]);if(N)for(var n of N(e))Le.call(e,n)&&k(t,n,e[n]);return t},h=(t,e)=>de(t,pe(e));const R=t=>{const{questionIsImg:e,answerIsImg:n,LLMConfig:l,dialogList:p,lang:u="cn"}=t,{dataFormatType:c,setDataFormatType:a}=A();return M(()=>{var o;u&&((o=F)==null||o.changeLanguage(u))},[u]),i.createElement(ae,{i18n:F},i.createElement("div",{className:`${$}`},i.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},i.createElement(ne,{dataFormatType:c,setDataFormatType:a})),i.createElement("div",{className:`${$}-container`},p==null?void 0:p.map((o,d)=>i.createElement(oe,h(y({},o),{key:d,index:d,questionIsImg:e,answerIsImg:n,LLMConfig:l}))))))},U=({type:t,questionIndex:e,answerIndex:n,llmFile:l})=>{if(t==="question")return l==null?void 0:l.find((u,c)=>e===c);let p=null;return l==null||l.forEach((u,c)=>{var a;(a=u.answerList)==null||a.forEach((o,d)=>{c===e&&n===d&&(p=o)})}),p},fe=t=>{var e,n;const{annotation:l,tips:p,showTips:u,drawLayerSlot:c}=t,{imgIndex:a,imgList:o,stepList:d,step:x,toolInstance:v}=l,[w,B]=E(),{setSelectedID:Q,newAnswerListMap:I}=A(),[z,T]=E([]),j=((e=w==null?void 0:w.dataType)==null?void 0:e.prompt)===W.Picture,P=((n=w==null?void 0:w.dataType)==null?void 0:n.response)===W.Picture,{t:G}=se(),[,H]=E(0);return M(()=>{var r,m,L;if(!o[a])return;const g=(r=o[a])!=null?r:{},f=(L=(m=g==null?void 0:g.questionList)==null?void 0:m.textList)!=null?L:[];T(f),(f==null?void 0:f.length)&&Q(f[0].id)},[a]),M(()=>{var r,m;const L=(r=o[a])!=null?r:{},g=L==null?void 0:L.questionList,f=(m=L==null?void 0:L.llmFile)==null?void 0:m.textList,V=g==null?void 0:g.textList,J=V==null?void 0:V.map((s,b)=>{var D;return h(y({},s),{question:j&&U({type:"question",questionIndex:b,llmFile:f})||(s==null?void 0:s.question),answerList:(D=s==null?void 0:s.answerList)==null?void 0:D.map((_,O)=>{var S,q,C;const K=`${(S=s==null?void 0:s.id)!=null?S:""}-${(q=_==null?void 0:_.id)!=null?q:""}`,X=P?U({type:"answer",questionIndex:b,answerIndex:O,llmFile:f})||{}:{};return y(h(y({},_),{answer:_.answer,newAnswer:(C=I[K])!=null?C:_.answer,order:O+1}),X)})})});T(J)},[I,j,P]),M(()=>{var r;if(d&&x){const m=(r=Y(d,x))==null?void 0:r.config;B(ee(m))}},[d,x]),M(()=>{if(v)return v.on("validUpdated",()=>{H(r=>r+1)}),()=>{v.unbindAll("validUpdated")}},[v]),i.createElement(ue,{className:le},!(v==null?void 0:v.valid)&&i.createElement(re,{message:G("InvalidQuestionAndSkip")}),c==null?void 0:c({}),u===!0&&i.createElement(ie,{tips:p}),i.createElement(R,{questionIsImg:j,answerIsImg:P,LLMConfig:w,dialogList:z}))},ve=t=>({annotation:t.annotation});var we=te(ve,null,null,{context:Z})(fe);export{R as LLMMultiWheelSourceView,we as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r,{useState as T,useRef as It,useMemo as N,useEffect as $}from"react";import{LabelBeeContext as Vt}from"../../../store/ctx.js";import{connect as Nt}from"react-redux";import{prefix as $t}from"../../../constant/index.js";import{getStepConfig as Bt}from"../../../store/annotation/reducer.js";import{jsonParser as dt}from"../../../utils/index.js";import Wt,{getSorts as ct}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as Ft}from"react-i18next";import{useCustomToolInstance as kt}from"../../../hooks/annotation.js";import{isBoolean as qt,isString as Gt,isNumber as Kt,isObject as zt,isArray as Ut}from"lodash";import{PageForward as B}from"../../../store/annotation/actionCreators.js";import{cKeyCode as Qt,EToolName as Jt}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Ht,EmptyConfig as Xt}from"../../LLMToolView/sidebar/index.js";import Yt from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as pt}from"antd";import Zt from"../../LLMToolView/sidebar/components/answerList/index.js";import te from"../../../store/LLMMultiWheel/index.js";import ee from"../../../utils/StepUtils.js";import{getRenderDataByResult as ne,getTagResult as oe,getCurrentResultFromResultList as re}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as z}from"ahooks";import le from"../../LLMToolView/sidebar/components/answerSort/index.js";import ie from"../../tagList/components/overall/index.js";var se=Object.defineProperty,ae=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,ft=(p,d,m)=>d in p?se(p,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[d]=m,l=(p,d)=>{for(var m in d||(d={}))de.call(d,m)&&ft(p,m,d[m]);if(mt)for(var m of mt(d))ce.call(d,m)&&ft(p,m,d[m]);return p},u=(p,d)=>ae(p,ue(d));const pe=Qt.default,vt=`${$t}-sidebar`,me={sort:[],answerSort:{},textAttribute:[],tagList:{}},fe=p=>{var d,m,U,Q,J,H;const{annotation:Lt,dispatch:R,checkMode:gt}=p,{imgIndex:M,imgList:W,stepList:A,step:h,skipBeforePageTurning:D}=Lt,[c,xt]=T(),{t:S}=Ft(),o=(d=W[M])!=null?d:{},X=dt(o==null?void 0:o.result),{toolInstanceRef:L}=kt({basicInfo:X}),[F,wt]=T(!0),[O,Y]=T({}),[g,Z]=T(me),k=It(),[_,q]=T({}),{selectedID:P,setNewAnswerListMap:tt,newAnswerListMap:et}=te(),b=N(()=>O[P],[P,O]),y=!L.current.valid||gt;$(()=>{var t;if(A&&h){const e=(t=Bt(A,h))==null?void 0:t.config;xt(dt(e))}},[h,JSON.stringify(A)]),$(()=>{!o||M===-1||(L.current.setValid=nt,L.current.clearResult=St,nt(),ot())},[M,c,o==null?void 0:o.id]);const St=()=>{var t,e,n,i;ot((t=o==null?void 0:o.questionList)==null?void 0:t.textList),((e=k.current)==null?void 0:e.clearValue)&&((n=k.current)==null||n.clearValue());const{waitSorts:f}=ct({selectedSort:(i=x==null?void 0:x.sort)!=null?i:[],initSelected:[],modelList:j?V!=null?V:[]:[]});q(u(l({},_),{waitSorts:f,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;qt(n)&&(wt(n),L.current.valid=n,(e=L.current)==null||e.emit("validUpdated"))},_t=()=>{const t=ee.getCurrentStepInfo(h,A);return re(o==null?void 0:o.result,t.step)},x=N(()=>_t(),[h,A,o]),ot=z(t=>{var e,n,i,f,s,w,C;const a=x;let E=(e=o==null?void 0:o.questionList)==null?void 0:e.textList;((n=a==null?void 0:a.modelData)==null?void 0:n.length)&&L.current.valid&&(E=a==null?void 0:a.modelData),t&&(E=t,a.sort=[],a.textAttribute=[],a.answerSort=[]);let at={};E==null||E.forEach((v,Dt)=>{var ut;const Ot=ne(c,u(l({},v),{answerList:(ut=v==null?void 0:v.answerList)==null?void 0:ut.map((K,Pt)=>(tt(u(l({},et),{[`${v.id}-${K.id}`]:K.answer})),u(l({},K),{order:Pt+1})))}));at[v.id]=u(l({},Ot),{order:Dt+1,id:v.id})});const{waitSorts:jt,newSort:Ct}=ct({selectedSort:(i=x==null?void 0:x.sort)!=null?i:[],modelList:j?V!=null?V:[]:[]});q({waitSorts:jt,newSort:Ct});const Tt=((f=c==null?void 0:c.inputList)==null?void 0:f.filter(v=>v==null?void 0:v.isOverall))||[],Rt=oe(Tt,a==null?void 0:a.tagList);Z({sort:(s=a==null?void 0:a.sort)!=null?s:[],textAttribute:(w=a==null?void 0:a.textAttribute)!=null?w:[],answerSort:(C=a==null?void 0:a.answerSort)!=null?C:{},tagList:Rt}),Y(at)});$(()=>{bt()},[O,F,g]),$(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const bt=z(()=>{var t,e;const n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var s;const w=(s=O[f.id])!=null?s:{};return{id:f.id,answerList:w.answerList}}),i=u(l({},g),{modelData:n});L.current.exportData=()=>[[i],{valid:F}],L.current.currentPageResult=u(l({},i),{toolName:Jt.LLMMultiWheel,valid:F})}),rt=t=>{if(t.ctrlKey&&t.keyCode===pe.Enter){if(D){D(()=>R(B()));return}R(B())}},yt=z(({order:t,value:e,key:n})=>{const{answerList:i}=b,f=i==null?void 0:i.map(s=>{var w,C;if((s==null?void 0:s.order)===t){if(n==="textEdit"&&Gt(e))return tt(u(l({},et),{[`${P}-${(w=s==null?void 0:s.id)!=null?w:""}`]:e})),u(l({},s),{newAnswer:e});if(Kt(e))return u(l({},s),{score:e});if(zt(e)&&n){const a={[e==null?void 0:e.key]:e.value},E=(C=s[n])!=null?C:{};return u(l({},s),{[n]:l(l({},E),a)})}}return s});Y(s=>u(l({},s),{[P]:u(l({},b),{answerList:f})}))}),I=(t,e)=>{Z(n=>u(l({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:Et,dialogSort:j=!1,inputList:G=[],tagInputListConfigurable:st,enableSort:Mt=!1}=c||{},V=N(()=>{var t,e,n;return j?(n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map((i,f)=>u(l({},i),{title:f+1})))!=null?n:[]:[]},[o,j]);if(N(()=>Ht(c),[c]))return r.createElement(Xt,null);const At=st&&((m=G.filter(t=>!t.isOverall))==null?void 0:m.length)>0,ht=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||Et||At;return r.createElement("div",{className:`${vt}`},r.createElement("div",{className:`${vt}__content`},r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("GlobalAnnotation")),j&&r.createElement(le,{waitSortList:(_==null?void 0:_.waitSorts)||[],sortList:(_==null?void 0:_.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(i=>i.id));I("sort",e),q(u(l({},_),{newSort:t}))},disabeledAll:y,title:S("SortConversationQuality"),prefixId:"model"}),(c==null?void 0:c.text)&&r.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},r.createElement(Yt,{textAttribute:(U=g==null?void 0:g.textAttribute)!=null?U:[],textConfig:(c==null?void 0:c.text)&&Ut(c.text)?c==null?void 0:c.text:[],setText:t=>I("textAttribute",t),disabeledAll:y})),Mt&&r.createElement(Wt,{modelData:(J=(Q=o==null?void 0:o.questionList)==null?void 0:Q.textList)!=null?J:[],selectedAnswerSort:t=>I("answerSort",t),selectedSort:(H=x==null?void 0:x.answerSort)!=null?H:[],ref:k,disabeledAll:y,imgIndex:M}),st&&G.length&&r.createElement(ie,{inputList:G,selectedTags:(g==null?void 0:g.tagList)||{},updateValue:t=>{const{key:e,value:n}=t,i=(g==null?void 0:g.tagList)||{};I("tagList",u(l({},i),{[e]:n}))},disabeledAll:y}),b&&r.createElement(r.Fragment,null,r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},S("QualifiedAnnotation")),r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},r.createElement(pt,{type:"primary",danger:!0},S("Annotating")),r.createElement("div",{style:{padding:16}},S("Group"),"\uFF1A",b.order)),r.createElement("div",null,ht&&r.createElement(Zt,{list:(b==null?void 0:b.answerList)||[],LLMConfig:c,updateValue:yt,disabeledAll:y})))),r.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(W==null?void 0:W.length)-1!==M&&r.createElement(pt,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(D){D(()=>R(B()));return}R(B())},disabled:y},S("Save"))))},ve=p=>({annotation:p.annotation});var Le=Nt(ve,null,null,{context:Vt})(fe);export{Le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{useTranslation as
|
|
1
|
+
import e from"react";import{useTranslation as u}from"react-i18next";import{Resizable as f}from"re-resizable";import{Radio as i,Image as g}from"antd";import{EDataFormatType as m,prefix as E}from"../../../../../constant/index.js";import{FileTextOutlined as x}from"@ant-design/icons";import w from"../../../../markdownView/index.js";import{isString as y,isObject as T}from"lodash";import{i18n as b}from"@labelbee/lb-utils";import h from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import v from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";const s=`${E}-LLMView`,c=({question:t,dataFormatType:n,isImg:a})=>{const r=y(t)?t:"",o=b.language==="en"?v:h;if(a){const l=T(t)?t==null?void 0:t.url:"";return e.createElement(g,{src:l||o,fallback:o})}return e.createElement("div",{style:{whiteSpace:"pre-wrap"}},n===m.Markdown?e.createElement(w,{value:r}):r)},F=t=>{const{question:n,dataFormatType:a,setDataFormatType:r,isImg:o}=t,l=300,{t:p}=u();return e.createElement(f,{defaultSize:{width:"100%",height:l},minHeight:l,enable:{bottom:!0},style:{padding:"26px 32px",borderBottom:"1px solid #EBEBEB",overflow:"hidden"}},e.createElement("div",{className:`${s}__title`,style:{display:"flex",justifyContent:"space-between"}},p("Title"),e.createElement(d,{dataFormatType:a,setDataFormatType:r})),e.createElement("div",{className:`${s}__headerContent`},e.createElement(c,{question:n,dataFormatType:a,isImg:o})))},d=t=>{const{dataFormatType:n,setDataFormatType:a}=t;return e.createElement("span",{style:{display:"flex"}},e.createElement(i.Group,{value:n,onChange:r=>{a(r.target.value)}},e.createElement(i.Button,{value:m.Default,style:{textAlign:"center",width:"52px"}},"</>"),e.createElement(i.Button,{value:m.Markdown,style:{textAlign:"center",width:"52px"}},e.createElement(x,null))),e.createElement("span",{style:{marginLeft:"8px",width:"4px",background:"#1890ff"}}))};export{c as RenderQuestion,d as ToggleDataFormatType,F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as
|
|
1
|
+
import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as d}from"../../../../../constant/index.js";import g from"classnames";import u from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import f from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";import{i18n as p}from"@labelbee/lb-utils";import a from"./index.module.scss.js";const o=`${d}-LLMView`,v=m=>{const{answerList:s,hoverKey:l}=m,n=p.language==="en"?f:u;return t.createElement("div",{className:a.imgView},s==null?void 0:s.map((e,r)=>t.createElement("div",{key:r,className:g({[`${a.item}`]:!0,[`${o}__contentActive`]:l===(e==null?void 0:e.order)})},t.createElement(i,{className:`${o}-tag`},e==null?void 0:e.order),t.createElement("div",{className:a.image},t.createElement(c,{src:e==null?void 0:e.url,fallback:n,style:{objectFit:"contain"}})))))};export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n,{useState as M,useEffect as O}from"react";import{Tag as S}from"antd";import{prefix as N,EDataFormatType as u,ELLMDataType as p}from"../../../constant/index.js";import $ from"classnames";import{I18nextProvider as k,useTranslation as C}from"react-i18next";import{i18n as v}from"@labelbee/lb-utils";import D from"../../markdownView/index.js";import L from"../modelAPIView/index.js";import R from"../../diffMatchPatchComponent/index.js";import F from"./components/header/index.js";import W from"./components/imgView/index.js";import{isString as q}from"lodash";var B=Object.defineProperty,w=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,f=(e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,K=(e,t)=>{for(var r in t||(t={}))H.call(t,r)&&f(e,r,t[r]);if(w)for(var r of w(t))Q.call(t,r)&&f(e,r,t[r]);return e};const a=`${N}-LLMView`,_=({i:e,dataFormatType:t,isTextControl:r})=>{var l;return t===u.Markdown?n.createElement(D,{value:(l=e==null?void 0:e.newAnswer)!=null?l:e==null?void 0:e.answer}):r?n.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},n.createElement(R,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):n.createElement("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"break-word"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},E=(e,t)=>{var r;return(t==null?void 0:t.isTextEdit)?!!((r=((t==null?void 0:t.textEdit)||[]).filter(s=>(s==null?void 0:s.title)===e.order)[0])==null?void 0:r.textControl):!1},z=e=>{var t,r;const{hoverKey:l,answerList:s,question:m,lang:c,modelAPIResponse:x,setModelAPIResponse:g,checkMode:y=!0,LLMConfig:i,answerHeaderSlot:P}=e,[d,h]=M(u.Default),I=((t=i==null?void 0:i.dataType)==null?void 0:t.prompt)===p.Picture,A=((r=i==null?void 0:i.dataType)==null?void 0:r.response)===p.Picture,{t:T}=C();O(()=>{var o;c&&((o=v)==null||o.changeLanguage(c))},[]);const V=n.createElement("div",null,s.map((o,b)=>{const j=E(o,i);return n.createElement("div",{className:$({[`${a}__content`]:!0,[`${a}__contentActive`]:l===(o==null?void 0:o.order)}),key:b},n.createElement(S,{className:`${a}-tag`},o==null?void 0:o.order),n.createElement(_,{i:o,isTextControl:j,dataFormatType:d}))}),q(m)&&n.createElement(L,{dataFormatType:d,modelAPIResponse:x,question:m,setModelAPIResponse:g,checkMode:y,annotation:e.annotation}));return n.createElement("div",{className:a},n.createElement(F,{question:m,dataFormatType:d,setDataFormatType:h,isImg:I}),n.createElement("div",{className:`${a}__textBox`},n.createElement("div",{className:`${a}__title`},T("Answer")," ",P),A?n.createElement(W,{hoverKey:l,answerList:s}):V))},G=e=>n.createElement(k,{i18n:v},n.createElement(z,K({},e)));export{a as LLMViewCls,_ as RenderAnswer,G as default,E as getTextControlByConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import s,{useReducer as
|
|
1
|
+
import s,{useReducer as ie,useContext as ae,useState as F,useEffect as se}from"react";import{prefix as le}from"../../../../../constant/index.js";import{Tag as de}from"antd";import{useTranslation as W}from"react-i18next";import{LeftOutlined as ce}from"@ant-design/icons";import{classnames as pe}from"../../../../../utils/index.js";import{isArray as ue,cloneDeep as fe}from"lodash";import{MathUtils as y}from"@labelbee/lb-annotation";import{LLMContext as ge}from"../../../../../store/ctx.js";var me=Object.defineProperty,ve=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,z=(i,p,l)=>p in i?me(i,p,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[p]=l,J=(i,p)=>{for(var l in p||(p={}))he.call(p,l)&&z(i,l,p[l]);if(q)for(var l of q(p))_e.call(p,l)&&z(i,l,p[l]);return i},ye=(i,p)=>ve(i,xe(p)),m;(function(i){i.Top="Top",i.Right="Right",i.Bottom="Bottom",i.Left="Left"})(m||(m={}));const w=`${le}-LLMSidebar-contentBox`,B="@",be=()=>{const{t:i}=W();return s.createElement("div",{className:`${w}__navigation`},s.createElement("span",null,i("Best")),s.createElement("div",{style:{display:"flex",alignItems:"center",flex:1,margin:"0px 20px"}},s.createElement(ce,null),s.createElement("div",{style:{height:0,border:"1px solid #999999",width:"100%"}})),s.createElement("span",null,i("Worst")))},Le=i=>{const[,p]=ie(e=>e+1,0),{sortList:l,setSortList:K,waitSortList:U,disabeledAll:V,header:Y,title:X,prefixId:G="answer"}=i,N=`${G}-waitBox`,x=`${G}-sortBox`,{setHoverKey:H}=ae(ge),[O,b]=F(void 0),[E,Q]=F(void 0),[_,Z]=F([]),{t:S}=W();se(()=>{Z(U)},[U]);const T=({item:e,operation:t,id:n})=>{const o={[`border${O}`]:"2px solid #8C9AFF"};return s.createElement("div",J({key:`${e==null?void 0:e.id}`,color:"#EBEBEB",id:n,className:pe({[`${w}__answerTag`]:!0}),style:E===(e==null?void 0:e.id)&&O?o:void 0,draggable:V||!(e==null?void 0:e.id)?"":"true",onMouseMove:()=>{H(e.id)},onMouseLeave:()=>{H(-1)}},t),e==null?void 0:e.title)},D=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),ee=(e,t)=>{const n=y.getLineLength(e,D(t.tl,t.tr)),o=y.getLineLength(e,D(t.tr,t.tr)),d=y.getLineLength(e,D(t.bl,t.br)),c=y.getLineLength(e,D(t.tl,t.bl));return{minDistance:Math.min(n,o,d,c),toTopDistance:n,toRightDistance:o,toBottompDistance:d,toLeftDistance:c}},te=(e,t)=>{const{minDistance:n,toTopDistance:o,toRightDistance:d,toBottompDistance:c,toLeftDistance:u}=ee(e,t);switch(n){case o:b(m.Top);break;case d:b(m.Right);break;case c:b(m.Bottom);break;case u:b(m.Left);break}},C=()=>{const e=document.getElementById(x);if(e==null?void 0:e.childNodes){let t=[];e.childNodes.forEach((n,o)=>{var d;let c=n;((d=n==null?void 0:n.childNodes)==null?void 0:d.length)>1&&(c=n.childNodes[0]);const u=c.getBoundingClientRect()||{},{bottom:a,top:f,left:r,right:g,width:v,height:h,x:R,y:M}=u,j={x:r+v/2,y:f+h/2},k={tl:{x:R,y:M},tr:{x:g,y:f},br:{x:g,y:a},bl:{x:r,y:a}},oe=l[o].reduce((re,$)=>{let I=$;return ue($)&&$.length>1&&(I=$[0]),I=ye(J({},I),{tagCenterPoint:j,tagVertexPoint:k}),[...re,I]},[]);t.push(oe)}),K(t)}},P=e=>{var t,n,o,d,c,u;const a=e.pageX,f=e.pageY,r={x:a,y:f};let g=l;if((g==null?void 0:g.length)>0){let v=g[0];for(let h=0;h<g.length;h++)if(h>0){const R=(t=g[h][0])==null?void 0:t.tagCenterPoint,M=(n=v[0])==null?void 0:n.tagCenterPoint,j=y.getLineLength(r,R),k=y.getLineLength(r,M);j<k&&(v=l[h])}if(!r.x||!r.y)return;if(L(e.target.id)===((o=v[0])==null?void 0:o.id)){Q(void 0);return}Q((d=v[0])==null?void 0:d.id),((c=v[0])==null?void 0:c.tagVertexPoint)&&r&&(r==null?void 0:r.x)&&(r==null?void 0:r.y)&&te(r,(u=v[0])==null?void 0:u.tagVertexPoint)}},A=e=>{var t;const{target:n}=e;let o=-1,d=-1,c=-1,u=[],a=fe(l);if(c=a.findIndex(f=>f[0].id===Number(E)),((t=n==null?void 0:n.parentNode)==null?void 0:t.parentNode.id)===x){o=L(n.parentNode.id);const f=L(n.id);u=a[~~o].filter(g=>g.id===~~f);const r=a[~~o].findIndex(g=>g.id===~~f);a[~~o].splice(r,1)}if((n==null?void 0:n.parentNode.id)===x){if(!E)return;o=L(n.id),d=a.findIndex(r=>r[0].id===o);const f=a.find(r=>r[0].id===o);f&&(u=f),a.splice(d,1),c=a.findIndex(r=>r[0].id===~~E)}switch(n.parentNode.id===N&&(o=L(n.id),d=_.findIndex(f=>f.id===o),u=[_[d]],_.splice(d,1)),O){case m.Left:a.splice(c,0,u);break;case m.Right:a.splice(c+1,0,u);break;case m.Top:case m.Bottom:a[c].push(...u);break;default:a.push(u);break}K(a),b(void 0),p()},L=e=>{const t=e.indexOf(B);return Number(e.substring(t+1,e.length))},ne=Y!=null?Y:s.createElement("div",{className:`${w}__title`},s.createElement("span",null,X!=null?X:S("RankingQualityOfAnswers")),_.length>0&&s.createElement(de,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},S("Unfinished")));return s.createElement("div",{style:{padding:"0px 16px",marginBottom:"16px",width:"100%"}},ne,s.createElement("div",null,s.createElement("div",{style:{display:"flex",alignItems:"center"}},s.createElement("span",{style:{marginRight:"16px"}},S("ToBeSorted")),s.createElement("div",{id:N,className:`${w}__answerBox`},_.length>0&&_.map(e=>T({item:e,id:`${N}-waitBoxItem${B}${e==null?void 0:e.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}})))),s.createElement(be,null),s.createElement("div",{id:x,className:`${w}__answerBox`},l.map((e,t)=>{var n;return e.length>1?s.createElement("div",{key:`item-${t}`,id:`${x}${B}${t}`,style:{border:"1px dashed #d9d9d9"}},e.map(o=>T({item:o,id:`${x}-sortBoxItem${B}${o==null?void 0:o.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}}))):T({item:e[0],id:`${x}${B}${(n=e[0])==null?void 0:n.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}})}))))};export{Le as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import m,{forwardRef as V,useState as $,useMemo as A,useEffect as F,useImperativeHandle as M}from"react";import{useTranslation as R}from"react-i18next";import{useDebounceFn as T}from"ahooks";import H from"../answerSort/index.js";import{Tag as W}from"antd";import{isArray as z}from"lodash";var N=Object.defineProperty,Q=Object.defineProperties,U=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,E=(a,t,r)=>t in a?N(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r,g=(a,t)=>{for(var r in t||(t={}))k.call(t,r)&&E(a,r,t[r]);if(D)for(var r of D(t))q.call(t,r)&&E(a,r,t[r]);return a},_=(a,t)=>Q(a,U(t));const P=({selectedSort:a,initSelected:t,modelList:r})=>{var i;const d=t!=null?t:a;let S=[];const f=r.filter(s=>!(d&&(d==null?void 0:d.length)>0?d.flat():[]).includes(s.id));return d&&(d==null?void 0:d.length)>0&&(S=(i=d.map(s=>{var w;return(w=s.map(u=>r.find(h=>h.id===u)))==null?void 0:w.filter(u=>u)}))==null?void 0:i.filter(s=>(s==null?void 0:s.length)>0)),{waitSorts:f,newSort:S}},B=(a,t)=>{const{selectedSort:r,modelData:i,selectedAnswerSort:d,disabeledAll:S,imgIndex:f}=a,[s,w]=$({waitSorts:{},selecteds:r}),{t:u}=R(),h=A(()=>i.map((o,l)=>_(g({},o),{title:l+1})),[i,f]),x=A(()=>i.reduce((n,e)=>e.answerList.length>n.length?e.answerList:n,[]).map((n,e)=>({id:n.id,title:`${e+1}`}))||[],[i,f]);F(()=>{r&&i.length>0&&y()},[i,f]);const L=o=>(h.filter(n=>n.answerList.some(e=>e.id===o))||[]).map(n=>_(g({},n),{id:n.id,title:n.title})),y=o=>{const l=s,n=o!=null?o:r;x.forEach(e=>{const c=L(e.id),p=n==null?void 0:n[e.id],{waitSorts:v,newSort:O}=P({selectedSort:p,modelList:c});l.waitSorts[e.id]=v,l.selecteds[e.id]=O}),w(l)};M(t,()=>({clearValue:()=>y({})}),[i,f]);const b=(o,l)=>{if(l.some(e=>e.some(c=>c==null?void 0:c.id))){const e=_(g({},s.selecteds),{[o]:l}),c={};Object.keys(e).forEach(p=>{c[p]=e[p].map(v=>v.map(O=>O.id))}),d(c),w(_(g({},s),{selecteds:e}))}},{run:j}=T(b,{wait:0}),I=Object.keys(s.waitSorts).some(o=>x.some(l=>l.id===o)&&z(s.waitSorts[o])&&s.waitSorts[o].length>0);return m.createElement("div",null,m.createElement("div",{style:{fontWeight:500,fontSize:"16px",width:"100%",lineHeight:"46px",padding:"0px 16px"}},m.createElement("span",null,u("RankingQualityOfAnswers")),I&&m.createElement(W,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},u("Unfinished"))),x.map((o,l)=>{var n,e,c,p;return m.createElement("div",{key:l,style:{display:"flex"}},m.createElement("div",{style:{fontSize:"16px",fontWeight:500,width:"80px",lineHeight:"50px",textAlign:"center"}},`${u("Answer")}${l+1}`),m.createElement(H,{waitSortList:(e=(n=s==null?void 0:s.waitSorts)==null?void 0:n[o.id])!=null?e:[],sortList:(p=(c=s==null?void 0:s.selecteds)==null?void 0:c[o.id])!=null?p:[],setSortList:v=>{j(o.id,v)},disabeledAll:S,header:"",prefixId:`modelAnswer${l}`}))}))};var C=V(B);export{C as default,P as getSorts};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`);return
|
|
1
|
+
import t,{useEffect as V}from"react";import{Form as g,Input as j,message as F}from"antd";import L from"classnames";import{useTranslation as N}from"react-i18next";import S from"../../../../latexEditor/index.js";import E from"./index.module.scss.js";import C from"../../../../markdownView/index.js";import B from"../../../../longText/index.js";var D=Object.defineProperty,A=Object.defineProperties,R=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,P=(a,e,r)=>e in a?D(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,$=(a,e)=>{for(var r in e||(e={}))k.call(e,r)&&P(a,r,e[r]);if(b)for(var r of b(e))M.call(e,r)&&P(a,r,e[r]);return a},q=(a,e)=>A(a,R(e));const z=a=>{const{disabeledAll:e,textConfig:r,textAttribute:w,setText:T}=a,{TextArea:I}=j,[v]=g.useForm(),{t:y}=N();V(()=>{const s=r.map((c,n)=>{var d;const m=(w==null?void 0:w.filter(o=>(o==null?void 0:o.textId)===(c==null?void 0:c.textId)))||[];return q($({},c),{value:(d=m[0])==null?void 0:d.value})});v.setFieldsValue({text:s})},[r,w]);const O=({newText:s,fieldName:c,max:n})=>{var d,m;const o=`textInput_${c}`,l=document.getElementById(o),u=l.value||"",f=(d=l==null?void 0:l.selectionStart)!=null?d:u.length,p=(m=l.selectionEnd)!=null?m:u.length,_=u.substring(0,f),x=u.substring(p,u.length),i=_+s+x;if(n&&(i==null?void 0:i.length)>n){F.error(y("MaximumCharacterError",{num:n}));return}l.value=i,v.setFields([{name:["text",c,"value"],value:i,errors:[]}]),h(),l.selectionStart=f+s.length,l.selectionEnd=f+s.length,l.focus()},h=()=>{const s=v.getFieldValue("text");T(s)};return t.createElement(g,{form:v},t.createElement(g.List,{name:"text"},(s,c)=>t.createElement(t.Fragment,null,s.map((n,d)=>{const{max:m,min:o,title:l,tip:u,isLaText:f}=r[n.name]||{},p=l,_=y("LeastCharacterError",{num:o});return t.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:"16px"},key:d},p&&t.createElement(g.Item,{name:[n.name,"title"],extra:t.createElement(B,{text:u!=null?u:"",overflowMaxLines:3,openByText:!0}),className:E.textTitle,required:!!o,label:" ",colon:!1},l,p&&t.createElement("span",{className:L({clearText:!0,clearText__disabled:e}),style:{verticalAlign:"initial"},onClick:()=>{e||(v.setFields([{name:["text",n.name,"value"],value:void 0,errors:o?[_]:[]}]),h())}})),f&&p&&t.createElement(S,{onSelectLatex:x=>O({newText:x,fieldName:n.name,max:m}),disabled:e}),p&&t.createElement(g.Item,{name:[n.name,"value"],style:{marginBottom:24},rules:[{validator:(x,i)=>o&&(i==null?void 0:i.length)<Number(o)?Promise.reject(_):Promise.resolve()}],initialValue:void 0},t.createElement(I,{maxLength:m,disabled:e,showCount:!!m,autoSize:{minRows:4,maxRows:10},style:{width:"100%"},id:`textInput_${n.name}`,onChange:()=>h()})),f&&p&&t.createElement(g.Item,{shouldUpdate:!0,noStyle:!0},()=>{const x=v.getFieldValue(["text",n.name,"value"])||"",i=x.replace(/\n/g,`
|
|
2
|
+
`);return t.createElement("div",{className:E.outputDisplay},t.createElement("div",{className:E.title},y("OutputDisplay")),t.createElement("div",{className:E.content},x?t.createElement(C,{value:i}):""))}))}))))};export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i,{useContext as q,useState as R,useEffect as P,useMemo as ct}from"react";import{prefix as dt}from"../../../constant/index.js";import{Button as ut,Empty as mt}from"antd";import pt from"./components/answerSort/index.js";import{connect as ft}from"react-redux";import{isBoolean as gt,isArray as vt,isString as xt,isNumber as Lt,isObject as wt}from"lodash";import St from"./components/answerList/index.js";import{LabelBeeContext as yt,LLMContext as z}from"../../../store/ctx.js";import{jsonParser as F}from"../../../utils/index.js";import{getStepConfig as Et}from"../../../store/annotation/reducer.js";import{useCustomToolInstance as bt}from"../../../hooks/annotation.js";import{PageForward as T}from"../../../store/annotation/actionCreators.js";import{cKeyCode as _t,EToolName as Ct}from"@labelbee/lb-annotation";import{useTranslation as W}from"react-i18next";import{getCurrentResultFromResultList as ht,getRenderDataByResult as jt,formatSort as Pt}from"../utils/data.js";import Tt from"../../../assets/annotation/LLMTool/empty.svg.js";import It from"./components/textInputBox/index.js";import At from"../../tagList/components/overall/index.js";import Ot from"../../../utils/StepUtils.js";var Nt=Object.defineProperty,Rt=Object.defineProperties,Dt=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable,J=(s,o,l)=>o in s?Nt(s,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[o]=l,d=(s,o)=>{for(var l in o||(o={}))Mt.call(o,l)&&J(s,l,o[l]);if(G)for(var l of G(o))Bt.call(o,l)&&J(s,l,o[l]);return s},p=(s,o)=>Rt(s,Dt(o));const $t=_t.default,I=`${dt}-sidebar`,Q=()=>{const{t:s}=W();return i.createElement("div",{className:`${I}`},i.createElement("div",{className:`${I}__content`,style:{display:"flex",justifyContent:"center",alignItems:"center"}},i.createElement(mt,{description:i.createElement("span",{style:{color:"#ccc"}},s("NoScoringScale")),imageStyle:{width:200,height:200},image:i.createElement("img",{src:Tt})})))},H=s=>{var o,l;const{indicatorScore:_=[],indicatorDetermine:g=[],text:C=[],enableSort:v,isTextEdit:S,tagInputListConfigurable:x,dialogSort:L=!1}=s||{},w=((o=_==null?void 0:_.filter(n=>n.label&&n.value&&n.score))==null?void 0:o.length)>0,h=((l=g==null?void 0:g.filter(n=>n.label&&n.value))==null?void 0:l.length)>0,A=(C==null?void 0:C.length)>0;return!(w||h||A||v||S||x||L)},Vt=s=>{var o,l;const{annotation:_,dispatch:g,checkMode:C}=s,{imgIndex:v,imgList:S,stepList:x,step:L,skipBeforePageTurning:w}=_,{modelAPIResponse:h,setModelAPIResponse:A}=q(z),{t:j}=W(),n=(o=S[v])!=null?o:{},D=F(n==null?void 0:n.result),{toolInstanceRef:f}=bt({basicInfo:D}),[c,X]=R(),[O,Y]=R(!0),{setNewAnswerList:Z}=q(z),[e,y]=R({}),E=!f.current.valid||C;P(()=>{var t;if(x&&L){const r=(t=Et(x,L))==null?void 0:t.config;X(F(r))}},[L,JSON.stringify(x)]),P(()=>{!n||v===-1||(f.current.setValid=M,f.current.clearResult=tt,M(),B())},[v,c,n==null?void 0:n.id]);const tt=()=>{B(n==null?void 0:n.questionList)},M=t=>{var r;const a=t!=null?t:D.valid;gt(a)&&(Y(a),f.current.valid=a,(r=f.current)==null||r.emit("validUpdated"))},B=t=>{const r=Ot.getCurrentStepInfo(L,x),a=ht(n==null?void 0:n.result,r.step);let u=n==null?void 0:n.questionList;(a==null?void 0:a.answerList)&&f.current.valid&&(u=a),t&&(u=t,a.sort=[]);const b=jt(c,u);y(d({},b)),A([])};P(()=>{et(),Z((e==null?void 0:e.answerList)||[])},[e,h,O]),P(()=>(window.addEventListener("keydown",$),()=>{window.removeEventListener("keydown",$)}),[]);const et=()=>{const{newSort:t,answerList:r,textAttribute:a,tagList:u}=e,b=Pt(t||[]),m={answerList:r,sort:b,tagList:u,textAttribute:a,id:n==null?void 0:n.id,modelAPIResponse:h};f.current.exportData=()=>[[m],{valid:O}],f.current.currentPageResult=p(d({},m),{toolName:Ct.LLM,valid:O})},$=t=>{if(t.ctrlKey&&t.keyCode===$t.Enter){if(w){w(()=>g(T()));return}g(T())}},nt=({order:t,value:r,key:a})=>{const{answerList:u}=e,b=u==null?void 0:u.map(m=>{var U;if((m==null?void 0:m.order)===t){if(a==="textEdit"&&xt(r))return p(d({},m),{newAnswer:r});if(Lt(r))return p(d({},m),{score:r});if(wt(r)&&a){const at={[r==null?void 0:r.key]:r.value},lt=(U=m[a])!=null?U:{};return p(d({},m),{[a]:d(d({},lt),at)})}}return m});y(p(d({},e),{answerList:b||[]}))};if(ct(()=>H(c),[c]))return i.createElement(Q,null);const{indicatorScore:V=[],indicatorDetermine:k=[],enableSort:ot,isTextEdit:rt,inputList:N=[],tagInputListConfigurable:K}=c||{},it=K&&((l=N.filter(t=>!t.isOverall))==null?void 0:l.length)>0,st=(k==null?void 0:k.length)>0||(V==null?void 0:V.length)>0||rt||it;return i.createElement("div",{className:`${I}`},i.createElement("div",{className:`${I}__content`},i.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},j("GlobalAnnotation")),ot&&i.createElement(pt,{waitSortList:(e==null?void 0:e.waitSorts)||[],sortList:(e==null?void 0:e.newSort)||[],setSortList:t=>{y(p(d({},e),{newSort:t}))},disabeledAll:E}),K&&N.length&&i.createElement(At,{inputList:N,selectedTags:(e==null?void 0:e.tagList)||{},updateValue:t=>{const{key:r,value:a}=t,u=e==null?void 0:e.tagList;y(p(d({},e),{tagList:p(d({},u),{[r]:a})}))},disabeledAll:E}),(c==null?void 0:c.text)&&i.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},i.createElement(It,{textAttribute:(e==null?void 0:e.textAttribute)||[],textConfig:(c==null?void 0:c.text)&&vt(c.text)?c==null?void 0:c.text:[],setText:t=>y(p(d({},e),{textAttribute:t})),disabeledAll:E})),i.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},j("QualifiedAnnotation")),i.createElement("div",null,st&&i.createElement(St,{list:(e==null?void 0:e.answerList)||[],LLMConfig:c,updateValue:nt,disabeledAll:E}))),i.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(S==null?void 0:S.length)-1!==v&&i.createElement(ut,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(w){w(()=>g(T()));return}g(T())},disabled:E},j("Save"))))},kt=s=>({annotation:s.annotation});var Kt=ft(kt,null,null,{context:yt})(Vt);export{Q as EmptyConfig,Kt as default,H as getLLMIsNoConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import K from"../../assets/attributeIcon/icon_eyeLock_a.svg.js";import B from"../../assets/attributeIcon/icon_eyeLock_h.svg.js";import{COLORS_ARRAY as b,NULL_COLOR as F}from"../../data/Style.js";import{ColorTag as G}from"../colorTag/index.js";import{Radio as y}from"antd/es";import n,{useState as C,useEffect as H}from"react";import{Popover as M,message as W}from"antd";import Y from"../colorPalette/index.js";import{CloseOutlined as $}from"@ant-design/icons";import{useTranslation as q}from"react-i18next";import J from"./components/limitPopover/index.js";import E from"lodash";import{CommonToolUtils as Q,MathUtils as s}from"@labelbee/lb-annotation";const R=[F].concat(b),X=n.forwardRef((e,_)=>{const w=n.useRef(),{t:g}=q(),A=e.list||[],[P,m]=C(!1),[T,D]=C(void 0),[c,I]=C([]);let d=[...R];e.forbidDefault===!0&&(d=d.slice(1));let k="sensebee-radio-group";e.noHeightLimit&&(k="sensebee-radio-group-no-limit-height");const L=t=>{var l,u;if(!Q.hotkeyFilter(t)||(e==null?void 0:e.forbidColor))return;let o=t.keyCode;e.forbidDefault===!0&&(o=o-1);let i;if(s.isInRange(t.keyCode,[48,57])&&(i=e.list[o-48]),s.isInRange(t.keyCode,[96,105])&&(i=e.list[o-96]),t.shiftKey&&i){if(!(e==null?void 0:e.attributeLockChange))return;f(t,i),t.preventDefault();return}(s.isInRange(t.keyCode,[48,57])||s.isInRange(t.keyCode,[96,105]))&&((u=e==null?void 0:e.attributeChanged)==null||u.call(e,(l=i==null?void 0:i.value)!=null?l:""))};H(()=>(window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)));const O=(t,l)=>{e.updateColorConfig&&e.updateColorConfig(t,l)},S=(t,l)=>{if(t.shiftKey&&(e==null?void 0:e.attributeLockChange)){f(t,l);return}e.attributeChanged(t.target.value)},j=E.debounce(S,100),f=(t,l)=>{var u;if(e==null?void 0:e.forbidColor)return;const o=c.includes(l.value);let i=E.cloneDeep(c);o?i=i.filter(a=>a!==l.value):i.push(l.value),I(i),(u=e==null?void 0:e.attributeLockChange)==null||u.call(e,i),o||W.success(g("AttributeLockNotify",{label:l.label})),t.preventDefault()};return n.createElement("div",{className:k,style:e.style},n.createElement(y.Group,{name:"radiogroup",defaultValue:e==null?void 0:e.selectedAttribute,value:e==null?void 0:e.selectedAttribute,ref:_},A.map((t,l)=>{var u,o,i;let a=(u=e==null?void 0:e.num)!=null?u:l;const N=(t==null?void 0:t.value)===(e==null?void 0:e.selectedAttribute);e.forbidDefault===!0&&typeof a=="number"&&a++,typeof a=="number"&&a<=9&&a>=0||(a="-");let v=l>8&&!e.forbidDefault?b[(l-1)%b.length]:d[l%d.length];(t==null?void 0:t.color)&&(v=t.color);const{defaultSize:z,logicalCondition:h,sizeRange:U}=((o=t==null?void 0:t.limit)==null?void 0:o.sizeLimit)||{},V=((i=t==null?void 0:t.limit)==null?void 0:i.positionLimit)||z||U||(h==null?void 0:h.length)>0,x=N&&V&&e.forbidShowLimitPopover!==!0;return n.createElement(y,{value:t.value,ref:w,key:t.label+l,onClick:r=>j(r,t)},n.createElement("span",{className:"sensebee-radio-label",title:t.label},!(e==null?void 0:e.forbidColor)&&n.createElement(M,{content:n.createElement(Y,{defaultColor:v,setColor:r=>O(t.value,r)}),title:n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},n.createElement("span",null,g("Palette")),n.createElement($,{onClick:()=>m(!1)})),visible:P&&T===l,onVisibleChange:r=>{!r||m(r)}},n.createElement(G,{color:v,style:{cursor:"pointer",marginRight:"8px"},onClick:()=>{(e==null?void 0:e.enableColorPicker)&&(D(l),m(!0))}})),t.label),!(e==null?void 0:e.forbidColor)&&(e==null?void 0:e.attributeLockChange)&&n.createElement("img",{onClick:r=>f(r,t),src:c.includes(t.value)?K:B,style:{display:c.includes(t.value)?"inline-block":""},className:"sensebee-radio-icon"}),x&&n.createElement(J,{limit:t.limit,updateSize:e==null?void 0:e.updateSize}),n.createElement("span",{className:"sensebee-radio-num"},a))})))});export{R as ATTRIBUTE_COLORS,X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import i,{useState as g,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 de}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,me=(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:fe,updateRegion:L,removeRegion:$,regions:A=[],activeToolPanel:pt,clipConfigurable:vt,clipTextConfigurable:pe,clipAttributeList:gt,clipAttributeConfigurable:ve,secondaryAttributeConfigurable:bt,subAttributeList:yt,isCheck:S,hoverRegionId:K,footer:_t,drawLayerSlot:ge,clipTextList:Et,lang:be})=>{var ye,_e;const{url:H,path:Ee}=f,[G,Y]=g(!1),[Se,he]=g(!1),[j,St]=g(0),[ht,Re]=g(!1),[C,Pe]=g(0),o=U(null),x=U(null),Ce=U(j),J=e=>{Ce.current=e,St(e)},[Te,Rt]=g(0),[k,Pt]=g(de.defaultValue),h=U(null),[we,Ct]=g({}),{audioClipState:Q,setAudioClipState:B}=jr(),[ee,te]=g(!1),c=X(Q),Ae=X(we);X(G);const I=X(A),je=xr(),[xe,Tt]=g([]),[De,wt]=g({}),[At,Le]=g(""),[Ie,jt]=g({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<de.min||e>de.max||(Pt(e),Ir(),Lt())};Dr({container:h.current,target:document.querySelector(`[data-id=${(_e=(ye=c.current)==null?void 0:ye.selectedRegion)==null?void 0:_e.id}]`),clipping:ee,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))),ne(),e.forEach(r=>{var n;(n=o.current)==null||n.addRegion(lt(me({},r),{drag:!S,resize:!S,color:"rgba(0, 0, 0, 0)"}))}),je()},p=e=>{var t,r,n,l,a,v,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:(v=(a=(l=I.current)==null?void 0:l.find(w=>w.id===s))==null?void 0:a.attribute)!=null?v:""}),_&&((b=W(s))==null||b.play())}else B({selectedRegion:{}})},{combineInstance:It}=Nr({waveRef:o,sortByStartRegions:xe,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:p}),{segmentInstance:Mt,onRegionMouseMove:kt,segmentTimeTip:Bt}=zr({waveRef:o,regionMap:De,updateRegion:L,removeRegion:$,generateRegions:O,setSelectedRegion:p}),ke={clipTextConfigurable:pe,clipAttributeList:gt,clipAttributeConfigurable:ve,clipConfigurable:vt,secondaryAttributeConfigurable:bt,subAttributeList:yt,clipTextList:Et};P(()=>{var e;be&&((e=Je)==null||e.changeLanguage(be))},[]),P(()=>{B({selectedAttribute:""})},[ve]),P(()=>{re()},[Q.selectedAttribute]),P(()=>{O()},[Q.attributeLockList]),Qe(()=>{B(ke),setTimeout(()=>{Be()})},[ke]),Qe(()=>{Tt(mr(A,["start"])),wt(A.reduce((e,t)=>{const{id:r}=t;return lt(me({},e),{[r]:t})},{})),S&&O()},[A]),P(()=>{p(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(),ne()),re()},re=()=>{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=Ee==null?void 0:Ee.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&&(he(!0),J(0),Pe(0),(t=o==null?void 0:o.current)==null||t.load(e))},ne=()=>{var e;(e=o.current)==null||e.clearRegions()},oe=e=>{const t=W(e);t&&(te(!1),t==null||t.remove(),$==null||$(e),p({}))},{run:Ne}=et(p,{wait:100});Wr({sortByStartRegions:xe,setSelectedRegion:p});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&&p({id:t});const a=W((t!=null?t:(n=c.current.selectedRegion)==null?void 0:n.id)||""),v=[];(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=>{v.includes(D)||v.push(D)})});const s=kr(v.sort((m,_)=>m-_),r);o.current.range=s},Nt=e=>{re(),setTimeout(()=>{te(!1)});const t=Ot(e),{id:r,start:n,end:l}=t;p({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;J(((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)}),he(!1),N(),E.on("setCurrentTimeByPosition",le),E.on("clearRegions",ne),E.on("removeRegionById",oe),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),u==null||u({hasError:!0}),fe==null||fe()}),e.on("region-created",r=>{var n;const{id:l,start:a,end:v}=r;if(I.current.find(s=>s.id===l))return;Le(l);const b={id:l,start:Z(a,3),end:Z(v,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:{}}pe&&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,v,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=(v=o==null?void 0:o.current)==null?void 0:v.cursor)==null||b.setStyle({borderColor:"transparent"}));const F={},se=[],ae={},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:ue}=(Ke=er[R.id])!=null?Ke:{},{start:nr,end:or}=R;if(ue){const{x:Ye,width:ir}=((Ge=ue.getBoundingClientRect)==null?void 0:Ge.call(ue))||{},lr=Ye+ir;[Ye,lr].forEach((ce,sr)=>{se.includes(ce)||(se.push(ce),ae[ce]=sr===0?nr:or)})}});const{x:qe,width:tr}=((D=(M=r.element).getBoundingClientRect)==null?void 0:D.call(M))||{},rr=qe+tr;se.forEach(R=>{Math.abs(nt(R,qe))<5&&(F.start=ae[R]),Math.abs(nt(R,rr))<5&&(F.end=ae[R])}),Ct(F),Ne({id:r.id}),te(!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)){oe(r.id);return}p({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}p({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(!Se)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(),p({})},$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&&oe(r)}break}},Vt=e=>{le(e)},He=cr.throttle(Vt,50);let ie=!1;const Ue=()=>{ie&&(N(),ie=!1),document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",Ue)},Xt=e=>{le(e),G&&(ie=!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(()=>{p({}),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,v=(n=x==null?void 0:x.current)==null?void 0:n.getBoundingClientRect();let s=(e.clientX-v.left)/(((l=x==null?void 0:x.current)==null?void 0:l.clientWidth)||0)*a;return s>a&&(s=a),s}return 0},le=e=>{var t;const r=Xe(e);(t=o==null?void 0:o.current)==null||t.skip(r-Ce.current),J(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:ee}),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&&(ge==null?void 0:ge({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]:Se})}),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:ee,zoom:k,instance:W(t),isCheck:S}):null}),i.createElement(Hr,{footer:_t})):Ze},Yr=f=>i.createElement(Ur,{i18n:Je},i.createElement(ct,me({},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 de}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,me=(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:fe,updateRegion:L,removeRegion:$,regions:A=[],activeToolPanel:pt,clipConfigurable:vt,clipTextConfigurable:pe,clipAttributeList:gt,clipAttributeConfigurable:ve,secondaryAttributeConfigurable:bt,subAttributeList:yt,isCheck:S,hoverRegionId:K,footer:_t,drawLayerSlot:ge,clipTextList:Et,lang:be})=>{var ye,_e;const{url:H,path:Ee}=f,[G,Y]=v(!1),[Se,he]=v(!1),[j,St]=v(0),[ht,Re]=v(!1),[C,Pe]=v(0),o=U(null),x=U(null),Ce=U(j),J=e=>{Ce.current=e,St(e)},[Te,Rt]=v(0),[k,Pt]=v(de.defaultValue),h=U(null),[we,Ct]=v({}),{audioClipState:Q,setAudioClipState:B}=jr(),[ee,te]=v(!1),c=X(Q),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<de.min||e>de.max||(Pt(e),Ir(),Lt())};Dr({container:h.current,target:document.querySelector(`[data-id=${(_e=(ye=c.current)==null?void 0:ye.selectedRegion)==null?void 0:_e.id}]`),clipping:ee,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))),ne(),e.forEach(r=>{var n;(n=o.current)==null||n.addRegion(lt(me({},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:pe,clipAttributeList:gt,clipAttributeConfigurable:ve,clipConfigurable:vt,secondaryAttributeConfigurable:bt,subAttributeList:yt,clipTextList:Et};P(()=>{var e;be&&((e=Je)==null||e.changeLanguage(be))},[]),P(()=>{B({selectedAttribute:""})},[ve]),P(()=>{re()},[Q.selectedAttribute]),P(()=>{O()},[Q.attributeLockList]),Qe(()=>{B(ke),setTimeout(()=>{Be()})},[ke]),Qe(()=>{Tt(mr(A,["start"])),wt(A.reduce((e,t)=>{const{id:r}=t;return lt(me({},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(),ne()),re()},re=()=>{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=Ee==null?void 0:Ee.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&&(he(!0),J(0),Pe(0),(t=o==null?void 0:o.current)==null||t.load(e))},ne=()=>{var e;(e=o.current)==null||e.clearRegions()},oe=e=>{const t=W(e);t&&(te(!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=>{re(),setTimeout(()=>{te(!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;J(((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)}),he(!1),N(),E.on("setCurrentTimeByPosition",le),E.on("clearRegions",ne),E.on("removeRegionById",oe),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),u==null||u({hasError:!0}),fe==null||fe()}),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:{}}pe&&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={},se=[],ae={},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:ue}=(Ke=er[R.id])!=null?Ke:{},{start:nr,end:or}=R;if(ue){const{x:Ye,width:ir}=((Ge=ue.getBoundingClientRect)==null?void 0:Ge.call(ue))||{},lr=Ye+ir;[Ye,lr].forEach((ce,sr)=>{se.includes(ce)||(se.push(ce),ae[ce]=sr===0?nr:or)})}});const{x:qe,width:tr}=((D=(M=r.element).getBoundingClientRect)==null?void 0:D.call(M))||{},rr=qe+tr;se.forEach(R=>{Math.abs(nt(R,qe))<5&&(F.start=ae[R]),Math.abs(nt(R,rr))<5&&(F.end=ae[R])}),Ct(F),Ne({id:r.id}),te(!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)){oe(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(!Se)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&&oe(r)}break}},Vt=e=>{le(e)},He=cr.throttle(Vt,50);let ie=!1;const Ue=()=>{ie&&(N(),ie=!1),document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",Ue)},Xt=e=>{le(e),G&&(ie=!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},le=e=>{var t;const r=Xe(e);(t=o==null?void 0:o.current)==null||t.skip(r-Ce.current),J(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:ee}),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&&(ge==null?void 0:ge({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]:Se})}),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:ee,zoom:k,instance:W(t),isCheck:S}):null}),i.createElement(Hr,{footer:_t})):Ze},Yr=f=>i.createElement(Ur,{i18n:Je},i.createElement(ct,me({},f)));export{ct as AudioPlayer,ut as AudioPlayerContext,Yr as WrapAudioPlayer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as w}from"react";import{precisionAdd as B,precisionMinus as C}from"../../../utils/audio.js";import{useLatest as
|
|
1
|
+
import{useEffect as w}from"react";import{precisionAdd as B,precisionMinus as C}from"../../../utils/audio.js";import{useLatest as f}from"ahooks";import{audioZoomInfo as g}from"../zoomSlider/index.js";const v=m=>{const{container:t,target:i,bufferWidth:o=10,clipping:h=!1,zoom:r=1,zoomHandler:c}=m,R=f(t),l=f(r),a=e=>{var n;e.ctrlKey&&((n=R.current)==null?void 0:n.contains(e.target))&&(e.deltaY>0?c(B(l.current,g.ratio)):c(C(l.current,g.ratio)))};if(w(()=>(document.addEventListener("wheel",a),()=>{document.removeEventListener("wheel",a)}),[]),t&&i&&h&&r>1){const{scrollLeft:e}=t,{right:n,left:d,width:p}=i.getBoundingClientRect(),{right:s,left:u,width:L}=t.getBoundingClientRect();if(p>L)return;u+o>d&&d>u&&window.requestAnimationFrame(()=>{t.scrollLeft=e-20}),n+o>s&&n<s&&window.requestAnimationFrame(()=>{t.scrollLeft=e+20})}};export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"react";import
|
|
1
|
+
import n from"react";import v from"react-markdown";import P from"remark-math";import O from"rehype-katex";import k from"rehype-raw";import x from"react-syntax-highlighter";import{docco as b}from"react-syntax-highlighter/dist/esm/styles/hljs";import j from"remark-gfm";import"github-markdown-css";import E from"./index.module.scss.js";import{classnames as N}from"../../utils/index.js";var S=Object.defineProperty,I=Object.defineProperties,M=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,g=(r,e,t)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))f.call(e,t)&&g(r,t,e[t]);if(o)for(var t of o(e))d.call(e,t)&&g(r,t,e[t]);return r},h=(r,e)=>I(r,M(e)),R=(r,e)=>{var t={};for(var a in r)f.call(r,a)&&e.indexOf(a)<0&&(t[a]=r[a]);if(r!=null&&o)for(var a of o(r))e.indexOf(a)<0&&d.call(r,a)&&(t[a]=r[a]);return t};const V=r=>{const{value:e,transformImageUri:t,transformLinkUri:a,components:_}=r,w=u=>{var i=u,{node:D,inline:y,className:s,children:l}=i,p=R(i,["node","inline","className","children"]);const c=/language-(\w+)/.exec(s||"");return!y&&c?n.createElement(x,h(m({},p),{className:"markdown-code-viewer",language:c[1],style:b,PreTag:"div"}),String(l).replace(/\n$/,"")):n.createElement("code",h(m({},p),{className:s}),l)};return n.createElement(v,{className:N({"markdown-body":!0,[E.markdownView]:!0}),remarkPlugins:[j,P],rehypePlugins:[k,[O,{output:"mathml"}]],transformImageUri:t,transformLinkUri:a,components:m({code:w},_)},e)};export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLatest as
|
|
1
|
+
import{useLatest as oe,useMemoizedFn as q,useDebounceEffect as he}from"ahooks";import{Spin as Ie}from"antd/es";import J,{useContext as _e,useRef as $,useState as O,useMemo as De,useCallback as be,useEffect as p}from"react";import{connect as Ce}from"react-redux";import{usePointCloudViews as we}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as xe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as Pe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Se,MathUtils as Le,ImgUtils as Oe}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Ve}from"./util.js";import{useUpdateRectList as Ee}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as ke}from"../../hooks/useToolStyle.js";import Be from"../../store/toolConfig/index.js";var Ne=Object.defineProperty,Ue=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,le=(d,c,s)=>c in d?Ne(d,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[c]=s,v=(d,c)=>{for(var s in c||(c={}))ze.call(c,s)&&le(d,s,c[s]);if(ie)for(var s of ie(c))Ae.call(c,s)&&le(d,s,c[s]);return d},C=(d,c)=>Ue(d,Me(c)),G=(d,c,s)=>new Promise((a,g)=>{var D=f=>{try{b(s.next(f))}catch(R){g(R)}},V=f=>{try{b(s.throw(f))}catch(R){g(R)}},b=f=>f.done?a(f.value):Promise.resolve(f.value).then(D,V);b((s=s.apply(d,c)).next())});const Te=d=>{var c,s;const{mappingData:a,size:g,config:D,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:f}=d,{selectBoxVisibleSwitch:R}=Be(),E=(c=a==null?void 0:a.url)!=null?c:"",w=(s=a==null?void 0:a.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:k,defaultAttribute:B,rectList:N,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:U,selectedID:x}=_e(xe),{value:M}=ke(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=we(),z=J.useRef(null),n=$(null),K=q(fe),y=q(pe),P=$(null),[me,Q]=O(!0),[W,X]=O(""),[ve,A]=O(!1),[ge,S]=O(!0),h=De(()=>N==null?void 0:N.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,N]),Y=$(h),L=oe(a==null?void 0:a.path),T=be(e=>G(void 0,null,function*(){try{const o=ae.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(o.length){const t=new Set(o),i=r.filter(l=>t.has(l.id)).map(l=>l.id);U(i)}return r}catch(o){}}),[U]),Z=e=>{const{boxID:o}=e;if(S(!1),!f&&o){T(()=>{const r=K==null?void 0:K(e);return r?(P.current=r,k(r),r):null});return}se(e,!0)},ee=e=>{L.current&&ce(C(v({},e),{imageName:L.current}))},te=e=>{if(e.length===0)return;if(!f){const r=e.find(t=>t.boxID);if(r){T(()=>{const t=y==null?void 0:y(r);return t?(P.current=t,k(t),I(),t):null});return}}const o=e.find(r=>r.extId);o&&T(()=>{const{imageName:r,extId:t}=o,i=y==null?void 0:y({boxID:t,imageName:r});return i?(P.current=i,k(i),i):null}),ue(e)},Re=q(()=>{let e=[];return j.forEach(o=>{const{rects:r=[],id:t,attribute:i,trackID:l}=o,u=r.find(F=>F.imageName===L.current),_=t+"_"+L.current;u&&(e=[...e,C(v({},u),{boxID:t,id:_,attribute:i,order:l})])}),e}),I=Ee(()=>{var e,o,r,t,i;const l=f?[]:Re(),u=(e=n.current)==null?void 0:e.selectedRectID,_=m.slice(0),F=R?Ve(_,l,h):[...l,...h];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(H=>u?m.includes(H.boxID)&&!u.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(r=n.current)==null||r.setResult(F),W?((t=n.current)==null||t.setSelectedRectID(W),X("")):ve&&u&&((i=n.current)==null||i.setSelectedRectID(u),A(!1))}),re=({targetId:e,id:o})=>{S(!1),U(e),X(o)};return p(()=>{if(z.current){const e=new Se({container:z.current,size:g,config:C(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",Z),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,r,t,i,l;(o=n.current)==null||o.unbind("updateDragResult",Z),(r=n.current)==null||r.unbind("afterAddingDrawingRect",ee),(t=n.current)==null||t.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(l=n.current)==null||l.destroy()}}},[]),p(()=>{const e=r=>G(void 0,null,function*(){try{return yield Oe.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>G(void 0,null,function*(){var r;Q(!0);let t=yield e(E);!t&&w&&(t=yield e(w)),t&&((r=n.current)==null||r.setImgNode(t),b(t)),Q(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&I()},[j]),p(()=>{var e,o;const r=h.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,B),r&&de(t=>{var i;const l=[];let u=null;return t.forEach(_=>{_.id!==n.current.selectedRectID?l.push(_):u=_}),r.extId===void 0&&(u=(i=n.current)==null?void 0:i.selectedRect),[...l,C(v({},u||{}),{attribute:B})]}),A(!0),I()},[B]),p(()=>{const e=Y.current;je.isEqual(e,h)||(A(!0),I(),Y.current=h)},[h]),p(()=>{I()},[f]),p(()=>{var e,o,r,t;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},l=C(v({},i),{attributeList:(r=D.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(l))},[D.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),I()},[m]),he(()=>{if(!x||!ge){S(!0);return}const{rectList:e,size:o,zoom:r}=n.current,t=e.find(u=>u.boxID===x||u.extId===x);if(!t){S(!0);return}const i={x:t.x+t.width/2,y:t.y+t.height/2},l=Le.getCurrentPosFromRectCenter(o,i,r);n.current.setHoverRectID(t.id),n.current.setCurrentPos(l),n.current.renderBasicCanvas(),n.current.render()},[x],{wait:200}),p(()=>{const{hiddenText:e}=M||{};if(e===void 0)return;const o=n.current;if(!o)return;const r=v(v({},o.style),M);o.setStyle(r)},[M]),p(()=>{I()},[R]),J.createElement(Ie,{spinning:me},J.createElement("div",{ref:z,style:v({position:"relative"},g)}))};var Fe=Ce(ye,null,null,{context:Pe})(Te);export{Fe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as w}from"../../utils/dom.js";import s,{useRef as j,useState as G,useContext as J,useMemo as K,useCallback as M,useEffect as Q}from"react";import W from"../AnnotationView/index.js";import X from"../../hooks/useSize.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{EPointCloudName as Z}from"@labelbee/lb-annotation";import{useHighlight as $}from"./hooks/useHighlight.js";import oo from"./components/HighlightVisible/index.js";import{PointCloudContext as to}from"./PointCloudContext.js";import eo from"./hooks/useDataLinkSwitch.js";import no from"../pointCloud2DRectOperationView/index.js";import{useToolStyleContext as io}from"../../hooks/useToolStyle.js";var lo=(o,u,i)=>new Promise((a,r)=>{var f=t=>{try{l(i.next(t))}catch(n){r(n)}},d=t=>{try{l(i.throw(t))}catch(n){r(n)}},l=t=>t.done?a(t.value):Promise.resolve(t.value).then(f,d);l((i=i.apply(o,u)).next())});const so=({view2dData:o,setSelectedID:u,currentData:i,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,l;const t=j(null),n=j(),{selectedBox:m}=Y(),p=X(t),{url:b,fallbackUrl:x,calib:C,path:v}=o,{toggle2dVisible:B,isHighlightVisible:I}=$({currentData:i}),[_,k]=G(!1),{highlight2DLoading:z,setHighlight2DLoading:S,cuboidBoxIn2DView:h,cacheImageNodeSize:N,setSelectedIDs:O,pointCloudBoxList:R}=J(to),{value:E}=io(),{hiddenText:H}=E||{},T=!o,U=K(()=>({zIndex:a?-1:101,is2DView:!h,imageName:o.path}),[a,h,o.path]),{rendered:A,isLinking:D}=eo(U),L=e=>{g(),N({path:v,imgNode:e})},g=M(()=>{var e,y;const P=(e=n.current)==null?void 0:e.toolInstance;if(u(""),!m||!P)return;const c=o.annotations.find(q=>q.annotation.id===m.info.id);let V="";c&&((y=c==null?void 0:c.annotation.pointList)==null?void 0:y.length)>0&&(P.focusPositionByPointList(c==null?void 0:c.annotation.pointList),V=m.info.id,u(V))},[m,n.current,o.annotations]);Q(()=>{g()},[g]);const F=()=>lo(void 0,null,function*(){k(!0),S(!0);try{yield B(b,x!=null?x:"",C)}catch(e){console.error("highlightOnClick error:",e)}finally{k(!1),S(!1)}});return s.createElement("div",{className:w("point-cloud-2d-image"),ref:t},h?s.createElement(W,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(l=o==null?void 0:o.fallbackUrl)!=null?l:"",annotations:o.annotations,size:p,ref:n,globalStyle:{display:T?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f,onRightClick:({targetId:e})=>O(e),pointCloudBoxList:R,hiddenText:H,renderToolName:Z.PointCloud}):s.createElement(s.Fragment,null,s.createElement(no,{shouldExcludePointCloudBoxListUpdate:!D,mappingData:o,size:p,checkMode:r,afterImgOnLoad:L}),!r&&A),C&&s.createElement(oo,{visible:I(b),onClick:F,loading:_,disabled:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{so as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as d}from"../../utils/dom.js";import{cKeyCode as G,PointCloud as J}from"@labelbee/lb-annotation";import{PointCloudUtils as T,toolStyleConverter as Q,EPerspectiveView as E}from"@labelbee/lb-utils";import N from"classnames";import o,{useContext as b,useState as y,useRef as W,useEffect as u,useMemo as X}from"react";import{PointCloudContainer as Y}from"./PointCloudLayout.js";import{PointCloudContext as $}from"./PointCloudContext.js";import{a2MapStateToProps as ee}from"../../store/annotation/map.js";import{connect as te}from"react-redux";import{jsonParser as oe}from"../../utils/index.js";import{useSingleBox as ne}from"./hooks/useSingleBox.js";import{useSphere as ie}from"./hooks/useSphere.js";import{Switch as le,Tooltip as re}from"antd";import ae from"../../hooks/useSize.js";import{usePointCloudViews as se}from"./hooks/usePointCloudViews.js";import{useTranslation as k}from"react-i18next";import{LabelBeeContext as ce}from"../../store/ctx.js";import de from"./components/PointCloudSizeSlider/index.js";import me from"./components/TitleButton/index.js";import{LeftOutlined as ue}from"@ant-design/icons";import{useToolStyleContext as pe}from"../../hooks/useToolStyle.js";var ve=Object.defineProperty,we=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,F=(n,l,r)=>l in n?ve(n,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[l]=r,A=(n,l)=>{for(var r in l||(l={}))Ce.call(l,r)&&F(n,r,l[r]);if(R)for(var r of R(l))Ve.call(l,r)&&F(n,r,l[r]);return n},Pe=(n,l)=>we(n,fe(l));const ge=G.default,Ee="LABELBEE-POINTCLOUD",_=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),p=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:r}=b(_),v=t=>N({[d("point-cloud-3d-view",t)]:!0,active:l});return o.createElement("span",{onClick:()=>{r(E[n])},className:v(n.toLocaleLowerCase())})},H=({isEnlarge:n})=>{const{reset3DView:l,followTopView:r}=b(_),{t:v}=k(),t=o.createElement(o.Fragment,null,o.createElement(p,{perspectiveView:"Top"}),o.createElement(p,{perspectiveView:"Front"}),o.createElement(p,{perspectiveView:"Left"}),o.createElement(p,{perspectiveView:"Back"}),o.createElement(p,{perspectiveView:"Right"}),o.createElement(p,{perspectiveView:"LFT"}),o.createElement(p,{perspectiveView:"RBT"})),P=o.createElement(o.Fragment,null,o.createElement(re,{title:v("CameraFollowTopView")},o.createElement("span",{onClick:()=>{r()},className:d("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:d("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:d("point-cloud-3d-sidebarZoom")},P,t):o.createElement("div",{className:d("point-cloud-3d-sidebar")},t,P)},_e=({currentData:n,config:l,highlightAttribute:r})=>{var v;const t=b($),[P,U]=y(!0),[f,h]=y(!1),C=W(null),{initPointCloud3d:B}=se(),V=ae(C),{t:x}=k(),{value:L}=pe(),{hiddenText:j}=L||{};u(()=>{let e=t.mainViewInstance;e&&e.updateHiddenTextAndRender(j,t.pointCloudBoxList)},[L]),u(()=>{!t.mainViewInstance||B==null||B(V)},[V]);const{selectedBox:m}=ne(),{selectedSphere:g}=ie(),[K,O]=y(!0),I=e=>{var i,a;const s=m==null?void 0:m.info;if(s){const c=A({},s.center);c.x=c.x-.01,c.z=1e3;const w=e===E.Top;(i=t.mainViewInstance)==null||i.updateCameraByBox(s,e,w?c:void 0)}g&&((a=t.mainViewInstance)==null||a.updateCameraBySphere(g,e))},M=()=>{var e;(e=t.mainViewInstance)==null||e.resetCamera()},Z=()=>{var e,i;const a=(e=t.topViewInstance)==null?void 0:e.pointCloudInstance.camera;a&&((i=t.mainViewInstance)==null||i.applyCameraTarget(a))};u(()=>{if(C.current&&(n==null?void 0:n.url)){let e=t.mainViewInstance;!e&&V.width&&(e=new J({container:C.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(V),config:l,hiddenText:j}),e.setHandlerPipe({setSelectedIDs:t.setSelectedIDs,setNeedUpdateCenter:O}),t.setMainViewInstance(e))}},[V,n]),u(()=>{var e;if(C.current&&(n==null?void 0:n.url)&&n.result&&t.mainViewInstance){let i=t.mainViewInstance;const a=T.getBoxParamsFromResultList(n.result);a.forEach(c=>{var w;const S=(w=Q.getColorFromConfig({attribute:c.attribute},Pe(A({},l),{attributeConfigurable:!0}),{}))==null?void 0:w.hex;i==null||i.addBoxToSense(c,S)}),i.render(),t.setPointCloudResult(a);const s=T.getRectParamsFromResultList(n.result);t.setRectList(s),t.setPointCloudValid((e=oe(n.result))==null?void 0:e.valid)}},[n,t.mainViewInstance]),u(()=>{var e,i,a,s,c;const w=(e=m==null?void 0:m.info)==null?void 0:e.id;if(!K){O(!0);return}if(w!==void 0){I(E.Top);const S=(s=(a=(i=t.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?s:1;(c=t.mainViewInstance)==null||c.updateCameraZoom(S)}},[(v=m==null?void 0:m.info)==null?void 0:v.id]),u(()=>{var e,i,a,s;if(g){I(E.Top);const c=(a=(i=(e=t.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(s=t.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",D),()=>{window.removeEventListener("keydown",D)}),[]);const D=e=>{if(e.keyCode===ge.Esc){h(!1);return}},z=X(()=>({reset3DView:M,setTarget3DView:I,isActive:!!m,followTopView:Z}),[m,t.mainViewInstance]);u(()=>{var e,i,a;const s=t.pointCloudBoxList.filter(c=>c.attribute===r);(s==null?void 0:s.length)>0&&((e=t.mainViewInstance)==null||e.clearHighlightBoxes(),(i=t.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((a=t.mainViewInstance)==null||a.clearHighlightBoxesAndRender())},[r,t.mainViewInstance]);const q=o.createElement(o.Fragment,null,o.createElement(de,{onChange:e=>{var i;(i=t.mainViewInstance)==null||i.updatePointSize({customSize:e})}}),o.createElement("span",{style:{marginRight:8}},x("ShowArrows")),o.createElement(le,{size:"small",checked:P,onChange:e=>{var i;U(e),(i=t.mainViewInstance)==null||i.setShowDirection(e)}}),f&&o.createElement(_.Provider,{value:z},o.createElement(H,{isEnlarge:f})));return o.createElement(Y,{className:N({[d("point-cloud-3d-container")]:!0,[d("point-cloud-container","zoom")]:f}),title:f?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(ue,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),x("3DView")):o.createElement(me,{title:x("3DView"),onClick:()=>{h(!0)}}),toolbar:q},o.createElement("div",{className:d("point-cloud-3d-content")},!f&&o.createElement(_.Provider,{value:z},o.createElement(H,null)),o.createElement("div",{className:d("point-cloud-3d-view"),id:Ee,ref:C})))};var he=te(ee,null,null,{context:ce})(_e);export{he as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as j}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,A=(n,r,a)=>r in n?xe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))Be.call(r,a)&&A(n,a,r[a]);if(I)for(var a of I(r))Le.call(r,a)&&A(n,a,r[a]);return n},y=(n,r)=>_e(n,Ve(r));const{EPolygonPattern:Oe}=pe,je=({currentData:n,config:r,checkMode:a,configString:E,imgIndex:S,toolInstanceRef:i,setResourceLoading:k})=>{const e=le(re),{changeSelectedBoxValid:T,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=ae(),{selectedSphere:v,updatePointCloudSphere:U}=ue(),{clearAllResult:w,updatePointCloudPattern:z}=fe(),{copySelectedBoxes:R,pasteSelectedBoxes:F,copiedBoxes:Ae}=ie({config:r,currentData:n}),{updateRotate:x}=se({currentData:n}),{updateRotateEdge:q}=ne({currentData:n}),{updatePointCloudData:m,topViewSelectedChanged:G}=Pe({setResourceLoading:k}),{redo:_,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=ve(),{syncThreeViewsAttribute:B}=we(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=Ce(),{selectedPolygon:L}=he(),{selectedLine:O}=ge(),{t:C}=ke(),{updatePointCloudColor:Q}=Se(k,r),X=j(n),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:h}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const p=h.pattern===Oe.Normal?f.Rect:f.Polygon;z(p);const oe={[f.Polygon]:C("PolygonPattern"),[f.Rect]:C("RectPattern")};g.success(C("ChangePatternMsg",{pattern:oe[p]})),h.clearActiveStatus(),h.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=de.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((u=i.current)==null||u.setDefaultAttribute(p))}return}}},ee=(t,o)=>{switch(t){case"c":R();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?_():V();break}}},te=j(t=>{if(!ce.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>te.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[E]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{m==null||m()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{i.current.setDefaultAttribute=t=>{var o;if(B(t),Q(t),L&&W(y(P({},L),{attribute:t})),O&&Y(y(P({},O),{attribute:t})),v){const s=U(y(P({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),G({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=y(P({},c),{[t]:o}),K(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{_()},i.current.undo=()=>{V()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},i.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{m==null||m(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{i.current.history={pushHistory:t=>{M({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=l=>{B(l)},u=l=>{g.error(l)},c=l=>{g.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(be,null,null,{context:ye})(je);export{Ie as default};
|