-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathmain.js
1 lines (1 loc) · 41.6 KB
/
main.js
1
!function(e,t){for(var n in t)e[n]=t[n]}(exports,function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t){e.exports=require("scenegraph")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(9);const i=new class{debug(e){o.isDevelopment&&console.log(this.stringify(e))}info(e){console.log(`[AXURE PLUGIN] [INFO]\r\n${this.stringify(e)}\r\n`)}error(e){console.log(`[AXURE PLUGIN] [ERROR]\r\n${this.stringify(e)}\r\n`)}stringify(e){return"string"==typeof e?e:JSON.stringify(e)}};t.default=i},function(e,t){e.exports=require("uxp")},function(e,t){e.exports=require("application")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUint8Array=t.base64Uint8Array=t.base64ArrayBuffer=t.uuid=t.getImageShapeData=void 0;const o=n(20);function i(e){return o.fromByteArray(e)}t.getImageShapeData=function(e){if(e&&1===e.length&&3===e[0].type){const t=e[0];if(0===t.patternFillType)return t.image}},t.uuid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`},t.base64ArrayBuffer=function(e){return i(new Uint8Array(e))},t.base64Uint8Array=i,t.toUint8Array=function(e){const t=JSON.stringify(e),n=unescape(encodeURIComponent(t)),o=new Uint8Array(n.length),i=n.split("");for(let e=0;e<i.length;e++)o[e]=i[e].charCodeAt(0);return o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isArtboard=void 0;const o=n(0);t.isArtboard=e=>e instanceof o.Artboard},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),i=n(7);const r=new class{getSceneNodesMarkedForExport(e){let t=[];return e.forEach(e=>{if(e.markedForExport&&!this.hasZeroSize(e)){if(e instanceof o.Group&&0===e.children.length)return;t.push(e)}const n=this.getSceneNodesMarkedForExport(e.children);n&&n.length>0&&(t=[...t,...n])}),t}hasBackgroundImageFill(e){if(e instanceof o.GraphicNode&&e.fill){return"image"===i.default.findFillType(e.fill)}for(let t=0;t<=e.children.length-1;t++){const n=e.children.at(t);if(n&&this.hasBackgroundImageFill(n))return!0}return!1}hasZeroSize(e){return e.boundsInParent.height<1||e.boundsInParent.width<1}};t.default=r},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(2),s=n(3),a=n(4),l=n(8),d=n(1),c=r.storage.localFileSystem;const u=new class{get defaultFill(){return{type:1,enabled:!0,color:{r:255,g:255,b:255,a:0}}}getGfxFill(e,t){return o(this,void 0,void 0,(function*(){if(e.fill){const n=this.findFillType(e.fill);switch(d.default.debug(`Adding ${n} fill`),n){case"color":return this.getGfxSolidFill(e);case"linear gradient":return this.getGfxLinearGradientFill(e);case"radial gradient":return this.getGfxRadialGradientFill(e);case"image":return this.getGfxImageFill(e,t)}}}))}findFillType(e){const t=e;let n;return"number"==typeof t.endR?n="radial gradient":"number"==typeof t.endX?n="linear gradient":e instanceof i.Color?n="color":e instanceof i.ImageFill&&(n="image"),n}getGfxSolidFill(e){const t=e.fill;return{enabled:e.fillEnabled,type:1,color:l.default.ConvertToRGBA(t)}}getGfxLinearGradientFill(e){const t=e.fill,n={gradientType:0,type:2,enabled:e.fillEnabled,from:{x:t.startX,y:t.startY},to:{x:t.endX,y:t.endY},stops:[]};for(const e of t.colorStops){const t={offset:e.stop,location:this.calcColorStopLocation(n.from,n.to,e.stop),color:l.default.ConvertToRGBA(e.color)};n.stops.push(t)}return n}getGfxRadialGradientFill(e){const t=e.fill,n=e.localBounds.width,o=e.localBounds.height,r=t,s=new i.Matrix(r.gradientTransform.a,r.gradientTransform.b,r.gradientTransform.c,r.gradientTransform.d,r.gradientTransform.e,r.gradientTransform.f),a=s.scaleFactors(),d={gradientType:1,type:2,enabled:e.fillEnabled},c={x:r.startX,y:r.startY},u=s.transformPoint({x:1,y:.5}),h=.5/r.endR;u.x=c.x-(c.x-u.x)/h,u.y=c.y-(c.y-u.y)/(h*o/n);const f=a.scaleY*(o/n),g=Object.assign(Object.assign({},d),{from:c,to:u,ellipseLength:f,stops:[]});for(const e of r.colorStops){const t={offset:e.stop,location:this.calcColorStopLocation(c,u,e.stop),color:l.default.ConvertToRGBA(e.color)};g.stops.push(t)}return g}getGfxImageFill(e,t){return o(this,void 0,void 0,(function*(){if(!t)return{alignment:{horizontal:1,vertical:1},enabled:!0,type:3,patternFillType:0,image:""};const n=yield c.getTemporaryFolder();let o;const l=(new Date).getTime().toString();try{o=yield n.createFolder(l)}catch(e){o=yield n.getEntry(l)}const d=e.guid+".png",u=yield o.createFile(d,{overwrite:!0});let h;if(e instanceof i.GraphicNode){const t=e.opacity;e.opacity=1;const n=JSON.parse(JSON.stringify(e.shadow));e.shadow=null;const o=e.rotation;e.rotateAround(-o,e.localCenterPoint);const r=e.strokeEnabled;e.strokeEnabled=!1;const a=[{node:e,outputFile:u,type:"png",scale:1,quality:100,background:new i.Color({r:0,g:0,b:0,a:0},0),minify:!1,embedImages:!0}];h=(yield s.createRenditions(a))[0],e.opacity=t,e.shadow=n,e.rotateAround(o,e.localCenterPoint),e.strokeEnabled=r}else{const t=[{node:e,outputFile:u,type:"png",scale:1,quality:100,background:new i.Color({r:0,g:0,b:0,a:0},0),minify:!1,embedImages:!0}];h=(yield s.createRenditions(t))[0]}const f=yield h.outputFile.read({format:r.storage.formats.binary});return{alignment:{horizontal:1,vertical:1},enabled:!0,type:3,patternFillType:0,image:a.base64ArrayBuffer(f)}}))}calcColorStopLocation(e,t,n){return{x:e.x-(e.x-t.x)*n,y:e.y-(e.y-t.y)*n}}};t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=new class{ConvertToRGBA(e){if(!e)return this.transparentColor;const t=e.toRgba();return{r:t.r/255,g:t.g/255,b:t.b/255,a:t.a/255}}get defaultColor(){return{a:1,r:0,g:0,b:0}}get transparentColor(){return{a:0,r:255,g:255,b:255}}};t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDevelopment=void 0,t.isDevelopment=!1},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=n(11),r=n(12),s=n(15),a=n(19),l=n(21),d=n(26),c=n(27),u=n(5),h=n(1),f=n(9),g=[22918,35603,40932,52589,13721];function p(e,t,n){return o(this,void 0,void 0,(function*(){try{n.disableButtons();const i=yield t.createAndSaveExportBunch(e);h.default.debug("exported folder: "+i);const r=function(e){return h.default.debug("Export folder to URL: "+e),`axure://export-from-adobe-xd?folder=${encodeURIComponent(e)}&source=adobe-xd`}(i);(yield function(e){return o(this,void 0,void 0,(function*(){for(const t of g)if(yield y(t,e))return!0;return!1}))}(r))?(h.default.debug("export was performed via websocket"),n.close()):(h.default.debug("no valid websocket was found. creating export URL..."),n.showAxureAppLink(r))}catch(e){v(e,!0),h.default.error(e),n.hideSpinner(),n.showMessage("Export failed. "+e)}finally{n.enableButtons()}}))}function y(e,t){return o(this,void 0,void 0,(function*(){return new Promise((n,o)=>{h.default.debug("opening websocket to port "+e);const i=new WebSocket("ws://localhost:"+e);i.onopen=()=>{h.default.debug("socket opened, sending message"),i.send(t)},i.onmessage=e=>{const o=e.data;h.default.debug("received message from websocket"),n(o===t),i.close()},i.onerror=t=>{h.default.error("Failed to open websocket on port "+e),n(!1)},i.onclose=e=>{h.default.debug("socket closed")}})}))}function x(e,t,n){return o(this,void 0,void 0,(function*(){try{let r=[];r=n?yield function(e){return o(this,void 0,void 0,(function*(){const t=new l.AxvgConverter(!0);let n=[];if(e.itemsIncludingLocked.filter(u.isArtboard).length>0){const o=e.itemsIncludingLocked.filter(u.isArtboard);n=yield t.convertSceneNodesToAxvg(o)}else n=yield t.convertSceneNodesToAxvg(e.itemsIncludingLocked);return n}))}(e):yield function(e){return o(this,void 0,void 0,(function*(){const t=new l.AxvgConverter(!0),n=e.children.filter(u.isArtboard);return yield t.convertSceneNodesToAxvg(n)}))}(t);const s={masters:{},scene:{items:r}};i.copyText("// axvg\n"+JSON.stringify(s))}catch(e){v(e,!0)}}))}function b(e,t){new s.ErrorDialog(e,t)}function m(e){return o(this,void 0,void 0,(function*(){if(!f.isDevelopment){const t=yield c.GAHelper.init();yield t.sendEvent(e)}}))}function v(e,t=!1){return o(this,void 0,void 0,(function*(){if(!f.isDevelopment){const n=yield c.GAHelper.init();yield n.sendError(e,t)}}))}e.exports={commands:{copySelection:function(e,t){return o(this,void 0,void 0,(function*(){m("Copy selection"),0!==e.itemsIncludingLocked.length?yield x(e,t,!0):b("Copy to RP","No object(s) selected")}))},copyAllArtboards:function(e,t){return o(this,void 0,void 0,(function*(){m("Copy all");t.children.some(u.isArtboard)?yield x(e,t,!1):b("Copy to RP","No artboard(s) selected")}))},exportSelectedArtboards:function(e,t){return o(this,void 0,void 0,(function*(){m("Export selection");if(!e.itemsIncludingLocked.some(u.isArtboard))return void b("Export to Axure Cloud","No artboard(s) selected");const n=new a.ArtboardsProvider(e,t,new l.AxvgConverter(!1),new d.ManifestConverter),o=new r.ExportDialog;o.show();yield p({exportOnlySelectedArtboards:!0},n,o)}))},exportAllArtboards:function(e,t){return o(this,void 0,void 0,(function*(){m("Export all");if(!t.children.some(u.isArtboard))return void b("Export to Axure Cloud","No artboard(s) selected");const n=new a.ArtboardsProvider(e,t,new l.AxvgConverter(!1),new d.ManifestConverter),o=new r.ExportDialog;o.show();yield p({exportOnlySelectedArtboards:!1},n,o)}))}}}},function(e,t){e.exports=require("clipboard")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExportDialog=void 0;const o=n(13),i=n(14),r="darwin"===o.platform()?"https://www.axure.cloud/desktop/mac/AxureCloud.dmg":"https://www.axure.cloud/desktop/win/AxureCloud.exe";t.ExportDialog=class{constructor(){this.dialog=null,this.closeButton=null,this.linkToAxureApp=null,this.messageContainer=null,this.spinnerContainer=null,this.linkContainer=null,this.unsuccessfulExportContainer=null,this.appDownload=null}show(){if(this.dialog)return this.dialog.showModal();this.initDialog()}close(){this.dialog&&this.dialog.close("reasonCanceled")}showAxureAppLink(e){this.unsuccessfulExportContainer&&this.appDownload&&(this.setAxureAppUrl(e),this.hideSpinner(),this.setContainerVisibility(this.unsuccessfulExportContainer,!0),this.setContainerVisibility(this.appDownload,!0),this.enableButtons())}setAxureAppUrl(e){this.linkToAxureApp&&this.linkToAxureApp.setAttribute("href",e)}enableButtons(){this.closeButton&&this.setContainerVisibility(this.closeButton,!0)}disableButtons(){this.closeButton&&this.setContainerVisibility(this.closeButton,!1)}showMessage(e){this.messageContainer&&(this.messageContainer.innerHTML=e,this.setContainerVisibility(this.messageContainer,!0),this.enableButtons())}setContainerVisibility(e,t){t?this.showContainer(e):this.hideContainer(e)}showContainer(e){e.classList.remove("hidden")}hideContainer(e){e.classList.add("hidden")}hideSpinner(){this.spinnerContainer&&this.setContainerVisibility(this.spinnerContainer,!1)}initDialog(){this.dialog=document.createElement("dialog"),this.dialog.innerHTML=i.ExportDialogLayout,document.body.appendChild(this.dialog),this.messageContainer=this.dialog.querySelector("#message-container"),this.unsuccessfulExportContainer=this.dialog.querySelector("#unsuccessful-export-container"),this.appDownload=this.dialog.querySelector("#app-download"),this.linkContainer=this.dialog.querySelector("#link-container"),this.spinnerContainer=this.dialog.querySelector("#spinner-container"),this.closeButton=this.dialog.querySelector("#close"),this.closeButton&&this.closeButton.addEventListener("click",()=>this.close()),this.linkToAxureApp=this.dialog.querySelector("#link-to-axure-app"),this.linkToAxureApp&&this.linkToAxureApp.addEventListener("click",()=>this.close());this.dialog.querySelector("#app-download-link").href=r}}},function(e,t){e.exports=require("os")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExportDialogLayout=void 0,t.ExportDialogLayout='\n<style>\n form {\n width: 420px;\n }\n .h1 {\n align-items: center;\n justify-content: space-between;\n display: flex;\n flex-direction: row;\n }\n .icon {\n border-radius: 4px;\n width: 24px;\n height: 24px;\n overflow: hidden;\n }\n\n input, span { \n display: inline;\n }\n .row-label { \n align-items: center; \n display: flex;\n flex-direction: row;\n }\n\n .buttons-container button {\n display: inline;\n }\n\n .hidden {\n display: none;\n }\n\n .spinner {\n margin: auto;\n }\n\n .spinner-img {\n display: block;\n margin: auto;\n display: block;\n width: 140px;\n height: 140px;\n }\n\n .spinner-text {\n text-align: center;\n }\n\n .link-container {\n width: 95%;\n margin: 30px auto 5px auto;\n }\n\n .link-to-app {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 30px;\n background-color: #017fc7;\n font-family: \'SourceSansPro-Regular\', \'Source Sans Pro\';\n color: #fff !important;\n text-decoration: none;\n border-radius: 5px;\n line-height: 30px;\n }\n\n .close-button {\n font-size: 16px;\n width: 100px;\n text-align: center;\n margin: auto;\n cursor: pointer; \n }\n\n .message-container {\n font-size: 16px;\n }\n\n .app-download {\n margin: 20px auto -20px auto;\n text-align: center;\n font-size: 10px;\n }\n</style>\n<form method="dialog">\n <h1 class="h1">\n <span>Export to Axure Cloud</span>\n <img class="icon" src="icons/icon.png" />\n </h1>\n <hr />\n <div id="spinner-container" class="spinner">\n <img class="spinner-img" src="spinner.gif">\n <p class="spinner-text">Exporting...</p>\n </div>\n <p id="message-container" class="message-container hidden">To export your artboards, the Axure Cloud App needs to be open.</p>\n <div id="unsuccessful-export-container" class="hidden">\n <p>To export your artboards, the Axure Cloud App needs to be open.</p>\n <div id="link-container" style="display: none" class="link-container"><a href="" class="link-to-app" id="link-to-axure-app">Open Axure Cloud and Export Artboards</a></div>\n </div>\n <div class="close-button hidden" id="close" uxp-variant="primary">Close</div>\n <p id="app-download" class="app-download hidden">If you don\'t already have the Axure Cloud App please <a id="app-download-link" href="https://www.axure.cloud/download/">download it here.</a></p>\n</form>\n '},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(16);Object.defineProperty(t,"ErrorDialog",{enumerable:!0,get:function(){return o.ErrorDialog}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorDialog=void 0;const o=n(17),i=n(18);class r extends o.Dialog{constructor(e,t){super(i.layout),this.title=e,this.message=t,this.closeButton=null,this.messageContainer=null,this.addContent()}addContent(){if(this.dialog){const e=this.dialog.querySelector(".dialog-title");e&&(e.textContent=this.title),this.messageContainer=this.dialog.querySelector("#message-container"),this.messageContainer&&(this.messageContainer.textContent=this.message)}}}t.ErrorDialog=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Dialog=void 0;t.Dialog=class{constructor(e){this.layout=e,this.dialog=null,this.open()}open(){if(this.dialog)return this.dialog.showModal();this.createDialog()}close(){this.dialog&&(this.dialog.close(),this.dialog.remove())}createDialog(){this.dialog=document.createElement("dialog"),this.dialog.innerHTML=this.layout,document.body.appendChild(this.dialog);const e=this.dialog.querySelector("#close");e&&e.addEventListener("click",()=>this.close())}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.layout=void 0,t.layout='\n<style>\n form {\n width: 420px;\n }\n .h1 {\n align-items: center;\n justify-content: space-between;\n display: flex;\n flex-direction: row;\n }\n .icon {\n border-radius: 4px;\n width: 24px;\n height: 24px;\n overflow: hidden;\n }\n\n input, span { \n display: inline;\n }\n .row-label { \n align-items: center; \n display: flex;\n flex-direction: row;\n }\n\n .buttons-container button {\n display: inline;\n }\n\n .hidden {\n display: none;\n }\n\n .close-button {\n font-size: 16px;\n width: 100px;\n text-align: center;\n margin: auto;\n cursor: pointer; \n }\n\n .message-container {\n font-size: 16px;\n }\n</style>\n<form method="dialog">\n <h1 class="h1">\n <span class="dialog-title"></span>\n <img class="icon" src="icons/icon.png" />\n </h1>\n <hr />\n <p id="message-container" class="message-container"></p>\n <div class="close-button" id="close" uxp-variant="primary">Close</div>\n</form>\n '},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ArtboardsProvider=void 0;const i=n(0),r=n(2),s=n(3),a=n(6),l=n(5),d=n(1),c=r.storage.localFileSystem;t.ArtboardsProvider=class{constructor(e,t,n,o){this.selection=e,this.documentRoot=t,this.axvgConverter=n,this.manifestConverter=o}isAnyArtboardSelected(){for(let e=0;e<this.selection.itemsIncludingLocked.length;e++){const t=this.selection.itemsIncludingLocked[e];if(l.isArtboard(t))return!0}return!1}createAndSaveExportBunch(e){return o(this,void 0,void 0,(function*(){let t=[];if(e.exportOnlySelectedArtboards){const e=this.selection.itemsIncludingLocked.filter(l.isArtboard).map(e=>e.guid);t=this.documentRoot.children.filter(t=>e.includes(t.guid)),d.default.debug("Selected artboards count: "+t.length)}else t=this.documentRoot.children.filter(l.isArtboard),d.default.debug("All artboards count: "+t.length);t=t.reverse();const n=yield c.getTemporaryFolder();let o;d.default.debug(n.nativePath);const i=(new Date).getTime().toString();try{o=yield n.createFolder(i)}catch(e){o=yield n.getEntry(i)}return d.default.debug("Export folder received"),yield this.exportArtboardsAssets(t,o),yield this.exportSceneNodesMarkedForExport(t,o),yield this.exportArtboardsToAxvgFiles(t,o),yield this.saveManifests(t,o),d.default.debug("--------------END------------------"),new Promise((e,t)=>{e(o.nativePath)})}))}saveManifests(e,t){return o(this,void 0,void 0,(function*(){const n=this.manifestConverter.getManifestForArtboards(e);for(const e of n.Artboards){const n={Shortcut:"",Artboards:[e]};d.default.debug(`Save ${e.Id}.manifest.json`);const o=yield t.createFile(e.Id+".manifest.json",{overwrite:!0});d.default.debug("Manifest file created: "+o.nativePath),yield o.write(JSON.stringify(n)),d.default.debug("single artboard manifest saved")}d.default.debug("Save manifest.json");const o=yield t.createFile("manifest.json",{overwrite:!0});d.default.debug("Manifest file created: "+o.nativePath),yield o.write(JSON.stringify(n)),d.default.debug("manifest saved")}))}exportArtboardsToAxvgFiles(e,t){return o(this,void 0,void 0,(function*(){d.default.debug("exportArtboardsToAxvgFiles, artboardsToExport: "+e.length);for(let n=0;n<e.length;n++){const o=e[n],i=yield this.getAxvgRootFromArtboard(o);yield this.saveRootAsAxvg(i,t),d.default.debug("Axvg for artboard is saved")}}))}getAxvgRootFromArtboard(e){return o(this,void 0,void 0,(function*(){const t={masters:{},scene:{items:[]}};return t.scene.items=yield this.axvgConverter.convertSceneNodesToAxvg([e]),t}))}exportArtboardsAssets(e,t){return o(this,void 0,void 0,(function*(){for(let n=0;n<e.length;n++){const o=e[n];yield this.exportSceneNodeAsImage(o,t,!1)}}))}exportSceneNodesMarkedForExport(e,t){return o(this,void 0,void 0,(function*(){for(const n of e){const e=a.default.getSceneNodesMarkedForExport(n.children);for(const n of e)a.default.hasZeroSize(n)||(d.default.debug("Exporting Scene Node "+n.guid),yield this.exportSceneNodeAsImage(n,t,!a.default.hasBackgroundImageFill(n)))}}))}exportSceneNodeAsImage(e,t,n,r=0){return o(this,void 0,void 0,(function*(){const o=[{format:"png",scale:1},{format:"png",scale:2}];n&&o.push({format:"svg",scale:1});const a=[];for(const n of o){d.default.debug("Save Artboard as "+n.format);const o=1===n.scale?"":`@${n.scale}x`,s=`${e.guid}${o}.${n.format}`,l=yield t.createFile(s,{overwrite:!0});d.default.debug("File created: "+l.nativePath);const c={node:e,outputFile:l,type:n.format,scale:n.scale/Math.pow(2,r),quality:100,background:new i.Color({r:0,g:0,b:0,a:0},0),minify:!1,embedImages:!0};a.push(c)}const l="render.too_large",c="io.failed";yield s.createRenditions(a).catch(t=>{let n=t;switch(t){case l:n=`The "${e.name}" node is too large to export. Please, try using smaller sizes or contact us at [email protected]`;break;case c:n=`Failed to create asset for "${e.name}" node. Please contact us at [email protected]`}throw new Error(n)})}))}saveRootAsAxvg(e,t){return o(this,void 0,void 0,(function*(){d.default.debug("Save axvg");const n=yield t.createFile(e.scene.items[0].id+".axvg.json",{overwrite:!0});return d.default.debug("Axvg file created: "+n.nativePath),n.write(JSON.stringify(e))}))}}},function(e,t,n){"use strict";t.byteLength=function(e){var t=d(e),n=t[0],o=t[1];return 3*(n+o)/4-o},t.toByteArray=function(e){var t,n,o=d(e),s=o[0],a=o[1],l=new r(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),c=0,u=a>0?s-4:s;for(n=0;n<u;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],l[c++]=t>>16&255,l[c++]=t>>8&255,l[c++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,l[c++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,l[c++]=t>>8&255,l[c++]=255&t);return l},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,r=[],s=0,a=n-i;s<a;s+=16383)r.push(c(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],r.push(o[t>>2]+o[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],r.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"="));return r.join("")};for(var o=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=s.length;a<l;++a)o[a]=s[a],i[s.charCodeAt(a)]=a;function d(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var i,r,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(o[(r=i)>>18&63]+o[r>>12&63]+o[r>>6&63]+o[63&r]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AxvgConverter=void 0;const i=n(0),r=n(22),s=n(23),a=n(4),l=n(8),d=n(7),c=n(25),u=n(5),h=n(1);t.AxvgConverter=class{constructor(e){this.convertImage=e}convertSceneNodesToAxvg(e){return o(this,void 0,void 0,(function*(){const t=[];for(const n of e){const e=yield this.getAxvgForSceneNode(n);e&&t.push(e)}return t}))}getGfxChildItems(e,t=c.default.default,n=1){return o(this,void 0,void 0,(function*(){const o=[];for(let i=0;i<=e.children.length-1;i++){const r=e.children.at(i);if(r){const e=yield this.getAxvgForSceneNode(r,t,n);e&&o.push(e)}}return o}))}getAxvgForArtboard(e){return o(this,void 0,void 0,(function*(){h.default.debug("Prepare artboard");const t={itemType:2,id:e.guid,name:e.name,rect:{location:{x:e.globalBounds.x,y:e.globalBounds.y},size:{height:e.globalBounds.height,width:e.globalBounds.width}},backgroundFill:(yield d.default.getGfxFill(e,this.convertImage))||d.default.defaultFill,resizingConstraints:this.defaultResizingConstraints,isNameDynamic:e.hasDefaultName,scene:{items:[]}},n=yield this.getGfxChildItems(e);return t.scene.items=n,t}))}getAxvgForRepeatGrid(e,t,n){return o(this,void 0,void 0,(function*(){const o=e.cellSize.width*e.numColumns+e.paddingX*(e.numColumns-1)>e.width,i=e.cellSize.height*e.numRows+e.paddingY*(e.numRows-1)>e.height,r=o||i;let a=[];for(let o=0;o<=e.children.length-1;o++){const i=e.children.at(o);if(i){const o=s.default.sumPoints(t,c.default.getLocationBeforeRotation(e)),r=yield this.getAxvgForSceneNode(i,o,n*e.opacity);r&&a.push(r)}}a=a.map(e=>0===e.itemType&&1===e.scene.items.length?e.scene.items[0]:e);const l=this.getResizingConstraints(e);if(r){return Object.assign(Object.assign({},this.getBasePropertiesForNode(e,t)),{resizingConstraints:l,effects:[],itemType:1,maskedScene:{items:a},backgroundFills:[],rotation:0,flippedHorizontal:!1,flippedVertical:!1,isMask:!0,opacity:1,strokes:[],type:0,strokePattern:[],strokeThickness:0,textAlignment:1,textRotation:0,textPadding:[0],textShadows:[]})}return Object.assign(Object.assign({},this.getBasePropertiesForNode(e,t)),{resizingConstraints:l,effects:[],itemType:0,scene:{items:a}})}))}getAxvgForGroup(e,t,n){return o(this,void 0,void 0,(function*(){if(0===e.children.length)return;const o=c.default.getLocationBeforeRotation(e),i=s.default.sumPoints(o,t);if(e.mask){h.default.debug("Preparing mask");const t=s.default.subtractPoints(i,c.default.getLocationBeforeRotation(e.mask)),o=yield this.getAxvgForShape(e.mask,t,n*e.opacity),r=yield this.getGfxChildItems(e,t,n*e.opacity);return o.isMask=!0,o.maskedScene={items:r.filter(e=>e.id!==o.id)},o.id=e.guid,o}let r;for(let t=0;t<=e.children.length-1;t++){const n=e.children.at(t);if(n){const e={x:n.boundsInParent.x,y:n.boundsInParent.y};r||(r=e),r.x>e.x&&(r.x=e.x),r.y>e.y&&(r.y=e.y)}}if(r){const o=s.default.subtractPoints(i,r),a=yield this.getGfxChildItems(e,o,n*e.opacity);return Object.assign(Object.assign({},this.getBasePropertiesForNode(e,t)),{resizingConstraints:this.getResizingConstraints(e),effects:[],itemType:0,scene:{items:a}})}}))}getAxvgForSymbolInstance(e,t,n){return o(this,void 0,void 0,(function*(){const o=s.default.sumPoints(t,c.default.getLocationBeforeRotation(e)),i=yield this.getGfxChildItems(e,o,n*e.opacity);return Object.assign(Object.assign({},this.getBasePropertiesForNode(e,t)),{resizingConstraints:this.getResizingConstraints(e),effects:[],itemType:0,scene:{items:i}})}))}getAxvgForShape(e,t,n){return o(this,void 0,void 0,(function*(){let o=Object.assign(Object.assign({itemType:1},this.getBasePropertiesForNode(e,t)),{resizingConstraints:this.getResizingConstraints(e),backgroundFills:[],type:0,opacity:e.opacity*n,strokes:[],strokePattern:[],strokeThickness:0,text:void 0,textAlignment:0,textPadding:[],effects:[],textShadows:[],textRotation:0,isMask:!1});if(e instanceof i.GraphicNode)if(e instanceof i.Text)this.fillTextData(e,o);else{if(e.strokeEnabled&&e.stroke){h.default.debug("Adding stroke");const t={fill:{color:l.default.ConvertToRGBA(e.stroke),enabled:!0,type:1},alignment:0};switch(e.strokePosition){case"inside":t.alignment=0;break;case"center":t.alignment=1;break;case"outside":t.alignment=2;break;default:h.default.error("Unknown Stroke Position")}o.strokes.push(t),o.strokeThickness=e.strokeWidth,e.strokeDashArray&&e.strokeDashArray.length>0&&(o.strokePattern=e.strokeDashArray)}if(e.fillEnabled&&e.fill){const t=yield d.default.getGfxFill(e,this.convertImage);t&&o.backgroundFills.push(t)}if(e.shadow){h.default.debug("Adding shadow");const t={type:1,shadowType:0,enabled:e.shadow.visible,blur:e.shadow.blur,offset:{x:e.shadow.x,y:e.shadow.y},spread:0,color:l.default.ConvertToRGBA(e.shadow.color)};o.effects.push(t)}if(e instanceof i.Rectangle){h.default.debug("Adding rectangle data"),o.type=0;o=Object.assign(Object.assign({},o),{corners:Object.values(e.cornerRadii),border:[],booleanOperation:0})}else{h.default.debug("Adding path data"),o.type=2;const t={size:{height:e.localBounds.height,width:e.localBounds.width},location:{x:e.localBounds.x,y:e.localBounds.y}},n=r.default.parseToPaths(e.pathData,t);o=Object.assign(Object.assign({},o),{booleanOperation:0,paths:n})}}if(0===o.type){const e=a.getImageShapeData(o.backgroundFills);if(e){o.type=4,o.backgroundFills=[];o=Object.assign(Object.assign({},o),{data:e})}}return o}))}getAxvgForSceneNode(e,t=c.default.default,n=1){return o(this,void 0,void 0,(function*(){if(e){if(!(e instanceof i.LinkedGraphic))return u.isArtboard(e)?(h.default.debug(`Artboard ${e.name} found`),this.getAxvgForArtboard(e)):e instanceof i.RepeatGrid?(h.default.debug(`RepeatGrid ${e.name} found`),this.getAxvgForRepeatGrid(e,t,n)):e instanceof i.Group?(h.default.debug(`Group ${e.name} found`),this.getAxvgForGroup(e,t,n)):e instanceof i.SymbolInstance?(h.default.debug(`Symbol Instance ${e.name} found`),this.getAxvgForSymbolInstance(e,t,n)):(h.default.debug(`Shape ${e.name} found`),this.getAxvgForShape(e,t,n));h.default.info("LinkedGraphic - not implemented")}}))}fillTextData(e,t){h.default.debug("Adding text data for "+e.name),h.default.debug("Text "+e.text),h.default.debug("Parent "+e.parent.name);const n=/\u000b|\u2424|\u2028|\n/;t.name=e.name.substring(0,20).split(n)[0];const o={horizontalAlignment:0,lineSpacing:e.lineSpacing,inlines:[]};switch(e.textAlign){case"right":o.horizontalAlignment=2;break;case"center":o.horizontalAlignment=1;break;default:o.horizontalAlignment=0}let i,r;if(!e.styleRanges||e.styleRanges.length>1){const t=this.getInlinesFromStyleRanges(e);i=t[t.length-1].characterSpacing,r=t[t.length-1].size,o.inlines=t}else{const t=e.text,n=this.getInlineForStyleRange(t,e.styleRanges[0]);i=n.characterSpacing,r=n.size,o.inlines.push(n)}if(n.test(e.text)||(o.lineSpacing=r),t.text={paragraphs:[o]},e.areaBox||(t.rect.size.width+=1+i),e.shadow){h.default.debug("Adding text shadow");const n={type:1,shadowType:0,enabled:e.shadow.visible,blur:e.shadow.blur,offset:{x:e.shadow.x,y:e.shadow.y},spread:0,color:l.default.ConvertToRGBA(e.shadow.color)};t.textShadows.push(n)}}getInlinesFromStyleRanges(e){const t=e.text,n=[];let o=0,i=0;for(let r=0;r<e.styleRanges.length;r++){const s=e.styleRanges[r];i=o+s.length;const a=t.substring(o,i),l=this.getInlineForStyleRange(a,s);n.push(l),o=i}return n}getInlineForStyleRange(e,t){const n=t.fontSize*t.charSpacing/1e3,o={type:0,text:e,textColor:l.default.ConvertToRGBA(t.fill),highlight:l.default.defaultColor,size:t.fontSize,family:t.fontFamily,typeface:`${t.fontFamily} - ${t.fontStyle}`,underline:t.underline,strikethrough:t.strikethrough,superscript:0,baselineOffset:0,characterSpacing:n,transform:0,stretch:5,style:0,weight:400};switch(t.textTransform){case"uppercase":o.transform=1;break;case"lowercase":o.transform=2}switch(t.textScript){case"subscript":o.superscript=-1;break;case"superscript":o.superscript=1;break;case"none":default:o.superscript=0}let i=t.fontStyle;return i&&i.includes("Italic")?(o.style=2,i=i.replace("Italic","").trim()):i&&i.includes("Oblique")&&(o.style=1,i=i.replace("Oblique","").trim()),o.weight=this.getGfxFontWeight(i),o}getGfxFontWeight(e){let t=400;switch(e.toLowerCase()){case"thin":t=100;break;case"extralight":case"ultralight":t=200;break;case"light":t=300;break;case"semilight":t=350;break;case"normal":t=400;break;case"medium":t=500;break;case"demibold":case"semibold":t=600;break;case"bold":t=700;break;case"extrabold":case"ultrabold":t=800;break;case"heavy":case"black":t=900;break;case"extrablack":case"ultrablack":t=950}return t}get backgroundResizingConstraints(){return{hasFixedLeft:!0,hasFixedRight:!0,hasFixedTop:!0,hasFixedBottom:!0,hasFixedWidth:!0,hasFixedHeight:!0}}get defaultResizingConstraints(){return{hasFixedLeft:!0,hasFixedRight:!1,hasFixedTop:!0,hasFixedBottom:!1,hasFixedWidth:!0,hasFixedHeight:!0}}getResizingConstraints(e){const t=this.defaultResizingConstraints;if(e.horizontalConstraints&&e.verticalConstraints){switch("size-resizes"===e.horizontalConstraints.size&&(t.hasFixedWidth=!1),e.horizontalConstraints.position){case"fixed-right":t.hasFixedLeft=!1,t.hasFixedRight=!0;break;case"fixed-both":t.hasFixedRight=!0;break;case"position-proportional":t.hasFixedLeft=!1}switch("size-resizes"===e.verticalConstraints.size&&(t.hasFixedHeight=!1),e.verticalConstraints.position){case"fixed-bottom":t.hasFixedTop=!1,t.hasFixedBottom=!0;break;case"fixed-both":t.hasFixedBottom=!0;break;case"position-proportional":t.hasFixedTop=!1}}return t}getBasePropertiesForNode(e,t=c.default.default){const n=s.default.sumPoints(t,c.default.getLocationBeforeRotation(e)),o=Math.round(e.rotation);return{flippedHorizontal:!1,flippedVertical:!1,id:e.guid,name:e.name,rect:{location:n,size:{height:e.localBounds.height,width:e.localBounds.width}},visible:e.visible,isLocked:e.locked,isNameDynamic:e.hasDefaultName,rotation:o}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=new class{parseToPaths(e,t,n=!1){let o=e.split("M");o.shift(),o=o.map(e=>"M "+e.trim());const i=[],s={height:t.size.height,width:t.size.width,x:t.location.x,y:t.location.y};for(const e of o){const t=new r(e,s);if(t.pathData.length>0){const e={closed:t.isClosed,data:t.pathData,endDecoration:1,startDecoration:1};i.push(e)}}if(n&&i.length>1){const e=i[i.length-1];e.data=e.data.reverse()}return i}};function i(e){return 3===e.type}t.default=o;class r{constructor(e,t){e=e.trim(),this._stringPathData=e,this._localBounds=t,this.isClosed=!1,e.endsWith("Z")&&(this._stringPathData=e.substring(0,e.length-1).trim(),this.isClosed=!0),this.pathData=this.getPathData()}calcX(e){return(e-this._localBounds.x)/(0===this._localBounds.width?1:this._localBounds.width)}calcY(e){return(e-this._localBounds.y)/(0===this._localBounds.height?1:this._localBounds.height)}pointEquals(e,t){return!(!e||!t)&&(e.x===t.x&&e.y===t.y)}getSegments(){const e=this._stringPathData.split(" ");let t;if(!(e.length>=3&&"M"===e[0]))return[];e.shift(),t={type:"M",points:[{x:this.calcX(+(e.shift()||0)),y:this.calcY(+(e.shift()||0))}]};const n=[];if(e.length>2){let t=0;do{const o=e[t];t++;const i=[];for(;!isNaN(+e[t]);)i.push({x:this.calcX(+e[t]),y:this.calcY(+e[t+1])}),t+=2,e[t]===o&&t++;n.push({type:o,points:i})}while(t<=e.length-3)}n.length&&n[0].points.unshift(...t.points);for(let e=0;e<n.length-1;e++)if("L"===n[e].type&&"C"===n[e+1].type){const t=n[e].points.pop();t&&n[e+1].points.unshift(t)}return n.filter(e=>e.points.length>0)}pushCubics(e,t){const n={type:3,to:t[0],higherHandle:t[1]},o={type:3,to:t[t.length-1],lowerHandle:t[t.length-2]};e.push(n);for(let n=2;n<t.length-3;n+=3){const o={type:3,lowerHandle:t[n],to:t[n+1],higherHandle:t[n+2]};e.push(o)}return e.push(o),e}pushLines(e,t){for(const n of t){const t={type:2,to:{x:n.x,y:n.y}};e.push(t)}return e}getPathData(){const e=this.getSegments();let t=[];for(const n of e)switch(n.type){case"L":t=this.pushLines(t,n.points);break;case"C":t=this.pushCubics(t,n.points)}if(this.isClosed&&t.length&&t.length>1&&this.pointEquals(t[0].to,t[t.length-1].to)){const e=t.shift(),n=t.pop();if(e&&n){const o=Math.max(e.type,n.type);let r=i(e)&&e.higherHandle||i(n)&&n.higherHandle,s=i(e)&&e.lowerHandle||i(n)&&n.lowerHandle;r=r||void 0,s=s||void 0;const a={to:e.to,type:o,higherHandle:r,lowerHandle:s};t.unshift(a)}}return t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(24);const i=new class{sumPoints(e,...t){const n=this.copyPoint(e);for(const e of t)n.x+=e.x,n.y+=e.y;return n}subtractPoints(e,...t){const n=this.copyPoint(e);for(const e of t)n.x-=e.x,n.y-=e.y;return n}copyPoint(e){return{x:e.x,y:e.y}}rotatePoint(e,t,n){const o=this.subtractPoints(e,t),i={x:o.x*n.cos-o.y*n.sin,y:o.x*n.sin+o.y*n.cos};return this.sumPoints(i,t)}angleBetweenPoint(e,t,n){const o=this.subtractPoints(e,t),i=this.subtractPoints(n,t);return this.angleBetweenVectors(o,i)}angleBetweenVectors(e,t){const n=Math.atan2(-e.y,e.x)-Math.atan2(-t.y,t.x);return new o.Rotation(n,"RAD")}changeLength(e,t,n){const o=n/this.getLength(e,t);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}getLength(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}equals(e,t){return!(!e||!t)&&(e.x===t.x&&e.y===t.y)}insideRect(e,t){const n=Math.round(e.x),o=Math.round(e.y),i={x:Math.round(t.location.x),y:Math.round(t.location.y)},r={height:Math.round(t.size.height),width:Math.round(t.size.width)};return n>=i.x&&n<=i.x+r.width&&o>=i.y&&o<=i.y+r.height}movePoint(e,t,n){return{x:e.x+t*n.sin,y:e.y-t*n.cos}}};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Rotation=void 0;const o=180/Math.PI;t.Rotation=class{constructor(e,t){this._rad=0,this._deg=0,"RAD"===t?this.rad=e:this.deg=e}get rad(){return this._rad}set rad(e){let t=e%(2*Math.PI);t=t<0?2*Math.PI+t:t,this._rad=t,this._deg=t*o}get deg(){return this._deg}set deg(e){let t=e%360;t=t<0?360+t:t,this._rad=t/o,this._deg=t}get cos(){return Math.cos(this._rad)}get sin(){return Math.sin(this._rad)}get tan(){return Math.tan(this._rad)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=new class{constructor(){this.default={x:0,y:0}}getLocationBeforeRotation(e){return{x:e.boundsInParent.x+e.boundsInParent.width/2-e.localBounds.width/2,y:e.boundsInParent.y+e.boundsInParent.height/2-e.localBounds.height/2}}};t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestConverter=void 0;const o=n(6);t.ManifestConverter=class{getManifestForArtboards(e){const t={Shortcut:"",Artboards:[]};for(let n=0;n<e.length;n++){const o=e[n],i=this.getSubAssetsMarkedForExport(o),r={Id:o.guid,Name:o.name,Asset:{LayerId:o.guid,Name:o.name,FileName:o.guid+"@2x.png",Scale:2},SubAssets:[{LayerId:o.guid,Name:o.name,FileName:o.guid+".axvg.json",Scale:1},{LayerId:o.guid,Name:o.name,FileName:o.guid+".png",Scale:1},...i]};t.Artboards.push(r)}return t}getSubAssetsMarkedForExport(e){const t=[],n=o.default.getSceneNodesMarkedForExport(e.children);for(const e of n)t.push({LayerId:e.guid,Name:e.name,Scale:1,FileName:e.guid+".png"}),t.push({LayerId:e.guid,Name:e.name,Scale:1,FileName:e.guid+"@2x.png"}),o.default.hasBackgroundImageFill(e)||t.push({LayerId:e.guid,Name:e.name,Scale:1,FileName:e.guid+".svg"});return t}}},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GAHelper=void 0;const i=n(2),r=n(28),s=n(3),a=n(4);class l{constructor(e){this.gaSender=e}static init(){return o(this,void 0,void 0,(function*(){const e=yield i.storage.localFileSystem.getDataFolder();let t;try{const n=yield e.getEntry("GAConfig.json"),o=yield n.read();t=JSON.parse(o).clientId}catch(n){t=a.uuid();const o=yield e.createFile("GAConfig.json",{overwrite:!0});yield o.write(JSON.stringify({clientId:t}))}const n="Adobe XD "+s.version,o=new r.GASender(n,t);return new l(o)}))}sendEvent(e){return o(this,void 0,void 0,(function*(){yield this.gaSender.sendEvent("Axure XD Plugin",e)}))}sendError(e,t=!1){return o(this,void 0,void 0,(function*(){yield this.gaSender.sendError(e,t)}))}}t.GAHelper=l},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GASender=void 0;const i=n(29);t.GASender=class{constructor(e,t){this.source=e,this.clientId=t}sendEvent(e,t,n){return o(this,void 0,void 0,(function*(){const o=this.payloadBase("event");e&&(o.ec=e),t&&(o.ea=t),this.addProps(o,n),yield this.send(o)}))}sendError(e,t=!1,n){return o(this,void 0,void 0,(function*(){const o=this.payloadBase("exception");o.exd=e,o.exf=t?"0":"1",this.addProps(o,n),yield this.send(o)}))}objectToQueryString(e){return Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}send(e){return o(this,void 0,void 0,(function*(){try{const t=this.objectToQueryString(e);yield fetch("https://www.google-analytics.com/collect",{method:"POST",body:t,mode:"cors"})}catch(e){console.log(e)}}))}payloadBase(e){return{v:1,tid:i.config.GATrackingId,ds:this.source,cid:this.clientId,t:e}}addProps(e,t){t&&Object.keys(t).forEach((function(n){e[n]=t[n]}))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.config=void 0,t.config={GATrackingId:"UA-586346-11"}}]));