Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

framer-plugin

Package Overview
Dependencies
Maintainers
0
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

framer-plugin - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

8

dist/index.js

@@ -1,4 +0,4 @@

var zt=Object.defineProperty;var Ht=(n,e,t)=>e in n?zt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>(Ht(n,typeof e!="symbol"?e+"":e,t),t),tt=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var r=(n,e,t)=>(tt(n,e,"read from private field"),t?t.call(n):e.get(n)),m=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},g=(n,e,t,o)=>(tt(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var we=(n,e,t,o)=>({set _(s){g(n,e,s,t)},get _(){return r(n,e,o)}});import ee from"react";import{useCallback as hn,useEffect as yn,useRef as fn}from"react";var Kt="invoke";function P(n){return Kt in n}function f(n){return n===null}function Re(n){return n===!0||n===!1}function d(n){return typeof n=="string"}function U(n){return typeof n=="number"&&Number.isFinite(n)}function Pe(n){return typeof n=="function"}function c(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Le(n){return Array.isArray(n)}function A(n,e){throw e||new Error(n?`Unexpected value: ${n}`:"Application entered invalid state")}function l(n,...e){if(n)return;let t=Error("Assertion Error"+(e.length>0?": "+e.join(" "):""));if(t.stack)try{let o=t.stack.split(`
`);o[1]?.includes("assert")?(o.splice(1,1),t.stack=o.join(`
`)):o[0]?.includes("assert")&&(o.splice(0,1),t.stack=o.join(`
`))}catch{}throw t}var jt="FileAsset",$t="__class";function Te(n){return c(n)?n[$t]===jt:!1}var I=class{constructor(e){i(this,"id");i(this,"url");i(this,"extension");this.url=e.url,this.id=e.id,this.extension=e.extension}};function xe(n){return n instanceof I}var Xt="ImageAsset",Yt="__class";function H(n){return c(n)?n[Yt]===Xt:!1}var R,z,Ge=class Ge{constructor(e,t){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");m(this,R,void 0);m(this,z,void 0);l(P(t)),g(this,z,t),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText}cloneWithAttributes({altText:e}){return new Ge({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText},r(this,z))}async measure(){return Zt(this.url)}async getData(){if(r(this,R)&&r(this,R).bytes.length>0)return r(this,R);let e=await r(this,z).invoke("getImageData",{id:this.id});if(!e)throw new Error("Failed to load image data");return g(this,R,e),e}async loadBitmap(){let{mimeType:e,bytes:t}=await this.getData(),o=new Blob([t],{type:e});return createImageBitmap(o)}async loadImage(){let e=await this.getData(),t=URL.createObjectURL(new Blob([e.bytes]));return new Promise((o,s)=>{let a=new Image;a.onload=()=>o(a),a.onerror=()=>s(),a.src=t})}};R=new WeakMap,z=new WeakMap;var y=Ge;function Ie(n){return n instanceof y}function F(n){return n.type==="bytes"?[n.bytes.buffer]:[]}function qt(n){if(!c(n))return!1;let e="bytes",t="mimeType";return!(!(e in n)||!(t in n)||!(n[e]instanceof Uint8Array)||!d(n[t]))}async function oe(n){if(n instanceof File)return Ee(n);let e=await nt(n.image);return{name:n.name,altText:n.altText,...e}}async function Ve(n){if(n instanceof File)return Ee(n);let e=await nt(n.file);return{name:n.name,...e}}async function nt(n){return n instanceof File?Ee(n):qt(n)?{type:"bytes",mimeType:n.mimeType,bytes:n.bytes}:{type:"url",url:n}}function Me(n){return Promise.all(n.map(oe))}async function Ee(n){return new Promise((e,t)=>{let o=new FileReader;o.onload=s=>{let a=n.type,u=s.target?.result;if(!u||!(u instanceof ArrayBuffer)){t(new Error("Failed to read file, arrayBuffer is null"));return}let v=new Uint8Array(u);e({bytes:v,mimeType:a,type:"bytes",name:n.name})},o.onerror=s=>{t(s)},o.readAsArrayBuffer(n)})}async function Zt(n){let e=n instanceof File,t=e?URL.createObjectURL(n):n,o=new Image;return o.crossOrigin="anonymous",o.src=t,await o.decode().finally(()=>{e&&URL.revokeObjectURL(t)}),{height:o.height,width:o.width}}var Qt="Font";function ot(n){return c(n)&&n.__class===Qt}function Jt(n){if(!U(n))return!1;switch(n){case 100:case 200:case 300:case 400:case 500:case 600:case 700:case 800:case 900:return!0;default:return!1}}function en(n){if(!d(n))return!1;switch(n){case"normal":case"italic":return!0;default:return!1}}function re(n){return c(n)?d(n.family)&&d(n.selector)&&Jt(n.weight)&&en(n.style):!1}var W=class{constructor(e){i(this,"selector");i(this,"family");i(this,"weight");i(this,"style");this.selector=e.selector,this.family=e.family,this.weight=e.weight,this.style=e.style}},it=new Map;function L(n){let e=it.get(n.selector);if(e)return e;let t=new W(n);return it.set(n.selector,t),t}function V(n){return{__class:"Font",selector:n.selector,family:n.family,weight:n.weight,style:n.style}}var rt="__class",Oe="LinearGradient",Be="RadialGradient",_e="ConicGradient";function Ne(n){if(!c(n))return!1;switch(n[rt]){case Oe:case Be:case _e:return!0;default:return!1}}function se(n){return n instanceof K||n instanceof j||n instanceof $}function st(n){if(n instanceof K)return{__class:Oe,angle:n.angle,stops:n.stops};if(n instanceof j)return{__class:Be,width:n.width,height:n.height,x:n.x,y:n.y,stops:n.stops};if(n instanceof $)return{__class:_e,angle:n.angle,x:n.x,y:n.y,stops:n.stops};A(n)}function Ce(n){switch(n[rt]){case Oe:return new K(n);case Be:return new j(n);case _e:return new $(n);default:A(n)}}var K=class n{constructor(e){i(this,"angle");i(this,"stops");this.angle=e.angle,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({angle:e.angle??this.angle,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(t=>`${t.color} ${t.position*100}%`).join(", ");return`linear-gradient(${this.angle}deg, ${e})`}},j=class n{constructor(e){i(this,"width");i(this,"height");i(this,"x");i(this,"y");i(this,"stops");this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({width:e.width??this.width,height:e.height??this.height,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map((t,o)=>{let s=this.stops[o+1],a=t.position===1&&s?.position===1?t.position-1e-4:t.position;return`${t.color} ${a*100}%`}).join(", ");return`radial-gradient(${this.width} ${this.height} at ${this.x} ${this.y}, ${e})`}},$=class n{constructor(e){i(this,"angle");i(this,"x");i(this,"y");i(this,"stops");this.angle=e.angle,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({angle:e.angle??this.angle,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(t=>`${t.color} ${t.position*360}deg`).join(", ");return`conic-gradient(from ${this.angle}deg at ${this.x} ${this.y}, ${e})`}};var N,Ue=class Ue{constructor(e,t){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");m(this,N,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.light=e.light,this.dark=e.dark,l(P(t)),g(this,N,t)}async setAttributes(e){let t=await r(this,N).invoke("setColorStyleAttributes",this.id,e);return t?new Ue(t,r(this,N)):null}async getPluginData(e){return r(this,N).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,N).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,N).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,N).invoke("removeColorStyle",this.id)}};N=new WeakMap;var M=Ue,tn="TextStyle",nn="__class";function at(n){return c(n)?n[nn]===tn:!1}var C,ze=class ze{constructor(e,t){i(this,"id");i(this,"name");i(this,"tag");i(this,"font");i(this,"boldFont");i(this,"italicFont");i(this,"boldItalicFont");i(this,"color");i(this,"transform");i(this,"alignment");i(this,"decoration");i(this,"balance");i(this,"breakpoints");i(this,"minWidth");i(this,"fontSize");i(this,"letterSpacing");i(this,"lineHeight");i(this,"paragraphSpacing");m(this,C,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.tag=e.tag,this.font=new W(e.font),this.boldFont=e.boldFont?new W(e.boldFont):null,this.italicFont=e.italicFont?new W(e.italicFont):null,this.boldItalicFont=e.boldItalicFont?new W(e.boldItalicFont):null,this.color=e.color,this.transform=e.transform,this.alignment=e.alignment,this.decoration=e.decoration,this.balance=e.balance,this.breakpoints=e.breakpoints,this.minWidth=e.minWidth,this.fontSize=e.fontSize,this.letterSpacing=e.letterSpacing,this.lineHeight=e.lineHeight,this.paragraphSpacing=e.paragraphSpacing,l(P(t)),g(this,C,t)}async setAttributes(e){let t=await r(this,C).invoke("setTextStyleAttributes",this.id,e);return t?new ze(t,r(this,C)):null}async getPluginData(e){return r(this,C).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,C).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,C).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,C).invoke("removeTextStyle",this.id)}};C=new WeakMap;var x=ze;function X(n){return n instanceof x}function lt(n){return{__class:"TextStyle",id:n.id,name:n.name,tag:n.tag,font:V(n.font),boldFont:n.boldFont?V(n.font):null,italicFont:n.italicFont?V(n.italicFont):null,boldItalicFont:n.boldItalicFont?V(n.boldItalicFont):null,color:n.color,transform:n.transform,alignment:n.alignment,decoration:n.decoration,balance:n.balance,breakpoints:n.breakpoints,minWidth:n.minWidth,fontSize:n.fontSize,letterSpacing:n.letterSpacing,lineHeight:n.lineHeight,paragraphSpacing:n.paragraphSpacing}}function E(n){if(rn(n))return sn(n);if(Le(n))return n.map(E);if(c(n)){let e={};for(let t in n)e[t]=E(n[t]);return e}return n}function dt(n,e){let t={};for(let o in n)t[o]=He(n[o],e);return t}function He(n,e){if(on(n))switch(n.__class){case"ImageAsset":return new y(n,e);case"FileAsset":return new I(n);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Ce(n);case"TextStyle":return new x(n,e);case"Font":return L(n);default:A(n)}if(c(n)){let t={};for(let o in n)t[o]=He(n[o],e);return t}return Le(n)?n.map(t=>He(t,e)):n}function on(n){return!!(H(n)||Te(n)||Ne(n))}function rn(n){return!!(Ie(n)||xe(n)||se(n)||X(n)||re(n))}function sn(n){if(Ie(n))return{__class:"ImageAsset",id:n.id,thumbnailUrl:n.thumbnailUrl,url:n.url,altText:n.altText};if(xe(n))return{__class:"FileAsset",id:n.id,extension:n.extension,url:n.url};if(se(n))return st(n);if(X(n))return lt(n);if(re(n))return V(n);A(n)}function an(n,e){for(let t in n){let o=n[t];H(o)&&(n[t]=new y(o,e)),Te(o)&&(n[t]=new I(o))}}var T,Se=class{constructor(e,t){i(this,"id");i(this,"name");m(this,T,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(P(t)),g(this,T,t),Object.freeze(this)}async getItemIds(){return r(this,T).invoke("getManagedCollectionItemIds",this.id)}async setItemOrder(e){return r(this,T).invoke("setManagedCollectionItemOrder",this.id,e)}async getFields(){return r(this,T).invoke("getManagedCollectionFields",this.id)}async setFields(e){return r(this,T).invoke("setManagedCollectionFields",this.id,e)}async addItems(e){return r(this,T).invoke("addManagedCollectionItems",this.id,e)}async removeItems(e){return r(this,T).invoke("removeManagedCollectionItems",this.id,e)}async setPluginData(e,t){return r(this,T).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,T).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,T).invoke("getPluginDataKeysForNode",this.id)}};T=new WeakMap;var S,Y=class{constructor(e,t){i(this,"id");i(this,"name");m(this,S,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(P(t)),g(this,S,t),Object.freeze(this)}async getFields(){return r(this,S).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,S).invoke("getCollectionItems",this.id)).map(t=>new Ke(t,r(this,S)))}async setPluginData(e,t){return r(this,S).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}};S=new WeakMap;var G,Ke=class{constructor(e,t){i(this,"id");i(this,"slug");i(this,"fieldData");m(this,G,void 0);this.id=e.id,this.slug=e.slug,this.fieldData=e.fieldData,an(this.fieldData,t),l(P(t)),g(this,G,t),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,t){return r(this,G).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,G).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,G).invoke("getPluginDataKeysForNode",this.id)}};G=new WeakMap;var ln=(()=>{let n=null;return{disableUntilMouseUp:()=>{if(n)return;n=document.createElement("style"),n.textContent="* { pointer-events: none !important; user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(n);let e=()=>{n&&(document.head.removeChild(n),n=null,s())},t=a=>{a.buttons>0&&a.buttons&1||e()},o=()=>{e()};window.addEventListener("pointerup",t,!0),window.addEventListener("pointermove",t,!0),window.addEventListener("blur",o);function s(){window.removeEventListener("pointerup",t,!0),window.removeEventListener("pointermove",t,!0),window.removeEventListener("blur",o)}}}})(),ut=5,dn=(()=>{let n=1;return{next:()=>`drag-${n++}`}})();function un(){}function ct(n,e,t){if(n.mode!=="canvas")return un;l(P(n));let o=dn.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,v=h=>{a.type!=="idle"&&(a.type==="dragging"&&n.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Ut())},he=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){v({cancelled:!1});return}let{clientX:ye,clientY:ne}=h;if(a.type==="pointerDown"){let ie=ye-a.dragStart.mouse.x,et=ne-a.dragStart.mouse.y;if(Math.abs(ie)<ut&&Math.abs(et)<ut)return;a={type:"dragging",dragStart:a.dragStart},n.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),ln.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let fe={x:ye,y:ne};n.invoke("onDrag",{dragSessionId:o,mouse:fe}).then(ie=>{a.type==="dragging"&&(document.body.style.cursor=ie??"")})},qe=h=>{h.key==="Escape"&&v({cancelled:!0})},Ze=()=>{v({cancelled:!0})},Qe=h=>{v({cancelled:!0});let te=e.getBoundingClientRect(),ye={x:te.x,y:te.y,width:te.width,height:te.height},ne,fe=e.querySelectorAll("svg");if(fe.length===1){let be=fe.item(0).getBoundingClientRect();ne={x:be.x,y:be.y,width:be.width,height:be.height}}let ie={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:ye,svgRect:ne,mouse:ie}},n.invoke("setDragData",o,t()),u.addEventListener("pointermove",he,!0),u.addEventListener("pointerup",he,!0),window.addEventListener("keydown",qe,!0),window.addEventListener("blur",Ze)},Je=()=>{let h=t();h.type==="detachedComponentLayers"&&n.invoke("preloadDetachedComponentLayers",h.url),h.type==="image"&&n.invoke("preloadImageUrlForInsertion",h.image),h.previewImage&&n.invoke("preloadDragPreviewImage",h.previewImage)};e.addEventListener("pointerdown",Qe),e.addEventListener("mouseenter",Je);function Ut(){document.body.style.cursor=s,u.removeEventListener("pointermove",he,!0),u.removeEventListener("pointerup",he,!0),window.removeEventListener("keydown",qe,!0),window.removeEventListener("blur",Ze)}return()=>{e.removeEventListener("pointerdown",Qe),e.removeEventListener("mouseenter",Je),v({cancelled:!0})}}var ae=class extends Error{};var cn={canvas:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function mt(n){return d(n)&&n in cn}var mn={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function gn(n){return d(n)&&n in mn}function gt(n){return c(n)&&gn(n["type"])}var pe,b,k,D=class{constructor(e,t){i(this,"id");m(this,pe,void 0);m(this,b,void 0);m(this,k,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,g(this,b,t),g(this,pe,e.originalId??null),l(P(t)),g(this,k,t)}get isReplica(){return r(this,pe)!==null}remove(){return r(this,b).removeNode(this.id)}select(){return r(this,b).setSelection([this.id])}clone(){return r(this,b).cloneNode(this.id)}setAttributes(e){return r(this,b).setAttributes(this.id,e)}getRect(){return r(this,b).getRect(this.id)}zoomIntoView(e){return r(this,b).zoomIntoView([this.id],e)}getParent(){return r(this,b).getParent(this.id)}getChildren(){return O(this)?Promise.resolve([]):r(this,b).getChildren(this.id)}async getNodesWithType(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,b)))}async getNodesWithAttribute(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,b)))}async getNodesWithAttributeSet(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,b)))}async*walk(){if(yield this,!O(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,k).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,k).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,k).invoke("getPluginDataKeysForNode",this.id)}};pe=new WeakMap,b=new WeakMap,k=new WeakMap;var B=class extends D{constructor(t,o){super(t,o);i(this,"__class","FrameNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"backgroundColor");i(this,"backgroundImage");i(this,"backgroundGradient");i(this,"rotation");i(this,"opacity");i(this,"borderRadius");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");i(this,"link");i(this,"linkOpenInNewTab");l(t.__class==="FrameNode","FrameNode must have a __class property"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.backgroundColor=t.backgroundColor??null,this.backgroundImage=t.backgroundImage?new y(t.backgroundImage,o):null,this.rotation=t.rotation??0,this.opacity=t.opacity??1,this.borderRadius=t.borderRadius??null,this.backgroundGradient=Ne(t.backgroundGradient)?Ce(t.backgroundGradient):null,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,this.aspectRatio=t.aspectRatio??null,this.link=t.link??null,this.linkOpenInNewTab=t.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},q,le=class extends D{constructor(t,o){super(t,o);i(this,"__class","TextNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"rotation");i(this,"opacity");i(this,"font");i(this,"inlineTextStyle");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"link");i(this,"linkOpenInNewTab");m(this,q,void 0);l(P(o)),g(this,q,o),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.rotation=t.rotation??0,this.opacity=t.opacity??1,this.font=t.font?L(t.font):null,this.inlineTextStyle=t.inlineTextStyle?new x(t.inlineTextStyle,o):null,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,this.link=t.link??null,this.linkOpenInNewTab=t.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}async setText(t){await r(this,q).invoke("setTextForNode",this.id,t)}async getText(){return r(this,q).invoke("getTextForNode",this.id)}};q=new WeakMap;var de=class extends D{constructor(t,o){super(t,o);i(this,"__class","SVGNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"svg");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");l(t.svg,"SVG node must have a non-empty SVG string"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.svg=t.svg,this.rotation=t.rotation??0,this.opacity=t.opacity??1,l(t.position,"Must have a position"),this.position=t.position??null,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},ue=class extends D{constructor(t,o){super(t,o);i(this,"__class","ComponentInstanceNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");i(this,"controls");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");l(t.componentIdentifier,"ComponentInstance node must have a component identifier"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.componentIdentifier=t.componentIdentifier,this.componentName=t.componentName??null,this.insertURL=t.insertURL??null,this.controls=dt(t.controls??{},o),this.rotation=t.rotation??0,this.opacity=t.opacity??1,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,this.aspectRatio=t.aspectRatio??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},ce=class extends D{constructor(t,o){super(t,o);i(this,"_class","WebPageNode");i(this,"path");i(this,"collectionId");l(t),this.path=t.path??null,this.collectionId=t.collectionId??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},me=class extends D{constructor(t,o){super(t,o);i(this,"__class","ComponentNode");i(this,"name");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");l(t.componentIdentifier,"ComponentNode must have a componentIdentifier"),this.componentIdentifier=t.componentIdentifier,this.insertURL=t.insertURL??null,this.componentName=t.componentName??null,this.name=t.name??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},ge=class extends D{constructor(t,o){super(t,o);i(this,"__class","UnknownNode");Object.freeze(this)}clone(){throw Error("Can not clone unknown node")}setAttributes(t){throw Error("Can not set attributes on unknown node")}};function p(n,e){switch(n.__class){case"WebPageNode":return new ce(n,e);case"ComponentNode":return new me(n,e);case"ComponentInstanceNode":return new ue(n,e);case"FrameNode":return new B(n,e);case"SVGNode":return new de(n,e);case"TextNode":return new le(n,e);case"UnknownNode":return new ge(n,e);default:return new ge(n,e)}}function je(n){return E(n)}function ke(n){return n instanceof B}function pt(n){return n instanceof le}function ht(n){return n instanceof de}function ve(n){return n instanceof ue}function yt(n){return n instanceof ce}function ft(n){return n instanceof me}function O(n){return n instanceof ge}function De(n){return!!(ke(n)||pt(n)||ve(n)||ht(n)||O(n))}function $e(n){return!!(yt(n)||ft(n)||O(n))}var Z=null;function bt(n){if(!Z){let t=document.createElement("style");document.head.appendChild(t),Z=t.sheet}if(!Z){n();return}let e=Z.insertRule("* { transition: none !important; animation: none !important; }");n(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Z&&Z.deleteRule(e)})})}var pn=2,Fe,We,Q,_,J,w,Ae=class{constructor({isTestEnv:e}={}){m(this,Fe,0);m(this,We,0);m(this,Q,[]);m(this,_,void 0);m(this,J,new Map);m(this,w,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let t=e.data;if(gt(t))switch(t.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+t.type);l(r(this,w)===t.mode,"Mode must match"),this.applyPluginTheme(t.theme),g(this,_,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,Q))r(this,_).call(this,...s);g(this,Q,[]);break}case"methodResponse":{let o=r(this,J).get(t.id);if(!o)throw new Error(`No handler for response with id ${t.id}`);r(this,J).delete(t.id),t.error?o.reject(new ae(t.error)):o.resolve(t.result);break}case"subscriptionMessage":{let{topic:o,payload:s}=t,a=this.subscriptions.get(o);if(!a)throw new Error("Received a subscription message but no handler present");for(let u of a)u(s);break}default:A(t)}});i(this,"applyPluginTheme",e=>{bt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let t in e.tokens)document.body.style.setProperty(t,e.tokens[t])})});if(e){g(this,w,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),g(this,w,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(mt(o),`Invalid mode: ${o}`),g(this,w,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal",breakingChangesVersion:pn};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,w)}invoke(e,...t){return this.invokeTransferable(e,void 0,...t)}invokeTransferable(e,t,...o){return new Promise((s,a)=>{let u={args:o,methodName:e,id:we(this,Fe)._++,type:"methodInvocation"},v=s;r(this,J).set(u.id,{resolve:v,reject:a}),this.queueMessage(u,t)})}subscribe(e,t){this.queueMessage({type:"subscribe",topic:e});let o=this.subscriptions.get(e)??new Set;return o.add(t),this.subscriptions.set(e,o),()=>{let s=this.subscriptions.get(e)??new Set;s.delete(t),s.size===0&&this.queueMessage({type:"unsubscribe",topic:e}),this.subscriptions.set(e,s)}}queueMessage(e,t){if(!r(this,_)){r(this,Q).push([e,t]);return}r(this,_).call(this,e,t)}async showUI(e){return this.invoke("showUI",e)}async hideUI(){return this.invoke("hideUI")}async closePlugin(e,t){return this.invoke("closePlugin",e,t)}async getCurrentUser(){return this.invoke("getCurrentUser")}async getProjectInfo(){return this.invoke("getProjectInfo")}async getSelection(){return(await this.invoke("getSelection")).map(t=>{let o=p(t,this);return l(De(o)),o})}async setSelection(e){let t=d(e)?[e]:Array.from(e);return this.invoke("setSelection",t)}subscribeToSelection(e){return this.subscribe("selection",t=>{let o=t.map(s=>{let a=p(s,this);return l(De(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),t=p(e,this);return l($e(t)),t}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",t=>{let o=p(t,this);l($e(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,t){let o=je(e),s=await this.invoke("createNode","FrameNode",t??null,o);if(!s)return null;let a=p(s,this);return l(a instanceof B),a}async removeNode(e){return this.invoke("removeNode",e)}async cloneNode(e){let t=await this.invoke("cloneNode",e);return t?p(t,this):null}async getNode(e){let t=await this.invoke("getNode",e);return t?p(t,this):null}async getParent(e){let t=await this.invoke("getParent",e);return t?p(t,this):null}async getChildren(e){return(await this.invoke("getChildren",e)).map(o=>{let s=p(o,this);return l(De(s)),s})}async getRect(e){return this.invoke("getRect",e)}async zoomIntoView(e,t){let o=d(e)?[e]:Array.from(e);return this.invoke("zoomIntoView",o,t)}async setAttributes(e,t){let o=je(t),s=await this.invoke("setAttributes",e,o);return s?p(s,this):null}async setParent(e,t,o){return this.invoke("setParent",e,t,o)}async getNodesWithType(e){return(await this.invoke("getNodesWithType",null,e)).map(o=>p(o,this))}async getNodesWithAttribute(e){return(await this.invoke("getNodesWithAttribute",null,e)).map(o=>p(o,this))}async getNodesWithAttributeSet(e){return(await this.invoke("getNodesWithAttributeSet",null,e)).map(o=>p(o,this))}async getImage(){let e=await this.invoke("getImage");return e?new y(e,this):null}subscribeToImage(e){return this.subscribe("image",t=>{if(!t){e(null);return}e(new y(t,this))})}async addImage(e){let t=await oe(e),o=F(t);return this.invokeTransferable("addImage",o,t)}async setImage(e){let t=await oe(e),o=F(t);return this.invokeTransferable("setImage",o,t)}async uploadImage(e){let t=await oe(e),o=F(t),s=await this.invokeTransferable("uploadImage",o,t);return new y(s,this)}async addImages(e){let t=await Me(e),o=t.flatMap(F);await this.invokeTransferable("addImages",o,t)}async uploadImages(e){let t=await Me(e),o=t.flatMap(F),s=await this.invokeTransferable("uploadImages",o,t),a=[];for(let u of s)a.push(new y(u,this));return a}async uploadFile(e){let t=await Ve(e),o=await this.invokeTransferable("uploadFile",F(t),t);return new I(o)}async uploadFiles(e){let t=await Promise.all(e.map(Ve)),o=t.flatMap(F),s=await this.invokeTransferable("uploadFiles",o,t),a=[];for(let u of s)a.push(new I(u));return a}async addSVG(e){return this.invoke("addSVG",e)}async addComponentInstance({url:e,attributes:t}){let o=E(t),s=await this.invoke("addComponentInstance",{url:e,attributes:c(o)?o:void 0}),a=p(s,this);return l(ve(a)),a}async addDetachedComponentLayers({url:e,layout:t,attributes:o}){let s=E(o),a=await this.invoke("addDetachedComponentLayers",{url:e,layout:t,attributes:c(s)?s:void 0}),u=p(a,this);return l(ke(u)),u}async preloadDetachedComponentLayers(e){await this.invoke("preloadDetachedComponentLayers",e)}async preloadImageUrlForInsertion(e){await this.invoke("preloadImageUrlForInsertion",e)}async preloadDragPreviewImage(e){await this.invoke("preloadDragPreviewImage",e)}async getText(){return this.invoke("getText")}async setText(e){return this.invoke("setText",e)}async addText(e,t){return this.invoke("addText",e,t)}async setCustomCode(e){return this.invoke("setCustomCode",e)}async getCustomCode(){return this.invoke("getCustomCode")}subscribeToCustomCode(e){return this.subscribe("customCode",e)}subscribeToText(e){return this.subscribe("text",e)}makeDraggable(e,t){return ct(this,e,t)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new Se(e,this)}async getCollection(e){let t=await this.invoke("getCollection",e);return t?new Y(t,this):null}async getActiveCollection(){let e=await this.invoke("getActiveCollection");return l(e),new Y(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(t=>new Y(t,this))}notify(e,t){let o=`notification-${we(this,We)._++}`;return this.invoke("notify",e,{notificationId:o,variant:t?.variant??"info",buttonText:t?.button?.text,durationMs:t?.durationMs}).then(s=>{s==="actionButtonClicked"&&t?.button?.onClick&&t.button.onClick(),t?.onDisappear&&t.onDisappear()}),{close:()=>this.invoke("closeNotification",o)}}async getPluginData(e){return this.invoke("getPluginData",e)}async setPluginData(e,t){return this.invoke("setPluginData",e,t)}async getPluginDataKeys(){return this.invoke("getPluginDataKeys")}async getColorStyles(){return(await this.invoke("getColorStyles")).map(t=>new M(t,this))}async getColorStyle(e){let t=await this.invoke("getColorStyle",e);return t?new M(t,this):null}async createColorStyle(e){let t=await this.invoke("createColorStyle",e);return new M(t,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",t=>{let o=t.map(s=>new M(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(t=>new x(t,this))}async getTextStyle(e){let t=await this.invoke("getTextStyle",e);return t?new x(t,this):null}async createTextStyle(e){let t=await this.invoke("createTextStyle",e);return new x(t,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",t=>{let o=t.map(s=>new x(s,this));return e(o)})}async getFont(e,t){let o=await this.invoke("getFont",e,t);return o?L(o):null}async getFonts(){return(await this.invoke("getFonts")).map(L)}async unstable_ensureMinimumDependencyVersion(e,t){return this.invoke("unstable_ensureMinimumDependencyVersion",e,t)}};Fe=new WeakMap,We=new WeakMap,Q=new WeakMap,_=new WeakMap,J=new WeakMap,w=new WeakMap;var Xe=new Ae;function Ye(n,e){let t=bn(()=>Pe(e)?e():e);yn(()=>{let o=n.current;if(o instanceof HTMLElement)return Xe.makeDraggable(o,t)},[t])}function bn(n){let e=fn(n);return e.current=n,hn((...t)=>e.current(...t),[])}var Pn=ee.forwardRef(function({data:e,children:t,...o},s){let a=ee.useRef(null);if(Ye(a,e),ee.isValidElement(t)){let u=Object.assign({},o);return c(t.props)&&Object.assign(u,t.props),u.ref=In(a,s,t.ref),ee.cloneElement(t,u)}return ee.Children.count(t)>1&&ee.Children.only(t),null}),Tn="current";function xn(n){return c(n)&&Tn in n}function In(...n){return e=>{for(let t of n)Pe(t)?t(e):xn(t)&&(t.current=e)}}var Nn={fixed:!0,sticky:!0,absolute:!0,relative:!0},Pt="position";function Ki(n){if(!(Pt in n))return!1;let e=n[Pt];return d(e)&&Nn[e]===!0}var Tt="top";function ji(n){if(!(Tt in n))return!1;let e=n[Tt];return d(e)||f(e)}var xt="width";function $i(n){if(!(xt in n))return!1;let e=n[xt];return d(e)||f(e)}var It="maxWidth";function Xi(n){if(!(It in n))return!1;let e=n[It];return d(e)||f(e)}var Nt="aspectRatio";function Yi(n){if(!(Nt in n))return!1;let e=n[Nt];return U(e)||f(e)}var Ct="name";function qi(n){if(!(Ct in n))return!1;let e=n[Ct];return d(e)||f(e)}var St="visible";function Zi(n){if(!(St in n))return!1;let e=n[St];return Re(e)}var kt="locked";function Qi(n){if(!(kt in n))return!1;let e=n[kt];return Re(e)}var vt="backgroundColor";function Ji(n){if(!(vt in n))return!1;let e=n[vt];return d(e)||f(e)}var Dt="backgroundImage";function eo(n){if(!(Dt in n))return!1;let e=n[Dt];return e instanceof y||f(e)}var At="backgroundImage";function to(n){if(!(At in n))return!1;let e=n[At];return e instanceof y?!1:H(e)||f(e)}var Ft="backgroundGradient";function no(n){if(!(Ft in n))return!1;let e=n[Ft];return se(e)||f(e)}var Wt="backgroundGradient";function io(n){if(!(Wt in n))return!1;let e=n[Wt];return c(e)||f(e)}var wt="rotation";function oo(n){if(!(wt in n))return!1;let e=n[wt];return U(e)}var Rt="opacity";function ro(n){if(!(Rt in n))return!1;let e=n[Rt];return U(e)}var Lt="borderRadius";function so(n){if(!(Lt in n))return!1;let e=n[Lt];return d(e)||f(e)}var Vt="svg";function ao(n){if(!(Vt in n))return!1;let e=n[Vt];return d(e)}var Mt="componentIdentifier";function lo(n){if(!(Mt in n))return!1;let e=n[Mt];return d(e)}var Et="font";function uo(n){if(!(Et in n))return!1;let e=n[Et];return re(e)}var Gt="font";function co(n){if(!(Gt in n))return!1;let e=n[Gt];return ot(e)||f(e)}var Ot="inlineTextStyle";function mo(n){if(!(Ot in n))return!1;let e=n[Ot];return X(e)||f(e)}var Bt="inlineTextStyle";function go(n){if(!(Bt in n))return!1;let e=n[Bt];return at(e)||f(e)}var _t="link";function po(n){if(!(_t in n))return!1;let e=n[_t];return d(e)||f(e)}export{ue as ComponentInstanceNode,me as ComponentNode,$ as ConicGradient,Pn as Draggable,B as FrameNode,ae as FramerPluginError,K as LinearGradient,j as RadialGradient,de as SVGNode,le as TextNode,ce as WebPageNode,Xe as framer,ve as isComponentInstanceNode,ft as isComponentNode,xe as isFileAsset,ke as isFrameNode,Ie as isImageAsset,ht as isSVGNode,pt as isTextNode,X as isTextStyle,yt as isWebPageNode,Yi as supportsAspectRatio,Ji as supportsBackgroundColor,no as supportsBackgroundGradient,io as supportsBackgroundGradientData,eo as supportsBackgroundImage,to as supportsBackgroundImageData,so as supportsBorderRadius,lo as supportsComponentInfo,uo as supportsFont,co as supportsFontData,mo as supportsInlineTextStyle,go as supportsInlineTextStyleData,po as supportsLink,Qi as supportsLocked,qi as supportsName,ro as supportsOpacity,ji as supportsPins,Ki as supportsPosition,oo as supportsRotation,ao as supportsSVG,$i as supportsSize,Xi as supportsSizeConstraints,Zi as supportsVisible,Ye as useMakeDraggable};
var jt=Object.defineProperty;var $t=(t,e,n)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var i=(t,e,n)=>($t(t,typeof e!="symbol"?e+"":e,n),n),it=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(it(t,e,"read from private field"),n?n.call(t):e.get(t)),c=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},m=(t,e,n,o)=>(it(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);var Le=(t,e,n,o)=>({set _(s){m(t,e,s,n)},get _(){return r(t,e,o)}});import te from"react";import{useCallback as Pn,useEffect as Tn,useRef as xn}from"react";var Xt="invoke";function T(t){return Xt in t}function y(t){return t===null}function Ve(t){return t===!0||t===!1}function d(t){return typeof t=="string"}function z(t){return typeof t=="number"&&Number.isFinite(t)}function Te(t){return typeof t=="function"}function g(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Me(t){return Array.isArray(t)}function F(t,e){throw e||new Error(t?`Unexpected value: ${t}`:"Application entered invalid state")}function l(t,...e){if(t)return;let n=Error("Assertion Error"+(e.length>0?": "+e.join(" "):""));if(n.stack)try{let o=n.stack.split(`
`);o[1]?.includes("assert")?(o.splice(1,1),n.stack=o.join(`
`)):o[0]?.includes("assert")&&(o.splice(0,1),n.stack=o.join(`
`))}catch{}throw n}var Yt="FileAsset",qt="__class";function xe(t){return g(t)?t[qt]===Yt:!1}var N=class{constructor(e){i(this,"id");i(this,"url");i(this,"extension");this.url=e.url,this.id=e.id,this.extension=e.extension}};function Ie(t){return t instanceof N}var Zt="ImageAsset",Qt="__class";function H(t){return g(t)?t[Qt]===Zt:!1}var L,K,Be=class Be{constructor(e,n){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");c(this,L,void 0);c(this,K,void 0);l(T(n)),m(this,K,n),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText}cloneWithAttributes({altText:e}){return new Be({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText},r(this,K))}async measure(){return en(this.url)}async getData(){if(r(this,L)&&r(this,L).bytes.length>0)return r(this,L);let e=await r(this,K).invoke("getImageData",{id:this.id});if(!e)throw new Error("Failed to load image data");return m(this,L,e),e}async loadBitmap(){let{mimeType:e,bytes:n}=await this.getData(),o=new Blob([n],{type:e});return createImageBitmap(o)}async loadImage(){let e=await this.getData(),n=URL.createObjectURL(new Blob([e.bytes]));return new Promise((o,s)=>{let a=new Image;a.onload=()=>o(a),a.onerror=()=>s(),a.src=n})}};L=new WeakMap,K=new WeakMap;var f=Be;function Ne(t){return t instanceof f}function W(t){return t.type==="bytes"?[t.bytes.buffer]:[]}function Jt(t){if(!g(t))return!1;let e="bytes",n="mimeType";return!(!(e in t)||!(n in t)||!(t[e]instanceof Uint8Array)||!d(t[n]))}async function re(t){if(t instanceof File)return Oe(t);let e=await ot(t.image);return{name:t.name,altText:t.altText,...e}}async function Ee(t){if(t instanceof File)return Oe(t);let e=await ot(t.file);return{name:t.name,...e}}async function ot(t){return t instanceof File?Oe(t):Jt(t)?{type:"bytes",mimeType:t.mimeType,bytes:t.bytes}:{type:"url",url:t}}function Ge(t){return Promise.all(t.map(re))}async function Oe(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=s=>{let a=t.type,u=s.target?.result;if(!u||!(u instanceof ArrayBuffer)){n(new Error("Failed to read file, arrayBuffer is null"));return}let v=new Uint8Array(u);e({bytes:v,mimeType:a,type:"bytes",name:t.name})},o.onerror=s=>{n(s)},o.readAsArrayBuffer(t)})}async function en(t){let e=t instanceof File,n=e?URL.createObjectURL(t):t,o=new Image;return o.crossOrigin="anonymous",o.src=n,await o.decode().finally(()=>{e&&URL.revokeObjectURL(n)}),{height:o.height,width:o.width}}var tn="Font";function st(t){return g(t)&&t.__class===tn}function nn(t){if(!z(t))return!1;switch(t){case 100:case 200:case 300:case 400:case 500:case 600:case 700:case 800:case 900:return!0;default:return!1}}function on(t){if(!d(t))return!1;switch(t){case"normal":case"italic":return!0;default:return!1}}function se(t){return g(t)?d(t.family)&&d(t.selector)&&nn(t.weight)&&on(t.style):!1}var w=class{constructor(e){i(this,"selector");i(this,"family");i(this,"weight");i(this,"style");this.selector=e.selector,this.family=e.family,this.weight=e.weight,this.style=e.style}},rt=new Map;function V(t){let e=rt.get(t.selector);if(e)return e;let n=new w(t);return rt.set(t.selector,n),n}function M(t){return{__class:"Font",selector:t.selector,family:t.family,weight:t.weight,style:t.style}}var at="__class",_e="LinearGradient",Ue="RadialGradient",ze="ConicGradient";function Ce(t){if(!g(t))return!1;switch(t[at]){case _e:case Ue:case ze:return!0;default:return!1}}function ae(t){return t instanceof j||t instanceof $||t instanceof X}function lt(t){if(t instanceof j)return{__class:_e,angle:t.angle,stops:t.stops};if(t instanceof $)return{__class:Ue,width:t.width,height:t.height,x:t.x,y:t.y,stops:t.stops};if(t instanceof X)return{__class:ze,angle:t.angle,x:t.x,y:t.y,stops:t.stops};F(t)}function Se(t){switch(t[at]){case _e:return new j(t);case Ue:return new $(t);case ze:return new X(t);default:F(t)}}var j=class t{constructor(e){i(this,"angle");i(this,"stops");this.angle=e.angle,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({angle:e.angle??this.angle,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(n=>`${n.color} ${n.position*100}%`).join(", ");return`linear-gradient(${this.angle}deg, ${e})`}},$=class t{constructor(e){i(this,"width");i(this,"height");i(this,"x");i(this,"y");i(this,"stops");this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({width:e.width??this.width,height:e.height??this.height,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map((n,o)=>{let s=this.stops[o+1],a=n.position===1&&s?.position===1?n.position-1e-4:n.position;return`${n.color} ${a*100}%`}).join(", ");return`radial-gradient(${this.width} ${this.height} at ${this.x} ${this.y}, ${e})`}},X=class t{constructor(e){i(this,"angle");i(this,"x");i(this,"y");i(this,"stops");this.angle=e.angle,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({angle:e.angle??this.angle,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(n=>`${n.color} ${n.position*360}deg`).join(", ");return`conic-gradient(from ${this.angle}deg at ${this.x} ${this.y}, ${e})`}};var rn="ColorStyle",sn="__class";function E(t){return g(t)?t[sn]===rn:!1}var C,He=class He{constructor(e,n){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");c(this,C,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.light=e.light,this.dark=e.dark,l(T(n)),m(this,C,n)}async setAttributes(e){let n=await r(this,C).invoke("setColorStyleAttributes",this.id,e);return n?new He(n,r(this,C)):null}async getPluginData(e){return r(this,C).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,C).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,C).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,C).invoke("removeColorStyle",this.id)}};C=new WeakMap;var b=He;function G(t){return t instanceof b}function Ke(t){return{__class:"ColorStyle",id:t.id,name:t.name,light:t.light,dark:t.dark}}var an="TextStyle",ln="__class";function dt(t){return g(t)?t[ln]===an:!1}var S,je=class je{constructor(e,n){i(this,"id");i(this,"name");i(this,"tag");i(this,"font");i(this,"boldFont");i(this,"italicFont");i(this,"boldItalicFont");i(this,"color");i(this,"transform");i(this,"alignment");i(this,"decoration");i(this,"balance");i(this,"breakpoints");i(this,"minWidth");i(this,"fontSize");i(this,"letterSpacing");i(this,"lineHeight");i(this,"paragraphSpacing");c(this,S,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.tag=e.tag,this.font=new w(e.font),this.boldFont=e.boldFont?new w(e.boldFont):null,this.italicFont=e.italicFont?new w(e.italicFont):null,this.boldItalicFont=e.boldItalicFont?new w(e.boldItalicFont):null,this.color=E(e.color)?new b(e.color,n):e.color,this.transform=e.transform,this.alignment=e.alignment,this.decoration=e.decoration,this.balance=e.balance,this.breakpoints=e.breakpoints,this.minWidth=e.minWidth,this.fontSize=e.fontSize,this.letterSpacing=e.letterSpacing,this.lineHeight=e.lineHeight,this.paragraphSpacing=e.paragraphSpacing,l(T(n)),m(this,S,n)}async setAttributes(e){let n=await r(this,S).invoke("setTextStyleAttributes",this.id,e);return n?new je(n,r(this,S)):null}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,S).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,S).invoke("removeTextStyle",this.id)}};S=new WeakMap;var I=je;function Y(t){return t instanceof I}function ut(t){return{__class:"TextStyle",id:t.id,name:t.name,tag:t.tag,font:M(t.font),boldFont:t.boldFont?M(t.font):null,italicFont:t.italicFont?M(t.italicFont):null,boldItalicFont:t.boldItalicFont?M(t.boldItalicFont):null,color:G(t.color)?Ke(t.color):t.color,transform:t.transform,alignment:t.alignment,decoration:t.decoration,balance:t.balance,breakpoints:t.breakpoints,minWidth:t.minWidth,fontSize:t.fontSize,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,paragraphSpacing:t.paragraphSpacing}}function ke(t){if(un(t))return cn(t);if(Me(t))return t.map(ke);if(g(t)&&!(t instanceof Uint8Array)){let e={};for(let n in t)e[n]=ke(t[n]);return e}return t}function ct(t,e){let n={};for(let o in t)n[o]=$e(t[o],e);return n}function $e(t,e){if(dn(t))switch(t.__class){case"ImageAsset":return new f(t,e);case"FileAsset":return new N(t);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Se(t);case"TextStyle":return new I(t,e);case"Font":return V(t);case"ColorStyle":return new b(t,e);default:F(t)}if(g(t)){let n={};for(let o in t)n[o]=$e(t[o],e);return n}return Me(t)?t.map(n=>$e(n,e)):t}function dn(t){return!!(H(t)||xe(t)||Ce(t))}function un(t){return!!(Ne(t)||Ie(t)||ae(t)||Y(t)||se(t)||G(t))}function cn(t){if(Ne(t))return{__class:"ImageAsset",id:t.id,thumbnailUrl:t.thumbnailUrl,url:t.url,altText:t.altText};if(Ie(t))return{__class:"FileAsset",id:t.id,extension:t.extension,url:t.url};if(ae(t))return lt(t);if(Y(t))return ut(t);if(se(t))return M(t);if(G(t))return Ke(t);F(t)}function mn(t,e){for(let n in t){let o=t[n];H(o)&&(t[n]=new f(o,e)),xe(o)&&(t[n]=new N(o)),E(o)&&(t[n]=new b(o,e))}}var x,De=class{constructor(e,n){i(this,"id");i(this,"name");c(this,x,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(T(n)),m(this,x,n),Object.freeze(this)}async getItemIds(){return r(this,x).invoke("getManagedCollectionItemIds",this.id)}async setItemOrder(e){return r(this,x).invoke("setManagedCollectionItemOrder",this.id,e)}async getFields(){return r(this,x).invoke("getManagedCollectionFields",this.id)}async setFields(e){return r(this,x).invoke("setManagedCollectionFields",this.id,e)}async addItems(e){return r(this,x).invoke("addManagedCollectionItems",this.id,e)}async removeItems(e){return r(this,x).invoke("removeManagedCollectionItems",this.id,e)}async setPluginData(e,n){return r(this,x).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,x).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,x).invoke("getPluginDataKeysForNode",this.id)}};x=new WeakMap;var k,q=class{constructor(e,n){i(this,"id");i(this,"name");c(this,k,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(T(n)),m(this,k,n),Object.freeze(this)}async getFields(){return r(this,k).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,k).invoke("getCollectionItems",this.id)).map(n=>new Xe(n,r(this,k)))}async setPluginData(e,n){return r(this,k).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,k).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,k).invoke("getPluginDataKeysForNode",this.id)}};k=new WeakMap;var O,Xe=class{constructor(e,n){i(this,"id");i(this,"slug");i(this,"fieldData");c(this,O,void 0);this.id=e.id,this.slug=e.slug,this.fieldData=e.fieldData,mn(this.fieldData,n),l(T(n)),m(this,O,n),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,n){return r(this,O).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,O).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,O).invoke("getPluginDataKeysForNode",this.id)}};O=new WeakMap;var gn=(()=>{let t=null;return{disableUntilMouseUp:()=>{if(t)return;t=document.createElement("style"),t.textContent="* { pointer-events: none !important; user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(t);let e=()=>{t&&(document.head.removeChild(t),t=null,s())},n=a=>{a.buttons>0&&a.buttons&1||e()},o=()=>{e()};window.addEventListener("pointerup",n,!0),window.addEventListener("pointermove",n,!0),window.addEventListener("blur",o);function s(){window.removeEventListener("pointerup",n,!0),window.removeEventListener("pointermove",n,!0),window.removeEventListener("blur",o)}}}})(),mt=5,pn=(()=>{let t=1;return{next:()=>`drag-${t++}`}})();function hn(){}function gt(t,e,n){if(t.mode!=="canvas")return hn;l(T(t));let o=pn.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,v=h=>{a.type!=="idle"&&(a.type==="dragging"&&t.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Ht())},ye=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){v({cancelled:!1});return}let{clientX:fe,clientY:ie}=h;if(a.type==="pointerDown"){let oe=fe-a.dragStart.mouse.x,nt=ie-a.dragStart.mouse.y;if(Math.abs(oe)<mt&&Math.abs(nt)<mt)return;a={type:"dragging",dragStart:a.dragStart},t.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),gn.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let be={x:fe,y:ie};t.invoke("onDrag",{dragSessionId:o,mouse:be}).then(oe=>{a.type==="dragging"&&(document.body.style.cursor=oe??"")})},Qe=h=>{h.key==="Escape"&&v({cancelled:!0})},Je=()=>{v({cancelled:!0})},et=h=>{v({cancelled:!0});let ne=e.getBoundingClientRect(),fe={x:ne.x,y:ne.y,width:ne.width,height:ne.height},ie,be=e.querySelectorAll("svg");if(be.length===1){let Pe=be.item(0).getBoundingClientRect();ie={x:Pe.x,y:Pe.y,width:Pe.width,height:Pe.height}}let oe={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:fe,svgRect:ie,mouse:oe}},t.invoke("setDragData",o,n()),u.addEventListener("pointermove",ye,!0),u.addEventListener("pointerup",ye,!0),window.addEventListener("keydown",Qe,!0),window.addEventListener("blur",Je)},tt=()=>{let h=n();h.type==="detachedComponentLayers"&&t.invoke("preloadDetachedComponentLayers",h.url),h.type==="image"&&t.invoke("preloadImageUrlForInsertion",h.image),h.previewImage&&t.invoke("preloadDragPreviewImage",h.previewImage)};e.addEventListener("pointerdown",et),e.addEventListener("mouseenter",tt);function Ht(){document.body.style.cursor=s,u.removeEventListener("pointermove",ye,!0),u.removeEventListener("pointerup",ye,!0),window.removeEventListener("keydown",Qe,!0),window.removeEventListener("blur",Je)}return()=>{e.removeEventListener("pointerdown",et),e.removeEventListener("mouseenter",tt),v({cancelled:!0})}}var le=class extends Error{};var yn={canvas:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function pt(t){return d(t)&&t in yn}var fn={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function bn(t){return d(t)&&t in fn}function ht(t){return g(t)&&bn(t["type"])}var he,P,D,A=class{constructor(e,n){i(this,"id");c(this,he,void 0);c(this,P,void 0);c(this,D,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,m(this,P,n),m(this,he,e.originalId??null),l(T(n)),m(this,D,n)}get isReplica(){return r(this,he)!==null}remove(){return r(this,P).removeNode(this.id)}select(){return r(this,P).setSelection([this.id])}clone(){return r(this,P).cloneNode(this.id)}setAttributes(e){return r(this,P).setAttributes(this.id,e)}getRect(){return r(this,P).getRect(this.id)}zoomIntoView(e){return r(this,P).zoomIntoView([this.id],e)}getParent(){return r(this,P).getParent(this.id)}getChildren(){return B(this)?Promise.resolve([]):r(this,P).getChildren(this.id)}async getNodesWithType(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttribute(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttributeSet(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,P)))}async*walk(){if(yield this,!B(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,D).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,D).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,D).invoke("getPluginDataKeysForNode",this.id)}};he=new WeakMap,P=new WeakMap,D=new WeakMap;var _=class extends A{constructor(n,o){super(n,o);i(this,"__class","FrameNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"backgroundColor");i(this,"backgroundImage");i(this,"backgroundGradient");i(this,"rotation");i(this,"opacity");i(this,"borderRadius");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");i(this,"link");i(this,"linkOpenInNewTab");l(n.__class==="FrameNode","FrameNode must have a __class property"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.backgroundColor=E(n.backgroundColor)?new b(n.backgroundColor,o):n.backgroundColor??null,this.backgroundImage=n.backgroundImage?new f(n.backgroundImage,o):null,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.borderRadius=n.borderRadius??null,this.backgroundGradient=Ce(n.backgroundGradient)?Se(n.backgroundGradient):null,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.aspectRatio=n.aspectRatio??null,this.link=n.link??null,this.linkOpenInNewTab=n.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},Z,de=class extends A{constructor(n,o){super(n,o);i(this,"__class","TextNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"rotation");i(this,"opacity");i(this,"font");i(this,"inlineTextStyle");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"link");i(this,"linkOpenInNewTab");c(this,Z,void 0);l(T(o)),m(this,Z,o),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.font=n.font?V(n.font):null,this.inlineTextStyle=n.inlineTextStyle?new I(n.inlineTextStyle,o):null,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.link=n.link??null,this.linkOpenInNewTab=n.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}async setText(n){await r(this,Z).invoke("setTextForNode",this.id,n)}async getText(){return r(this,Z).invoke("getTextForNode",this.id)}};Z=new WeakMap;var ue=class extends A{constructor(n,o){super(n,o);i(this,"__class","SVGNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"svg");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");l(n.svg,"SVG node must have a non-empty SVG string"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.svg=n.svg,this.rotation=n.rotation??0,this.opacity=n.opacity??1,l(n.position,"Must have a position"),this.position=n.position??null,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},ce=class extends A{constructor(n,o){super(n,o);i(this,"__class","ComponentInstanceNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");i(this,"controls");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");l(n.componentIdentifier,"ComponentInstance node must have a component identifier"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.componentIdentifier=n.componentIdentifier,this.componentName=n.componentName??null,this.insertURL=n.insertURL??null,this.controls=ct(n.controls??{},o),this.rotation=n.rotation??0,this.opacity=n.opacity??1,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.aspectRatio=n.aspectRatio??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},me=class extends A{constructor(n,o){super(n,o);i(this,"_class","WebPageNode");i(this,"path");i(this,"collectionId");l(n),this.path=n.path??null,this.collectionId=n.collectionId??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},ge=class extends A{constructor(n,o){super(n,o);i(this,"__class","ComponentNode");i(this,"name");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");l(n.componentIdentifier,"ComponentNode must have a componentIdentifier"),this.componentIdentifier=n.componentIdentifier,this.insertURL=n.insertURL??null,this.componentName=n.componentName??null,this.name=n.name??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},pe=class extends A{constructor(n,o){super(n,o);i(this,"__class","UnknownNode");Object.freeze(this)}clone(){throw Error("Can not clone unknown node")}setAttributes(n){throw Error("Can not set attributes on unknown node")}};function p(t,e){switch(t.__class){case"WebPageNode":return new me(t,e);case"ComponentNode":return new ge(t,e);case"ComponentInstanceNode":return new ce(t,e);case"FrameNode":return new _(t,e);case"SVGNode":return new ue(t,e);case"TextNode":return new de(t,e);case"UnknownNode":return new pe(t,e);default:return new pe(t,e)}}function ve(t){return t instanceof _}function yt(t){return t instanceof de}function ft(t){return t instanceof ue}function Ae(t){return t instanceof ce}function bt(t){return t instanceof me}function Pt(t){return t instanceof ge}function B(t){return t instanceof pe}function Fe(t){return!!(ve(t)||yt(t)||Ae(t)||ft(t)||B(t))}function Ye(t){return!!(bt(t)||Pt(t)||B(t))}var Q=null;function Tt(t){if(!Q){let n=document.createElement("style");document.head.appendChild(n),Q=n.sheet}if(!Q){t();return}let e=Q.insertRule("* { transition: none !important; animation: none !important; }");t(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Q&&Q.deleteRule(e)})})}var we,Re,J,U,ee,R,We=class{constructor({isTestEnv:e}={}){c(this,we,0);c(this,Re,0);c(this,J,[]);c(this,U,void 0);c(this,ee,new Map);c(this,R,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let n=e.data;if(ht(n))switch(n.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+n.type);l(r(this,R)===n.mode,"Mode must match"),this.applyPluginTheme(n.theme),m(this,U,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,J))r(this,U).call(this,...s);m(this,J,[]);break}case"methodResponse":{let o=r(this,ee).get(n.id);if(!o)throw new Error(`No handler for response with id ${n.id}`);r(this,ee).delete(n.id),n.error?o.reject(new le(n.error)):o.resolve(n.result);break}case"subscriptionMessage":{let{topic:o,payload:s}=n,a=this.subscriptions.get(o);if(!a)throw new Error("Received a subscription message but no handler present");for(let u of a)u(s);break}default:F(n)}});i(this,"applyPluginTheme",e=>{Tt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let n in e.tokens)document.body.style.setProperty(n,e.tokens[n])})});if(e){m(this,R,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),m(this,R,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(pt(o),`Invalid mode: ${o}`),m(this,R,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal"};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,R)}invoke(e,...n){return this.invokeTransferable(e,void 0,...n)}invokeTransferable(e,n,...o){return new Promise((s,a)=>{let u={args:o,methodName:e,id:Le(this,we)._++,type:"methodInvocation"},v=s;r(this,ee).set(u.id,{resolve:v,reject:a}),this.queueMessage(u,n)})}subscribe(e,n){this.queueMessage({type:"subscribe",topic:e});let o=this.subscriptions.get(e)??new Set;return o.add(n),this.subscriptions.set(e,o),()=>{let s=this.subscriptions.get(e)??new Set;s.delete(n),s.size===0&&this.queueMessage({type:"unsubscribe",topic:e}),this.subscriptions.set(e,s)}}queueMessage(e,n){if(e.type==="methodInvocation"&&(e.args=e.args.map(ke)),!r(this,U)){r(this,J).push([e,n]);return}r(this,U).call(this,e,n)}async showUI(e){return this.invoke("showUI",e)}async hideUI(){return this.invoke("hideUI")}async closePlugin(e,n){return this.invoke("closePlugin",e,n)}async getCurrentUser(){return this.invoke("getCurrentUser")}async getProjectInfo(){return this.invoke("getProjectInfo")}async getSelection(){return(await this.invoke("getSelection")).map(n=>{let o=p(n,this);return l(Fe(o)),o})}async setSelection(e){let n=d(e)?[e]:Array.from(e);return this.invoke("setSelection",n)}subscribeToSelection(e){return this.subscribe("selection",n=>{let o=n.map(s=>{let a=p(s,this);return l(Fe(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),n=p(e,this);return l(Ye(n)),n}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",n=>{let o=p(n,this);l(Ye(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,n){let o=await this.invoke("createNode","FrameNode",n??null,e);if(!o)return null;let s=p(o,this);return l(s instanceof _),s}async removeNode(e){return this.invoke("removeNode",e)}async cloneNode(e){let n=await this.invoke("cloneNode",e);return n?p(n,this):null}async getNode(e){let n=await this.invoke("getNode",e);return n?p(n,this):null}async getParent(e){let n=await this.invoke("getParent",e);return n?p(n,this):null}async getChildren(e){return(await this.invoke("getChildren",e)).map(o=>{let s=p(o,this);return l(Fe(s)),s})}async getRect(e){return this.invoke("getRect",e)}async zoomIntoView(e,n){let o=d(e)?[e]:Array.from(e);return this.invoke("zoomIntoView",o,n)}async setAttributes(e,n){let o=await this.invoke("setAttributes",e,n);return o?p(o,this):null}async setParent(e,n,o){return this.invoke("setParent",e,n,o)}async getNodesWithType(e){return(await this.invoke("getNodesWithType",null,e)).map(o=>p(o,this))}async getNodesWithAttribute(e){return(await this.invoke("getNodesWithAttribute",null,e)).map(o=>p(o,this))}async getNodesWithAttributeSet(e){return(await this.invoke("getNodesWithAttributeSet",null,e)).map(o=>p(o,this))}async getImage(){let e=await this.invoke("getImage");return e?new f(e,this):null}subscribeToImage(e){return this.subscribe("image",n=>{if(!n){e(null);return}e(new f(n,this))})}async addImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("addImage",o,n)}async setImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("setImage",o,n)}async uploadImage(e){let n=await re(e),o=W(n),s=await this.invokeTransferable("uploadImage",o,n);return new f(s,this)}async addImages(e){let n=await Ge(e),o=n.flatMap(W);await this.invokeTransferable("addImages",o,n)}async uploadImages(e){let n=await Ge(e),o=n.flatMap(W),s=await this.invokeTransferable("uploadImages",o,n),a=[];for(let u of s)a.push(new f(u,this));return a}async uploadFile(e){let n=await Ee(e),o=await this.invokeTransferable("uploadFile",W(n),n);return new N(o)}async uploadFiles(e){let n=await Promise.all(e.map(Ee)),o=n.flatMap(W),s=await this.invokeTransferable("uploadFiles",o,n),a=[];for(let u of s)a.push(new N(u));return a}async addSVG(e){return this.invoke("addSVG",e)}async addComponentInstance({url:e,attributes:n}){let o=await this.invoke("addComponentInstance",{url:e,attributes:n}),s=p(o,this);return l(Ae(s)),s}async addDetachedComponentLayers({url:e,layout:n,attributes:o}){let s=await this.invoke("addDetachedComponentLayers",{url:e,layout:n,attributes:o}),a=p(s,this);return l(ve(a)),a}async preloadDetachedComponentLayers(e){await this.invoke("preloadDetachedComponentLayers",e)}async preloadImageUrlForInsertion(e){await this.invoke("preloadImageUrlForInsertion",e)}async preloadDragPreviewImage(e){await this.invoke("preloadDragPreviewImage",e)}async getText(){return this.invoke("getText")}async setText(e){return this.invoke("setText",e)}async addText(e,n){return this.invoke("addText",e,n)}async setCustomCode(e){return this.invoke("setCustomCode",e)}async getCustomCode(){return this.invoke("getCustomCode")}subscribeToCustomCode(e){return this.subscribe("customCode",e)}subscribeToText(e){return this.subscribe("text",e)}makeDraggable(e,n){return gt(this,e,n)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new De(e,this)}async getCollection(e){let n=await this.invoke("getCollection",e);return n?new q(n,this):null}async getActiveCollection(){let e=await this.invoke("getActiveCollection");return l(e),new q(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(n=>new q(n,this))}notify(e,n){let o=`notification-${Le(this,Re)._++}`;return this.invoke("notify",e,{notificationId:o,variant:n?.variant??"info",buttonText:n?.button?.text,durationMs:n?.durationMs}).then(s=>{s==="actionButtonClicked"&&n?.button?.onClick&&n.button.onClick(),n?.onDisappear&&n.onDisappear()}),{close:()=>this.invoke("closeNotification",o)}}async getPluginData(e){return this.invoke("getPluginData",e)}async setPluginData(e,n){return this.invoke("setPluginData",e,n)}async getPluginDataKeys(){return this.invoke("getPluginDataKeys")}async getColorStyles(){return(await this.invoke("getColorStyles")).map(n=>new b(n,this))}async getColorStyle(e){let n=await this.invoke("getColorStyle",e);return n?new b(n,this):null}async createColorStyle(e){let n=await this.invoke("createColorStyle",e);return new b(n,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",n=>{let o=n.map(s=>new b(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(n=>new I(n,this))}async getTextStyle(e){let n=await this.invoke("getTextStyle",e);return n?new I(n,this):null}async createTextStyle(e){let n=await this.invoke("createTextStyle",e);return new I(n,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",n=>{let o=n.map(s=>new I(s,this));return e(o)})}async getFont(e,n){let o=await this.invoke("getFont",e,n);return o?V(o):null}async getFonts(){return(await this.invoke("getFonts")).map(V)}async unstable_ensureMinimumDependencyVersion(e,n){return this.invoke("unstable_ensureMinimumDependencyVersion",e,n)}};we=new WeakMap,Re=new WeakMap,J=new WeakMap,U=new WeakMap,ee=new WeakMap,R=new WeakMap;var qe=new We;function Ze(t,e){let n=In(()=>Te(e)?e():e);Tn(()=>{let o=t.current;if(o instanceof HTMLElement)return qe.makeDraggable(o,n)},[n])}function In(t){let e=xn(t);return e.current=t,Pn((...n)=>e.current(...n),[])}var Nn=te.forwardRef(function({data:e,children:n,...o},s){let a=te.useRef(null);if(Ze(a,e),te.isValidElement(n)){let u=Object.assign({},o);return g(n.props)&&Object.assign(u,n.props),u.ref=kn(a,s,n.ref),te.cloneElement(n,u)}return te.Children.count(n)>1&&te.Children.only(n),null}),Cn="current";function Sn(t){return g(t)&&Cn in t}function kn(...t){return e=>{for(let n of t)Te(n)?n(e):Sn(n)&&(n.current=e)}}var Dn={fixed:!0,sticky:!0,absolute:!0,relative:!0},xt="position";function qi(t){if(!(xt in t))return!1;let e=t[xt];return d(e)&&Dn[e]===!0}var It="top";function Zi(t){if(!(It in t))return!1;let e=t[It];return d(e)||y(e)}var Nt="width";function Qi(t){if(!(Nt in t))return!1;let e=t[Nt];return d(e)||y(e)}var Ct="maxWidth";function Ji(t){if(!(Ct in t))return!1;let e=t[Ct];return d(e)||y(e)}var St="aspectRatio";function eo(t){if(!(St in t))return!1;let e=t[St];return z(e)||y(e)}var kt="name";function to(t){if(!(kt in t))return!1;let e=t[kt];return d(e)||y(e)}var Dt="visible";function no(t){if(!(Dt in t))return!1;let e=t[Dt];return Ve(e)}var vt="locked";function io(t){if(!(vt in t))return!1;let e=t[vt];return Ve(e)}var At="backgroundColor";function oo(t){if(!(At in t))return!1;let e=t[At];return d(e)||G(e)||y(e)}var Ft="backgroundColor";function ro(t){if(!(Ft in t))return!1;let e=t[Ft];return d(e)||E(e)||y(e)}var Wt="backgroundImage";function so(t){if(!(Wt in t))return!1;let e=t[Wt];return e instanceof f||y(e)}var wt="backgroundImage";function ao(t){if(!(wt in t))return!1;let e=t[wt];return e instanceof f?!1:H(e)||y(e)}var Rt="backgroundGradient";function lo(t){if(!(Rt in t))return!1;let e=t[Rt];return ae(e)||y(e)}var Lt="backgroundGradient";function uo(t){if(!(Lt in t))return!1;let e=t[Lt];return g(e)||y(e)}var Vt="rotation";function co(t){if(!(Vt in t))return!1;let e=t[Vt];return z(e)}var Mt="opacity";function mo(t){if(!(Mt in t))return!1;let e=t[Mt];return z(e)}var Et="borderRadius";function go(t){if(!(Et in t))return!1;let e=t[Et];return d(e)||y(e)}var Gt="svg";function po(t){if(!(Gt in t))return!1;let e=t[Gt];return d(e)}var Ot="componentIdentifier";function ho(t){if(!(Ot in t))return!1;let e=t[Ot];return d(e)}var Bt="font";function yo(t){if(!(Bt in t))return!1;let e=t[Bt];return se(e)}var _t="font";function fo(t){if(!(_t in t))return!1;let e=t[_t];return st(e)||y(e)}var Ut="inlineTextStyle";function bo(t){if(!(Ut in t))return!1;let e=t[Ut];return Y(e)||y(e)}var zt="inlineTextStyle";function Po(t){if(!(zt in t))return!1;let e=t[zt];return dt(e)||y(e)}var Kt="link";function To(t){if(!(Kt in t))return!1;let e=t[Kt];return d(e)||y(e)}export{ce as ComponentInstanceNode,ge as ComponentNode,X as ConicGradient,Nn as Draggable,_ as FrameNode,le as FramerPluginError,j as LinearGradient,$ as RadialGradient,ue as SVGNode,de as TextNode,me as WebPageNode,qe as framer,G as isColorStyle,Ae as isComponentInstanceNode,Pt as isComponentNode,Ie as isFileAsset,ve as isFrameNode,Ne as isImageAsset,ft as isSVGNode,yt as isTextNode,Y as isTextStyle,bt as isWebPageNode,eo as supportsAspectRatio,oo as supportsBackgroundColor,ro as supportsBackgroundColorData,lo as supportsBackgroundGradient,uo as supportsBackgroundGradientData,so as supportsBackgroundImage,ao as supportsBackgroundImageData,go as supportsBorderRadius,ho as supportsComponentInfo,yo as supportsFont,fo as supportsFontData,bo as supportsInlineTextStyle,Po as supportsInlineTextStyleData,To as supportsLink,io as supportsLocked,to as supportsName,mo as supportsOpacity,Zi as supportsPins,qi as supportsPosition,co as supportsRotation,po as supportsSVG,Qi as supportsSize,Ji as supportsSizeConstraints,no as supportsVisible,Ze as useMakeDraggable};
{
"name": "framer-plugin",
"version": "0.4.1",
"version": "0.5.0",
"type": "module",

@@ -5,0 +5,0 @@ "main": "src/index.ts",

@@ -44,3 +44,3 @@ export type { ImageAsset } from "./assets"

export type { Font } from "./fonts"
export { isTextStyle } from "./styles"
export { isTextStyle, isColorStyle } from "./styles"
export { framer } from "./framer"

@@ -47,0 +47,0 @@ export { isImageAsset, isFileAsset } from "./assets"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc