1 line
6.4 KiB
JavaScript
1 line
6.4 KiB
JavaScript
"use strict";(self.webpackChunkExcalidraw=self.webpackChunkExcalidraw||[]).push([[9],{8527:function(e,t,r){r.r(t),r.d(t,{decodePngMetadata:function(){return E},decodeSvgMetadata:function(){return L},encodePngMetadata:function(){return m},encodeSvgMetadata:function(){return A},getTEXtChunk:function(){return g}});var n=r(8950),a=r(7945),c=r.n(a),u=r(2983),o=r.n(u),s=r(1194),i=r(3434),f=r.n(i),p=r(2744),d=function(e){return new Promise((function(t,r){var n="string"==typeof e?new Blob([(new TextEncoder).encode(e)]):new Blob([e]),a=new FileReader;a.onload=function(e){if(!e.target||"string"!=typeof e.target.result)return r(new Error("couldn't convert to byte string"));t(e.target.result)},a.readAsBinaryString(n)}))},l=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0,a=e.length;n<a;n++)r[n]=e.charCodeAt(n);return t},x=function(e){return new TextDecoder("utf-8").decode(l(e))},w=function(){var e=(0,n.Z)(c().mark((function e(t){var r=arguments;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r.length>1&&void 0!==r[1]&&r[1])){e.next=5;break}e.t0=btoa(t),e.next=10;break;case 5:return e.t1=btoa,e.next=8,d(t);case 8:e.t2=e.sent,e.t0=(0,e.t1)(e.t2);case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),v=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n=arguments;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]&&n[1],e.abrupt("return",r?atob(t):x(atob(t)));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),b=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.text,!1===t.compress){e.next=11;break}return e.prev=2,e.next=5,d((0,p.deflate)(r));case 5:n=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),console.error("encode: cannot deflate",e.t0);case 11:if(e.t1=!!n,e.t2=n,e.t2){e.next=17;break}return e.next=16,d(r);case 16:e.t2=e.sent;case 17:return e.t3=e.t2,e.abrupt("return",{version:"1",encoding:"bstring",compressed:e.t1,encoded:e.t3});case 19:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}(),h=function(){var e=(0,n.Z)(c().mark((function e(t){var r;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.encoding,e.next="bstring"===e.t0?3:12;break;case 3:if(!t.compressed){e.next=7;break}e.t1=t.encoded,e.next=10;break;case 7:return e.next=9,x(t.encoded);case 9:e.t1=e.sent;case 10:return r=e.t1,e.abrupt("break",13);case 12:throw new Error('decode: unknown encoding "'.concat(t.encoding,'"'));case 13:if(!t.compressed){e.next=15;break}return e.abrupt("return",(0,p.inflate)(new Uint8Array(l(r)),{to:"string"}));case 15:return e.abrupt("return",r);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),y=r(8288),k=function(e){return"arrayBuffer"in e?e.arrayBuffer():new Promise((function(t,r){var n=new FileReader;n.onload=function(e){var n;if(null===(n=e.target)||void 0===n||!n.result)return r(new Error("couldn't convert blob to ArrayBuffer"));t(e.target.result)},n.readAsArrayBuffer(e)}))},g=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=o(),e.t1=Uint8Array,e.next=4,k(t);case 4:if(e.t2=e.sent,e.t3=new e.t1(e.t2),r=(0,e.t0)(e.t3),!(n=r.find((function(e){return"tEXt"===e.name})))){e.next=10;break}return e.abrupt("return",s.decode(n.data));case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),m=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n,a,u;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blob,n=t.metadata,e.t0=o(),e.t1=Uint8Array,e.next=5,k(r);case 5:return e.t2=e.sent,e.t3=new e.t1(e.t2),a=(0,e.t0)(e.t3),e.t4=s,e.t5=y.LO.excalidraw,e.t6=JSON,e.next=13,b({text:n,compress:!0});case 13:return e.t7=e.sent,e.t8=e.t6.stringify.call(e.t6,e.t7),u=e.t4.encode.call(e.t4,e.t5,e.t8),a.splice(-1,0,u),e.abrupt("return",new Blob([f()(a)],{type:"image/png"}));case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),E=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g(t);case 2:if((null==(r=e.sent)?void 0:r.keyword)!==y.LO.excalidraw){e.next=19;break}if(e.prev=4,"encoded"in(n=JSON.parse(r.text))){e.next=10;break}if(!("type"in n)||n.type!==y.r8.excalidraw){e.next=9;break}return e.abrupt("return",r.text);case 9:throw new Error("FAILED");case 10:return e.next=12,h(n);case 12:return e.abrupt("return",e.sent);case 15:throw e.prev=15,e.t0=e.catch(4),console.error(e.t0),new Error("FAILED");case 19:throw new Error("INVALID");case 20:case"end":return e.stop()}}),e,null,[[4,15]])})));return function(t){return e.apply(this,arguments)}}(),A=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n,a;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.text,e.t0=w,e.t1=JSON,e.next=5,b({text:r});case 5:return e.t2=e.sent,e.t3=e.t1.stringify.call(e.t1,e.t2),e.next=9,(0,e.t0)(e.t3,!0);case 9:return n=e.sent,a="",a+="\x3c!-- payload-type:".concat(y.LO.excalidraw," --\x3e"),a+="\x3c!-- payload-version:2 --\x3e",a+="\x3c!-- payload-start --\x3e",a+=n,a+="\x3c!-- payload-end --\x3e",e.abrupt("return",a);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),L=function(){var e=(0,n.Z)(c().mark((function e(t){var r,n,a,u,o,s,i;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.svg).includes("payload-type:".concat(y.LO.excalidraw))){e.next=26;break}if(n=r.match(/<!-- payload-start -->(.+?)<!-- payload-end -->/)){e.next=5;break}throw new Error("INVALID");case 5:return a=r.match(/<!-- payload-version:(\d+) -->/),u=(null==a?void 0:a[1])||"1",o="1"!==u,e.prev=8,e.next=11,v(n[1],o);case 11:if(s=e.sent,"encoded"in(i=JSON.parse(s))){e.next=17;break}if(!("type"in i)||i.type!==y.r8.excalidraw){e.next=16;break}return e.abrupt("return",s);case 16:throw new Error("FAILED");case 17:return e.next=19,h(i);case 19:return e.abrupt("return",e.sent);case 22:throw e.prev=22,e.t0=e.catch(8),console.error(e.t0),new Error("FAILED");case 26:throw new Error("INVALID");case 27:case"end":return e.stop()}}),e,null,[[8,22]])})));return function(t){return e.apply(this,arguments)}}()}}]); |