From b07bb8bbf68dc70ee5f8d5061434070011604f79 Mon Sep 17 00:00:00 2001 From: Lukas Oppermann Date: Tue, 1 Aug 2023 09:49:31 +0200 Subject: [PATCH] fix for references tokens from other files --- dist/ui.html | 8 ++++---- dist/ui.js | 8 ++++---- src/transformer/standardTransformer.ts | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dist/ui.html b/dist/ui.html index b094c434..a1858d82 100644 --- a/dist/ui.html +++ b/dist/ui.html @@ -637,7 +637,7 @@ margin-right: var(--size-xxsmall); margin-left: var(--size-xxxsmall); } -`,kt=({versionDifference:n})=>"major"!==n&&"minor"!==n?e.createElement(e.Fragment,null):e.createElement("div",{id:"versionNotice",className:wt},e.createElement("div",{className:"icon"},"🎉"),e.createElement("div",null,"The ",e.createElement("a",{className:"subtle",href:"https://www.figma.com/community/plugin/888356646278934516/Design-Tokens",target:"_blank",rel:"noreferrer"},"Design Token plugin")," was updated.",e.createElement("br",null),"Find out about changes & new features in the ",e.createElement("a",{href:"https://github.com/lukasoppermann/design-tokens/releases",target:"_blank",rel:"noreferrer"},"release notes →"))),Et={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",contentType:"text/plain;charset=UTF-8",authType:"token",reference:"main",exclusionPrefix:"",excludeExtensionProp:!1,alias:"alias, ref, reference",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",typography:"typography",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion",opacity:"opacity, opacities"},exports:{color:!0,gradient:!0,font:!0,typography:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0,opacity:!0,variables:!0}};function zt(e,n){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===n?e:Math.min(n,Math.max(0,parseFloat(e))),t&&(e=parseInt(String(e*n),10)/100),Math.abs(e-n)<1e-6?1:e=360===n?(e<0?e%n+n:e%n)/parseFloat(String(n)):e%n/parseFloat(String(n))}function Ct(e){return Math.min(1,Math.max(0,e))}function St(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function _t(e){return e<=1?"".concat(100*Number(e),"%"):e}function Mt(e){return 1===e.length?"0"+e:String(e)}function Pt(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=0,i=(r+a)/2;if(r===a)o=0,l=0;else{var s=r-a;switch(o=i>.5?s/(2-r-a):s/(r+a),r){case e:l=(n-t)/s+(n1&&(t-=1),t<1/6?e+6*t*(n-e):t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}function At(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=r,i=r-a,s=0===r?0:i/r;if(r===a)l=0;else{switch(r){case e:l=(n-t)/i+(n>16,g:(65280&e)>>8,b:255&e}}(n)),this.originalInput=n;var a=function(e){var n={r:0,g:0,b:0},t=1,r=null,a=null,l=null,o=!1,i=!1;return"string"==typeof e&&(e=function(e){if(0===(e=e.trim().toLowerCase()).length)return!1;var n=!1;if(Ft[e])e=Ft[e],n=!0;else if("transparent"===e)return{r:0,g:0,b:0,a:0,format:"name"};var t=jt.rgb.exec(e);return t?{r:t[1],g:t[2],b:t[3]}:(t=jt.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=jt.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=jt.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=jt.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=jt.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=jt.hex8.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),a:Rt(t[4]),format:n?"name":"hex8"}:(t=jt.hex6.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),format:n?"name":"hex"}:(t=jt.hex4.exec(e))?{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),a:Rt(t[4]+t[4]),format:n?"name":"hex8"}:!!(t=jt.hex3.exec(e))&&{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),format:n?"name":"hex"}}(e)),"object"==typeof e&&($t(e.r)&&$t(e.g)&&$t(e.b)?(n=function(e,n,t){return{r:255*zt(e,255),g:255*zt(n,255),b:255*zt(t,255)}}(e.r,e.g,e.b),o=!0,i="%"===String(e.r).substr(-1)?"prgb":"rgb"):$t(e.h)&&$t(e.s)&&$t(e.v)?(r=_t(e.s),a=_t(e.v),n=function(e,n,t){e=6*zt(e,360),n=zt(n,100),t=zt(t,100);var r=Math.floor(e),a=e-r,l=t*(1-n),o=t*(1-a*n),i=t*(1-(1-a)*n),s=r%6;return{r:255*[t,o,l,l,i,t][s],g:255*[i,t,t,o,l,l][s],b:255*[l,l,i,t,t,o][s]}}(e.h,r,a),o=!0,i="hsv"):$t(e.h)&&$t(e.s)&&$t(e.l)&&(r=_t(e.s),l=_t(e.l),n=function(e,n,t){var r,a,l;if(e=zt(e,360),n=zt(n,100),t=zt(t,100),0===n)a=t,l=t,r=t;else{var o=t<.5?t*(1+n):t+n-t*n,i=2*t-o;r=Ot(i,o,e+1/3),a=Ot(i,o,e),l=Ot(i,o,e-1/3)}return{r:255*r,g:255*a,b:255*l}}(e.h,r,l),o=!0,i="hsl"),Object.prototype.hasOwnProperty.call(e,"a")&&(t=e.a)),t=St(t),{ok:o,format:e.format||i,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:t}}(n);this.originalInput=n,this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=t.format)&&void 0!==r?r:a.format,this.gradientType=t.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=a.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),n=e.r/255,t=e.g/255,r=e.b/255;return.2126*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=St(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=At(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=At(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsva(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHsl=function(){var e=Pt(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=Pt(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsla(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHex=function(e){return void 0===e&&(e=!1),Lt(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,n,t,r,a){var l=[Mt(Math.round(e).toString(16)),Mt(Math.round(n).toString(16)),Mt(Math.round(t).toString(16)),Mt(Nt(r))];return a&&l[0].startsWith(l[0].charAt(1))&&l[1].startsWith(l[1].charAt(1))&&l[2].startsWith(l[2].charAt(1))&&l[3].startsWith(l[3].charAt(1))?l[0].charAt(0)+l[1].charAt(0)+l[2].charAt(0)+l[3].charAt(0):l.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),n=Math.round(this.g),t=Math.round(this.b);return 1===this.a?"rgb(".concat(e,", ").concat(n,", ").concat(t,")"):"rgba(".concat(e,", ").concat(n,", ").concat(t,", ").concat(this.roundA,")")},e.prototype.toPercentageRgb=function(){var e=function(e){return"".concat(Math.round(100*zt(e,255)),"%")};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*zt(e,255))};return 1===this.a?"rgb(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%)"):"rgba(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%, ").concat(this.roundA,")")},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+Lt(this.r,this.g,this.b,!1),n=0,t=Object.entries(Ft);n=0;return n||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l+=n/100,t.l=Ct(t.l),new e(t)},e.prototype.brighten=function(n){void 0===n&&(n=10);var t=this.toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-n/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-n/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-n/100*255))),new e(t)},e.prototype.darken=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l-=n/100,t.l=Ct(t.l),new e(t)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s-=n/100,t.s=Ct(t.s),new e(t)},e.prototype.saturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s+=n/100,t.s=Ct(t.s),new e(t)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(n){var t=this.toHsl(),r=(t.h+n)%360;return t.h=r<0?360+r:r,new e(t)},e.prototype.mix=function(n,t){void 0===t&&(t=50);var r=this.toRgb(),a=new e(n).toRgb(),l=t/100;return new e({r:(a.r-r.r)*l+r.r,g:(a.g-r.g)*l+r.g,b:(a.b-r.b)*l+r.b,a:(a.a-r.a)*l+r.a})},e.prototype.analogous=function(n,t){void 0===n&&(n=6),void 0===t&&(t=30);var r=this.toHsl(),a=360/t,l=[this];for(r.h=(r.h-(a*n>>1)+720)%360;--n;)r.h=(r.h+a)%360,l.push(new e(r));return l},e.prototype.complement=function(){var n=this.toHsl();return n.h=(n.h+180)%360,new e(n)},e.prototype.monochromatic=function(n){void 0===n&&(n=6);for(var t=this.toHsv(),r=t.h,a=t.s,l=t.v,o=[],i=1/n;n--;)o.push(new e({h:r,s:a,v:l})),l=(l+i)%1;return o},e.prototype.splitcomplement=function(){var n=this.toHsl(),t=n.h;return[this,new e({h:(t+72)%360,s:n.s,l:n.l}),new e({h:(t+216)%360,s:n.s,l:n.l})]},e.prototype.onBackground=function(n){var t=this.toRgb(),r=new e(n).toRgb();return new e({r:r.r+(t.r-r.r)*t.a,g:r.g+(t.g-r.g)*t.a,b:r.b+(t.b-r.b)*t.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(n){for(var t=this.toHsl(),r=t.h,a=[this],l=360/n,o=1;o`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,Bt=e=>{return(n=Vt(e),void 0===n&&(n=""),void 0===t&&(t={}),new Ht(n,t)).toHex8String();var n,t},Wt=({width:e})=>Object.assign({value:e.value,type:e.type},void 0!==e.unit&&{unit:e.unit}),qt=(e,n)=>{if(null!=e)return"color"===n?Vt(e):e},Qt=e=>Object.assign(Object.assign({value:qt(e.value,e.type),type:e.type},void 0!==e.description&&{comment:e.description}),void 0!==e.unit&&{unit:e.unit}),Kt=e=>{Array.isArray(e)&&1===e.length&&(e=e[0]);const n={};return Object.keys(e).forEach((function(t){Object.prototype.hasOwnProperty.call(e[t],"value")?n[t]=Qt(e[t]):n[t]=Kt(e[t])})),1===Object.keys(n).length?Object.values(n)[0]:n},Gt={size:Wt,color:Kt,gradient:Kt,font:Kt,effect:e=>{const n=e.map((e=>["dropShadow","innerShadow"].includes(e.effectType.value)?(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"},color:{value:Vt(e.color.value),type:"color"},offset:{x:{value:e.offset.x.value,type:"number",unit:"pixel"},y:{value:e.offset.y.value,type:"number",unit:"pixel"}},spread:{value:e.spread.value,type:"number",unit:"pixel"}}))(e):(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"}}))(e)));return Array.isArray(n)&&1===n.length?n[0]:n},grid:Kt,border:e=>Object.fromEntries(Object.entries(e).map((([e,n])=>{if("dashPattern"===e){const t=Qt(n);return t.value=t.value.join(", "),[e,t]}return[e,Qt(n)]}))),breakpoint:Wt,radius:Kt,spacing:Kt,motion:e=>Object.assign(Object.assign({type:{value:e.transitionType.value,type:"string"},duration:{value:e.duration.value,type:"number",unit:"s"}},e.direction?{direction:{value:e.direction.value,type:"string"}}:{}),{easing:{value:e.easingType.value.replace("cubicBezier","cubic-bezier"),type:"string"},easingFunction:e.easingFunction}),opacity:({opacity:e})=>({value:e.value,type:e.type})},Yt=(e,n=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof n)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${n}" (${typeof n}) must be of type number`);const t=Math.pow(10,n);return Math.round(e*t)/t},Zt=(e,{excludeExtensionProp:n})=>{if(!0!==n)return{extensions:Object.assign({},e.extensions)}},Xt=e=>"pixel"===e.lineHeight.unit?Yt(e.lineHeight.value,3):"percent"===e.lineHeight.unit?Yt(e.fontSize.value*(e.lineHeight.value/100),3):Yt(1.2*e.fontSize.value,3),Jt=e=>"pixel"===e.letterSpacing.unit?Yt(e.letterSpacing.value,3):"percent"===e.letterSpacing.unit?Yt(e.fontSize.value*(e.letterSpacing.value/100),3):void 0,er=({values:e})=>({value:e.width.value,type:"dimension"}),nr=e=>{var n,t,r;if(e.extensions&&e.extensions[sn.key.extensionPluginData]&&e.extensions[sn.key.extensionPluginData].alias)return{type:Object.hasOwnProperty.call(e.values[0],"fill")?"color":"custom-gradient",value:`{${e.extensions[sn.key.extensionPluginData].alias}}`,blendMode:(null===(r=null===(t=null===(n=e.values[0])||void 0===n?void 0:n.fill)||void 0===t?void 0:t.blendMode)||void 0===r?void 0:r.toLowerCase())||"normal"};const a=e.values.map((e=>Object.hasOwnProperty.call(e,"fill")?(({fill:e})=>{var n;return{type:"color",value:Bt(e.value),blendMode:(null===(n=e.blendMode)||void 0===n?void 0:n.toLowerCase())||"normal"}})(e):(({gradientType:e,rotation:n,stops:t,opacity:r})=>({type:"custom-gradient",value:{gradientType:e.value,rotation:n.value,stops:t.map((e=>({position:e.position.value,color:Bt(Object.assign(Object.assign({},e.color.value),{a:e.color.value.a*r.value}))})))}}))(e)));return 1===a.length?a[0]:Object.assign({},a)},tr={size:er,color:nr,gradient:nr,font:({values:e})=>({type:"custom-fontStyle",value:{fontSize:e.fontSize.value,textDecoration:e.textDecoration.value,fontFamily:e.fontFamily.value,fontWeight:e.fontWeight.value,fontStyle:e.fontStyle.value,fontStretch:e.fontStretch.value,letterSpacing:Jt(e),lineHeight:Xt(e),paragraphIndent:e.paragraphIndent.value,paragraphSpacing:e.paragraphSpacing.value,textCase:e.textCase.value}}),effect:({values:e})=>{const n=e.map((e=>{return["dropShadow","innerShadow"].includes(e.effectType.value)?{type:"custom-shadow",value:{shadowType:(n=e).effectType.value,radius:n.radius.value,color:Bt(n.color.value),offsetX:n.offset.x.value,offsetY:n.offset.y.value,spread:n.spread.value}}:null;var n}));return 1===n.length?n[0]:Object.assign({},n)},grid:({values:e})=>{const n=e.map((e=>({type:"custom-grid",value:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pattern:e.pattern.value},e.sectionSize?{sectionSize:e.sectionSize.value}:{}),e.gutterSize?{gutterSize:e.gutterSize.value}:{}),e.alignment?{alignment:e.alignment.value}:{}),e.count?{count:e.count.value}:{}),e.offset?{offset:e.offset.value}:{})})));return 1===n.length?n[0]:Object.assign({},n)},border:({values:e})=>({type:"custom-stroke",value:{align:e.strokeAlign.value,dashPattern:e.dashPattern.value,lineCap:e.strokeCap.value,lineJoin:e.strokeJoin.value,miterLimit:e.strokeMiterLimit.value,weight:e.strokeWeight.value,color:Bt(e.stroke.value)}}),breakpoint:er,radius:({values:e})=>({type:"custom-radius",value:{smoothing:e.smoothing.value,topLeft:e.radii.topLeft.value,topRight:e.radii.topRight.value,bottomLeft:e.radii.bottomLeft.value,bottomRight:e.radii.bottomRight.value}}),spacing:({values:e})=>({type:"custom-spacing",value:{top:e.top.value,bottom:e.bottom.value,left:e.left.value,right:e.right.value}}),motion:({values:e})=>({type:"custom-transition",value:Object.assign(Object.assign({transitionType:e.transitionType.value,duration:e.duration.value},e.direction?{direction:e.direction.value}:{}),{easingType:e.easingCurveType.value,easingFunction:Object.fromEntries(Object.entries(e.easingFunction).map((e=>[e[0],e[1].value])))})}),opacity:({values:e})=>({value:e.opacity.value,type:"custom-opacity"})},rr=(e,n)=>"typography"===e.category?Object.assign({name:e.name,description:e.description},(({name:e,values:n})=>({fontSize:{type:"dimension",value:n.fontSize.value},textDecoration:{type:"string",value:n.textDecoration.value},fontFamily:{type:"string",value:n.fontFamily.value},fontWeight:{type:"number",value:n.fontWeight.value},fontStyle:{type:"string",value:n.fontStyle.value},fontStretch:{type:"string",value:n.fontStretch.value},letterSpacing:{type:"dimension",value:Jt(n)},lineHeight:{type:"dimension",value:Xt(n)},paragraphIndent:{type:"dimension",value:n.paragraphIndent.value},paragraphSpacing:{type:"dimension",value:n.paragraphSpacing.value},textCase:{type:"string",value:n.textCase.value}}))(e)):"variables"===e.extensions[sn.key.extensionPluginData].exportKey?Object.assign(Object.assign({name:e.name,description:e.description},(({values:e,category:n})=>{var t;return/^{[\w\s\.]*}$/.test(e)?{type:n,value:e}:"color"===n?{type:"color",value:Bt(e.fill.value),blendMode:(null===(t=e.fill.blendMode)||void 0===t?void 0:t.toLowerCase())||"normal"}:["dimension","boolean","string"].includes(n)?{type:n,value:e}:void 0})(e)),Zt(e,n)):Object.assign(Object.assign({name:e.name,description:e.description},(e=>tr[e.category](e))(e)),Zt(e,n)),ar=(e,n)=>{const t=e=>e&&"object"==typeof e;return t(e)&&t(n)?(Object.keys(n).forEach((r=>{const a=e[r],l=n[r];Array.isArray(a)&&Array.isArray(l)?e[r]=a.concat(l):t(a)&&t(l)?e[r]=ar(Object.assign({},a),l):e[r]=l})),e):n},lr=ar,or=(e,n,t)=>{if("string"==typeof e&&""!==e)return e;throw new Error(`converting "${n}" to ${t}, resulting in "${e}"`)},ir=(e,n="default")=>"camelCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ (.)/g,(function(e){return e.toUpperCase()})).replace(/ /g,"");return or(n,e,"camelCase")})(e):"kebabCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ /g,"-");return or(n,e,"kebabCase")})(e):e.trim().toLowerCase(),sr={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Font Styles",key:"font"},typography:{label:"Typography",key:"typography",exclude:["original"]},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"},opacity:{label:"Opacity",key:"opacity"},variables:{label:"Figma Variables (BETA)",key:"variables",exclude:["original"]}},ur=e=>{var n,t;return void 0!==(null===(t=null===(n=e.extensions)||void 0===n?void 0:n[sn.key.extensionPluginData])||void 0===t?void 0:t.exportKey)?e.extensions[sn.key.extensionPluginData].exportKey:"missingExportKey"},cr={original:(e,n)=>"variables"===e.extensions[sn.key.extensionPluginData].exportKey?null:Object.assign(Object.assign({name:e.name,category:e.category,exportKey:e.extensions[sn.key.extensionPluginData].exportKey},e.description&&e.description.length>0&&{comment:e.description}),Gt[e.category](e.values)||{}),standard:rr,standardDeprecated:rr},dr=(e,n)=>"standard"===n.tokenFormat?JSON.parse(JSON.stringify(e.filter((e=>e.category===sr.font.key)))).map((e=>(e.name="typography/"+e.name.substr(e.name.indexOf("/")+1).trim().trimStart(),e.category=sr.typography.key,e.exportKey=sr.typography.key,!0!==n.excludeExtensionProp&&(e.extensions[sn.key.extensionPluginData].exportKey=sr.typography.key),e))):[],fr=(e,n)=>{0===e.length&&(e="[{}]");let t=JSON.parse(e);t=[...t,...dr(t,n)];const r=((e,n)=>e.length<=0?[]:e.map((e=>{var t,r,a,l;if(!1===n.prefixInName)e.name=e.name.substr(e.name.indexOf("/")+1).trim().trimLeft();else if(void 0!==(null===(r=null===(t=e.extensions)||void 0===t?void 0:t[sn.key.extensionPluginData])||void 0===r?void 0:r.alias)){const n=e.name.substr(0,e.name.indexOf("/")).trim().trimLeft();e.extensions[sn.key.extensionPluginData].alias=`${n}.${e.extensions[sn.key.extensionPluginData].alias}`}return n.keyInName&&(e.name=`${ur(e)}/${e.name}`,void 0!==(null===(l=null===(a=e.extensions)||void 0===a?void 0:a[sn.key.extensionPluginData])||void 0===l?void 0:l.alias)&&(e.extensions[sn.key.extensionPluginData].alias=`${ur(e)}.${e.extensions[sn.key.extensionPluginData].alias}`)),e})))(t.filter((({exportKey:e})=>n.exports[e])),n),a=r.map((e=>cr[n.tokenFormat](e,n))).filter(Boolean),l=((e,n)=>{if(e.length<=0)return[];const t=e.map((e=>{const t=e.name.split("/").map((e=>ir(e,n.nameConversion)));return delete e.name,r=e,t.reduceRight(((e,n)=>({[n]:e})),r);var r}));return t.reduce(((e={},n)=>lr(e,n)))})(a,n);return l},pr=(e,n=!0)=>!0===n?JSON.stringify(e):JSON.stringify(e,null,2);const gr=je` +`,kt=({versionDifference:n})=>"major"!==n&&"minor"!==n?e.createElement(e.Fragment,null):e.createElement("div",{id:"versionNotice",className:wt},e.createElement("div",{className:"icon"},"🎉"),e.createElement("div",null,"The ",e.createElement("a",{className:"subtle",href:"https://www.figma.com/community/plugin/888356646278934516/Design-Tokens",target:"_blank",rel:"noreferrer"},"Design Token plugin")," was updated.",e.createElement("br",null),"Find out about changes & new features in the ",e.createElement("a",{href:"https://github.com/lukasoppermann/design-tokens/releases",target:"_blank",rel:"noreferrer"},"release notes →"))),Et={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",contentType:"text/plain;charset=UTF-8",authType:"token",reference:"main",exclusionPrefix:"",excludeExtensionProp:!1,alias:"alias, ref, reference",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",typography:"typography",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion",opacity:"opacity, opacities"},exports:{color:!0,gradient:!0,font:!0,typography:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0,opacity:!0,variables:!0}};function zt(e,n){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===n?e:Math.min(n,Math.max(0,parseFloat(e))),t&&(e=parseInt(String(e*n),10)/100),Math.abs(e-n)<1e-6?1:e=360===n?(e<0?e%n+n:e%n)/parseFloat(String(n)):e%n/parseFloat(String(n))}function Ct(e){return Math.min(1,Math.max(0,e))}function St(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function _t(e){return e<=1?"".concat(100*Number(e),"%"):e}function Mt(e){return 1===e.length?"0"+e:String(e)}function Pt(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=0,i=(r+a)/2;if(r===a)o=0,l=0;else{var s=r-a;switch(o=i>.5?s/(2-r-a):s/(r+a),r){case e:l=(n-t)/s+(n1&&(t-=1),t<1/6?e+6*t*(n-e):t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}function At(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=r,i=r-a,s=0===r?0:i/r;if(r===a)l=0;else{switch(r){case e:l=(n-t)/i+(n>16,g:(65280&e)>>8,b:255&e}}(n)),this.originalInput=n;var a=function(e){var n={r:0,g:0,b:0},t=1,r=null,a=null,l=null,o=!1,i=!1;return"string"==typeof e&&(e=function(e){if(0===(e=e.trim().toLowerCase()).length)return!1;var n=!1;if(Ft[e])e=Ft[e],n=!0;else if("transparent"===e)return{r:0,g:0,b:0,a:0,format:"name"};var t=jt.rgb.exec(e);return t?{r:t[1],g:t[2],b:t[3]}:(t=jt.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=jt.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=jt.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=jt.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=jt.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=jt.hex8.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),a:Rt(t[4]),format:n?"name":"hex8"}:(t=jt.hex6.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),format:n?"name":"hex"}:(t=jt.hex4.exec(e))?{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),a:Rt(t[4]+t[4]),format:n?"name":"hex8"}:!!(t=jt.hex3.exec(e))&&{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),format:n?"name":"hex"}}(e)),"object"==typeof e&&($t(e.r)&&$t(e.g)&&$t(e.b)?(n=function(e,n,t){return{r:255*zt(e,255),g:255*zt(n,255),b:255*zt(t,255)}}(e.r,e.g,e.b),o=!0,i="%"===String(e.r).substr(-1)?"prgb":"rgb"):$t(e.h)&&$t(e.s)&&$t(e.v)?(r=_t(e.s),a=_t(e.v),n=function(e,n,t){e=6*zt(e,360),n=zt(n,100),t=zt(t,100);var r=Math.floor(e),a=e-r,l=t*(1-n),o=t*(1-a*n),i=t*(1-(1-a)*n),s=r%6;return{r:255*[t,o,l,l,i,t][s],g:255*[i,t,t,o,l,l][s],b:255*[l,l,i,t,t,o][s]}}(e.h,r,a),o=!0,i="hsv"):$t(e.h)&&$t(e.s)&&$t(e.l)&&(r=_t(e.s),l=_t(e.l),n=function(e,n,t){var r,a,l;if(e=zt(e,360),n=zt(n,100),t=zt(t,100),0===n)a=t,l=t,r=t;else{var o=t<.5?t*(1+n):t+n-t*n,i=2*t-o;r=Ot(i,o,e+1/3),a=Ot(i,o,e),l=Ot(i,o,e-1/3)}return{r:255*r,g:255*a,b:255*l}}(e.h,r,l),o=!0,i="hsl"),Object.prototype.hasOwnProperty.call(e,"a")&&(t=e.a)),t=St(t),{ok:o,format:e.format||i,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:t}}(n);this.originalInput=n,this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=t.format)&&void 0!==r?r:a.format,this.gradientType=t.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=a.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),n=e.r/255,t=e.g/255,r=e.b/255;return.2126*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=St(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=At(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=At(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsva(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHsl=function(){var e=Pt(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=Pt(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsla(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHex=function(e){return void 0===e&&(e=!1),Lt(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,n,t,r,a){var l=[Mt(Math.round(e).toString(16)),Mt(Math.round(n).toString(16)),Mt(Math.round(t).toString(16)),Mt(Nt(r))];return a&&l[0].startsWith(l[0].charAt(1))&&l[1].startsWith(l[1].charAt(1))&&l[2].startsWith(l[2].charAt(1))&&l[3].startsWith(l[3].charAt(1))?l[0].charAt(0)+l[1].charAt(0)+l[2].charAt(0)+l[3].charAt(0):l.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),n=Math.round(this.g),t=Math.round(this.b);return 1===this.a?"rgb(".concat(e,", ").concat(n,", ").concat(t,")"):"rgba(".concat(e,", ").concat(n,", ").concat(t,", ").concat(this.roundA,")")},e.prototype.toPercentageRgb=function(){var e=function(e){return"".concat(Math.round(100*zt(e,255)),"%")};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*zt(e,255))};return 1===this.a?"rgb(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%)"):"rgba(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%, ").concat(this.roundA,")")},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+Lt(this.r,this.g,this.b,!1),n=0,t=Object.entries(Ft);n=0;return n||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l+=n/100,t.l=Ct(t.l),new e(t)},e.prototype.brighten=function(n){void 0===n&&(n=10);var t=this.toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-n/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-n/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-n/100*255))),new e(t)},e.prototype.darken=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l-=n/100,t.l=Ct(t.l),new e(t)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s-=n/100,t.s=Ct(t.s),new e(t)},e.prototype.saturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s+=n/100,t.s=Ct(t.s),new e(t)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(n){var t=this.toHsl(),r=(t.h+n)%360;return t.h=r<0?360+r:r,new e(t)},e.prototype.mix=function(n,t){void 0===t&&(t=50);var r=this.toRgb(),a=new e(n).toRgb(),l=t/100;return new e({r:(a.r-r.r)*l+r.r,g:(a.g-r.g)*l+r.g,b:(a.b-r.b)*l+r.b,a:(a.a-r.a)*l+r.a})},e.prototype.analogous=function(n,t){void 0===n&&(n=6),void 0===t&&(t=30);var r=this.toHsl(),a=360/t,l=[this];for(r.h=(r.h-(a*n>>1)+720)%360;--n;)r.h=(r.h+a)%360,l.push(new e(r));return l},e.prototype.complement=function(){var n=this.toHsl();return n.h=(n.h+180)%360,new e(n)},e.prototype.monochromatic=function(n){void 0===n&&(n=6);for(var t=this.toHsv(),r=t.h,a=t.s,l=t.v,o=[],i=1/n;n--;)o.push(new e({h:r,s:a,v:l})),l=(l+i)%1;return o},e.prototype.splitcomplement=function(){var n=this.toHsl(),t=n.h;return[this,new e({h:(t+72)%360,s:n.s,l:n.l}),new e({h:(t+216)%360,s:n.s,l:n.l})]},e.prototype.onBackground=function(n){var t=this.toRgb(),r=new e(n).toRgb();return new e({r:r.r+(t.r-r.r)*t.a,g:r.g+(t.g-r.g)*t.a,b:r.b+(t.b-r.b)*t.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(n){for(var t=this.toHsl(),r=t.h,a=[this],l=360/n,o=1;o`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,Bt=e=>{return(n=Vt(e),void 0===n&&(n=""),void 0===t&&(t={}),new Ht(n,t)).toHex8String();var n,t},Wt=({width:e})=>Object.assign({value:e.value,type:e.type},void 0!==e.unit&&{unit:e.unit}),qt=(e,n)=>{if(null!=e)return"color"===n?Vt(e):e},Qt=e=>Object.assign(Object.assign({value:qt(e.value,e.type),type:e.type},void 0!==e.description&&{comment:e.description}),void 0!==e.unit&&{unit:e.unit}),Kt=e=>{Array.isArray(e)&&1===e.length&&(e=e[0]);const n={};return Object.keys(e).forEach((function(t){Object.prototype.hasOwnProperty.call(e[t],"value")?n[t]=Qt(e[t]):n[t]=Kt(e[t])})),1===Object.keys(n).length?Object.values(n)[0]:n},Gt={size:Wt,color:Kt,gradient:Kt,font:Kt,effect:e=>{const n=e.map((e=>["dropShadow","innerShadow"].includes(e.effectType.value)?(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"},color:{value:Vt(e.color.value),type:"color"},offset:{x:{value:e.offset.x.value,type:"number",unit:"pixel"},y:{value:e.offset.y.value,type:"number",unit:"pixel"}},spread:{value:e.spread.value,type:"number",unit:"pixel"}}))(e):(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"}}))(e)));return Array.isArray(n)&&1===n.length?n[0]:n},grid:Kt,border:e=>Object.fromEntries(Object.entries(e).map((([e,n])=>{if("dashPattern"===e){const t=Qt(n);return t.value=t.value.join(", "),[e,t]}return[e,Qt(n)]}))),breakpoint:Wt,radius:Kt,spacing:Kt,motion:e=>Object.assign(Object.assign({type:{value:e.transitionType.value,type:"string"},duration:{value:e.duration.value,type:"number",unit:"s"}},e.direction?{direction:{value:e.direction.value,type:"string"}}:{}),{easing:{value:e.easingType.value.replace("cubicBezier","cubic-bezier"),type:"string"},easingFunction:e.easingFunction}),opacity:({opacity:e})=>({value:e.value,type:e.type})},Yt=(e,n=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof n)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${n}" (${typeof n}) must be of type number`);const t=Math.pow(10,n);return Math.round(e*t)/t},Zt=(e,{excludeExtensionProp:n})=>{if(!0!==n)return{extensions:Object.assign({},e.extensions)}},Xt=(e,n="/",t=".")=>e.split(n).join(t).toLowerCase(),Jt=e=>"pixel"===e.lineHeight.unit?Yt(e.lineHeight.value,3):"percent"===e.lineHeight.unit?Yt(e.fontSize.value*(e.lineHeight.value/100),3):Yt(1.2*e.fontSize.value,3),er=e=>"pixel"===e.letterSpacing.unit?Yt(e.letterSpacing.value,3):"percent"===e.letterSpacing.unit?Yt(e.fontSize.value*(e.letterSpacing.value/100),3):void 0,nr=({values:e})=>({value:e.width.value,type:"dimension"}),tr=e=>{var n,t,r;if(e.extensions&&e.extensions[sn.key.extensionPluginData]&&e.extensions[sn.key.extensionPluginData].alias)return{type:Object.hasOwnProperty.call(e.values[0],"fill")?"color":"custom-gradient",value:`{${e.extensions[sn.key.extensionPluginData].alias}}`,blendMode:(null===(r=null===(t=null===(n=e.values[0])||void 0===n?void 0:n.fill)||void 0===t?void 0:t.blendMode)||void 0===r?void 0:r.toLowerCase())||"normal"};const a=e.values.map((e=>Object.hasOwnProperty.call(e,"fill")?(({fill:e})=>{var n;return{type:"color",value:Bt(e.value),blendMode:(null===(n=e.blendMode)||void 0===n?void 0:n.toLowerCase())||"normal"}})(e):(({gradientType:e,rotation:n,stops:t,opacity:r})=>({type:"custom-gradient",value:{gradientType:e.value,rotation:n.value,stops:t.map((e=>({position:e.position.value,color:Bt(Object.assign(Object.assign({},e.color.value),{a:e.color.value.a*r.value}))})))}}))(e)));return 1===a.length?a[0]:Object.assign({},a)},rr={size:nr,color:tr,gradient:tr,font:({values:e})=>({type:"custom-fontStyle",value:{fontSize:e.fontSize.value,textDecoration:e.textDecoration.value,fontFamily:e.fontFamily.value,fontWeight:e.fontWeight.value,fontStyle:e.fontStyle.value,fontStretch:e.fontStretch.value,letterSpacing:er(e),lineHeight:Jt(e),paragraphIndent:e.paragraphIndent.value,paragraphSpacing:e.paragraphSpacing.value,textCase:e.textCase.value}}),effect:({values:e})=>{const n=e.map((e=>{return["dropShadow","innerShadow"].includes(e.effectType.value)?{type:"custom-shadow",value:{shadowType:(n=e).effectType.value,radius:n.radius.value,color:Bt(n.color.value),offsetX:n.offset.x.value,offsetY:n.offset.y.value,spread:n.spread.value}}:null;var n}));return 1===n.length?n[0]:Object.assign({},n)},grid:({values:e})=>{const n=e.map((e=>({type:"custom-grid",value:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pattern:e.pattern.value},e.sectionSize?{sectionSize:e.sectionSize.value}:{}),e.gutterSize?{gutterSize:e.gutterSize.value}:{}),e.alignment?{alignment:e.alignment.value}:{}),e.count?{count:e.count.value}:{}),e.offset?{offset:e.offset.value}:{})})));return 1===n.length?n[0]:Object.assign({},n)},border:({values:e})=>({type:"custom-stroke",value:{align:e.strokeAlign.value,dashPattern:e.dashPattern.value,lineCap:e.strokeCap.value,lineJoin:e.strokeJoin.value,miterLimit:e.strokeMiterLimit.value,weight:e.strokeWeight.value,color:Bt(e.stroke.value)}}),breakpoint:nr,radius:({values:e})=>({type:"custom-radius",value:{smoothing:e.smoothing.value,topLeft:e.radii.topLeft.value,topRight:e.radii.topRight.value,bottomLeft:e.radii.bottomLeft.value,bottomRight:e.radii.bottomRight.value}}),spacing:({values:e})=>({type:"custom-spacing",value:{top:e.top.value,bottom:e.bottom.value,left:e.left.value,right:e.right.value}}),motion:({values:e})=>({type:"custom-transition",value:Object.assign(Object.assign({transitionType:e.transitionType.value,duration:e.duration.value},e.direction?{direction:e.direction.value}:{}),{easingType:e.easingCurveType.value,easingFunction:Object.fromEntries(Object.entries(e.easingFunction).map((e=>[e[0],e[1].value])))})}),opacity:({values:e})=>({value:e.opacity.value,type:"custom-opacity"})},ar=(e,n)=>"typography"===e.category?Object.assign({name:e.name,description:e.description},(({name:e,values:n})=>({fontSize:{type:"dimension",value:n.fontSize.value},textDecoration:{type:"string",value:n.textDecoration.value},fontFamily:{type:"string",value:n.fontFamily.value},fontWeight:{type:"number",value:n.fontWeight.value},fontStyle:{type:"string",value:n.fontStyle.value},fontStretch:{type:"string",value:n.fontStretch.value},letterSpacing:{type:"dimension",value:er(n)},lineHeight:{type:"dimension",value:Jt(n)},paragraphIndent:{type:"dimension",value:n.paragraphIndent.value},paragraphSpacing:{type:"dimension",value:n.paragraphSpacing.value},textCase:{type:"string",value:n.textCase.value}}))(e)):"variables"===e.extensions[sn.key.extensionPluginData].exportKey?Object.assign(Object.assign({name:e.name,description:e.description},(({values:e,category:n})=>{var t;const r=/^{[\w\s\.\-\_\/\@\+\&\:]*}$/;return console.log(e,r.test(e)),r.test(e)?{type:n,value:Xt(e,"/",".")}:"color"===n?{type:"color",value:Bt(e.fill.value),blendMode:(null===(t=e.fill.blendMode)||void 0===t?void 0:t.toLowerCase())||"normal"}:["dimension","boolean","string"].includes(n)?{type:n,value:e}:void 0})(e)),Zt(e,n)):Object.assign(Object.assign({name:e.name,description:e.description},(e=>rr[e.category](e))(e)),Zt(e,n)),lr=(e,n)=>{const t=e=>e&&"object"==typeof e;return t(e)&&t(n)?(Object.keys(n).forEach((r=>{const a=e[r],l=n[r];Array.isArray(a)&&Array.isArray(l)?e[r]=a.concat(l):t(a)&&t(l)?e[r]=lr(Object.assign({},a),l):e[r]=l})),e):n},or=lr,ir=(e,n,t)=>{if("string"==typeof e&&""!==e)return e;throw new Error(`converting "${n}" to ${t}, resulting in "${e}"`)},sr=(e,n="default")=>"camelCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ (.)/g,(function(e){return e.toUpperCase()})).replace(/ /g,"");return ir(n,e,"camelCase")})(e):"kebabCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ /g,"-");return ir(n,e,"kebabCase")})(e):e.trim().toLowerCase(),ur={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Font Styles",key:"font"},typography:{label:"Typography",key:"typography",exclude:["original"]},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"},opacity:{label:"Opacity",key:"opacity"},variables:{label:"Figma Variables (BETA)",key:"variables",exclude:["original"]}},cr=e=>{var n,t;return void 0!==(null===(t=null===(n=e.extensions)||void 0===n?void 0:n[sn.key.extensionPluginData])||void 0===t?void 0:t.exportKey)?e.extensions[sn.key.extensionPluginData].exportKey:"missingExportKey"},dr={original:(e,n)=>"variables"===e.extensions[sn.key.extensionPluginData].exportKey?null:Object.assign(Object.assign({name:e.name,category:e.category,exportKey:e.extensions[sn.key.extensionPluginData].exportKey},e.description&&e.description.length>0&&{comment:e.description}),Gt[e.category](e.values)||{}),standard:ar,standardDeprecated:ar},fr=(e,n)=>"standard"===n.tokenFormat?JSON.parse(JSON.stringify(e.filter((e=>e.category===ur.font.key)))).map((e=>(e.name="typography/"+e.name.substr(e.name.indexOf("/")+1).trim().trimStart(),e.category=ur.typography.key,e.exportKey=ur.typography.key,!0!==n.excludeExtensionProp&&(e.extensions[sn.key.extensionPluginData].exportKey=ur.typography.key),e))):[],pr=(e,n)=>{0===e.length&&(e="[{}]");let t=JSON.parse(e);t=[...t,...fr(t,n)];const r=((e,n)=>e.length<=0?[]:e.map((e=>{var t,r,a,l;if(!1===n.prefixInName)e.name=e.name.substr(e.name.indexOf("/")+1).trim().trimLeft();else if(void 0!==(null===(r=null===(t=e.extensions)||void 0===t?void 0:t[sn.key.extensionPluginData])||void 0===r?void 0:r.alias)){const n=e.name.substr(0,e.name.indexOf("/")).trim().trimLeft();e.extensions[sn.key.extensionPluginData].alias=`${n}.${e.extensions[sn.key.extensionPluginData].alias}`}return n.keyInName&&(e.name=`${cr(e)}/${e.name}`,void 0!==(null===(l=null===(a=e.extensions)||void 0===a?void 0:a[sn.key.extensionPluginData])||void 0===l?void 0:l.alias)&&(e.extensions[sn.key.extensionPluginData].alias=`${cr(e)}.${e.extensions[sn.key.extensionPluginData].alias}`)),e})))(t.filter((({exportKey:e})=>n.exports[e])),n),a=r.map((e=>dr[n.tokenFormat](e,n))).filter(Boolean),l=((e,n)=>{if(e.length<=0)return[];const t=e.map((e=>{const t=e.name.split("/").map((e=>sr(e,n.nameConversion)));return delete e.name,r=e,t.reduceRight(((e,n)=>({[n]:e})),r);var r}));return t.reduce(((e={},n)=>or(e,n)))})(a,n);return l},gr=(e,n=!0)=>!0===n?JSON.stringify(e):JSON.stringify(e,null,2);const hr=je` display: flex; flex-direction: column; h1:first-child { @@ -647,7 +647,7 @@ display: grid; grid-template-columns: repeat(3, 1fr); } -`,hr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),o=(0,e.useRef)();return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{if("[]"!==t)try{n.href=`data:application/design-tokens+json;charset=utf-8,${encodeURIComponent(t)}`,n.click(),e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🎉 Design token export successful!"}}},"*")}catch(n){e.postMessage({pluginMessage:{payload:{notification:"⛔️ Design token failed!"}}},"*"),console.error("Export error: ",n)}else e.postMessage({pluginMessage:{payload:{notification:"⛔️ No design token detected!"}}},"*")})(parent,o.current,pr(i,t.compression))}},className:gr},e.createElement(Je,{size:"xlarge",weight:"bold"},"File Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output file",type:"switch",checked:n.compression,onChange:e=>t((n=>{n.compression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"}),"standard"===n.tokenFormat&&e.createElement(e.Fragment,null,e.createElement(Be,{label:"Exclude extension property",type:"switch",checked:n.excludeExtensionProp,onChange:e=>t((n=>{n.excludeExtensionProp=e}))}),e.createElement(gn,{width:240,label:"The extension property holds additional information about the token"}))),e.createElement(Je,{size:"large",weight:"bold"},"Include types in export"),e.createElement("div",{className:"grid-3-col"},Object.entries(sr).map((([,{key:r,label:a,exclude:l}])=>(void 0===l||!l.includes(n.tokenFormat))&&e.createElement(Be,{key:r,label:a,checked:n.exports[r],onChange:e=>t((n=>{n.exports[r]=e}))})))),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")),e.createElement("a",{ref:o,download:`${n.filename}${n.extension}`,title:`${n.filename}${n.extension}`}))},mr=e=>401===e.status?"🚨 401: Check your access token":404===e.status?"🚨 404: Check your server url, auth type and the access token":e.status>399?`🚨 ${e.status}: An error occurred, please check the console for details.`:"🎉 Design tokens pushed to server!",vr=e=>{e.onerror=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 An error occurred while sending the tokens: check your settings & your server."}}},"*")},e.onload=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:mr(e.target)}}},"*")}};const br=je` +`,mr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),o=(0,e.useRef)();return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{if("[]"!==t)try{n.href=`data:application/design-tokens+json;charset=utf-8,${encodeURIComponent(t)}`,n.click(),e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🎉 Design token export successful!"}}},"*")}catch(n){e.postMessage({pluginMessage:{payload:{notification:"⛔️ Design token failed!"}}},"*"),console.error("Export error: ",n)}else e.postMessage({pluginMessage:{payload:{notification:"⛔️ No design token detected!"}}},"*")})(parent,o.current,gr(i,t.compression))}},className:hr},e.createElement(Je,{size:"xlarge",weight:"bold"},"File Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output file",type:"switch",checked:n.compression,onChange:e=>t((n=>{n.compression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"}),"standard"===n.tokenFormat&&e.createElement(e.Fragment,null,e.createElement(Be,{label:"Exclude extension property",type:"switch",checked:n.excludeExtensionProp,onChange:e=>t((n=>{n.excludeExtensionProp=e}))}),e.createElement(gn,{width:240,label:"The extension property holds additional information about the token"}))),e.createElement(Je,{size:"large",weight:"bold"},"Include types in export"),e.createElement("div",{className:"grid-3-col"},Object.entries(ur).map((([,{key:r,label:a,exclude:l}])=>(void 0===l||!l.includes(n.tokenFormat))&&e.createElement(Be,{key:r,label:a,checked:n.exports[r],onChange:e=>t((n=>{n.exports[r]=e}))})))),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")),e.createElement("a",{ref:o,download:`${n.filename}${n.extension}`,title:`${n.filename}${n.extension}`}))},vr=e=>401===e.status?"🚨 401: Check your access token":404===e.status?"🚨 404: Check your server url, auth type and the access token":e.status>399?`🚨 ${e.status}: An error occurred, please check the console for details.`:"🎉 Design tokens pushed to server!",br=e=>{e.onerror=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 An error occurred while sending the tokens: check your settings & your server."}}},"*")},e.onload=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:vr(e.target)}}},"*")}};const yr=je` display: flex; flex-direction: column; h1:first-child { @@ -657,10 +657,10 @@ display: grid; grid-template-columns: repeat(3, 1fr); } -`,yr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),[o,i]=(0,e.useState)("");return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{""===n.url&&e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 No server url was provided, push aborted!"}}},"*");const r=new XMLHttpRequest;r.open("POST",n.url),((e,n)=>{n.authType!==sn.key.authType.gitlabToken&&(e.setRequestHeader("Accept",n.acceptHeader||"application/vnd.github.everest-preview+json"),e.setRequestHeader("Content-Type",n.contentType||"text/plain;charset=UTF-8")),""!==n.accessToken&&""!==n.authType&&n.authType!==sn.key.authType.gitlabToken&&e.setRequestHeader("Authorization",`${n.authType} ${n.accessToken}`)})(r,n),vr(r);const a=((e,n)=>{let t;return e.authType===sn.key.authType.gitlabToken?(t=new FormData,t.append("token",e.accessToken),t.append("ref",e.reference),t.append("variables[FIGMA_EVENT_TYPE]",n.event_type),t.append("variables[FIGMA_CLIENT_PAYLOAD_TOKENS]",n.client_payload.tokens),t.append("variables[FIGMA_CLIENT_PAYLOAD_FILENAME]",n.client_payload.filename),t.append("variables[FIGMA_CLIENT_PAYLOAD_COMMIT_MESSAGE]",n.client_payload.commitMessage)):t=JSON.stringify(n,null,2),t})(n,t);r.send(a)})(parent,{url:n.serverUrl,accessToken:n.accessToken,acceptHeader:n.acceptHeader,contentType:n.contentType,authType:n.authType,reference:n.reference},{event_type:n.eventType,client_payload:{tokens:`${pr(i,n.urlJsonCompression)}`,filename:`${n.filename}${n.extension}`,commitMessage:`${o}`}})}},className:br},e.createElement(Je,{size:"xlarge",weight:"bold"},"URL Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output",type:"switch",checked:n.urlJsonCompression,onChange:e=>t((n=>{n.urlJsonCompression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"})),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"Server settings"),e.createElement("h3",null,"Event type",e.createElement(gn,{width:150,label:'"event_type" property in post request'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^[\\w\\-\\.\\+@]+$",placeholder:"update-tokens",value:n.eventType,onChange:e=>t((n=>{n.eventType=e}))})),e.createElement("h3",null,"Server url",e.createElement(gn,{width:150,label:"Url the request is sent to, must be https"})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^https://.*",placeholder:"https://api.github.com/repos/:username/:repo/dispatches",value:n.serverUrl,onChange:e=>t((n=>{n.serverUrl=e}))})),e.createElement("h3",null,"Accept header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"application/vnd.github.v3+json",value:n.acceptHeader,onChange:e=>t((n=>{n.acceptHeader=e}))})),e.createElement("h3",null,"Content-Type header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"text/plain;charset=UTF-8",value:n.contentType,onChange:e=>t((n=>{n.contentType=e}))})),e.createElement("h3",null,"Auth type"),e.createElement(fn,{fill:!0},e.createElement(Ge,{defaultValue:n.authType,onChange:({value:e})=>t((n=>{n.authType=e})),placeholder:"Auth type",options:[{label:"(Github) token",value:sn.key.authType.token},{label:"(Gitlab) token",value:sn.key.authType.gitlabToken},{label:"Basic authentication",value:sn.key.authType.basic},{label:"Bearer token authentication",value:sn.key.authType.bearer}]})),e.createElement("h3",null,"Access token"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"Your access token",value:n.accessToken,onChange:e=>t((n=>{n.accessToken=e}))})),n.authType===sn.key.authType.gitlabToken&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Reference",e.createElement(gn,{width:150,label:'The branch or commit to associate with a Gitlab trigger. Only used when Gitlab is selected for "Auth type"'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"main",value:n.reference,onChange:e=>t((n=>{n.reference=e}))}))),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"About This Export"),e.createElement("h3",null,"Commit Message",e.createElement(gn,{width:200,label:'Typically this will be a "commit message" for Git. Your organization may require a specific convention for these messages.'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",placeholder:"Describe what has changed since the last export",value:o,onChange:e=>i(e)})),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")))},xr=parent,wr=je` +`,xr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),[o,i]=(0,e.useState)("");return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{""===n.url&&e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 No server url was provided, push aborted!"}}},"*");const r=new XMLHttpRequest;r.open("POST",n.url),((e,n)=>{n.authType!==sn.key.authType.gitlabToken&&(e.setRequestHeader("Accept",n.acceptHeader||"application/vnd.github.everest-preview+json"),e.setRequestHeader("Content-Type",n.contentType||"text/plain;charset=UTF-8")),""!==n.accessToken&&""!==n.authType&&n.authType!==sn.key.authType.gitlabToken&&e.setRequestHeader("Authorization",`${n.authType} ${n.accessToken}`)})(r,n),br(r);const a=((e,n)=>{let t;return e.authType===sn.key.authType.gitlabToken?(t=new FormData,t.append("token",e.accessToken),t.append("ref",e.reference),t.append("variables[FIGMA_EVENT_TYPE]",n.event_type),t.append("variables[FIGMA_CLIENT_PAYLOAD_TOKENS]",n.client_payload.tokens),t.append("variables[FIGMA_CLIENT_PAYLOAD_FILENAME]",n.client_payload.filename),t.append("variables[FIGMA_CLIENT_PAYLOAD_COMMIT_MESSAGE]",n.client_payload.commitMessage)):t=JSON.stringify(n,null,2),t})(n,t);r.send(a)})(parent,{url:n.serverUrl,accessToken:n.accessToken,acceptHeader:n.acceptHeader,contentType:n.contentType,authType:n.authType,reference:n.reference},{event_type:n.eventType,client_payload:{tokens:`${gr(i,n.urlJsonCompression)}`,filename:`${n.filename}${n.extension}`,commitMessage:`${o}`}})}},className:yr},e.createElement(Je,{size:"xlarge",weight:"bold"},"URL Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output",type:"switch",checked:n.urlJsonCompression,onChange:e=>t((n=>{n.urlJsonCompression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"})),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"Server settings"),e.createElement("h3",null,"Event type",e.createElement(gn,{width:150,label:'"event_type" property in post request'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^[\\w\\-\\.\\+@]+$",placeholder:"update-tokens",value:n.eventType,onChange:e=>t((n=>{n.eventType=e}))})),e.createElement("h3",null,"Server url",e.createElement(gn,{width:150,label:"Url the request is sent to, must be https"})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^https://.*",placeholder:"https://api.github.com/repos/:username/:repo/dispatches",value:n.serverUrl,onChange:e=>t((n=>{n.serverUrl=e}))})),e.createElement("h3",null,"Accept header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"application/vnd.github.v3+json",value:n.acceptHeader,onChange:e=>t((n=>{n.acceptHeader=e}))})),e.createElement("h3",null,"Content-Type header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"text/plain;charset=UTF-8",value:n.contentType,onChange:e=>t((n=>{n.contentType=e}))})),e.createElement("h3",null,"Auth type"),e.createElement(fn,{fill:!0},e.createElement(Ge,{defaultValue:n.authType,onChange:({value:e})=>t((n=>{n.authType=e})),placeholder:"Auth type",options:[{label:"(Github) token",value:sn.key.authType.token},{label:"(Gitlab) token",value:sn.key.authType.gitlabToken},{label:"Basic authentication",value:sn.key.authType.basic},{label:"Bearer token authentication",value:sn.key.authType.bearer}]})),e.createElement("h3",null,"Access token"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"Your access token",value:n.accessToken,onChange:e=>t((n=>{n.accessToken=e}))})),n.authType===sn.key.authType.gitlabToken&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Reference",e.createElement(gn,{width:150,label:'The branch or commit to associate with a Gitlab trigger. Only used when Gitlab is selected for "Auth type"'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"main",value:n.reference,onChange:e=>t((n=>{n.reference=e}))}))),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"About This Export"),e.createElement("h3",null,"Commit Message",e.createElement(gn,{width:200,label:'Typically this will be a "commit message" for Git. Your organization may require a specific convention for these messages.'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",placeholder:"Describe what has changed since the last export",value:o,onChange:e=>i(e)})),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")))},wr=parent,kr=je` padding: 8px var(--size-xxsmall) 0; margin-bottom: 0; form { margin-bottom: 0; } -`;(0,n.s)(document.getElementById("pluginUI")).render(e.createElement((()=>{const[n,t]=(0,e.useState)(null),[r,a]=(0,e.useState)(null),[l,o]=(0,e.useState)(null),[i,s]=(0,e.useState)(null),[u,c]=function(n){var t=(0,e.useState)((function(){return Tn("function"==typeof n?n():n,!0)})),r=t[1];return[t[0],(0,e.useCallback)((function(e){r("function"==typeof e?xt(e):Tn(e))}),[])]}(Et);return onmessage=e=>{const{command:n,payload:r}=e.data.pluginMessage||{};[tn.urlExport,tn.export,tn.generalSettings].includes(n)&&(c(Object.assign(Object.assign({},r.settings),{filename:r.settings.filename||r.metadata.filename})),t(r.versionDifference),s(r.metadata),o(r.data),a(n)),[tn.help,tn.demo,tn.openUrl].includes(n)&&(window.open(r.url),parent.postMessage({pluginMessage:{command:tn.closePlugin}},"*"))},e.createElement(rn.Provider,{value:{figmaUIApi:xr,figmaMetaData:i}},e.createElement(an.Provider,{value:{settings:u,updateSettings:c}},e.createElement(ln.Provider,{value:{tokens:l,setTokens:o}},e.createElement("main",{className:wr,onKeyDown:e=>((e,n)=>{if("Escape"===e.code){if(document.activeElement.classList.contains("select-menu__button--active"))return;n.postMessage({pluginMessage:{command:tn.closePlugin}},"*")}"Tab"===e.code&&(e=>{const n=((e=document)=>[...e.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled"))))(),t=n[n.length-1];e.shiftKey&&document.activeElement===n[0]&&(t.focus(),e.preventDefault()),e.shiftKey||document.activeElement!==t||(n[0].focus(),e.preventDefault())})(e)})(e,xr)},e.createElement(kt,{versionDifference:n}),r===tn.generalSettings&&e.createElement(En,null),r===tn.export&&e.createElement(hr,null),r===tn.urlExport&&e.createElement(yr,null)))))}),null))})()})(); \ No newline at end of file +`;(0,n.s)(document.getElementById("pluginUI")).render(e.createElement((()=>{const[n,t]=(0,e.useState)(null),[r,a]=(0,e.useState)(null),[l,o]=(0,e.useState)(null),[i,s]=(0,e.useState)(null),[u,c]=function(n){var t=(0,e.useState)((function(){return Tn("function"==typeof n?n():n,!0)})),r=t[1];return[t[0],(0,e.useCallback)((function(e){r("function"==typeof e?xt(e):Tn(e))}),[])]}(Et);return onmessage=e=>{const{command:n,payload:r}=e.data.pluginMessage||{};[tn.urlExport,tn.export,tn.generalSettings].includes(n)&&(c(Object.assign(Object.assign({},r.settings),{filename:r.settings.filename||r.metadata.filename})),t(r.versionDifference),s(r.metadata),o(r.data),a(n)),[tn.help,tn.demo,tn.openUrl].includes(n)&&(window.open(r.url),parent.postMessage({pluginMessage:{command:tn.closePlugin}},"*"))},e.createElement(rn.Provider,{value:{figmaUIApi:wr,figmaMetaData:i}},e.createElement(an.Provider,{value:{settings:u,updateSettings:c}},e.createElement(ln.Provider,{value:{tokens:l,setTokens:o}},e.createElement("main",{className:kr,onKeyDown:e=>((e,n)=>{if("Escape"===e.code){if(document.activeElement.classList.contains("select-menu__button--active"))return;n.postMessage({pluginMessage:{command:tn.closePlugin}},"*")}"Tab"===e.code&&(e=>{const n=((e=document)=>[...e.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled"))))(),t=n[n.length-1];e.shiftKey&&document.activeElement===n[0]&&(t.focus(),e.preventDefault()),e.shiftKey||document.activeElement!==t||(n[0].focus(),e.preventDefault())})(e)})(e,wr)},e.createElement(kt,{versionDifference:n}),r===tn.generalSettings&&e.createElement(En,null),r===tn.export&&e.createElement(mr,null),r===tn.urlExport&&e.createElement(xr,null)))))}),null))})()})(); \ No newline at end of file diff --git a/dist/ui.js b/dist/ui.js index ca18248c..c5c14e80 100644 --- a/dist/ui.js +++ b/dist/ui.js @@ -637,7 +637,7 @@ select.select-menu { margin-right: var(--size-xxsmall); margin-left: var(--size-xxxsmall); } -`,kt=({versionDifference:n})=>"major"!==n&&"minor"!==n?e.createElement(e.Fragment,null):e.createElement("div",{id:"versionNotice",className:wt},e.createElement("div",{className:"icon"},"🎉"),e.createElement("div",null,"The ",e.createElement("a",{className:"subtle",href:"https://www.figma.com/community/plugin/888356646278934516/Design-Tokens",target:"_blank",rel:"noreferrer"},"Design Token plugin")," was updated.",e.createElement("br",null),"Find out about changes & new features in the ",e.createElement("a",{href:"https://github.com/lukasoppermann/design-tokens/releases",target:"_blank",rel:"noreferrer"},"release notes →"))),Et={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",contentType:"text/plain;charset=UTF-8",authType:"token",reference:"main",exclusionPrefix:"",excludeExtensionProp:!1,alias:"alias, ref, reference",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",typography:"typography",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion",opacity:"opacity, opacities"},exports:{color:!0,gradient:!0,font:!0,typography:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0,opacity:!0,variables:!0}};function zt(e,n){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===n?e:Math.min(n,Math.max(0,parseFloat(e))),t&&(e=parseInt(String(e*n),10)/100),Math.abs(e-n)<1e-6?1:e=360===n?(e<0?e%n+n:e%n)/parseFloat(String(n)):e%n/parseFloat(String(n))}function Ct(e){return Math.min(1,Math.max(0,e))}function St(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function _t(e){return e<=1?"".concat(100*Number(e),"%"):e}function Mt(e){return 1===e.length?"0"+e:String(e)}function Pt(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=0,i=(r+a)/2;if(r===a)o=0,l=0;else{var s=r-a;switch(o=i>.5?s/(2-r-a):s/(r+a),r){case e:l=(n-t)/s+(n1&&(t-=1),t<1/6?e+6*t*(n-e):t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}function At(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=r,i=r-a,s=0===r?0:i/r;if(r===a)l=0;else{switch(r){case e:l=(n-t)/i+(n>16,g:(65280&e)>>8,b:255&e}}(n)),this.originalInput=n;var a=function(e){var n={r:0,g:0,b:0},t=1,r=null,a=null,l=null,o=!1,i=!1;return"string"==typeof e&&(e=function(e){if(0===(e=e.trim().toLowerCase()).length)return!1;var n=!1;if(Ft[e])e=Ft[e],n=!0;else if("transparent"===e)return{r:0,g:0,b:0,a:0,format:"name"};var t=jt.rgb.exec(e);return t?{r:t[1],g:t[2],b:t[3]}:(t=jt.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=jt.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=jt.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=jt.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=jt.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=jt.hex8.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),a:Rt(t[4]),format:n?"name":"hex8"}:(t=jt.hex6.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),format:n?"name":"hex"}:(t=jt.hex4.exec(e))?{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),a:Rt(t[4]+t[4]),format:n?"name":"hex8"}:!!(t=jt.hex3.exec(e))&&{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),format:n?"name":"hex"}}(e)),"object"==typeof e&&($t(e.r)&&$t(e.g)&&$t(e.b)?(n=function(e,n,t){return{r:255*zt(e,255),g:255*zt(n,255),b:255*zt(t,255)}}(e.r,e.g,e.b),o=!0,i="%"===String(e.r).substr(-1)?"prgb":"rgb"):$t(e.h)&&$t(e.s)&&$t(e.v)?(r=_t(e.s),a=_t(e.v),n=function(e,n,t){e=6*zt(e,360),n=zt(n,100),t=zt(t,100);var r=Math.floor(e),a=e-r,l=t*(1-n),o=t*(1-a*n),i=t*(1-(1-a)*n),s=r%6;return{r:255*[t,o,l,l,i,t][s],g:255*[i,t,t,o,l,l][s],b:255*[l,l,i,t,t,o][s]}}(e.h,r,a),o=!0,i="hsv"):$t(e.h)&&$t(e.s)&&$t(e.l)&&(r=_t(e.s),l=_t(e.l),n=function(e,n,t){var r,a,l;if(e=zt(e,360),n=zt(n,100),t=zt(t,100),0===n)a=t,l=t,r=t;else{var o=t<.5?t*(1+n):t+n-t*n,i=2*t-o;r=Ot(i,o,e+1/3),a=Ot(i,o,e),l=Ot(i,o,e-1/3)}return{r:255*r,g:255*a,b:255*l}}(e.h,r,l),o=!0,i="hsl"),Object.prototype.hasOwnProperty.call(e,"a")&&(t=e.a)),t=St(t),{ok:o,format:e.format||i,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:t}}(n);this.originalInput=n,this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=t.format)&&void 0!==r?r:a.format,this.gradientType=t.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=a.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),n=e.r/255,t=e.g/255,r=e.b/255;return.2126*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=St(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=At(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=At(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsva(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHsl=function(){var e=Pt(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=Pt(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsla(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHex=function(e){return void 0===e&&(e=!1),Lt(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,n,t,r,a){var l=[Mt(Math.round(e).toString(16)),Mt(Math.round(n).toString(16)),Mt(Math.round(t).toString(16)),Mt(Nt(r))];return a&&l[0].startsWith(l[0].charAt(1))&&l[1].startsWith(l[1].charAt(1))&&l[2].startsWith(l[2].charAt(1))&&l[3].startsWith(l[3].charAt(1))?l[0].charAt(0)+l[1].charAt(0)+l[2].charAt(0)+l[3].charAt(0):l.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),n=Math.round(this.g),t=Math.round(this.b);return 1===this.a?"rgb(".concat(e,", ").concat(n,", ").concat(t,")"):"rgba(".concat(e,", ").concat(n,", ").concat(t,", ").concat(this.roundA,")")},e.prototype.toPercentageRgb=function(){var e=function(e){return"".concat(Math.round(100*zt(e,255)),"%")};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*zt(e,255))};return 1===this.a?"rgb(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%)"):"rgba(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%, ").concat(this.roundA,")")},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+Lt(this.r,this.g,this.b,!1),n=0,t=Object.entries(Ft);n=0;return n||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l+=n/100,t.l=Ct(t.l),new e(t)},e.prototype.brighten=function(n){void 0===n&&(n=10);var t=this.toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-n/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-n/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-n/100*255))),new e(t)},e.prototype.darken=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l-=n/100,t.l=Ct(t.l),new e(t)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s-=n/100,t.s=Ct(t.s),new e(t)},e.prototype.saturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s+=n/100,t.s=Ct(t.s),new e(t)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(n){var t=this.toHsl(),r=(t.h+n)%360;return t.h=r<0?360+r:r,new e(t)},e.prototype.mix=function(n,t){void 0===t&&(t=50);var r=this.toRgb(),a=new e(n).toRgb(),l=t/100;return new e({r:(a.r-r.r)*l+r.r,g:(a.g-r.g)*l+r.g,b:(a.b-r.b)*l+r.b,a:(a.a-r.a)*l+r.a})},e.prototype.analogous=function(n,t){void 0===n&&(n=6),void 0===t&&(t=30);var r=this.toHsl(),a=360/t,l=[this];for(r.h=(r.h-(a*n>>1)+720)%360;--n;)r.h=(r.h+a)%360,l.push(new e(r));return l},e.prototype.complement=function(){var n=this.toHsl();return n.h=(n.h+180)%360,new e(n)},e.prototype.monochromatic=function(n){void 0===n&&(n=6);for(var t=this.toHsv(),r=t.h,a=t.s,l=t.v,o=[],i=1/n;n--;)o.push(new e({h:r,s:a,v:l})),l=(l+i)%1;return o},e.prototype.splitcomplement=function(){var n=this.toHsl(),t=n.h;return[this,new e({h:(t+72)%360,s:n.s,l:n.l}),new e({h:(t+216)%360,s:n.s,l:n.l})]},e.prototype.onBackground=function(n){var t=this.toRgb(),r=new e(n).toRgb();return new e({r:r.r+(t.r-r.r)*t.a,g:r.g+(t.g-r.g)*t.a,b:r.b+(t.b-r.b)*t.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(n){for(var t=this.toHsl(),r=t.h,a=[this],l=360/n,o=1;o`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,Bt=e=>{return(n=Vt(e),void 0===n&&(n=""),void 0===t&&(t={}),new Ht(n,t)).toHex8String();var n,t},Wt=({width:e})=>Object.assign({value:e.value,type:e.type},void 0!==e.unit&&{unit:e.unit}),qt=(e,n)=>{if(null!=e)return"color"===n?Vt(e):e},Qt=e=>Object.assign(Object.assign({value:qt(e.value,e.type),type:e.type},void 0!==e.description&&{comment:e.description}),void 0!==e.unit&&{unit:e.unit}),Kt=e=>{Array.isArray(e)&&1===e.length&&(e=e[0]);const n={};return Object.keys(e).forEach((function(t){Object.prototype.hasOwnProperty.call(e[t],"value")?n[t]=Qt(e[t]):n[t]=Kt(e[t])})),1===Object.keys(n).length?Object.values(n)[0]:n},Gt={size:Wt,color:Kt,gradient:Kt,font:Kt,effect:e=>{const n=e.map((e=>["dropShadow","innerShadow"].includes(e.effectType.value)?(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"},color:{value:Vt(e.color.value),type:"color"},offset:{x:{value:e.offset.x.value,type:"number",unit:"pixel"},y:{value:e.offset.y.value,type:"number",unit:"pixel"}},spread:{value:e.spread.value,type:"number",unit:"pixel"}}))(e):(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"}}))(e)));return Array.isArray(n)&&1===n.length?n[0]:n},grid:Kt,border:e=>Object.fromEntries(Object.entries(e).map((([e,n])=>{if("dashPattern"===e){const t=Qt(n);return t.value=t.value.join(", "),[e,t]}return[e,Qt(n)]}))),breakpoint:Wt,radius:Kt,spacing:Kt,motion:e=>Object.assign(Object.assign({type:{value:e.transitionType.value,type:"string"},duration:{value:e.duration.value,type:"number",unit:"s"}},e.direction?{direction:{value:e.direction.value,type:"string"}}:{}),{easing:{value:e.easingType.value.replace("cubicBezier","cubic-bezier"),type:"string"},easingFunction:e.easingFunction}),opacity:({opacity:e})=>({value:e.value,type:e.type})},Yt=(e,n=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof n)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${n}" (${typeof n}) must be of type number`);const t=Math.pow(10,n);return Math.round(e*t)/t},Zt=(e,{excludeExtensionProp:n})=>{if(!0!==n)return{extensions:Object.assign({},e.extensions)}},Xt=e=>"pixel"===e.lineHeight.unit?Yt(e.lineHeight.value,3):"percent"===e.lineHeight.unit?Yt(e.fontSize.value*(e.lineHeight.value/100),3):Yt(1.2*e.fontSize.value,3),Jt=e=>"pixel"===e.letterSpacing.unit?Yt(e.letterSpacing.value,3):"percent"===e.letterSpacing.unit?Yt(e.fontSize.value*(e.letterSpacing.value/100),3):void 0,er=({values:e})=>({value:e.width.value,type:"dimension"}),nr=e=>{var n,t,r;if(e.extensions&&e.extensions[sn.key.extensionPluginData]&&e.extensions[sn.key.extensionPluginData].alias)return{type:Object.hasOwnProperty.call(e.values[0],"fill")?"color":"custom-gradient",value:`{${e.extensions[sn.key.extensionPluginData].alias}}`,blendMode:(null===(r=null===(t=null===(n=e.values[0])||void 0===n?void 0:n.fill)||void 0===t?void 0:t.blendMode)||void 0===r?void 0:r.toLowerCase())||"normal"};const a=e.values.map((e=>Object.hasOwnProperty.call(e,"fill")?(({fill:e})=>{var n;return{type:"color",value:Bt(e.value),blendMode:(null===(n=e.blendMode)||void 0===n?void 0:n.toLowerCase())||"normal"}})(e):(({gradientType:e,rotation:n,stops:t,opacity:r})=>({type:"custom-gradient",value:{gradientType:e.value,rotation:n.value,stops:t.map((e=>({position:e.position.value,color:Bt(Object.assign(Object.assign({},e.color.value),{a:e.color.value.a*r.value}))})))}}))(e)));return 1===a.length?a[0]:Object.assign({},a)},tr={size:er,color:nr,gradient:nr,font:({values:e})=>({type:"custom-fontStyle",value:{fontSize:e.fontSize.value,textDecoration:e.textDecoration.value,fontFamily:e.fontFamily.value,fontWeight:e.fontWeight.value,fontStyle:e.fontStyle.value,fontStretch:e.fontStretch.value,letterSpacing:Jt(e),lineHeight:Xt(e),paragraphIndent:e.paragraphIndent.value,paragraphSpacing:e.paragraphSpacing.value,textCase:e.textCase.value}}),effect:({values:e})=>{const n=e.map((e=>{return["dropShadow","innerShadow"].includes(e.effectType.value)?{type:"custom-shadow",value:{shadowType:(n=e).effectType.value,radius:n.radius.value,color:Bt(n.color.value),offsetX:n.offset.x.value,offsetY:n.offset.y.value,spread:n.spread.value}}:null;var n}));return 1===n.length?n[0]:Object.assign({},n)},grid:({values:e})=>{const n=e.map((e=>({type:"custom-grid",value:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pattern:e.pattern.value},e.sectionSize?{sectionSize:e.sectionSize.value}:{}),e.gutterSize?{gutterSize:e.gutterSize.value}:{}),e.alignment?{alignment:e.alignment.value}:{}),e.count?{count:e.count.value}:{}),e.offset?{offset:e.offset.value}:{})})));return 1===n.length?n[0]:Object.assign({},n)},border:({values:e})=>({type:"custom-stroke",value:{align:e.strokeAlign.value,dashPattern:e.dashPattern.value,lineCap:e.strokeCap.value,lineJoin:e.strokeJoin.value,miterLimit:e.strokeMiterLimit.value,weight:e.strokeWeight.value,color:Bt(e.stroke.value)}}),breakpoint:er,radius:({values:e})=>({type:"custom-radius",value:{smoothing:e.smoothing.value,topLeft:e.radii.topLeft.value,topRight:e.radii.topRight.value,bottomLeft:e.radii.bottomLeft.value,bottomRight:e.radii.bottomRight.value}}),spacing:({values:e})=>({type:"custom-spacing",value:{top:e.top.value,bottom:e.bottom.value,left:e.left.value,right:e.right.value}}),motion:({values:e})=>({type:"custom-transition",value:Object.assign(Object.assign({transitionType:e.transitionType.value,duration:e.duration.value},e.direction?{direction:e.direction.value}:{}),{easingType:e.easingCurveType.value,easingFunction:Object.fromEntries(Object.entries(e.easingFunction).map((e=>[e[0],e[1].value])))})}),opacity:({values:e})=>({value:e.opacity.value,type:"custom-opacity"})},rr=(e,n)=>"typography"===e.category?Object.assign({name:e.name,description:e.description},(({name:e,values:n})=>({fontSize:{type:"dimension",value:n.fontSize.value},textDecoration:{type:"string",value:n.textDecoration.value},fontFamily:{type:"string",value:n.fontFamily.value},fontWeight:{type:"number",value:n.fontWeight.value},fontStyle:{type:"string",value:n.fontStyle.value},fontStretch:{type:"string",value:n.fontStretch.value},letterSpacing:{type:"dimension",value:Jt(n)},lineHeight:{type:"dimension",value:Xt(n)},paragraphIndent:{type:"dimension",value:n.paragraphIndent.value},paragraphSpacing:{type:"dimension",value:n.paragraphSpacing.value},textCase:{type:"string",value:n.textCase.value}}))(e)):"variables"===e.extensions[sn.key.extensionPluginData].exportKey?Object.assign(Object.assign({name:e.name,description:e.description},(({values:e,category:n})=>{var t;return/^{[\w\s\.]*}$/.test(e)?{type:n,value:e}:"color"===n?{type:"color",value:Bt(e.fill.value),blendMode:(null===(t=e.fill.blendMode)||void 0===t?void 0:t.toLowerCase())||"normal"}:["dimension","boolean","string"].includes(n)?{type:n,value:e}:void 0})(e)),Zt(e,n)):Object.assign(Object.assign({name:e.name,description:e.description},(e=>tr[e.category](e))(e)),Zt(e,n)),ar=(e,n)=>{const t=e=>e&&"object"==typeof e;return t(e)&&t(n)?(Object.keys(n).forEach((r=>{const a=e[r],l=n[r];Array.isArray(a)&&Array.isArray(l)?e[r]=a.concat(l):t(a)&&t(l)?e[r]=ar(Object.assign({},a),l):e[r]=l})),e):n},lr=ar,or=(e,n,t)=>{if("string"==typeof e&&""!==e)return e;throw new Error(`converting "${n}" to ${t}, resulting in "${e}"`)},ir=(e,n="default")=>"camelCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ (.)/g,(function(e){return e.toUpperCase()})).replace(/ /g,"");return or(n,e,"camelCase")})(e):"kebabCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ /g,"-");return or(n,e,"kebabCase")})(e):e.trim().toLowerCase(),sr={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Font Styles",key:"font"},typography:{label:"Typography",key:"typography",exclude:["original"]},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"},opacity:{label:"Opacity",key:"opacity"},variables:{label:"Figma Variables (BETA)",key:"variables",exclude:["original"]}},ur=e=>{var n,t;return void 0!==(null===(t=null===(n=e.extensions)||void 0===n?void 0:n[sn.key.extensionPluginData])||void 0===t?void 0:t.exportKey)?e.extensions[sn.key.extensionPluginData].exportKey:"missingExportKey"},cr={original:(e,n)=>"variables"===e.extensions[sn.key.extensionPluginData].exportKey?null:Object.assign(Object.assign({name:e.name,category:e.category,exportKey:e.extensions[sn.key.extensionPluginData].exportKey},e.description&&e.description.length>0&&{comment:e.description}),Gt[e.category](e.values)||{}),standard:rr,standardDeprecated:rr},dr=(e,n)=>"standard"===n.tokenFormat?JSON.parse(JSON.stringify(e.filter((e=>e.category===sr.font.key)))).map((e=>(e.name="typography/"+e.name.substr(e.name.indexOf("/")+1).trim().trimStart(),e.category=sr.typography.key,e.exportKey=sr.typography.key,!0!==n.excludeExtensionProp&&(e.extensions[sn.key.extensionPluginData].exportKey=sr.typography.key),e))):[],fr=(e,n)=>{0===e.length&&(e="[{}]");let t=JSON.parse(e);t=[...t,...dr(t,n)];const r=((e,n)=>e.length<=0?[]:e.map((e=>{var t,r,a,l;if(!1===n.prefixInName)e.name=e.name.substr(e.name.indexOf("/")+1).trim().trimLeft();else if(void 0!==(null===(r=null===(t=e.extensions)||void 0===t?void 0:t[sn.key.extensionPluginData])||void 0===r?void 0:r.alias)){const n=e.name.substr(0,e.name.indexOf("/")).trim().trimLeft();e.extensions[sn.key.extensionPluginData].alias=`${n}.${e.extensions[sn.key.extensionPluginData].alias}`}return n.keyInName&&(e.name=`${ur(e)}/${e.name}`,void 0!==(null===(l=null===(a=e.extensions)||void 0===a?void 0:a[sn.key.extensionPluginData])||void 0===l?void 0:l.alias)&&(e.extensions[sn.key.extensionPluginData].alias=`${ur(e)}.${e.extensions[sn.key.extensionPluginData].alias}`)),e})))(t.filter((({exportKey:e})=>n.exports[e])),n),a=r.map((e=>cr[n.tokenFormat](e,n))).filter(Boolean),l=((e,n)=>{if(e.length<=0)return[];const t=e.map((e=>{const t=e.name.split("/").map((e=>ir(e,n.nameConversion)));return delete e.name,r=e,t.reduceRight(((e,n)=>({[n]:e})),r);var r}));return t.reduce(((e={},n)=>lr(e,n)))})(a,n);return l},pr=(e,n=!0)=>!0===n?JSON.stringify(e):JSON.stringify(e,null,2);const gr=je` +`,kt=({versionDifference:n})=>"major"!==n&&"minor"!==n?e.createElement(e.Fragment,null):e.createElement("div",{id:"versionNotice",className:wt},e.createElement("div",{className:"icon"},"🎉"),e.createElement("div",null,"The ",e.createElement("a",{className:"subtle",href:"https://www.figma.com/community/plugin/888356646278934516/Design-Tokens",target:"_blank",rel:"noreferrer"},"Design Token plugin")," was updated.",e.createElement("br",null),"Find out about changes & new features in the ",e.createElement("a",{href:"https://github.com/lukasoppermann/design-tokens/releases",target:"_blank",rel:"noreferrer"},"release notes →"))),Et={filename:"design-tokens",extension:".tokens.json",nameConversion:"default",tokenFormat:"standard",compression:!1,urlJsonCompression:!0,serverUrl:void 0,eventType:"update-tokens",accessToken:void 0,acceptHeader:"application/vnd.github.everest-preview+json",contentType:"text/plain;charset=UTF-8",authType:"token",reference:"main",exclusionPrefix:"",excludeExtensionProp:!1,alias:"alias, ref, reference",keyInName:!1,prefixInName:!0,prefix:{color:"color",gradient:"gradient",typography:"typography",font:"font",effect:"effect",grid:"grid",border:"border, borders",breakpoint:"breakpoint, breakpoints",radius:"radius, radii",size:"size, sizes",spacing:"spacing",motion:"motion",opacity:"opacity, opacities"},exports:{color:!0,gradient:!0,font:!0,typography:!0,effect:!0,grid:!0,border:!0,breakpoint:!0,radius:!0,size:!0,spacing:!0,motion:!0,opacity:!0,variables:!0}};function zt(e,n){(function(e){return"string"==typeof e&&-1!==e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var t=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=360===n?e:Math.min(n,Math.max(0,parseFloat(e))),t&&(e=parseInt(String(e*n),10)/100),Math.abs(e-n)<1e-6?1:e=360===n?(e<0?e%n+n:e%n)/parseFloat(String(n)):e%n/parseFloat(String(n))}function Ct(e){return Math.min(1,Math.max(0,e))}function St(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function _t(e){return e<=1?"".concat(100*Number(e),"%"):e}function Mt(e){return 1===e.length?"0"+e:String(e)}function Pt(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=0,i=(r+a)/2;if(r===a)o=0,l=0;else{var s=r-a;switch(o=i>.5?s/(2-r-a):s/(r+a),r){case e:l=(n-t)/s+(n1&&(t-=1),t<1/6?e+6*t*(n-e):t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}function At(e,n,t){e=zt(e,255),n=zt(n,255),t=zt(t,255);var r=Math.max(e,n,t),a=Math.min(e,n,t),l=0,o=r,i=r-a,s=0===r?0:i/r;if(r===a)l=0;else{switch(r){case e:l=(n-t)/i+(n>16,g:(65280&e)>>8,b:255&e}}(n)),this.originalInput=n;var a=function(e){var n={r:0,g:0,b:0},t=1,r=null,a=null,l=null,o=!1,i=!1;return"string"==typeof e&&(e=function(e){if(0===(e=e.trim().toLowerCase()).length)return!1;var n=!1;if(Ft[e])e=Ft[e],n=!0;else if("transparent"===e)return{r:0,g:0,b:0,a:0,format:"name"};var t=jt.rgb.exec(e);return t?{r:t[1],g:t[2],b:t[3]}:(t=jt.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=jt.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=jt.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=jt.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=jt.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=jt.hex8.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),a:Rt(t[4]),format:n?"name":"hex8"}:(t=jt.hex6.exec(e))?{r:Tt(t[1]),g:Tt(t[2]),b:Tt(t[3]),format:n?"name":"hex"}:(t=jt.hex4.exec(e))?{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),a:Rt(t[4]+t[4]),format:n?"name":"hex8"}:!!(t=jt.hex3.exec(e))&&{r:Tt(t[1]+t[1]),g:Tt(t[2]+t[2]),b:Tt(t[3]+t[3]),format:n?"name":"hex"}}(e)),"object"==typeof e&&($t(e.r)&&$t(e.g)&&$t(e.b)?(n=function(e,n,t){return{r:255*zt(e,255),g:255*zt(n,255),b:255*zt(t,255)}}(e.r,e.g,e.b),o=!0,i="%"===String(e.r).substr(-1)?"prgb":"rgb"):$t(e.h)&&$t(e.s)&&$t(e.v)?(r=_t(e.s),a=_t(e.v),n=function(e,n,t){e=6*zt(e,360),n=zt(n,100),t=zt(t,100);var r=Math.floor(e),a=e-r,l=t*(1-n),o=t*(1-a*n),i=t*(1-(1-a)*n),s=r%6;return{r:255*[t,o,l,l,i,t][s],g:255*[i,t,t,o,l,l][s],b:255*[l,l,i,t,t,o][s]}}(e.h,r,a),o=!0,i="hsv"):$t(e.h)&&$t(e.s)&&$t(e.l)&&(r=_t(e.s),l=_t(e.l),n=function(e,n,t){var r,a,l;if(e=zt(e,360),n=zt(n,100),t=zt(t,100),0===n)a=t,l=t,r=t;else{var o=t<.5?t*(1+n):t+n-t*n,i=2*t-o;r=Ot(i,o,e+1/3),a=Ot(i,o,e),l=Ot(i,o,e-1/3)}return{r:255*r,g:255*a,b:255*l}}(e.h,r,l),o=!0,i="hsl"),Object.prototype.hasOwnProperty.call(e,"a")&&(t=e.a)),t=St(t),{ok:o,format:e.format||i,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:t}}(n);this.originalInput=n,this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=t.format)&&void 0!==r?r:a.format,this.gradientType=t.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=a.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},e.prototype.getLuminance=function(){var e=this.toRgb(),n=e.r/255,t=e.g/255,r=e.b/255;return.2126*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(e){return this.a=St(e),this.roundA=Math.round(100*this.a)/100,this},e.prototype.toHsv=function(){var e=At(this.r,this.g,this.b);return{h:360*e.h,s:e.s,v:e.v,a:this.a}},e.prototype.toHsvString=function(){var e=At(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.v);return 1===this.a?"hsv(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsva(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHsl=function(){var e=Pt(this.r,this.g,this.b);return{h:360*e.h,s:e.s,l:e.l,a:this.a}},e.prototype.toHslString=function(){var e=Pt(this.r,this.g,this.b),n=Math.round(360*e.h),t=Math.round(100*e.s),r=Math.round(100*e.l);return 1===this.a?"hsl(".concat(n,", ").concat(t,"%, ").concat(r,"%)"):"hsla(".concat(n,", ").concat(t,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHex=function(e){return void 0===e&&(e=!1),Lt(this.r,this.g,this.b,e)},e.prototype.toHexString=function(e){return void 0===e&&(e=!1),"#"+this.toHex(e)},e.prototype.toHex8=function(e){return void 0===e&&(e=!1),function(e,n,t,r,a){var l=[Mt(Math.round(e).toString(16)),Mt(Math.round(n).toString(16)),Mt(Math.round(t).toString(16)),Mt(Nt(r))];return a&&l[0].startsWith(l[0].charAt(1))&&l[1].startsWith(l[1].charAt(1))&&l[2].startsWith(l[2].charAt(1))&&l[3].startsWith(l[3].charAt(1))?l[0].charAt(0)+l[1].charAt(0)+l[2].charAt(0)+l[3].charAt(0):l.join("")}(this.r,this.g,this.b,this.a,e)},e.prototype.toHex8String=function(e){return void 0===e&&(e=!1),"#"+this.toHex8(e)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var e=Math.round(this.r),n=Math.round(this.g),t=Math.round(this.b);return 1===this.a?"rgb(".concat(e,", ").concat(n,", ").concat(t,")"):"rgba(".concat(e,", ").concat(n,", ").concat(t,", ").concat(this.roundA,")")},e.prototype.toPercentageRgb=function(){var e=function(e){return"".concat(Math.round(100*zt(e,255)),"%")};return{r:e(this.r),g:e(this.g),b:e(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var e=function(e){return Math.round(100*zt(e,255))};return 1===this.a?"rgb(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%)"):"rgba(".concat(e(this.r),"%, ").concat(e(this.g),"%, ").concat(e(this.b),"%, ").concat(this.roundA,")")},e.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+Lt(this.r,this.g,this.b,!1),n=0,t=Object.entries(Ft);n=0;return n||!r||!e.startsWith("hex")&&"name"!==e?("rgb"===e&&(t=this.toRgbString()),"prgb"===e&&(t=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(t=this.toHexString()),"hex3"===e&&(t=this.toHexString(!0)),"hex4"===e&&(t=this.toHex8String(!0)),"hex8"===e&&(t=this.toHex8String()),"name"===e&&(t=this.toName()),"hsl"===e&&(t=this.toHslString()),"hsv"===e&&(t=this.toHsvString()),t||this.toHexString()):"name"===e&&0===this.a?this.toName():this.toRgbString()},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l+=n/100,t.l=Ct(t.l),new e(t)},e.prototype.brighten=function(n){void 0===n&&(n=10);var t=this.toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(-n/100*255))),t.g=Math.max(0,Math.min(255,t.g-Math.round(-n/100*255))),t.b=Math.max(0,Math.min(255,t.b-Math.round(-n/100*255))),new e(t)},e.prototype.darken=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.l-=n/100,t.l=Ct(t.l),new e(t)},e.prototype.tint=function(e){return void 0===e&&(e=10),this.mix("white",e)},e.prototype.shade=function(e){return void 0===e&&(e=10),this.mix("black",e)},e.prototype.desaturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s-=n/100,t.s=Ct(t.s),new e(t)},e.prototype.saturate=function(n){void 0===n&&(n=10);var t=this.toHsl();return t.s+=n/100,t.s=Ct(t.s),new e(t)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(n){var t=this.toHsl(),r=(t.h+n)%360;return t.h=r<0?360+r:r,new e(t)},e.prototype.mix=function(n,t){void 0===t&&(t=50);var r=this.toRgb(),a=new e(n).toRgb(),l=t/100;return new e({r:(a.r-r.r)*l+r.r,g:(a.g-r.g)*l+r.g,b:(a.b-r.b)*l+r.b,a:(a.a-r.a)*l+r.a})},e.prototype.analogous=function(n,t){void 0===n&&(n=6),void 0===t&&(t=30);var r=this.toHsl(),a=360/t,l=[this];for(r.h=(r.h-(a*n>>1)+720)%360;--n;)r.h=(r.h+a)%360,l.push(new e(r));return l},e.prototype.complement=function(){var n=this.toHsl();return n.h=(n.h+180)%360,new e(n)},e.prototype.monochromatic=function(n){void 0===n&&(n=6);for(var t=this.toHsv(),r=t.h,a=t.s,l=t.v,o=[],i=1/n;n--;)o.push(new e({h:r,s:a,v:l})),l=(l+i)%1;return o},e.prototype.splitcomplement=function(){var n=this.toHsl(),t=n.h;return[this,new e({h:(t+72)%360,s:n.s,l:n.l}),new e({h:(t+216)%360,s:n.s,l:n.l})]},e.prototype.onBackground=function(n){var t=this.toRgb(),r=new e(n).toRgb();return new e({r:r.r+(t.r-r.r)*t.a,g:r.g+(t.g-r.g)*t.a,b:r.b+(t.b-r.b)*t.a})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(n){for(var t=this.toHsl(),r=t.h,a=[this],l=360/n,o=1;o`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a})`,Bt=e=>{return(n=Vt(e),void 0===n&&(n=""),void 0===t&&(t={}),new Ht(n,t)).toHex8String();var n,t},Wt=({width:e})=>Object.assign({value:e.value,type:e.type},void 0!==e.unit&&{unit:e.unit}),qt=(e,n)=>{if(null!=e)return"color"===n?Vt(e):e},Qt=e=>Object.assign(Object.assign({value:qt(e.value,e.type),type:e.type},void 0!==e.description&&{comment:e.description}),void 0!==e.unit&&{unit:e.unit}),Kt=e=>{Array.isArray(e)&&1===e.length&&(e=e[0]);const n={};return Object.keys(e).forEach((function(t){Object.prototype.hasOwnProperty.call(e[t],"value")?n[t]=Qt(e[t]):n[t]=Kt(e[t])})),1===Object.keys(n).length?Object.values(n)[0]:n},Gt={size:Wt,color:Kt,gradient:Kt,font:Kt,effect:e=>{const n=e.map((e=>["dropShadow","innerShadow"].includes(e.effectType.value)?(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"},color:{value:Vt(e.color.value),type:"color"},offset:{x:{value:e.offset.x.value,type:"number",unit:"pixel"},y:{value:e.offset.y.value,type:"number",unit:"pixel"}},spread:{value:e.spread.value,type:"number",unit:"pixel"}}))(e):(e=>({type:{value:e.effectType.value,type:"string"},radius:{value:e.radius.value,type:"number",unit:"pixel"}}))(e)));return Array.isArray(n)&&1===n.length?n[0]:n},grid:Kt,border:e=>Object.fromEntries(Object.entries(e).map((([e,n])=>{if("dashPattern"===e){const t=Qt(n);return t.value=t.value.join(", "),[e,t]}return[e,Qt(n)]}))),breakpoint:Wt,radius:Kt,spacing:Kt,motion:e=>Object.assign(Object.assign({type:{value:e.transitionType.value,type:"string"},duration:{value:e.duration.value,type:"number",unit:"s"}},e.direction?{direction:{value:e.direction.value,type:"string"}}:{}),{easing:{value:e.easingType.value.replace("cubicBezier","cubic-bezier"),type:"string"},easingFunction:e.easingFunction}),opacity:({opacity:e})=>({value:e.value,type:e.type})},Yt=(e,n=2)=>{if(void 0===e)return;if("number"!=typeof e||"number"!=typeof n)throw new Error(`Invalid parameters, both value "${e}" (${typeof e}) and decimalPlaces "${n}" (${typeof n}) must be of type number`);const t=Math.pow(10,n);return Math.round(e*t)/t},Zt=(e,{excludeExtensionProp:n})=>{if(!0!==n)return{extensions:Object.assign({},e.extensions)}},Xt=(e,n="/",t=".")=>e.split(n).join(t).toLowerCase(),Jt=e=>"pixel"===e.lineHeight.unit?Yt(e.lineHeight.value,3):"percent"===e.lineHeight.unit?Yt(e.fontSize.value*(e.lineHeight.value/100),3):Yt(1.2*e.fontSize.value,3),er=e=>"pixel"===e.letterSpacing.unit?Yt(e.letterSpacing.value,3):"percent"===e.letterSpacing.unit?Yt(e.fontSize.value*(e.letterSpacing.value/100),3):void 0,nr=({values:e})=>({value:e.width.value,type:"dimension"}),tr=e=>{var n,t,r;if(e.extensions&&e.extensions[sn.key.extensionPluginData]&&e.extensions[sn.key.extensionPluginData].alias)return{type:Object.hasOwnProperty.call(e.values[0],"fill")?"color":"custom-gradient",value:`{${e.extensions[sn.key.extensionPluginData].alias}}`,blendMode:(null===(r=null===(t=null===(n=e.values[0])||void 0===n?void 0:n.fill)||void 0===t?void 0:t.blendMode)||void 0===r?void 0:r.toLowerCase())||"normal"};const a=e.values.map((e=>Object.hasOwnProperty.call(e,"fill")?(({fill:e})=>{var n;return{type:"color",value:Bt(e.value),blendMode:(null===(n=e.blendMode)||void 0===n?void 0:n.toLowerCase())||"normal"}})(e):(({gradientType:e,rotation:n,stops:t,opacity:r})=>({type:"custom-gradient",value:{gradientType:e.value,rotation:n.value,stops:t.map((e=>({position:e.position.value,color:Bt(Object.assign(Object.assign({},e.color.value),{a:e.color.value.a*r.value}))})))}}))(e)));return 1===a.length?a[0]:Object.assign({},a)},rr={size:nr,color:tr,gradient:tr,font:({values:e})=>({type:"custom-fontStyle",value:{fontSize:e.fontSize.value,textDecoration:e.textDecoration.value,fontFamily:e.fontFamily.value,fontWeight:e.fontWeight.value,fontStyle:e.fontStyle.value,fontStretch:e.fontStretch.value,letterSpacing:er(e),lineHeight:Jt(e),paragraphIndent:e.paragraphIndent.value,paragraphSpacing:e.paragraphSpacing.value,textCase:e.textCase.value}}),effect:({values:e})=>{const n=e.map((e=>{return["dropShadow","innerShadow"].includes(e.effectType.value)?{type:"custom-shadow",value:{shadowType:(n=e).effectType.value,radius:n.radius.value,color:Bt(n.color.value),offsetX:n.offset.x.value,offsetY:n.offset.y.value,spread:n.spread.value}}:null;var n}));return 1===n.length?n[0]:Object.assign({},n)},grid:({values:e})=>{const n=e.map((e=>({type:"custom-grid",value:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pattern:e.pattern.value},e.sectionSize?{sectionSize:e.sectionSize.value}:{}),e.gutterSize?{gutterSize:e.gutterSize.value}:{}),e.alignment?{alignment:e.alignment.value}:{}),e.count?{count:e.count.value}:{}),e.offset?{offset:e.offset.value}:{})})));return 1===n.length?n[0]:Object.assign({},n)},border:({values:e})=>({type:"custom-stroke",value:{align:e.strokeAlign.value,dashPattern:e.dashPattern.value,lineCap:e.strokeCap.value,lineJoin:e.strokeJoin.value,miterLimit:e.strokeMiterLimit.value,weight:e.strokeWeight.value,color:Bt(e.stroke.value)}}),breakpoint:nr,radius:({values:e})=>({type:"custom-radius",value:{smoothing:e.smoothing.value,topLeft:e.radii.topLeft.value,topRight:e.radii.topRight.value,bottomLeft:e.radii.bottomLeft.value,bottomRight:e.radii.bottomRight.value}}),spacing:({values:e})=>({type:"custom-spacing",value:{top:e.top.value,bottom:e.bottom.value,left:e.left.value,right:e.right.value}}),motion:({values:e})=>({type:"custom-transition",value:Object.assign(Object.assign({transitionType:e.transitionType.value,duration:e.duration.value},e.direction?{direction:e.direction.value}:{}),{easingType:e.easingCurveType.value,easingFunction:Object.fromEntries(Object.entries(e.easingFunction).map((e=>[e[0],e[1].value])))})}),opacity:({values:e})=>({value:e.opacity.value,type:"custom-opacity"})},ar=(e,n)=>"typography"===e.category?Object.assign({name:e.name,description:e.description},(({name:e,values:n})=>({fontSize:{type:"dimension",value:n.fontSize.value},textDecoration:{type:"string",value:n.textDecoration.value},fontFamily:{type:"string",value:n.fontFamily.value},fontWeight:{type:"number",value:n.fontWeight.value},fontStyle:{type:"string",value:n.fontStyle.value},fontStretch:{type:"string",value:n.fontStretch.value},letterSpacing:{type:"dimension",value:er(n)},lineHeight:{type:"dimension",value:Jt(n)},paragraphIndent:{type:"dimension",value:n.paragraphIndent.value},paragraphSpacing:{type:"dimension",value:n.paragraphSpacing.value},textCase:{type:"string",value:n.textCase.value}}))(e)):"variables"===e.extensions[sn.key.extensionPluginData].exportKey?Object.assign(Object.assign({name:e.name,description:e.description},(({values:e,category:n})=>{var t;const r=/^{[\w\s\.\-\_\/\@\+\&\:]*}$/;return console.log(e,r.test(e)),r.test(e)?{type:n,value:Xt(e,"/",".")}:"color"===n?{type:"color",value:Bt(e.fill.value),blendMode:(null===(t=e.fill.blendMode)||void 0===t?void 0:t.toLowerCase())||"normal"}:["dimension","boolean","string"].includes(n)?{type:n,value:e}:void 0})(e)),Zt(e,n)):Object.assign(Object.assign({name:e.name,description:e.description},(e=>rr[e.category](e))(e)),Zt(e,n)),lr=(e,n)=>{const t=e=>e&&"object"==typeof e;return t(e)&&t(n)?(Object.keys(n).forEach((r=>{const a=e[r],l=n[r];Array.isArray(a)&&Array.isArray(l)?e[r]=a.concat(l):t(a)&&t(l)?e[r]=lr(Object.assign({},a),l):e[r]=l})),e):n},or=lr,ir=(e,n,t)=>{if("string"==typeof e&&""!==e)return e;throw new Error(`converting "${n}" to ${t}, resulting in "${e}"`)},sr=(e,n="default")=>"camelCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ (.)/g,(function(e){return e.toUpperCase()})).replace(/ /g,"");return ir(n,e,"camelCase")})(e):"kebabCase"===n?(e=>{const n=e.toLowerCase().replace(/['"]/g,"").replace(/([-_ ]){1,}/g," ").replace(/\W+/g," ").trim().replace(/ /g,"-");return ir(n,e,"kebabCase")})(e):e.trim().toLowerCase(),ur={color:{label:"Colors",key:"color"},gradient:{label:"Gradients",key:"gradient"},font:{label:"Font Styles",key:"font"},typography:{label:"Typography",key:"typography",exclude:["original"]},effect:{label:"Effects",key:"effect"},grid:{label:"Grids",key:"grid"},border:{label:"Borders",key:"border"},breakpoint:{label:"Breakpoints",key:"breakpoint"},radius:{label:"Radii",key:"radius"},size:{label:"Sizes",key:"size"},spacing:{label:"Spacing",key:"spacing"},motion:{label:"Motion",key:"motion"},opacity:{label:"Opacity",key:"opacity"},variables:{label:"Figma Variables (BETA)",key:"variables",exclude:["original"]}},cr=e=>{var n,t;return void 0!==(null===(t=null===(n=e.extensions)||void 0===n?void 0:n[sn.key.extensionPluginData])||void 0===t?void 0:t.exportKey)?e.extensions[sn.key.extensionPluginData].exportKey:"missingExportKey"},dr={original:(e,n)=>"variables"===e.extensions[sn.key.extensionPluginData].exportKey?null:Object.assign(Object.assign({name:e.name,category:e.category,exportKey:e.extensions[sn.key.extensionPluginData].exportKey},e.description&&e.description.length>0&&{comment:e.description}),Gt[e.category](e.values)||{}),standard:ar,standardDeprecated:ar},fr=(e,n)=>"standard"===n.tokenFormat?JSON.parse(JSON.stringify(e.filter((e=>e.category===ur.font.key)))).map((e=>(e.name="typography/"+e.name.substr(e.name.indexOf("/")+1).trim().trimStart(),e.category=ur.typography.key,e.exportKey=ur.typography.key,!0!==n.excludeExtensionProp&&(e.extensions[sn.key.extensionPluginData].exportKey=ur.typography.key),e))):[],pr=(e,n)=>{0===e.length&&(e="[{}]");let t=JSON.parse(e);t=[...t,...fr(t,n)];const r=((e,n)=>e.length<=0?[]:e.map((e=>{var t,r,a,l;if(!1===n.prefixInName)e.name=e.name.substr(e.name.indexOf("/")+1).trim().trimLeft();else if(void 0!==(null===(r=null===(t=e.extensions)||void 0===t?void 0:t[sn.key.extensionPluginData])||void 0===r?void 0:r.alias)){const n=e.name.substr(0,e.name.indexOf("/")).trim().trimLeft();e.extensions[sn.key.extensionPluginData].alias=`${n}.${e.extensions[sn.key.extensionPluginData].alias}`}return n.keyInName&&(e.name=`${cr(e)}/${e.name}`,void 0!==(null===(l=null===(a=e.extensions)||void 0===a?void 0:a[sn.key.extensionPluginData])||void 0===l?void 0:l.alias)&&(e.extensions[sn.key.extensionPluginData].alias=`${cr(e)}.${e.extensions[sn.key.extensionPluginData].alias}`)),e})))(t.filter((({exportKey:e})=>n.exports[e])),n),a=r.map((e=>dr[n.tokenFormat](e,n))).filter(Boolean),l=((e,n)=>{if(e.length<=0)return[];const t=e.map((e=>{const t=e.name.split("/").map((e=>sr(e,n.nameConversion)));return delete e.name,r=e,t.reduceRight(((e,n)=>({[n]:e})),r);var r}));return t.reduce(((e={},n)=>or(e,n)))})(a,n);return l},gr=(e,n=!0)=>!0===n?JSON.stringify(e):JSON.stringify(e,null,2);const hr=je` display: flex; flex-direction: column; h1:first-child { @@ -647,7 +647,7 @@ select.select-menu { display: grid; grid-template-columns: repeat(3, 1fr); } -`,hr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),o=(0,e.useRef)();return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{if("[]"!==t)try{n.href=`data:application/design-tokens+json;charset=utf-8,${encodeURIComponent(t)}`,n.click(),e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🎉 Design token export successful!"}}},"*")}catch(n){e.postMessage({pluginMessage:{payload:{notification:"⛔️ Design token failed!"}}},"*"),console.error("Export error: ",n)}else e.postMessage({pluginMessage:{payload:{notification:"⛔️ No design token detected!"}}},"*")})(parent,o.current,pr(i,t.compression))}},className:gr},e.createElement(Je,{size:"xlarge",weight:"bold"},"File Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output file",type:"switch",checked:n.compression,onChange:e=>t((n=>{n.compression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"}),"standard"===n.tokenFormat&&e.createElement(e.Fragment,null,e.createElement(Be,{label:"Exclude extension property",type:"switch",checked:n.excludeExtensionProp,onChange:e=>t((n=>{n.excludeExtensionProp=e}))}),e.createElement(gn,{width:240,label:"The extension property holds additional information about the token"}))),e.createElement(Je,{size:"large",weight:"bold"},"Include types in export"),e.createElement("div",{className:"grid-3-col"},Object.entries(sr).map((([,{key:r,label:a,exclude:l}])=>(void 0===l||!l.includes(n.tokenFormat))&&e.createElement(Be,{key:r,label:a,checked:n.exports[r],onChange:e=>t((n=>{n.exports[r]=e}))})))),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")),e.createElement("a",{ref:o,download:`${n.filename}${n.extension}`,title:`${n.filename}${n.extension}`}))},mr=e=>401===e.status?"🚨 401: Check your access token":404===e.status?"🚨 404: Check your server url, auth type and the access token":e.status>399?`🚨 ${e.status}: An error occurred, please check the console for details.`:"🎉 Design tokens pushed to server!",vr=e=>{e.onerror=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 An error occurred while sending the tokens: check your settings & your server."}}},"*")},e.onload=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:mr(e.target)}}},"*")}};const br=je` +`,mr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),o=(0,e.useRef)();return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{if("[]"!==t)try{n.href=`data:application/design-tokens+json;charset=utf-8,${encodeURIComponent(t)}`,n.click(),e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🎉 Design token export successful!"}}},"*")}catch(n){e.postMessage({pluginMessage:{payload:{notification:"⛔️ Design token failed!"}}},"*"),console.error("Export error: ",n)}else e.postMessage({pluginMessage:{payload:{notification:"⛔️ No design token detected!"}}},"*")})(parent,o.current,gr(i,t.compression))}},className:hr},e.createElement(Je,{size:"xlarge",weight:"bold"},"File Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output file",type:"switch",checked:n.compression,onChange:e=>t((n=>{n.compression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"}),"standard"===n.tokenFormat&&e.createElement(e.Fragment,null,e.createElement(Be,{label:"Exclude extension property",type:"switch",checked:n.excludeExtensionProp,onChange:e=>t((n=>{n.excludeExtensionProp=e}))}),e.createElement(gn,{width:240,label:"The extension property holds additional information about the token"}))),e.createElement(Je,{size:"large",weight:"bold"},"Include types in export"),e.createElement("div",{className:"grid-3-col"},Object.entries(ur).map((([,{key:r,label:a,exclude:l}])=>(void 0===l||!l.includes(n.tokenFormat))&&e.createElement(Be,{key:r,label:a,checked:n.exports[r],onChange:e=>t((n=>{n.exports[r]=e}))})))),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")),e.createElement("a",{ref:o,download:`${n.filename}${n.extension}`,title:`${n.filename}${n.extension}`}))},vr=e=>401===e.status?"🚨 401: Check your access token":404===e.status?"🚨 404: Check your server url, auth type and the access token":e.status>399?`🚨 ${e.status}: An error occurred, please check the console for details.`:"🎉 Design tokens pushed to server!",br=e=>{e.onerror=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 An error occurred while sending the tokens: check your settings & your server."}}},"*")},e.onload=e=>{parent.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:vr(e.target)}}},"*")}};const yr=je` display: flex; flex-direction: column; h1:first-child { @@ -657,10 +657,10 @@ select.select-menu { display: grid; grid-template-columns: repeat(3, 1fr); } -`,yr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),[o,i]=(0,e.useState)("");return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{""===n.url&&e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 No server url was provided, push aborted!"}}},"*");const r=new XMLHttpRequest;r.open("POST",n.url),((e,n)=>{n.authType!==sn.key.authType.gitlabToken&&(e.setRequestHeader("Accept",n.acceptHeader||"application/vnd.github.everest-preview+json"),e.setRequestHeader("Content-Type",n.contentType||"text/plain;charset=UTF-8")),""!==n.accessToken&&""!==n.authType&&n.authType!==sn.key.authType.gitlabToken&&e.setRequestHeader("Authorization",`${n.authType} ${n.accessToken}`)})(r,n),vr(r);const a=((e,n)=>{let t;return e.authType===sn.key.authType.gitlabToken?(t=new FormData,t.append("token",e.accessToken),t.append("ref",e.reference),t.append("variables[FIGMA_EVENT_TYPE]",n.event_type),t.append("variables[FIGMA_CLIENT_PAYLOAD_TOKENS]",n.client_payload.tokens),t.append("variables[FIGMA_CLIENT_PAYLOAD_FILENAME]",n.client_payload.filename),t.append("variables[FIGMA_CLIENT_PAYLOAD_COMMIT_MESSAGE]",n.client_payload.commitMessage)):t=JSON.stringify(n,null,2),t})(n,t);r.send(a)})(parent,{url:n.serverUrl,accessToken:n.accessToken,acceptHeader:n.acceptHeader,contentType:n.contentType,authType:n.authType,reference:n.reference},{event_type:n.eventType,client_payload:{tokens:`${pr(i,n.urlJsonCompression)}`,filename:`${n.filename}${n.extension}`,commitMessage:`${o}`}})}},className:br},e.createElement(Je,{size:"xlarge",weight:"bold"},"URL Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output",type:"switch",checked:n.urlJsonCompression,onChange:e=>t((n=>{n.urlJsonCompression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"})),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"Server settings"),e.createElement("h3",null,"Event type",e.createElement(gn,{width:150,label:'"event_type" property in post request'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^[\\w\\-\\.\\+@]+$",placeholder:"update-tokens",value:n.eventType,onChange:e=>t((n=>{n.eventType=e}))})),e.createElement("h3",null,"Server url",e.createElement(gn,{width:150,label:"Url the request is sent to, must be https"})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^https://.*",placeholder:"https://api.github.com/repos/:username/:repo/dispatches",value:n.serverUrl,onChange:e=>t((n=>{n.serverUrl=e}))})),e.createElement("h3",null,"Accept header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"application/vnd.github.v3+json",value:n.acceptHeader,onChange:e=>t((n=>{n.acceptHeader=e}))})),e.createElement("h3",null,"Content-Type header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"text/plain;charset=UTF-8",value:n.contentType,onChange:e=>t((n=>{n.contentType=e}))})),e.createElement("h3",null,"Auth type"),e.createElement(fn,{fill:!0},e.createElement(Ge,{defaultValue:n.authType,onChange:({value:e})=>t((n=>{n.authType=e})),placeholder:"Auth type",options:[{label:"(Github) token",value:sn.key.authType.token},{label:"(Gitlab) token",value:sn.key.authType.gitlabToken},{label:"Basic authentication",value:sn.key.authType.basic},{label:"Bearer token authentication",value:sn.key.authType.bearer}]})),e.createElement("h3",null,"Access token"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"Your access token",value:n.accessToken,onChange:e=>t((n=>{n.accessToken=e}))})),n.authType===sn.key.authType.gitlabToken&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Reference",e.createElement(gn,{width:150,label:'The branch or commit to associate with a Gitlab trigger. Only used when Gitlab is selected for "Auth type"'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"main",value:n.reference,onChange:e=>t((n=>{n.reference=e}))}))),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"About This Export"),e.createElement("h3",null,"Commit Message",e.createElement(gn,{width:200,label:'Typically this will be a "commit message" for Git. Your organization may require a specific convention for these messages.'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",placeholder:"Describe what has changed since the last export",value:o,onChange:e=>i(e)})),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")))},xr=parent,wr=je` +`,xr=()=>{const{settings:n,updateSettings:t}=(0,e.useContext)(an),{tokens:r,setTokens:a}=(0,e.useContext)(ln),{figmaUIApi:l}=(0,e.useContext)(rn),[o,i]=(0,e.useState)("");return e.createElement("form",{onSubmit:e=>{if(e.preventDefault(),!0===e.target.checkValidity()){const{accessToken:e}=n,t=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{""===n.url&&e.postMessage({pluginMessage:{command:tn.closePlugin,payload:{notification:"🚨 No server url was provided, push aborted!"}}},"*");const r=new XMLHttpRequest;r.open("POST",n.url),((e,n)=>{n.authType!==sn.key.authType.gitlabToken&&(e.setRequestHeader("Accept",n.acceptHeader||"application/vnd.github.everest-preview+json"),e.setRequestHeader("Content-Type",n.contentType||"text/plain;charset=UTF-8")),""!==n.accessToken&&""!==n.authType&&n.authType!==sn.key.authType.gitlabToken&&e.setRequestHeader("Authorization",`${n.authType} ${n.accessToken}`)})(r,n),br(r);const a=((e,n)=>{let t;return e.authType===sn.key.authType.gitlabToken?(t=new FormData,t.append("token",e.accessToken),t.append("ref",e.reference),t.append("variables[FIGMA_EVENT_TYPE]",n.event_type),t.append("variables[FIGMA_CLIENT_PAYLOAD_TOKENS]",n.client_payload.tokens),t.append("variables[FIGMA_CLIENT_PAYLOAD_FILENAME]",n.client_payload.filename),t.append("variables[FIGMA_CLIENT_PAYLOAD_COMMIT_MESSAGE]",n.client_payload.commitMessage)):t=JSON.stringify(n,null,2),t})(n,t);r.send(a)})(parent,{url:n.serverUrl,accessToken:n.accessToken,acceptHeader:n.acceptHeader,contentType:n.contentType,authType:n.authType,reference:n.reference},{event_type:n.eventType,client_payload:{tokens:`${gr(i,n.urlJsonCompression)}`,filename:`${n.filename}${n.extension}`,commitMessage:`${o}`}})}},className:yr},e.createElement(Je,{size:"xlarge",weight:"bold"},"URL Export settings"),e.createElement(fn,null,e.createElement(Be,{label:"Compress JSON output",type:"switch",checked:n.urlJsonCompression,onChange:e=>t((n=>{n.urlJsonCompression=e}))}),e.createElement(gn,{width:240,label:"Compression removes line breaks and whitespace from the json string"})),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"Server settings"),e.createElement("h3",null,"Event type",e.createElement(gn,{width:150,label:'"event_type" property in post request'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^[\\w\\-\\.\\+@]+$",placeholder:"update-tokens",value:n.eventType,onChange:e=>t((n=>{n.eventType=e}))})),e.createElement("h3",null,"Server url",e.createElement(gn,{width:150,label:"Url the request is sent to, must be https"})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"^https://.*",placeholder:"https://api.github.com/repos/:username/:repo/dispatches",value:n.serverUrl,onChange:e=>t((n=>{n.serverUrl=e}))})),e.createElement("h3",null,"Accept header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"application/vnd.github.v3+json",value:n.acceptHeader,onChange:e=>t((n=>{n.acceptHeader=e}))})),e.createElement("h3",null,"Content-Type header"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"text/plain;charset=UTF-8",value:n.contentType,onChange:e=>t((n=>{n.contentType=e}))})),e.createElement("h3",null,"Auth type"),e.createElement(fn,{fill:!0},e.createElement(Ge,{defaultValue:n.authType,onChange:({value:e})=>t((n=>{n.authType=e})),placeholder:"Auth type",options:[{label:"(Github) token",value:sn.key.authType.token},{label:"(Gitlab) token",value:sn.key.authType.gitlabToken},{label:"Basic authentication",value:sn.key.authType.basic},{label:"Bearer token authentication",value:sn.key.authType.bearer}]})),e.createElement("h3",null,"Access token"),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"Your access token",value:n.accessToken,onChange:e=>t((n=>{n.accessToken=e}))})),n.authType===sn.key.authType.gitlabToken&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Reference",e.createElement(gn,{width:150,label:'The branch or commit to associate with a Gitlab trigger. Only used when Gitlab is selected for "Auth type"'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",required:!0,pattern:"\\S+",placeholder:"main",value:n.reference,onChange:e=>t((n=>{n.reference=e}))}))),e.createElement(mn,null),e.createElement(Je,{size:"xlarge",weight:"bold"},"About This Export"),e.createElement("h3",null,"Commit Message",e.createElement(gn,{width:200,label:'Typically this will be a "commit message" for Git. Your organization may require a specific convention for these messages.'})),e.createElement(fn,{fill:!0},e.createElement(qe,{type:"text",placeholder:"Describe what has changed since the last export",value:o,onChange:e=>i(e)})),e.createElement(cn,null,e.createElement(bn,{align:"start",href:"https://github.com/lukasoppermann/design-tokens#design-tokens"},"Documentation"),e.createElement(on,null),e.createElement(He,{type:"submit",autofocus:!0},"Save & Export")))},wr=parent,kr=je` padding: 8px var(--size-xxsmall) 0; margin-bottom: 0; form { margin-bottom: 0; } -`;(0,n.s)(document.getElementById("pluginUI")).render(e.createElement((()=>{const[n,t]=(0,e.useState)(null),[r,a]=(0,e.useState)(null),[l,o]=(0,e.useState)(null),[i,s]=(0,e.useState)(null),[u,c]=function(n){var t=(0,e.useState)((function(){return Tn("function"==typeof n?n():n,!0)})),r=t[1];return[t[0],(0,e.useCallback)((function(e){r("function"==typeof e?xt(e):Tn(e))}),[])]}(Et);return onmessage=e=>{const{command:n,payload:r}=e.data.pluginMessage||{};[tn.urlExport,tn.export,tn.generalSettings].includes(n)&&(c(Object.assign(Object.assign({},r.settings),{filename:r.settings.filename||r.metadata.filename})),t(r.versionDifference),s(r.metadata),o(r.data),a(n)),[tn.help,tn.demo,tn.openUrl].includes(n)&&(window.open(r.url),parent.postMessage({pluginMessage:{command:tn.closePlugin}},"*"))},e.createElement(rn.Provider,{value:{figmaUIApi:xr,figmaMetaData:i}},e.createElement(an.Provider,{value:{settings:u,updateSettings:c}},e.createElement(ln.Provider,{value:{tokens:l,setTokens:o}},e.createElement("main",{className:wr,onKeyDown:e=>((e,n)=>{if("Escape"===e.code){if(document.activeElement.classList.contains("select-menu__button--active"))return;n.postMessage({pluginMessage:{command:tn.closePlugin}},"*")}"Tab"===e.code&&(e=>{const n=((e=document)=>[...e.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled"))))(),t=n[n.length-1];e.shiftKey&&document.activeElement===n[0]&&(t.focus(),e.preventDefault()),e.shiftKey||document.activeElement!==t||(n[0].focus(),e.preventDefault())})(e)})(e,xr)},e.createElement(kt,{versionDifference:n}),r===tn.generalSettings&&e.createElement(En,null),r===tn.export&&e.createElement(hr,null),r===tn.urlExport&&e.createElement(yr,null)))))}),null))})()})(); \ No newline at end of file +`;(0,n.s)(document.getElementById("pluginUI")).render(e.createElement((()=>{const[n,t]=(0,e.useState)(null),[r,a]=(0,e.useState)(null),[l,o]=(0,e.useState)(null),[i,s]=(0,e.useState)(null),[u,c]=function(n){var t=(0,e.useState)((function(){return Tn("function"==typeof n?n():n,!0)})),r=t[1];return[t[0],(0,e.useCallback)((function(e){r("function"==typeof e?xt(e):Tn(e))}),[])]}(Et);return onmessage=e=>{const{command:n,payload:r}=e.data.pluginMessage||{};[tn.urlExport,tn.export,tn.generalSettings].includes(n)&&(c(Object.assign(Object.assign({},r.settings),{filename:r.settings.filename||r.metadata.filename})),t(r.versionDifference),s(r.metadata),o(r.data),a(n)),[tn.help,tn.demo,tn.openUrl].includes(n)&&(window.open(r.url),parent.postMessage({pluginMessage:{command:tn.closePlugin}},"*"))},e.createElement(rn.Provider,{value:{figmaUIApi:wr,figmaMetaData:i}},e.createElement(an.Provider,{value:{settings:u,updateSettings:c}},e.createElement(ln.Provider,{value:{tokens:l,setTokens:o}},e.createElement("main",{className:kr,onKeyDown:e=>((e,n)=>{if("Escape"===e.code){if(document.activeElement.classList.contains("select-menu__button--active"))return;n.postMessage({pluginMessage:{command:tn.closePlugin}},"*")}"Tab"===e.code&&(e=>{const n=((e=document)=>[...e.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled"))))(),t=n[n.length-1];e.shiftKey&&document.activeElement===n[0]&&(t.focus(),e.preventDefault()),e.shiftKey||document.activeElement!==t||(n[0].focus(),e.preventDefault())})(e)})(e,wr)},e.createElement(kt,{versionDifference:n}),r===tn.generalSettings&&e.createElement(En,null),r===tn.export&&e.createElement(mr,null),r===tn.urlExport&&e.createElement(xr,null)))))}),null))})()})(); \ No newline at end of file diff --git a/src/transformer/standardTransformer.ts b/src/transformer/standardTransformer.ts index 912253f2..df3f8385 100644 --- a/src/transformer/standardTransformer.ts +++ b/src/transformer/standardTransformer.ts @@ -4,6 +4,7 @@ import { StandardTokenInterface, StandardTokenTypes, StandardTokenDataInterface, import roundWithDecimals from '../utilities/roundWithDecimals' import { tokenExtensions } from './tokenExtensions' import config from '@config/config' +import { changeNotation } from '@src/utilities/changeNotation' const lineHeightToDimension = (values): number => { if (values.lineHeight.unit === 'pixel') { @@ -257,11 +258,13 @@ const valueTransformer = { } const transformVariable = ({ values, category }): StandardTokenDataInterface => { + const refRegEx = /^{[\w\s\.\-\_\/\@\+\&\:]*}$/ + console.log(values, refRegEx.test(values)) // is alias - if (/^{[\w\s\.]*}$/.test(values)) { + if (refRegEx.test(values)) { return { type: category as StandardTokenTypes, - value: values + value: changeNotation(values, "/", ".") } } if (category === 'color') {