function CanvasDesigner(){function a(a){return a.data&&a.data.uid===b.uid?!a.data.sdp?!a.data.canvasDesignerSyncData?!a.data.dataURL?void 0:void f(a.data.dataURL):(b.pointsLength=a.data.canvasDesignerSyncData.points.length,void e(a.data.canvasDesignerSyncData)):void webrtcHandler.createAnswer(a.data,function(a){return a.sdp?void b.postMessage(a):void g(a.stream)}):void 0}var b=this;b.iframe=null;var c={line:!0,arrow:!0,pencil:!0,dragSingle:!0,dragMultiple:!0,eraser:!0,rectangle:!0,arc:!0,bezier:!0,quadratic:!0,text:!0,image:!0,pdf:!0,marker:!0,zoom:!0,lineWidth:!0,colorsPicker:!0,extraOptions:!0,code:!0};b.icons={line:null,arrow:null,pencil:null,dragSingle:null,dragMultiple:null,eraser:null,rectangle:null,arc:null,bezier:null,quadratic:null,text:null,image:null,pdf:null,pdf_next:null,pdf_prev:null,pdf_close:null,marker:null,zoom:null,lineWidth:null,colorsPicker:null,extraOptions:null,code:null};var d="pencil",e=function(){},f=function(){},g=function(){};b.uid=function(){if(window.crypto&&window.crypto.getRandomValues&&-1===navigator.userAgent.indexOf("Safari")){for(var b=window.crypto.getRandomValues(new Uint32Array(3)),a="",c=0,d=b.length;c<d;c++)a+=b[c].toString(36);return a}return(Math.random()*new Date().getTime()).toString(36).replace(/\./g,"")}(),b.appendTo=function(e,f){f=f||function(){},b.iframe=document.createElement("iframe"),b.iframe.onload=function(){f(),f=null},b.iframe.src=b.widgetHtmlURL+"?widgetJsURL="+b.widgetJsURL+"&tools="+JSON.stringify(c)+"&selectedIcon="+d+"&icons="+JSON.stringify(b.icons),b.iframe.style.width="100%",b.iframe.style.height="100%",b.iframe.style.border=0,window.removeEventListener("message",a),window.addEventListener("message",a,!1),e.appendChild(b.iframe)},b.destroy=function(){b.iframe&&(b.iframe.parentNode.removeChild(b.iframe),b.iframe=null),window.removeEventListener("message",a)},b.addSyncListener=function(a){e=a},b.syncData=function(a){b.iframe&&b.postMessage({canvasDesignerSyncData:a})},b.setTools=function(a){c=a},b.setSelected=function(a){"undefined"!=typeof c[a]&&(d=a)},b.toDataURL=function(a,c){f=c;b.iframe&&b.postMessage({genDataURL:!0,format:a})},b.sync=function(){b.iframe&&b.postMessage({syncPoints:!0})},b.pointsLength=0,b.undo=function(a){return b.iframe?"string"==typeof a&&c[a]?void b.postMessage({undo:!0,tool:a}):void b.postMessage({undo:!0,index:a||b.pointsLength-1||-1}):void 0},b.postMessage=function(a){b.iframe&&(a.uid=b.uid,b.iframe.contentWindow.postMessage(a,"*"))},b.captureStream=function(a){b.iframe&&(g=a,b.postMessage({captureStream:!0}))},b.clearCanvas=function(){b.iframe&&b.postMessage({clearCanvas:!0})},b.renderStream=function(){b.iframe&&b.postMessage({renderStream:!0})},b.widgetHtmlURL="widget.html",b.widgetJsURL="widget.min.js"}