").css({position:"absolute",top:45,right:10,width:180,bottom:45,background:"#fff",overflow:"auto"}).insertAfter("#lib_framewrap"),x=n("
").appendTo("#imgbrowse").on("click touchend",(function(){n.each(h,(function(e){var t=this[0],r=this[1];"svg"===t?l.importSvgString(r):b(r),l.moveSelectedElements(20*e,20*e,!1)})),v.empty(),h=[],n("#imgbrowse_holder").hide()})).css({position:"absolute",bottom:10,right:-10})),v.toggle(e),x.toggle(e)},_=function _onMessage3(){return(_=_asyncToGenerator(regeneratorRuntime.mark((function _callee(e){var t,r,s,c,w,_,y,k,S,T,A,E,B,G,I,L,R;return regeneratorRuntime.wrap((function _callee$(j){for(;;)switch(j.prev=j.next){case 0:if(t=e.origin,(r=e.data)&&["string","object"].includes(_typeof(r))){j.next=3;break}return j.abrupt("return");case 3:if(j.prev=3,"imagelib"===(r="object"===_typeof(r)?r:JSON.parse(r)).namespace){j.next=7;break}return j.abrupt("return");case 7:if(u.includes("*")||u.includes(t)){j.next=10;break}return console.log("Origin ".concat(t," not whitelisted for posting to ").concat(window.origin)),j.abrupt("return");case 10:if(_="href"in r,(w="name"in r)||!f){j.next=15;break}return f=!1,j.abrupt("return");case 15:_&&(s=r.href,r=r.data),n("#dialog_box").hide(),c=w?"meta":r.charAt(0),j.next=28;break;case 20:if(j.prev=20,j.t0=j.catch(3),"string"!=typeof r){j.next=28;break}if("{"===(y=r.charAt(0))||!f){j.next=27;break}return f=!1,j.abrupt("return");case 27:"|"===y&&(k=r.indexOf("|",1),s=r.substr(1,k-1),r=r.substr(k+1),c=r.charAt(0));case 28:j.t1=c,j.next="meta"===j.t1?31:"<"===j.t1?47:"d"===j.t1?49:60;break;case 31:if(f=!1,m[(T=r).id]=T,B=T.name||"file",G=p.notification.retrieving.replace("%s",B),"m"===g){j.next=43;break}return j.next=39,n.process_cancel(G);case 39:f=!0,n("#dialog_box").hide(),j.next=46;break;case 43:S=n("
").text(G).data("id",T.id),v.append(S),T.entry=S;case 46:return j.abrupt("return");case 47:return A=!0,j.abrupt("break",62);case 49:if(!r.startsWith("data:image/svg+xml")){j.next=57;break}return"data:image/svg+xml;base64,",I=r.substring("data:image/svg+xml;base64,".length),r=i(I),A=!0,j.abrupt("break",62);case 57:if(!r.startsWith("data:image/")){j.next=60;break}return E=!0,j.abrupt("break",62);case 60:return"m"!==g?d():m[s].entry.remove(),j.abrupt("return");case 62:j.t2=g,j.next="s"===j.t2?65:"m"===j.t2?68:"o"===j.t2?72:83;break;case 65:return A?l.importSvgString(r):E&&b(r),d(),j.abrupt("break",83);case 68:return h.push([A?"svg":"img",r]),T=m[s],A?(T&&T.name?L=T.name:(R=(new DOMParser).parseFromString(o(r),"text/xml").documentElement,L=n(R).children("title").first().text()||"(SVG #"+r.length+")"),T?v.children().each((function(){n(this).data("id")===s&&(T.preview_url?n(this).html(n("
").append(n("").attr("src",T.preview_url),L)):n(this).text(L),x.removeAttr("disabled"))})):(v.append(n("").text(L)),x.removeAttr("disabled"))):(T&&T.preview_url?(L=T.name||"",S=n("
").append(n("").attr("src",T.preview_url),L)):S=n("").attr("src",r),T?v.children().each((function(){n(this).data("id")===s&&(n(this).html(S),x.removeAttr("disabled"))})):(v.append(n("").append(S)),x.removeAttr("disabled"))),j.abrupt("break",83);case 72:if(A){j.next=74;break}return j.abrupt("break",83);case 74:return d(),j.next=77,a.openPrep();case 77:if(j.sent){j.next=80;break}return j.abrupt("return");case 80:return l.clear(),l.setSvgString(r),j.abrupt("break",83);case 83:case"end":return j.stop()}}),_callee,null,[[3,20]])})))).apply(this,arguments)},w=function _onMessage2(e){return _.apply(this,arguments)},b=function _importImage(e){var t=l.addSVGElementFromJson({element:"image",attr:{x:0,y:0,width:0,height:0,id:l.getNextId(),style:"pointer-events:inherit"}});l.clearSelection(),l.addToSelection([t]),l.setImageURL(e)},d=function _closeBrowser(){n("#imgbrowse_holder").hide(),document.activeElement.blur()},n=e.$,i=e.decode64,o=e.dropXMLInternalSubset,a=r,T.next=10,t.import("./locale/".concat(a.curPrefs.lang,".js"));case 10:return s=T.sent,c=s.default,p=a.uiStrings,l=a.canvas,u=c.imgLibs.map((function(e){var t=e.url;try{return new URL(t).origin}catch(e){return location.origin}})),m={},g="s",h=[],f=!1,window.addEventListener("message",w,!0),S=[{id:"tool_imagelib",type:"app_menu",icon:"imagelib.png",position:4,events:{mouseup:k}}],T.abrupt("return",{svgicons:"ext-imagelib.xml",buttons:c.buttons.map((function(e,t){return Object.assign(S[t],e)})),callback:function callback(){n("