@neosjs/screen-shot
Version:
JS截屏插件
6 lines • 58.6 kB
JavaScript
"use strict";/*!
* @neosjs/screen-shot
* Version: 1.1.0
* ReleaseTime: 2025/4/18 15:48:49
*/const G=require("html2canvas");function _interopDefaultCompat(A){return A&&typeof A=="object"&&"default"in A?A.default:A}const G__default=_interopDefaultCompat(G),u$2=[{id:1,title:"square"},{id:2,title:"round"},{id:3,title:"right-top"},{id:4,title:"brush"},{id:5,title:"mosaicPen"},{id:6,title:"text"},{id:7,title:"separateLine"},{id:8,title:"save"},{id:9,title:"undo"},{id:10,title:"close"},{id:11,title:"confirm"}];function getSelectedClassName(A){let F="";switch(A){case 1:F="square-active";break;case 2:F="round-active";break;case 3:F="right-top-active";break;case 4:F="brush-active";break;case 5:F="mosaicPen-active";break;case 6:F="text-active"}return F}function getBrushSelectedName(A){let F="";switch(A){case 1:F="brush-small-active";break;case 2:F="brush-medium-active";break;case 3:F="brush-big-active";break}return F}function setSelectedClassName(A,F,W){let U=getSelectedClassName(F);W&&(U=getBrushSelectedName(F));const j=(A.path||A.composedPath&&A.composedPath())[1].children;for(let q=0;q<j.length;q++){const J=j[q];J.className.includes("active")&&J.classList.remove(J.classList[2])}A.target.className+=" "+U}function calculateOptionIcoPosition(A){switch(A){case 1:return 16;case 2:return 24*2+8;case 3:return 24*4-6;case 4:return 24*5+8;case 5:return 24*7+6;case 6:return 24*9-6;default:return 0}}function takeOutHistory(){var A;const F=new Y;F.popHistory();const W=(A=F.getScreenShotContainer())==null?void 0:A.getContext("2d");W!=null&&F.getHistory().length>0&&W.putImageData(F.getHistory()[F.getHistory().length-1].data,0,0),F.setUndoClickNum(F.getUndoClickNum()+1),F.getHistory().length-1<=0&&(F.setUndoClickNum(0),F.setUndoStatus(!1))}function getToolRelativePosition(A,F,W=document.body){const U=W.getBoundingClientRect();return{left:A||Math.abs(U.left),top:F||Math.abs(U.top)}}let u$1=!1,a$2=null,l$2=!1,n$1=0,r$2=0,i$1=!1,s$1=null;const t={r:0,g:0,b:0,a:.3};let o$2=!0,b$2="#6cb6ff",c$2=!1,g$1=15,m$2=!1,p$1=!1,S$2=null,f$2=null,C$2=class{constructor(){l$2&&(u$1=!1,n$1=0,r$2=0,b$2="#6cb6ff",c$2=!1,i$1=!1,o$2=!0,a$2=null,l$2=!1,s$1=null,S$2=null,g$1=15,m$2=!1,p$1=!1,f$2=null)}setInitStatus(F){l$2=F}getInitStatus(){return l$2}getWebRtcStatus(){return u$1}setWebRtcStatus(F){u$1=F}setScreenShotDom(F){s$1=F}getCutBoxBdColor(){return b$2}setCutBoxBdColor(F){b$2=F}getCutDotRound(){return c$2}setCutDotRound(F){c$2=F}getScreenShotDom(){return s$1}getScreenFlow(){return a$2}setScreenFlow(F){a$2=F}getCanvasSize(){return{canvasWidth:n$1,canvasHeight:r$2}}setCanvasSize(F,W){n$1=F,r$2=W}getShowScreenDataStatus(){return i$1}setShowScreenDataStatus(F){i$1=F}setMaskColor(F){t.r=F.r,t.g=F.g,t.b=F.b,t.a=F.a}getMaskColor(){return t}setWriteImgState(F){o$2=F}getWriteImgState(){return o$2}setSaveCallback(F){S$2=F}getSaveCallback(){return S$2}setMaxUndoNum(F){g$1=F}getMaxUndoNum(){return g$1}setRatioArrow(F){m$2=F}getRatioArrow(){return m$2}setImgAutoFit(F){p$1=F}getImgAutoFit(){return p$1}setSaveImgTitle(F){f$2=F}getSaveImgTitle(){return f$2}};const m$1=["#f03e3e","#1c7ed6","#37b24d","#f59f00","#ae3ec9","#F66632","#000000","#FEFFFF"];let k$1=!1,x=!1,E$1=!1,P="#f03e3e",I$2="",v=2,L=10,N=6,H$1=0,S$1=[];const X=!1;let M=!1,y$3={startX:0,startY:0,width:0,height:0},l$1=null,i=null,u=null,a$1=null,o$1=null,b$1=null,m=null,d$1=null,B$1=18,s=null,f$1=null,g=null,z=null,c$1=null,R=null,C$1=!1,D$1=!1,_$1="",$,T$1=!1,O$2=!1;class Y{constructor(){D$1&&(D$1=!1,l$1=null,x=!1,i=null,a$1=null,s=null,o$1=null,b$1=null,m=null,d$1=null,u=null,y$3={startX:0,startY:0,width:0,height:0},E$1=!1,T$1=!1,O$2=!1,M=!1,P="#F53340",I$2="",v=2,B$1=18,L=10,S$1=[],H$1=0,f$1=null,g=null,z=null,c$1=null)}setInitStatus(F){D$1=F}setScreenShotInfo(F,W){this.getScreenShotContainer(),l$1!=null&&(C$1&&document.body.classList.add("__screenshot-lock-scroll"),l$1.width=F,l$1.height=W)}setScreenShotPosition(F,W){if(this.getScreenShotContainer(),l$1==null)return;const{left:U,top:j}=getToolRelativePosition(F,W);l$1.style.left=U+"px",l$1.style.top=j+"px"}showScreenShotPanel(){this.getScreenShotContainer(),l$1!=null&&(l$1.style.display="block")}getScreenShotContainer(){return l$1=document.getElementById("screenShotContainer"),l$1}getToolController(){return i=document.getElementById("toolPanel"),i}getCutBoxSizeContainer(){return u=document.getElementById("cutBoxSizePanel"),u}getTextInputController(){return a$1=document.getElementById("textInputPanel"),a$1}getTextStatus(){return X}getScreenShotImageController(){return R}setScreenShotImageController(F){R=F}setToolStatus(F){if(i=this.getToolController(),F){i.style.display="flex";return}i.style.display="none"}setCutBoxSizeStatus(F){if(u!=null){if(F){u.style.display="flex";return}u.style.display="none"}}setCutBoxSizePosition(F,W){if(u==null)return;const{left:U,top:j}=getToolRelativePosition(F,W);u.style.left=U+"px";let q=0;l$1&&(q=parseInt(l$1.style.top)),u.style.top=j+q+"px"}setTextEditState(F){O$2=F}getTextEditState(){return O$2}setCutBoxSize(F,W){if(u==null)return;F=Math.floor(F),W=Math.floor(W);const U=u.childNodes;if(U.length>0){U[0].innerText=`${F} * ${W}`;return}const j=document.createElement("p");j.innerText=`${F} * ${W}`,u.appendChild(j)}setTextStatus(F){if(a$1=this.getTextInputController(),a$1!=null){if(F){a$1.style.display="block";return}a$1.style.display="none"}}setToolInfo(F,W){i=document.getElementById("toolPanel");const{left:U,top:j}=getToolRelativePosition(F,W);i.style.left=U+"px";let q=0;l$1&&(q=parseInt(l$1.style.top)),i.style.top=j+q+"px"}getToolClickStatus(){return E$1}setToolClickStatus(F){E$1=F}setResetScrollbarState(F){T$1=F}getResetScrollbarState(){return T$1}getCutOutBoxPosition(){return y$3}getDragging(){return x}setDragging(F){x=F}getDraggingTrim(){return k$1}getToolPositionStatus(){return M}setToolPositionStatus(F){M=F}setDraggingTrim(F){k$1=F}setCutOutBoxPosition(F,W,U,j){y$3.startX=F,y$3.startY=W,y$3.width=U,y$3.height=j}setFontSize(F){B$1=F}setOptionStatus(F){if(o$1=this.getOptionIcoController(),s=this.getOptionController(),!(o$1==null||s==null)){if(F){o$1.style.display="block",s.style.display="flex";return}o$1.style.display="none",s.style.display="none"}}getFontSize(){return B$1}setTextSizeOptionStatus(F){if(b$1=this.getOptionTextSizeController(),b$1!=null){if(F){b$1.style.display="flex";return}b$1.style.display="none"}}setTextSizePanelStatus(F){if(d$1=this.getTextSizeContainer(),d$1!=null){if(F){console.log("\u663E\u793A"),d$1.style.display="flex";return}d$1.style.display="none"}}setBrushSelectionStatus(F){if(m=this.getBrushSelectionController(),m!=null){if(F){m.style.display="flex";return}m.style.display="none"}}hiddenOptionIcoStatus(){o$1=this.getOptionIcoController(),o$1!=null&&(o$1.style.display="none")}getOptionIcoController(){return o$1=document.getElementById("optionIcoController"),o$1}getTextSizeContainer(){return d$1=document.getElementById("textSizePanel"),d$1}getOptionTextSizeController(){return b$1=document.getElementById("textSelectPanel"),b$1}getBrushSelectionController(){return m=document.getElementById("brushSelectPanel"),m}getOptionController(){return s=document.getElementById("optionPanel"),s}setOptionPosition(F){if(o$1=this.getOptionIcoController(),s=this.getOptionController(),o$1==null||s==null)return;const W=this.getToolPosition();if(W==null)return;const U=W.left+F+"px",j=W.top+44+"px",q=W.left+"px",J=W.top+44+6+"px";o$1.style.left=U,o$1.style.top=j,s.style.left=q,s.style.top=J}getToolPosition(){if(i=this.getToolController(),i!=null)return{left:i.offsetLeft,top:i.offsetTop}}getSelectedColor(){return P}setSelectedColor(F,W){P=F,this.setColorSelectPanel(W)}setColorSelectPanel(F){for(let U=0;U<m$1.length;U++){const j=document.getElementById(`colorItem_${U}`);if(j==null)return;j.style.borderColor="transparent"}const W=document.getElementById(`colorItem_${F}`);W!=null&&(W.style.borderColor="#fff")}getColorSelectPanel(){return z=document.getElementById("colorSelectPanel"),z}getToolName(){return I$2}setToolName(F){I$2=F}getPenSize(){return v}setPenSize(F){v=F}getMosaicPenSize(){return L}setMosaicPenSize(F){L=F}getBorderSize(){return N}setBorderSize(F){N=F||6}getHistory(){return S$1}shiftHistory(){return S$1.shift()}popHistory(){return S$1.pop()}pushHistory(F){S$1.push(F)}getUndoClickNum(){return H$1}setUndoClickNum(F){H$1=F}getColorPanel(){return f$1=document.getElementById("colorPanel"),f$1}setColorPanelStatus(F){if(f$1=this.getColorPanel(),f$1!=null){if(F){f$1.style.display="flex";return}f$1.style.display="none"}}getNoScrollStatus(){return C$1}setNoScrollStatus(F){F!=null&&(C$1=F)}setActiveToolName(F){_$1=F}getActiveToolName(){return _$1}setTextInfo(F){$=F}getTextInfo(){return $}getRightPanel(){return g=document.getElementById("rightPanel"),g}setRightPanel(F){if(g=this.getRightPanel(),g!=null){if(F){g.style.display="flex";return}g.style.display="none"}}setUndoStatus(F){if(c$1=this.getUndoController(),c$1!=null){if(F){c$1.classList.add("undo"),c$1.classList.remove("undo-disabled"),c$1.addEventListener("click",this.cancelEvent);return}c$1.classList.add("undo-disabled"),c$1.classList.remove("undo"),c$1.removeEventListener("click",this.cancelEvent)}}cancelEvent(){takeOutHistory()}getUndoController(){return c$1=document.getElementById("undoPanel"),c$1}destroyDOM(){if(l$1==null||i==null||o$1==null||s==null||a$1==null||u==null)return;const F=new C$2;C$1&&document.body.classList.remove("__screenshot-lock-scroll"),document.body.removeChild(l$1),document.body.removeChild(i),document.body.removeChild(o$1),document.body.removeChild(s),document.body.removeChild(a$1),document.body.removeChild(u),document.body.classList.contains("no-cursor")&&document.body.classList.remove("no-cursor"),T$1&&(document.documentElement.classList.remove("hidden-screen-shot-scroll"),document.body.classList.remove("hidden-screen-shot-scroll")),F.setInitStatus(!0)}}function getCanvas2dCtx(A,F,W){const U=window.devicePixelRatio||1;A.width=Math.round(F*U),A.height=Math.round(W*U),A.style.width=F+"px",A.style.height=W+"px";const j=A.getContext("2d");return j&&j.scale(U,U),j}function saveCanvasToImage(A,F,W,U,j){const q=new C$2,J=window.devicePixelRatio||1,Q=A.getImageData(F*J,W*J,U*J,j*J),tt=document.createElement("canvas"),et=getCanvas2dCtx(tt,U,j);if(et){et.putImageData(Q,0,0);const ot=document.createElement("a");ot.href=tt.toDataURL("png");const rt=(q==null?void 0:q.getSaveImgTitle())||new Date().getTime();ot.download=`${rt}.png`,ot.click()}}function saveCanvasToBase64(A,F,W,U,j,q=100,J=!0){const Q=window.devicePixelRatio||1,tt=A.getImageData(F*Q,W*Q,U*Q,j*Q),et=document.createElement("canvas"),ot=getCanvas2dCtx(et,U,j);return ot?(ot.putImageData(tt,0,0),J&&(et==null||et.toBlob(rt=>{var it;if(rt==null)return;const at=window.ClipboardItem;if(at==null)return et.toDataURL("png");const lt=new at({[rt.type]:rt});(it=navigator.clipboard)==null||it.write([lt]).then(()=>"\u5199\u5165\u6210\u529F")},"image/png",q)),et.toDataURL("png")):""}function getCanvasImgData(A){var F;const W=new Y,U=new C$2,j=(F=W.getScreenShotContainer())==null?void 0:F.getContext("2d"),{startX:q,startY:J,width:Q,height:tt}=W.getCutOutBoxPosition();let et="";return j&&(A?saveCanvasToImage(j,q,J,Q,tt):et=saveCanvasToBase64(j,q,J,Q,tt,100,U.getWriteImgState())),et}function drawCutOutBox(A,F,W,U,j,q,J,Q,tt=!0){const et=J==null?void 0:J.width,ot=J==null?void 0:J.height,rt=window.devicePixelRatio||1,it=new C$2,at=it.getCutDotRound();if(!et||!ot||!Q||!J)return;j.clearRect(0,0,et,ot),W=W!=0?W:5,U=U!=0?U:5,j.save();const lt=it.getMaskColor();if(j.fillStyle="rgba(0, 0, 0, .5)",lt&&(j.fillStyle=`rgba(${lt.r}, ${lt.g}, ${lt.b}, ${lt.a})`),j.fillRect(0,0,et,ot),j.globalCompositeOperation="source-atop",j.clearRect(A,F,W,U),j.globalCompositeOperation="source-over",j.strokeStyle=it.getCutBoxBdColor(),j.strokeRect(A-1,F-1,W+2,U+2),j.closePath(),tt){j.fillStyle=it.getCutBoxBdColor();let nt=q;at?(nt=q/2,j.strokeStyle=it.getCutBoxBdColor(),j.beginPath(),j.arc(A,F,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/2+W/2,F,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/10+W,F,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/10,F-nt/2+U/2,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/10+W,F-nt/2+U/2,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/10,F-nt/5+U,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/2+W/2,F+U,nt,0,2*Math.PI),j.fill(),j.stroke(),j.beginPath(),j.arc(A-nt/10+W,F-nt/5+U,nt,0,2*Math.PI),j.fill(),j.stroke()):(j.fill(),j.fillRect(A-nt/2,F-nt/2,nt,nt),j.fillRect(A-nt/2+W/2,F-nt/2,nt,nt),j.fillRect(A-nt/2+W,F-nt/2,nt,nt),j.fillRect(A-nt/2,F-nt/2+U/2,nt,nt),j.fillRect(A-nt/2+W,F-nt/2+U/2,nt,nt),j.fillRect(A-nt/2,F-nt/2+U,nt,nt),j.fillRect(A-nt/2+W/2,F-nt/2+U,nt,nt),j.fillRect(A-nt/2+W,F-nt/2+U,nt,nt),j.stroke())}j.restore(),j.save(),j.globalCompositeOperation="destination-over";let{imgWidth:ht,imgHeight:st}={imgWidth:parseInt(J==null?void 0:J.style.width),imgHeight:parseInt(J==null?void 0:J.style.height)};const ct=it.getScreenShotDom();return ct!=null&&(ht=ct.clientWidth,st=ct.clientHeight),!it.getWebRtcStatus()&&!it.getImgAutoFit()&&ct==null&&(ht=Q.width/rt,st=Q.height/rt),j.drawImage(Q,0,0,ht,st),j.restore(),W>0&&U>0?{startX:A,startY:F,width:W,height:U}:W<0&&U<0?{startX:A+W,startY:F+U,width:Math.abs(W),height:Math.abs(U)}:W>0&&U<0?{startX:A,startY:F+U,width:W,height:Math.abs(U)}:W<0&&U>0?{startX:A+W,startY:F,width:Math.abs(W),height:U}:{startX:A,startY:F,width:W,height:U}}function drawText(A,F,W,U,j,q){q.save(),q.lineWidth=1,q.fillStyle=U,q.textBaseline="middle",q.font=`bold ${j}px none`;const J=A.split(`
`);console.log(J);const Q=j*1.4;J.forEach((tt,et)=>{const ot=W+Q*et;q.fillText(tt,F,ot)}),q.restore()}function addHistory(){const A=new Y,F=new C$2,W=A.getScreenShotContainer();if(W==null)return;const U=W.getContext("2d"),j=W;A.getHistory().length>F.getMaxUndoNum()&&A.shiftHistory(),A.pushHistory({data:U.getImageData(0,0,j.width,j.height)}),A.setUndoStatus(!0)}function toolClickEvent(A,F,W,U,j){var q,J,Q;const tt=new Y,et=new C$2,ot=tt.getTextInputController(),rt=tt.getScreenShotContainer(),it=tt.getScreenShotImageController();if(tt.setActiveToolName(A),rt==null||it==null)return;const at=rt.getContext("2d");if(!tt.getToolClickStatus()){const lt=((q=tt.getToolPosition())==null?void 0:q.left)||0,ht=((J=tt.getToolPosition())==null?void 0:J.top)||0;ht&&tt.getToolPositionStatus()&&tt.setToolInfo(lt,ht-46),tt.setToolStatus(!0);const st=tt.getCutOutBoxPosition();drawCutOutBox(st.startX,st.startY,st.width,st.height,at,tt.getBorderSize(),rt,it,!1)}if(tt.setToolName(A),setSelectedClassName(W,F,!1),A==="text"?(tt.setTextSizePanelStatus(!0),tt.setBrushSelectionStatus(!1),(Q=tt.getColorSelectPanel())==null||Q.classList.add("text-select-status")):(tt.setTextSizePanelStatus(!1),tt.setBrushSelectionStatus(!0)),tt.setOptionStatus(!0),tt.setOptionPosition(calculateOptionIcoPosition(F)),tt.setRightPanel(!0),A=="mosaicPen"&&(tt.setRightPanel(!1),tt.hiddenOptionIcoStatus()),ot!=null&&tt.getTextStatus()||ot!=null&&A!=="text"){const lt=ot.innerText;if(lt&<!==""){const{positionX:ht,positionY:st,color:ct,size:nt}=tt.getTextInfo();drawText(lt,ht,st,ct,nt,at),addHistory()}ot.innerHTML="",tt.setTextStatus(!1)}if(tt.setDragging(!1),tt.setDraggingTrim(!1),A=="save"){getCanvasImgData(!0);const lt=et.getSaveCallback();lt&<(0,"\u4FDD\u5B58\u6210\u529F"),tt.destroyDOM(),tt.setInitStatus(!0)}if(A=="close"&&(j&&j(),tt.destroyDOM(),tt.setInitStatus(!0)),A=="confirm"){const lt=getCanvasImgData(!1);U&&U({base64:lt,cutInfo:tt.getCutOutBoxPosition()}),tt.destroyDOM(),tt.setInitStatus(!0)}A=="undo"&&(tt.setOptionStatus(!1),takeOutHistory()),tt.setToolClickStatus(!0)}function setBrushSize(A,F,W){const U=new Y;setSelectedClassName(W,F,!0);let j=2;switch(A){case"small":j=2;break;case"medium":j=5;break;case"big":j=10;break}return U.setPenSize(j),j}function setMosaicPenSize(A,F,W){const U=new Y;setSelectedClassName(W,F,!0);let j=10;switch(A){case"small":j=10;break;case"medium":j=20;break;case"big":j=40;break}return U.setMosaicPenSize(j),j}function getColor(A){const F=new Y,W=m$1[A];return F.setSelectedColor(W,A),F.setColorPanelStatus(!0),W}function selectTextSize(){new Y().setTextSizeOptionStatus(!0)}function setTextSize(A){new Y().setFontSize(A)}function hiddenTextSizeOptionStatus(){new Y().setTextSizeOptionStatus(!1)}var h=Object.defineProperty,p=(A,F,W)=>F in A?h(A,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):A[F]=W,r$1=(A,F,W)=>(p(A,typeof F!="symbol"?F+"":F,W),W);class S{constructor(F){r$1(this,"screenShotController"),r$1(this,"toolController"),r$1(this,"optionIcoController"),r$1(this,"optionController"),r$1(this,"cutBoxSizeContainer"),r$1(this,"textInputController"),r$1(this,"completeCallback"),r$1(this,"closeCallback"),r$1(this,"showIconArr"),r$1(this,"toolbar"),r$1(this,"textFontSizeList",[{name:"\u5927",value:28},{name:"\u4E2D",value:16},{name:"\u5C0F",value:12}]);var W;this.screenShotController=document.createElement("canvas"),this.toolController=document.createElement("div"),this.optionIcoController=document.createElement("div"),this.optionController=document.createElement("div"),this.cutBoxSizeContainer=document.createElement("div"),this.textInputController=document.createElement("div"),this.completeCallback=F==null?void 0:F.onComplete,this.closeCallback=F==null?void 0:F.onClose,this.showIconArr=["close"],this.optionController.addEventListener("click",U=>{const j=U.target;j.id==="colorSelectPanel"||j.id==="textSizePanel"||hiddenTextSizeOptionStatus()}),(!F||!Object.prototype.hasOwnProperty.call(F,"onComplete"))&&(this.completeCallback=U=>{sessionStorage.setItem("screenShotImg",JSON.stringify(U))}),(W=F==null?void 0:F.showToolIcon)!=null&&W.length&&F.showToolIcon.forEach(U=>this.showIconArr.push(U)),this.setAllControllerId(),this.setOptionIcoClassName(),this.toolbar=u$2,this.setToolBarIcon(F),this.setTextSizeSelectPanel(),this.setBrushSelectPanel(),this.setTextInputPanel(),this.setDomToBody(),this.hiddenAllDom()}setToolBarIcon(F){for(let W=0;W<this.toolbar.length;W++){const U=this.toolbar[W];let j=!0;for(let Q=0;Q<this.showIconArr.length;Q++)if(this.showIconArr[Q]===U.title){j=!1;break}if(j)continue;const q=document.createElement("div");q.className="tool-panel";const J=document.createElement("div");if(U.title=="undo"?(J.className="item-panel undo-disabled",J.id="undoPanel"):(J.className=`item-panel ${U.title}`,q.addEventListener("click",Q=>{toolClickEvent(U.title,U.id,Q,this.completeCallback,this.closeCallback)})),F!=null&&F.confirmBtnText&&U.title==="confirm"){const Q=document.createElement("span");Q.innerHTML=F.confirmBtnText,q.className="tool-panel tool-panel--confirm",q.appendChild(Q)}J.setAttribute("data-title",U.title),J.setAttribute("data-id",U.id+""),q.setAttribute("data-title",U.title),q.setAttribute("data-id",U.id+""),q.appendChild(J),this.toolController.appendChild(q)}this.showIconArr.length||(this.toolController.style.padding="0")}setTextSizeSelectPanel(){const F=document.createElement("div");F.className="text-size-panel",F.innerText="\u4E2D",F.id="textSizePanel";const W=document.createElement("div");W.className="text-select-panel",W.id="textSelectPanel";for(let U=0;U<this.textFontSizeList.length;U++){const j=document.createElement("div"),q=this.textFontSizeList[U];j.className="text-item",j.setAttribute("data-value",`${q.value}`),j.setAttribute("data-name",`${q.name}`),j.innerText=`${q.name}`,j.addEventListener("click",()=>{W.style.display="none";const J=j.getAttribute("data-value"),Q=j.getAttribute("data-name");F.innerText=`${Q}`,J&&setTextSize(+J)}),W.appendChild(j)}F.style.display="none",W.style.display="none",F.addEventListener("click",()=>{selectTextSize()}),this.optionController.appendChild(F),this.optionController.appendChild(W)}setBrushSelectPanel(){const F=document.createElement("div");F.id="brushSelectPanel",F.className="brush-select-panel";for(let j=0;j<3;j++){const q=document.createElement("div");switch(q.className="item-panel",j){case 0:q.classList.add("brush-small"),q.classList.add("brush-small-active"),q.addEventListener("click",J=>{setBrushSize("small",1,J),setMosaicPenSize("small",1,J)});break;case 1:q.classList.add("brush-medium"),q.addEventListener("click",J=>{setBrushSize("medium",2,J),setMosaicPenSize("medium",2,J)});break;case 2:q.classList.add("brush-big"),q.addEventListener("click",J=>{setBrushSize("big",3,J),setMosaicPenSize("big",3,J)});break}F.appendChild(q)}const W=document.createElement("div");W.className="right-panel";const U=document.createElement("div");U.id="colorPanel",U.className="color-panel";for(let j=0;j<m$1.length;j++){const q=document.createElement("div");q.className="color-item",q.id=`colorItem_${j}`,q.style.backgroundColor=m$1[j],q.addEventListener("click",()=>getColor(j)),q.setAttribute("data-index",j+""),U.appendChild(q)}W.appendChild(U),W.id="rightPanel",this.optionController.appendChild(F),this.optionController.appendChild(W)}setTextInputPanel(){this.textInputController.contentEditable="true",this.textInputController.spellcheck=!1}setAllControllerId(){this.screenShotController.id="screenShotContainer",this.toolController.id="toolPanel",this.optionIcoController.id="optionIcoController",this.optionController.id="optionPanel",this.cutBoxSizeContainer.id="cutBoxSizePanel",this.textInputController.id="textInputPanel"}hiddenAllDom(){this.screenShotController.style.display="none",this.toolController.style.display="none",this.optionIcoController.style.display="none",this.optionController.style.display="none",this.cutBoxSizeContainer.style.display="none",this.textInputController.style.display="none"}setDomToBody(){this.clearBody(),document.body.appendChild(this.screenShotController),document.body.appendChild(this.toolController),document.body.appendChild(this.optionIcoController),document.body.appendChild(this.optionController),document.body.appendChild(this.cutBoxSizeContainer),document.body.appendChild(this.textInputController)}clearBody(){var F,W,U,j,q,J;(F=document.getElementById("screenShotContainer"))==null||F.remove(),(W=document.getElementById("toolPanel"))==null||W.remove(),(U=document.getElementById("optionIcoController"))==null||U.remove(),(j=document.getElementById("optionPanel"))==null||j.remove(),(q=document.getElementById("optionPanel"))==null||q.remove(),(J=document.getElementById("textInputPanel"))==null||J.remove()}setOptionIcoClassName(){this.optionIcoController.className="icon-panel"}}function drawMasking(A,F){const W=new C$2,U=new C$2,j=U.getCanvasSize(),q={width:parseFloat(window.getComputedStyle(document.body).width),height:parseFloat(window.getComputedStyle(document.body).height)},J=Math.max(q.width||0,Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),Math.max(document.body.clientWidth,document.documentElement.clientWidth)),Q=Math.max(q.height||0,Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),Math.max(document.body.offsetHeight,document.documentElement.offsetHeight),Math.max(document.body.clientHeight,document.documentElement.clientHeight));A.clearRect(0,0,J,Q),F!=null&&U.getShowScreenDataStatus()&&(j.canvasWidth!==0&&j.canvasHeight!==0?A.drawImage(F,0,0,j.canvasWidth,j.canvasHeight):A.drawImage(F,0,0,J,Q)),A.save();const tt=W.getMaskColor();A.fillStyle="rgba(0, 0, 0, .6)",tt&&(A.fillStyle=`rgba(${tt.r}, ${tt.g}, ${tt.b}, ${tt.a})`),j.canvasWidth!==0&&j.canvasHeight!==0?A.fillRect(0,0,j.canvasWidth,j.canvasHeight):A.fillRect(0,0,J,Q),A.restore()}function nonNegativeData(A){return A>0?A:0}function fixedData(A,F,W){return nonNegativeData(A)+F>W?nonNegativeData(W-F):nonNegativeData(A)}function getDrawBoundaryStatus(A,F,W){return!(A<W.startX||F<W.startY||A>W.startX+W.width||F>W.startY+W.height)}var d=Object.defineProperty,a=(A,F,W)=>F in A?d(A,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):A[F]=W,r=(A,F,W)=>(a(A,typeof F!="symbol"?F+"":F,W),W);class c{constructor(F,W){r(this,"toolController",null);const U=new Y,j=document.getElementById("textInputPanel");this.toolController=W,F.tabIndex=9999,document.body.addEventListener("keydown",q=>{if(U.getTextEditState()){U.setTextEditState(!1);return}q.code==="Escape"&&this.triggerEvent("close"),q.code==="Enter"&&j&&j.style.display!=="block"&&this.triggerEvent("confirm"),(q.metaKey||q.ctrlKey)&&q.code==="KeyZ"&&this.triggerEvent("undo")})}triggerEvent(F){if(this.toolController!=null)for(let W=0;W<this.toolController.childNodes.length;W++){const U=this.toolController.childNodes[W];U.getAttribute("data-title")===F&&U.click()}}}function setPlugInParameters(A){const F=new C$2;(A==null?void 0:A.enableWebRtc)===!0&&F.setWebRtcStatus(!0),(A==null?void 0:A.screenFlow)instanceof MediaStream&&F.setScreenFlow(A.screenFlow),A!=null&&A.canvasWidth&&A!=null&&A.canvasHeight&&F.setCanvasSize(A.canvasWidth,A.canvasHeight),(A==null?void 0:A.showScreenData)===!0&&F.setShowScreenDataStatus(!0),A!=null&&A.maskColor&&typeof A.maskColor=="object"&&F.setMaskColor(A.maskColor),(A==null?void 0:A.writeBase64)===!1&&F.setWriteImgState(A.writeBase64),A!=null&&A.screenShotDom&&F.setScreenShotDom(A.screenShotDom),A!=null&&A.cutDotColor&&F.setCutBoxBdColor(A.cutDotColor),A!=null&&A.cutDotRound&&F.setCutDotRound(A.cutDotRound),A!=null&&A.onSave&&F.setSaveCallback(A.onSave),A!=null&&A.maxUndoNum&&F.setMaxUndoNum(A.maxUndoNum),A!=null&&A.useRatioArrow&&F.setRatioArrow(A.useRatioArrow),A!=null&&A.imgAutoFit&&F.setImgAutoFit(A.imgAutoFit),A!=null&&A.saveImgTitle&&F.setSaveImgTitle(A.saveImgTitle)}function calculateToolLocation(A,F,W,U,j){let q=(A.width-F)/2+(A.startX-j.left);U==="left"&&(q=A.startX),U==="right"&&(q=A.startX+A.width-F),q<0&&(q=0),q+F>W&&(q=W-F);let J=A.startY+A.height+10;return(A.width<0&&A.height<0||A.width>0&&A.height<0)&&(J=A.startY+10),J-=j.top,{mouseX:q,mouseY:J}}function drawCrossImg(A){const F=[];return A.querySelectorAll("img").forEach(W=>{const U=W.getAttribute("src");if(!U||U&&U.startsWith("base64"))return;const j=new Promise((q,J)=>{const Q=new Image;Q.crossOrigin="anonymous",Q.src=`${U}&time=${+new Date().getTime()}`,Q.onload=function(){const tt=W.width,et=W.height,ot=document.createElement("canvas");ot.width=tt,ot.height=et,ot.getContext("2d").drawImage(Q,0,0,tt,et);const rt=ot==null?void 0:ot.toDataURL();W.setAttribute("src",rt),q("\u8F6C\u6362\u6210\u529F")},Q.onerror=J,U!==null&&(Q.src=U)});F.push(j)}),Promise.all(F)}function drawPencil(A,F,W,U,j){A.save(),A.lineWidth=U,A.strokeStyle=j,A.lineTo(F,W),A.stroke(),A.restore()}function initPencil(A,F,W){A.beginPath(),A.moveTo(F,W)}function drawRectangle(A,F,W,U,j,q,J){J.save(),J.strokeStyle=j,J.lineWidth=q,J.beginPath(),J.rect(A,F,W,U),J.stroke(),J.restore()}function drawCircle(A,F,W,U,j,q,J){const Q=F<U?F:U,tt=W<j?W:j,et=F>=U?F:U,ot=W>=j?W:j,rt=(et-Q)*.5,it=(ot-tt)*.5,at=Q+rt,lt=tt+it;if(A.save(),A.beginPath(),A.lineWidth=q,A.strokeStyle=J,typeof A.ellipse=="function")A.ellipse(at,lt,rt,it,0,0,2*Math.PI);else throw"\u4F60\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301ellipse\uFF0C\u65E0\u6CD5\u7ED8\u5236\u692D\u5706";A.stroke(),A.closePath(),A.restore()}function drawLineArrow(A,F,W,U,j,q,J,Q,tt){const et=Math.atan2(W-j,F-U)*180/Math.PI,ot=(et+q)*Math.PI/180,rt=(et-q)*Math.PI/180,it=J*Math.cos(ot),at=J*Math.sin(ot),lt=J*Math.cos(rt),ht=J*Math.sin(rt);A.save(),A.beginPath();let st=F-it,ct=W-at;A.moveTo(st,ct),A.moveTo(F,W),A.lineTo(U,j),st=U+it,ct=j+at,A.moveTo(st,ct),A.lineTo(U,j),st=U+lt,ct=j+ht,A.lineTo(st,ct),A.strokeStyle=tt,A.lineWidth=Q,A.stroke(),A.restore()}var l=Object.defineProperty,n=Math.pow,y$2=(A,F,W)=>F in A?l(A,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):A[F]=W,o=(A,F,W)=>(y$2(A,typeof F!="symbol"?F+"":F,W),W);class DrawArrow{constructor(){o(this,"beginPoint",{x:0,y:0}),o(this,"stopPoint",{x:0,y:0}),o(this,"polygonVertex",[]),o(this,"angle",0),o(this,"arrowInfo",{edgeLen:50,angle:30}),o(this,"size",1)}draw(F,W,U,j,q,J,Q){switch(this.beginPoint.x=W,this.beginPoint.y=U,this.stopPoint.x=j,this.stopPoint.y=q,this.arrowCord(this.beginPoint,this.stopPoint),this.sideCord(),this.drawArrow(F,J),Q){case 2:this.size=1;break;case 5:this.size=1.3;break;case 10:this.size=1.7;break;default:this.size=1;break}}arrowCord(F,W){this.polygonVertex[0]=F.x,this.polygonVertex[1]=F.y,this.polygonVertex[6]=W.x,this.polygonVertex[7]=W.y,this.getRadian(F,W),this.polygonVertex[8]=W.x-this.arrowInfo.edgeLen*Math.cos(Math.PI/180*(this.angle+this.arrowInfo.angle)),this.polygonVertex[9]=W.y-this.arrowInfo.edgeLen*Math.sin(Math.PI/180*(this.angle+this.arrowInfo.angle)),this.polygonVertex[4]=W.x-this.arrowInfo.edgeLen*Math.cos(Math.PI/180*(this.angle-this.arrowInfo.angle)),this.polygonVertex[5]=W.y-this.arrowInfo.edgeLen*Math.sin(Math.PI/180*(this.angle-this.arrowInfo.angle))}getRadian(F,W){this.angle=Math.atan2(W.y-F.y,W.x-F.x)/Math.PI*180,this.setArrowInfo(50*this.size,30*this.size),this.dynArrowSize()}sideCord(){const F={x:0,y:0};F.x=(this.polygonVertex[4]+this.polygonVertex[8])/2,F.y=(this.polygonVertex[5]+this.polygonVertex[9])/2,this.polygonVertex[2]=(this.polygonVertex[4]+F.x)/2,this.polygonVertex[3]=(this.polygonVertex[5]+F.y)/2,this.polygonVertex[10]=(this.polygonVertex[8]+F.x)/2,this.polygonVertex[11]=(this.polygonVertex[9]+F.y)/2}setArrowInfo(F,W){this.arrowInfo.edgeLen=F,this.arrowInfo.angle=W}dynArrowSize(){const F=this.stopPoint.x-this.beginPoint.x,W=this.stopPoint.y-this.beginPoint.y,U=Math.sqrt(n(F,2)+n(W,2));U<50?this.arrowInfo.edgeLen=U/2:U<250?this.arrowInfo.edgeLen/=2:U<500&&(this.arrowInfo.edgeLen=this.arrowInfo.edgeLen*U/500)}drawArrow(F,W){F.fillStyle=W,F.beginPath(),F.moveTo(this.polygonVertex[0],this.polygonVertex[1]),F.lineTo(this.polygonVertex[2],this.polygonVertex[3]),F.lineTo(this.polygonVertex[4],this.polygonVertex[5]),F.lineTo(this.polygonVertex[6],this.polygonVertex[7]),F.lineTo(this.polygonVertex[8],this.polygonVertex[9]),F.lineTo(this.polygonVertex[10],this.polygonVertex[11]),F.closePath(),F.fill()}}const D=(A,F,W)=>{const U=A.width,j=A.data,q=[];return q[0]=j[4*(W*U+F)],q[1]=j[4*(W*U+F)+1],q[2]=j[4*(W*U+F)+2],q[3]=j[4*(W*U+F)+3],q},I$1=(A,F,W,U)=>{const j=A.width,q=A.data;q[4*(W*j+F)]=U[0],q[4*(W*j+F)+1]=U[1],q[4*(W*j+F)+2]=U[2],q[4*(W*j+F)+3]=U[3]};function drawMosaic(A,F,W,U,j){const q=window.devicePixelRatio||1,J=j.getImageData(A*q,F*q,W*q,W*q),Q=J.width,tt=J.height,et=Q/U,ot=tt/U;for(let rt=0;rt<ot;rt++)for(let it=0;it<et;it++){const at=D(J,it*U+Math.floor(Math.random()*U),rt*U+Math.floor(Math.random()*U));for(let lt=0;lt<U;lt++)for(let ht=0;ht<U;ht++)I$1(J,it*U+ht,rt*U+lt,at)}j.putImageData(J,A*q,F*q)}function updateContainerMouseStyle(A,F){switch(F){case"text":A.style.cursor="text";break;default:A.style.cursor="default";break}}function zoomCutOutBoxPosition(A,F,W,U,j,q,J){let Q,tt,et,ot=0;switch(J){case 2:return tt=F-(U+q)>0?U+q:F,ot=nonNegativeData(q-(F-U)),{tempStartX:W,tempStartY:tt,tempWidth:j,tempHeight:ot};case 3:return ot=nonNegativeData(F-U),{tempStartX:W,tempStartY:U,tempWidth:j,tempHeight:ot};case 4:return Q=A-(W+j)>0?W+j:A,et=nonNegativeData(j-(A-W)),{tempStartX:Q,tempStartY:U,tempWidth:et,tempHeight:q};case 5:return et=nonNegativeData(A-W),{tempStartX:W,tempStartY:U,tempWidth:et,tempHeight:q};case 6:return Q=A-(W+j)>0?W+j:A,tt=F-(U+q)>0?U+q:F,et=nonNegativeData(j-(A-W)),ot=nonNegativeData(q-(F-U)),{tempStartX:Q,tempStartY:tt,tempWidth:et,tempHeight:ot};case 7:return et=nonNegativeData(A-W),ot=nonNegativeData(F-U),{tempStartX:W,tempStartY:U,tempWidth:et,tempHeight:ot};case 8:return tt=F-(U+q)>0?U+q:F,et=nonNegativeData(A-W),ot=nonNegativeData(q-(F-U)),{tempStartX:W,tempStartY:tt,tempWidth:et,tempHeight:ot};case 9:return Q=A-(W+j)>0?W+j:A,et=nonNegativeData(j-(A-W)),ot=nonNegativeData(F-U),{tempStartX:Q,tempStartY:U,tempWidth:et,tempHeight:ot}}}function saveBorderArrInfo(A,F){const{startX:W,startY:U,width:j,height:q}=F,J=A/2,Q=[];return Q[0]={x:W+J,y:U+J,width:j-A,height:q-A,index:1,option:1},Q[1]={x:W+J,y:U,width:j-A,height:J,index:2,option:2},Q[2]={x:W-J+j/2,y:U-J,width:A,height:J,index:2,option:2},Q[3]={x:W+J,y:U-J+q,width:j-A,height:J,index:2,option:3},Q[4]={x:W-J+j/2,y:U+q,width:A,height:J,index:2,option:3},Q[5]={x:W,y:U+J,width:J,height:q-A,index:3,option:4},Q[6]={x:W-J,y:U-J+q/2,width:J,height:A,index:3,option:4},Q[7]={x:W-J+j,y:U+J,width:J,height:q-A,index:3,option:5},Q[8]={x:W+j,y:U-J+q/2,width:J,height:A,index:3,option:5},Q[9]={x:W-J,y:U-J,width:A,height:A,index:4,option:6},Q[10]={x:W-J+j,y:U-J+q,width:A,height:A,index:4,option:7},Q[11]={x:W-J+j,y:U-J,width:A,height:A,index:5,option:8},Q[12]={x:W-J,y:U-J+q,width:A,height:A,index:5,option:9},Q}function isPC(){const A=navigator.userAgent,F=["Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"];let W=!0;for(let U=0;U<F.length;U++)if(A.indexOf(F[U])>0){W=!1;break}return W}function isTouchDevice(){const A="maxTouchPoints"in navigator&&navigator.maxTouchPoints>0,F="msMaxTouchPoints"in navigator&&navigator.msMaxTouchPoints>0,W="ontouchstart"in window,U=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches;return A||F||W||U}var O$1=Object.defineProperty,T=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,w$1=(A,F,W)=>F in A?O$1(A,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):A[F]=W,y$1=(A,F)=>{for(var W in F||(F={}))B.call(F,W)&&w$1(A,W,F[W]);if(T)for(var W of T(F))k.call(F,W)&&w$1(A,W,F[W]);return A},b=(A,F,W)=>new Promise((U,j)=>{var q=tt=>{try{Q(W.next(tt))}catch(et){j(et)}},J=tt=>{try{Q(W.throw(tt))}catch(et){j(et)}},Q=tt=>tt.done?U(tt.value):Promise.resolve(tt.value).then(q,J);Q((W=W.apply(A,F)).next())});const Z=(A,F,W)=>{A.addEventListener("contextmenu",U=>{if(U.preventDefault(),W){W();return}F.destroyDOM(),F.setInitStatus(!0)})},_=(A,F,W,U,j,q)=>{const J=document.createElement("canvas");J.width=A,J.height=F;const Q=getCanvas2dCtx(J,A,F);if(Q){Q.drawImage(j,0,0);const tt=0,et=F-U,ot=W,rt=F-et;return Q.getImageData(tt*q,et*q,ot*q,rt*q)}return null},I=(A,F,W,U)=>{A.addEventListener("keydown",j=>{if(F!=null&&((j.metaKey||j.ctrlKey)&&j.code==="Enter"||j.code==="Escape")){W.setTextEditState(!0);const q=A.innerText;if(!q||q===""){W.setTextStatus(!1);return}drawText(q,U.mouseX,U.mouseY,W.getSelectedColor(),W.getFontSize(),F),A.innerHTML="",W.setTextStatus(!1),addHistory()}})},E=(A,F,W,U,j)=>{if(W.toolController==null||W.screenShotContainer==null)return;const q={code:0,data:null,msg:""},J=calculateToolLocation(U.drawGraphPosition,W.toolController.offsetWidth,W.screenShotContainer.width/A,U.placement,U.position),Q=W.screenShotContainer.height/A;if(J.mouseY>Q-64){if(J.mouseY-=U.drawGraphPosition.height+64,J.mouseY<0){const tt=parseInt(W.screenShotContainer.style.height);J.mouseY=tt-U.fullScreenDiffHeight}F.setToolPositionStatus(!0),F.setCutBoxSizeStatus(!1)}if(U.getFullScreenStatus){const tt=parseInt(W.screenShotContainer.style.height),et=(U.drawGraphPosition.width/A-W.toolController.offsetWidth)/2;J.mouseY=tt-U.fullScreenDiffHeight,J.mouseX=et}F.setToolInfo(J.mouseX+U.position.left,J.mouseY+U.position.top),F.setCutBoxSizePosition(U.drawGraphPosition.startX,U.drawGraphPosition.startY-35),F.setCutBoxSize(U.drawGraphPosition.width,U.drawGraphPosition.height),q.code=1,q.data=!1,j(q)},V=(A,F,W)=>{const U=new Image,j={code:0,data:null,msg:""};U.src=A,U.width=F.width,U.height=F.height,U.crossOrigin="Anonymous",U.onload=()=>{var q;(q=F.getContext("2d"))==null||q.drawImage(U,0,0,F.width,F.height),j.code=1,W(j)}},ee=(A,F,W,U,j)=>{F.setScreenShotInfo(U.width,U.height),F.setScreenShotPosition(j.left,j.top),A.width=U.width,A.height=U.height,W.canvasWidth!==0&&W.canvasHeight!==0&&(F.setScreenShotInfo(W.canvasWidth,W.canvasHeight),A.width=W.canvasWidth,A.height=W.canvasHeight)},te=(A,F,W,U)=>new Promise((j,q)=>{G__default(F||document.body,{onclone:W?drawCrossImg:void 0,proxy:U}).then(J=>{j({code:0,data:{canvas:J}})}).catch(J=>{const Q={code:-1,msg:J};A!=null&&A(Q),q(Q)})}),oe=(A,F,W,U)=>{let j=F==null?void 0:F.width,q=F==null?void 0:F.height;A.canvasWidth!==0&&A.canvasHeight!==0&&(j=A.canvasWidth,q=A.canvasHeight);let J=j,Q=q;return W&&(J=j*U,Q=q*U),{containerWidth:j,containerHeight:q,imgContainerWidth:J,imgContainerHeight:Q}},se=(A,F,W,U,j,q,J,Q)=>{let tt=A,et=U*A/W;et>F&&(tt=A*F/et,et=F),tt=j.w>0?j.w:tt,et=j.h>0?j.h:et,q==null||q.drawImage(J,j.x,j.y,tt,et);const ot=F-et;if(Q.state&&ot>0&&Q.fillState){q.beginPath();let rt=A,it=ot;Q!=null&&Q.fillWidth&&Q.fillWidth>0&&(rt=Q.fillWidth),Q!=null&&Q.fillHeight&&Q.fillHeight>0&&(it=Q.fillHeight),q.rect(0,et,rt,it),q.fillStyle=Q.color||"",q.fill()}},H=(A,F,W)=>{let U=A.width*F,j=A.height*F,q=!0,J={};return W&&(U=window.screen.width*F,j=window.screen.height*F,q=!1,J={displaySurface:"window"}),{audio:!1,video:y$1({width:U,height:j},J),preferCurrentTab:q}},re=(A,F,W,U,j,q,J,Q)=>{if(A.getToolClickStatus()&&(F.startX=q,F.startY=J),A.getToolName()=="brush"&&Q.screenShotCanvas&&initPencil(Q.screenShotCanvas,q,J),A.getToolName()=="text"&&Q.textInputController&&Q.screenShotContainer&&Q.screenShotCanvas){if(!W)return;A.setTextStatus(!0),U.mouseX!=0&&U.mouseY!=0&&U.mouseX!=q&&U.mouseY!=J&&(drawText(Q.textInputController.innerText,U.mouseX,U.mouseY,A.getSelectedColor(),A.getFontSize(),Q.screenShotCanvas),Q.textInputController.innerText!==""&&A.setTextStatus(!1),Q.textInputController.innerHTML="",addHistory());const tt=q+j.left;Q.textInputController.style.left=tt+"px",Q.textInputController.style.fontSize=A.getFontSize()+"px",Q.textInputController.style.fontFamily="none",Q.textInputController.style.color=A.getSelectedColor(),setTimeout(()=>{if(Q.textInputController){const et=Q.textInputController.offsetHeight,ot=J-Math.floor(et/2)+j.top;Q.textInputController.style.top=ot+"px",Q.textInputController.focus(),U.mouseX=q,U.mouseY=J,A.setTextInfo({positionX:q,positionY:J,color:A.getSelectedColor(),size:A.getFontSize()})}})}},ne=(A,F,W,U,j,q,J,Q,tt,et,ot,rt,it)=>{const at={code:0,data:null,msg:""};switch(tt.getToolName()){case"square":drawRectangle(F,W,U,j,tt.getSelectedColor(),tt.getPenSize(),ot.screenShotCanvas);break;case"round":drawCircle(ot.screenShotCanvas,q,J,F,W,tt.getPenSize(),tt.getSelectedColor());break;case"right-top":if(et){drawLineArrow(ot.screenShotCanvas,F,W,q,J,30,10,tt.getPenSize(),tt.getSelectedColor());break}new DrawArrow().draw(ot.screenShotCanvas,F,W,q,J,tt.getSelectedColor(),tt.getPenSize());break;case"brush":drawPencil(ot.screenShotCanvas,q,J,tt.getPenSize(),tt.getSelectedColor());break;case"mosaicPen":A||(rt.showLastHistory(),at.code=1,at.data=!0,at.msg="\u9700\u8981\u66F4\u65B0\u7EC4\u4EF6\u72B6\u6001",it(at)),drawMosaic(q-10,J-10,tt.getMosaicPenSize(),Q,ot.screenShotCanvas);break}return at},ue=(A,F,W,U,j,q,J,Q,tt,et,ot,rt)=>{const it={code:0,msg:"",data:null};if(et.screenShotContainer==null)return;const{moveStartX:at,moveStartY:lt}=ot.movePosition;if(ot.cutOutBoxBorderArr.length>0&&!Q.getDraggingTrim()){let ht=!1;J.beginPath();for(let st=0;st<ot.cutOutBoxBorderArr.length;st++)if(J.rect(ot.cutOutBoxBorderArr[st].x,ot.cutOutBoxBorderArr[st].y,ot.cutOutBoxBorderArr[st].width,ot.cutOutBoxBorderArr[st].height),J.isPointInPath(A*tt,F*tt)){switch(ot.cutOutBoxBorderArr[st].index){case 1:Q.getToolClickStatus()?updateContainerMouseStyle(et.screenShotContainer,Q.getActiveToolName()):et.screenShotContainer.style.cursor="move";break;case 2:if(Q.getToolClickStatus())break;et.screenShotContainer.style.cursor="ns-resize";break;case 3:if(Q.getToolClickStatus())break;et.screenShotContainer.style.cursor="ew-resize";break;case 4:if(Q.getToolClickStatus())break;et.screenShotContainer.style.cursor="nwse-resize";break;case 5:if(Q.getToolClickStatus())break;et.screenShotContainer.style.cursor="nesw-resize";break}it.code=1,it.data=ot.cutOutBoxBorderArr[st].option,it.msg="\u4FEE\u6539borderOption\u7684\u503C",rt(it),ht=!0;break}it.code=2,it.data=ht,it.msg="\u4FEE\u6539mouseInsideCropBox\u7684\u503C",rt(it),J.closePath(),ht||(et.screenShotContainer.style.cursor="default",it.code=3,it.data=null,it.msg="\u91CD\u7F6EborderOption\u7684\u503C",rt(it))}if(Q.getDraggingTrim())if(ot.borderOption===1){let ht=fixedData(A-(at-W),j,et.screenShotContainer.width),st=fixedData(F-(lt-U),q,et.screenShotContainer.height);const ct=et.screenShotContainer.width/tt,nt=et.screenShotContainer.height/tt,ut=ht+j,dt=st+q;ut>ct&&(ht=ct-j),dt>nt&&(st=nt-q),Object.assign(ot.tempGraphPosition,drawCutOutBox(ht,st,j,q,J,Q.getBorderSize(),et.screenShotContainer,et.screenShotImageController))}else{const{tempStartX:ht,tempStartY:st,tempWidth:ct,tempHeight:nt}=zoomCutOutBoxPosition(A,F,W,U,j,q,ot.borderOption);Object.assign(ot.tempGraphPosition,drawCutOutBox(ht,st,ct,nt,J,Q.getBorderSize(),et.screenShotContainer,et.screenShotImageController))}},le=(A,F)=>{F.screenShotContainer==null||F.toolController==null||F.textInputController==null||F.optionIcoController==null||F.optionController==null||F.cutBoxSizeContainer==null||A<=0||(F.screenShotContainer.style.zIndex=`${A}`,F.toolController.style.zIndex=`${A+1}`,F.textInputController.style.zIndex=`${A+1}`,F.optionIcoController.style.zIndex=`${A+1}`,F.optionController.style.zIndex=`${A+1}`,F.cutBoxSizeContainer.style.zIndex=`${A+1}`)},ie=(A,F,W,U,j,q)=>{const J=F.x,Q=F.y,tt=F.w,et=F.h;U.screenShotContainer!=null&&(j.drawGraphPosition.startX=J,j.drawGraphPosition.startY=Q,j.drawGraphPosition.width=tt,j.drawGraphPosition.height=et,W.setCutOutBoxPosition(J,Q,tt,et),drawCutOutBox(J,Q,tt,et,U.screenShotCanvas,W.getBorderSize(),U.screenShotContainer,U.screenShotImageController),j.cutOutBoxBorderArr.length=0,j.cutOutBoxBorderArr.push(...saveBorderArrInfo(W.getBorderSize(),j.drawGraphPosition)),U.screenShotContainer.style.cursor="move",W.setToolStatus(!0),W.setCutBoxSizeStatus(!0),U.toolController!=null&&E(A,W,{toolController:U.toolController,screenShotContainer:U.screenShotContainer},{drawGraphPosition:j.drawGraphPosition,placement:j.placement,position:j.position,fullScreenDiffHeight:j.fullScreenDiffHeight,getFullScreenStatus:j.getFullScreenStatus},q.toolBarCallerCallback))},me=(A,F)=>{isPC()&&(A==null||A.addEventListener("mousedown",F.mouseDownEvent),A==null||A.addEventListener("mousemove",F.mouseMoveEvent),A==null||A.addEventListener("mouseup",F.mouseUpEvent)),isTouchDevice()&&(A==null||A.addEventListener("touchstart",F.mouseDownEvent,!1),A==null||A.addEventListener("touchmove",F.mouseMoveEvent,!1),A==null||A.addEventListener("touchend",F.mouseUpEvent,!1))},de=(A,F,W,U,j,q)=>{if(A instanceof MediaStream)j.videoController.srcObject=A,q.loadScreenFlowData(W);else throw F!=null&&F({code:-1,msg:"\u89C6\u9891\u6D41\u63A5\u5165\u5931\u8D25"}),U.destroyDOM(),"\u89C6\u9891\u6D41\u63A5\u5165\u5931\u8D25";return A},he=(A,F,W,U,j)=>b(void 0,null,function*(){let q=null;try{q=yield navigator.mediaDevices.getDisplayMedia(H(W.screenShotImageController,U.dpr,U.wrcWindowMode)),W.videoController.srcObject=q,j({code:1,data:q,msg:"\u66F4\u65B0captureStream\u6570\u636E"})}catch(J){const Q="\u6D4F\u89C8\u5668\u4E0D\u652F\u6301webrtc\u6216\u8005\u7528\u6237\u672A\u6388\u6743";throw A!=null&&A({code:-1,msg:Q,errorInfo:J}),F.destroyDOM(),`${Q}( ${J} )`}return q}),pe=A=>{const F=A.srcObject;F&&"getTracks"in F&&(F.getTracks().forEach(W=>W.stop()),A.srcObject=null)},y=(A,F,W,U,j)=>{if(!isPC()&&A instanceof TouchEvent&&W.screenShotCanvas&&ue(A.touches[0].pageX,A.touches[0].pageY,U.tempGraphPosition.startX,U.tempGraphPosition.startY,U.tempGraphPosition.width,U.tempGraphPosition.height,W.screenShotCanvas,F,U.dpr,{screenShotContainer:W.screenShotContainer,screenShotImageController:W.screenShotImageController},{movePosition:U.movePosition,tempGraphPosition:U.tempGraphPosition,cutOutBoxBorderArr:U.cutOutBoxBorderArr,borderOption:U.borderOption},j.croppingBoxCallerCallback),F.getToolName()=="undo")return;F.setDragging(!0),F.setToolPositionStatus(!1);const q=nonNegativeData(A instanceof MouseEvent?A.offsetX:A.touches[0].pageX),J=nonNegativeData(A instanceof MouseEvent?A.offsetY:A.touches[0].pageY);re(F,U.drawGraphPosition,U.mouseInsideCropBox,U.textInputPosition,U.position,q,J,{textInputController:W.textInputController,screenShotContainer:W.screenShotContainer,screenShotCanvas:W.screenShotCanvas}),U.borderOption?(F.setDraggingTrim(!0),U.movePosition.moveStartX=q,U.movePosition.moveStartY=J):(j.saveDrawGraphCallerCallback({code:1,msg:"\u4FDD\u5B58\u5F53\u524D\u88C1\u526A\u6846\u7684\u5750\u6807",data:{drawGraphPrevX:U.drawGraphPosition.startX,drawGraphPrevY:U.drawGraphPosition.startY}}),U.drawGraphPosition.startX=q,U.drawGraphPosition.startY=J)},O=(A,F,W,U)=>{if(!A.getToolClickStatus()&&!F.dragFlag&&!F.clickCutFullScreen){F.drawGraphPosition.startX=F.drawGraphPrevX,F.drawGraphPosition.startY=F.drawGraphPrevY;return}const j=A.getCutOutBoxPosition();if(j.width===0&&j.height===0&&j.startX===0&&j.startY===0&&!F.dragFlag&&F.clickCutFullScreen){const q=A.getBorderSize();U.updateTempGraphPositionCallback({code:1,msg:"\u66F4\u65B0getFullScreenStatus\u4E0EtempGraphPosition",data:{getFullScreenStatus:!0,tempGraphPosition:drawCutOutBox(0,0,W.screenShotContainer.width-q/2,W.screenShotContainer.height-q/2,W.screenShotCanvas,q,W.screenShotContainer,W.screenShotImageController)}})}if(!(W.screenShotContainer==null||W.screenShotCanvas==null)){if(A.getToolClickStatus()&&F.drawStatus){addHistory();return}else if(A.getToolClickStatus()&&!F.drawStatus)return;if(Object.assign(F.drawGraphPosition,F.tempGraphPosition),!A.getToolClickStatus()){const{startX:q,startY:J,width:Q,height:tt}=F.drawGraphPosition;A.setCutOutBoxPosition(q,J,Q,tt)}Object.assign(F.cutOutBoxBorderArr,saveBorderArrInfo(A.getBorderSize(),F.drawGraphPosition)),(W.screenShotContainer!=null&&F.dragFlag||F.clickCutFullScreen)&&(W.screenShotContainer.style.cursor="move",A.setToolStatus(!0),A.setCutBoxSizeStatus(!0),U.updateDrawStatusCallback({code:1,msg:"\u66F4\u65B0dragFlag",data:!1}),W.toolController!=null&&E(F.dpr,A,{toolController:W.toolController,screenShotContainer:W.screenShotContainer},{drawGraphPosition:F.drawGraphPosition,placement:F.placement,position:F.position,fullScreenDiffHeight:F.fullScreenDiffHeight,getFullScreenStatus:F.getFullScreenStatus},U.toolBarCallerCallback))}};var f=Object.defineProperty,w=(A,F,W)=>F in A?f(A,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):A[F]=W,e=(A,F,W)=>(w(A,typeof F!="symbol"?F+"":F,W),W),C=(A,F,W)=>new Promise((U,j)=>{var q=tt=>{try{Q(W.next(tt))}catch(et){j(et)}},J=tt=>{try{Q(W.throw(tt))}catch(et){j(et)}},Q=tt=>tt.done?U(tt.value):Promise.resolve(tt.value).then(q,J);Q((W=W.apply(A,F)).next())});class K{constructor(F){e(this,"version","1.1.0"),e(this,"buildTime","1744962529947"),e(this,"data"),e(this,"videoController"),e(this,"screenShotContainer"),e(this,"screenShotDom",null),e(this,"toolController"),e(this,"screenShotImageController"),e(this,"screenShotCanvas"),e(this,"textInputController"),e(this,"optionController"),e(this,"optionIcoController"),e(this,"cutBoxSizeContainer"),e(this,"plugInParameters"),e(this,"webrtcReplyTime",500),e(this,"keyboardEventHandle",null),e(this,"drawGraphPosition",{startX:0,startY:0,width:0,height:0}),e(this,"tempGraphPosition",{startX:0,startY:0,width:0,height:0}),e(this,"wrcImgPosition",{x:0,y:0,w:0,h:0}),e(this,"hiddenScrollBar",{color:"#000000",fillState:!1,state:!1,fillWidth:0,fillHeight:0}),e(this,"wrcWindowMode",!1),e(this,"cutOutBoxBorderArr",[]),e(this,"borderOption",null),e(this,"movePosition",{moveStartX:0,moveStartY:0}),e(this,"dragFlag",!1),e(this,"clickCutFullScreen",!1),e(this,"getFullScreenStatus",!1),e(this,"drawGraphPrevX",0),e(this,"drawGraphPrevY",0),e(this,"degreeOfBlur",5),e(this,"dpr",window.devicePixelRatio||1),e(this,"fullScreenDiffHeight",60),e(this,"position",{left:0,top:0}),e(this,"imgSrc",null),e(this,"loadCrossImg",!1),e(this,"mouseInsideCropBox",!1),e(this,"proxyUrl"),e(this,"drawStatus",!1),e(this,"captureStream",null),e(this,"cropBoxInfo",null),e(this,"textInputPosition",{mouseX:0,mouseY:0}),e(this,"placement","right"),e(this,"customRightClickEvent",{state:!1}),e(this,"wrcScreenShot",(Q,tt)=>{document.body.classList.add("no-cursor");const et=ot=>{ot.code===1&&ot.data instanceof MediaStream&&(this.captureStream=ot.data)};he(Q,this.data,{screenShotImageController:this.screenShotImageController,videoController:this.videoController},{dpr:this.dpr,wrcWindowMode:this.wrcWindowMode},et).then(()=>{this.loadScreenFlowData(tt)})}),e(this,"mouseDownEvent",Q=>{if(this.drawStatus=!1,this.data.setColorPanelStatus(!0),this.data.setTextSizeOptionStatus(!1),Q instanceof MouseEvent&&Q.button!=0)return;const tt=et=>{et.code===1&&et.data!=null&&(this.drawGraphPrevX=et.data.startX,this.drawGraphPrevY=et.data.startY)};y(Q,this.data,{screenShotCanvas:this.screenShotCanvas,screenShotContainer:this.screenShotContainer,screenShotImageController:this.screenShotImageController,textInputController:this.textInputController},{tempGraphPosition:this.tempGraphPosition,dpr:this.dpr,movePosition:this.movePosition,cutOutBoxBorderArr:this.cutOutBoxBorderArr,borderOption:this.borderOption,drawGraphPosition:this.drawGraphPosition,mouseInsideCropBox:this.mouseInsideCropBox,textInputPosition:this.textInputPosition,position:this.position},{croppingBoxCallerCallback:this.croppingBoxCallerCallback,saveDrawGraphCallerCallback:tt})}),e(this,"mouseMoveEvent",Q=>{if(this.screenShotCanvas==null||this.screenShotContainer==null||this.data.getToolName()=="undo")return;Q.preventDefault(),!this.data.getToolClickStatus()&&this.data.getDragging()&&(this.dragFlag=!0,this.data.setToolStatus(!1),this.data.setCutBoxSizeStatus(!1));const{startX:tt,startY:et,width:ot,height:rt}=this.drawGraphPosition,it=nonNegativeData(Q instanceof MouseEvent?Q.offsetX:Q.touches[0].pageX),at=nonNegativeData(Q instanceof MouseEvent?Q.offsetY:Q.touches[0].pageY),lt=it-tt,ht=at-et;if(this.data.getToolClickStatus()&&this.data.getDragging()){const st=this.data.getCutOutBoxPosition();if(!getDrawBoundaryStatus(tt,et,st)||!getDrawBoundaryStatus(it,at,st))return;this.data.getToolName()!="mosaicPen"&&(this.showLastHistory(),this.drawStatus=!0);const ct=nt=>{nt.code===1&&nt.data!=null&&typeof nt.data=="boolean"&&(this.drawStatus=nt.data)};ne(this.drawStatus,tt,et,lt,ht,it,at,this.degreeOfBlur,this.data,this.plugInParameters.getRatioArrow(),{screenShotCanvas:this