@rogieking/figui3 6.3.0 → 6.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fig.js CHANGED
@@ -1,4 +1,4 @@
1
- var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var q=HTMLLIElement,K=function(){return Reflect.construct(q,[],K)};if(K.prototype=J.create(q.prototype),$.define("ungap-li",K,j),!/is="ungap-li"/.test(new K().outerHTML))throw j}catch(_){(function(){var X="attributeChangedCallback",Y="connectedCallback",N="disconnectedCallback",G=Element.prototype,B=J.assign,H=J.create,A=J.defineProperties,O=J.getOwnPropertyDescriptor,D=J.setPrototypeOf,R=$.define,L=$.get,U=$.upgrade,M=$.whenDefined,T=H(null),E=new WeakMap,S={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(W){return typeof W=="string"&&/^HTML(?!Element)/.test(W)}).forEach(function(W){function z(){}var F=self[W];D(z,F),(z.prototype=F.prototype).constructor=z,F={},F[W]={value:z},A(self,F)}),new MutationObserver(t).observe(Q,S),N0(Document.prototype,"importNode"),N0(Node.prototype,"cloneNode"),A($,{define:{value:function(W,z,F){if(W=W.toLowerCase(),F&&Z in F){T[W]=B({},F,{Class:z});var k=F[Z]+'[is="'+W+'"]',P=Q.querySelectorAll(k);for(var I=0,y=P.length;I<y;I++)o(P[I])}else R.apply($,arguments)}},get:{value:function(W){return W in T?T[W].Class:L.call($,W)}},upgrade:{value:function(W){var z=b(W);if(z&&!(W instanceof z.Class))Y0(W,z);else U.call($,W)}},whenDefined:{value:function(W){return W in T?Promise.resolve():M.call($,W)}}});var f=Q.createElement;A(Q,{createElement:{value:function(W,z){var F=f.call(Q,W);if(z&&"is"in z)F.setAttribute("is",z.is),$.upgrade(F);return F}}});var c=O(G,"attachShadow").value,l=O(G,"innerHTML");A(G,{attachShadow:{value:function(){var W=c.apply(this,arguments);return new MutationObserver(t).observe(W,S),W}},innerHTML:{get:l.get,set:function(W){if(l.set.call(this,W),/\bis=("|')?[a-z0-9_-]+\1/i.test(W))a(this,o)}}});function t(W){for(var z=0,F=W.length;z<F;z++){var k=W[z],P=k.addedNodes,I=k.removedNodes;for(var y=0,n=P.length;y<n;y++)o(P[y]);for(var Z0=0,G1=I.length;Z0<G1;Z0++)h(I[Z0])}}function g(W){for(var z=0,F=W.length;z<F;z++){var k=W[z],P=k.attributeName,I=k.oldValue,y=k.target,n=y.getAttribute(P);if(X in y&&!(I==n&&n==null))y[X](P,I,y.getAttribute(P),null)}}function h(W){if(W.nodeType!==1)return;var z=b(W);if(z&&W instanceof z.Class&&N in W&&E.get(W)!==N)E.set(W,N),Promise.resolve(W).then(U1);a(W,h)}function b(W){var z=W.getAttribute("is");if(z){if(z=z.toLowerCase(),z in T)return T[z]}return null}function W1(W){W[Y]()}function U1(W){W[N]()}function Y0(W,z){var F=z.Class,k=F.observedAttributes||[];if(D(W,F.prototype),k.length){new MutationObserver(g).observe(W,{attributes:!0,attributeFilter:k,attributeOldValue:!0});var P=[];for(var I=0,y=k.length;I<y;I++)P.push({attributeName:k[I],oldValue:null,target:W});g(P)}}function o(W){if(W.nodeType!==1)return;var z=b(W);if(z){if(!(W instanceof z.Class))Y0(W,z);if(Y in W&&W.isConnected&&E.get(W)!==Y)E.set(W,Y),Promise.resolve(W).then(W1)}a(W,o)}function a(W,z){for(var F=W.content,k=(F&&F.nodeType==11?F:W).querySelectorAll("[is]"),P=0,I=k.length;P<I;P++)z(k[P])}function N0(W,z){var F=W[z],k={};k[z]={value:function(){var P=F.apply(this,arguments);switch(P.nodeType){case 1:case 11:a(P,o)}return P}},A(W,k)}})()}})(document,customElements,Object)});function M1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function w(Q,$={}){let J=document.createElement("fig-icon");if(Q)J.setAttribute("name",Q);if($.size)J.setAttribute("size",$.size);if($.className)J.className=$.className;return J}function u(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function B1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}var A0=M1()&&!B1(),O1=(A0?Promise.resolve().then(() => (W0(),A1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function j0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!A0){Z();return}O1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function s(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var R1=1e4;function z1(){return R1++}function x(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var m=null,U0=null;function q0(Q=1,$=1){if(!m)m=document.createElement("canvas"),U0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==$)m.height=$;return{canvas:m,ctx:U0}}class M0 extends HTMLElement{type;#$;constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button",this.shadowRoot.innerHTML=`
1
+ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var q=HTMLLIElement,K=function(){return Reflect.construct(q,[],K)};if(K.prototype=J.create(q.prototype),$.define("ungap-li",K,j),!/is="ungap-li"/.test(new K().outerHTML))throw j}catch(_){(function(){var X="attributeChangedCallback",Y="connectedCallback",N="disconnectedCallback",L=Element.prototype,B=J.assign,H=J.create,M=J.defineProperties,G=J.getOwnPropertyDescriptor,z=J.setPrototypeOf,R=$.define,U=$.get,A=$.upgrade,D=$.whenDefined,T=H(null),E=new WeakMap,S={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(W){return typeof W=="string"&&/^HTML(?!Element)/.test(W)}).forEach(function(W){function O(){}var F=self[W];z(O,F),(O.prototype=F.prototype).constructor=O,F={},F[W]={value:O},M(self,F)}),new MutationObserver(K0).observe(Q,S),W0(Document.prototype,"importNode"),W0(Node.prototype,"cloneNode"),M($,{define:{value:function(W,O,F){if(W=W.toLowerCase(),F&&Z in F){T[W]=B({},F,{Class:O});var k=F[Z]+'[is="'+W+'"]',P=Q.querySelectorAll(k);for(var f=0,y=P.length;f<y;f++)d(P[f])}else R.apply($,arguments)}},get:{value:function(W){return W in T?T[W].Class:U.call($,W)}},upgrade:{value:function(W){var O=e(W);if(O&&!(W instanceof O.Class))Y0(W,O);else A.call($,W)}},whenDefined:{value:function(W){return W in T?Promise.resolve():D.call($,W)}}});var I=Q.createElement;M(Q,{createElement:{value:function(W,O){var F=I.call(Q,W);if(O&&"is"in O)F.setAttribute("is",O.is),$.upgrade(F);return F}}});var V=G(L,"attachShadow").value,s=G(L,"innerHTML");M(L,{attachShadow:{value:function(){var W=V.apply(this,arguments);return new MutationObserver(K0).observe(W,S),W}},innerHTML:{get:s.get,set:function(W){if(s.set.call(this,W),/\bis=("|')?[a-z0-9_-]+\1/i.test(W))o(this,d)}}});function K0(W){for(var O=0,F=W.length;O<F;O++){var k=W[O],P=k.addedNodes,f=k.removedNodes;for(var y=0,i=P.length;y<i;y++)d(P[y]);for(var Q0=0,G1=f.length;Q0<G1;Q0++)X0(f[Q0])}}function _0(W){for(var O=0,F=W.length;O<F;O++){var k=W[O],P=k.attributeName,f=k.oldValue,y=k.target,i=y.getAttribute(P);if(X in y&&!(f==i&&i==null))y[X](P,f,y.getAttribute(P),null)}}function X0(W){if(W.nodeType!==1)return;var O=e(W);if(O&&W instanceof O.Class&&N in W&&E.get(W)!==N)E.set(W,N),Promise.resolve(W).then(U1);o(W,X0)}function e(W){var O=W.getAttribute("is");if(O){if(O=O.toLowerCase(),O in T)return T[O]}return null}function N1(W){W[Y]()}function U1(W){W[N]()}function Y0(W,O){var F=O.Class,k=F.observedAttributes||[];if(z(W,F.prototype),k.length){new MutationObserver(_0).observe(W,{attributes:!0,attributeFilter:k,attributeOldValue:!0});var P=[];for(var f=0,y=k.length;f<y;f++)P.push({attributeName:k[f],oldValue:null,target:W});_0(P)}}function d(W){if(W.nodeType!==1)return;var O=e(W);if(O){if(!(W instanceof O.Class))Y0(W,O);if(Y in W&&W.isConnected&&E.get(W)!==Y)E.set(W,Y),Promise.resolve(W).then(N1)}o(W,d)}function o(W,O){for(var F=W.content,k=(F&&F.nodeType==11?F:W).querySelectorAll("[is]"),P=0,f=k.length;P<f;P++)O(k[P])}function W0(W,O){var F=W[O],k={};k[O]={value:function(){var P=F.apply(this,arguments);switch(P.nodeType){case 1:case 11:o(P,d)}return P}},M(W,k)}})()}})(document,customElements,Object)});function M1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function b(Q,$={}){let J=document.createElement("fig-icon");if(Q)J.setAttribute("name",Q);if($.size)J.setAttribute("size",$.size);if($.className)J.className=$.className;return J}function m(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function B1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}var A0=M1()&&!B1(),O1=(A0?Promise.resolve().then(() => (N0(),A1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function $0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!A0){Z();return}O1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function c(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var R1=1e4;function z1(){return R1++}function x(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var g=null,U0=null;function J0(Q=1,$=1){if(!g)g=document.createElement("canvas"),U0=g.getContext("2d");if(g.width!==Q)g.width=Q;if(g.height!==$)g.height=$;return{canvas:g,ctx:U0}}class M0 extends HTMLElement{type;#$;constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button",this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  button, button:hover, button:active {
4
4
  padding: 0 var(--spacer-2);
@@ -32,9 +32,9 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
32
32
  <button type="${this.type}">
33
33
  <slot></slot>
34
34
  </button>
35
- `,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",M0);class B0 extends HTMLElement{#$="Menu";#Q=null;#J;#j;#q=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#W.bind(this),this.#j=this.#L.bind(this),this.#_=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#K(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#Z=Z}#U(){if(!this.#Z)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#N(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#j)}#G(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#Y(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#N()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#K(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#A(this.value),this.#U(),this.type==="dropdown")this.select.selectedIndex=-1}#W(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#L(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#A(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#U()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#A(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#j)}}customElements.define("fig-dropdown",B0);class C extends HTMLElement{static#$=0;static#Q=500;#J;#j;#q;#Z;#_;#X;#K;#U;#N;#G=null;#Y;#W=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#B.bind(this),this.#j=this.hidePopupOutsideClick.bind(this),this.#q=this.showDelayedPopup.bind(this),this.#Z=this.#A.bind(this),this.#_=this.#M.bind(this),this.#X=this.#z.bind(this),this.#K=this.#O.bind(this),this.#U=this.#R.bind(this),this.#N=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#G=this.closest("dialog"),this.#G)this.#G.addEventListener("close",this.#N)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#G)this.#G.removeEventListener("close",this.#N),this.#G=null;if(this.action==="click")document.body.removeEventListener("click",this.#j);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#q),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#K),this.removeEventListener("touchcancel",this.#U);else if(this.action==="click")this.removeEventListener("click",this.#q),this.removeEventListener("touchstart",this.#q)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","none"),Q)this.popup.setAttribute("popover","manual");let J=s();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#j)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#K,{passive:!0}),this.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#q),document.body.addEventListener("click",this.#j),this.addEventListener("touchstart",this.#q,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}get#L(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#L)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-C.#$<C.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#G&&!this.#G.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,C.#$=Date.now()}hidePopup(){if(this.#L)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.popup)this.destroy();this.isOpen=!1,C.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#A(Q){if(!this.#W)this.hidePopup()}#M(Q){if(this.action==="hover")this.#W=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#z(Q){if(this.action==="hover"&&this.#W)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#W=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#W)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#W=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#W)this.#W=!1,clearTimeout(this.#Y),this.hidePopup()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#D(Q){if(!this.popup)return;let $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#D(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#B(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#H=new WeakMap;static show(Q,$,J={}){C.hide(Q);let Z=J.delay??500,q=Date.now()-C.#$<C.#Q?0:Z,K={timeout:null,popup:null};C.#H.set(Q,K),K.timeout=setTimeout(()=>{let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","none"),_)X.setAttribute("popover","manual");let Y=document.createElement("span");if(Y.innerText=$,X.append(Y),_)document.body.append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,K.popup=X,C.#$=Date.now()},q)}static hide(Q){let $=C.#H.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();C.#H.delete(Q)}}customElements.define("fig-tooltip",C);class O0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#J=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#j(),this.#q()})}disconnectedCallback(){this.#Z()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#j()}#j(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let K=$.lastIndexOf(J);Z=K>0?K:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;C.show(this,this.#$)},this.#J=()=>{C.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#Z(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);C.hide(this)}}customElements.define("fig-truncate",O0);class R0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this)}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),requestAnimationFrame(()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let K of this.children){let _=K.getBoundingClientRect();if(_.height===0)continue;if(q+=1,K===Q)continue;let X=window.getComputedStyle(K),Y=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");Z+=_.height+Y}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-dialog",""),Z.appendChild(w("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,K=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(K)this.style.left="0",this.style.right="0";if(q&&K)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(K)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog"}}}j0("fig-dialog",R0,{extends:"dialog"});class z0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(z1()+1);let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this.resolveAnchor();if(Q?.classList)Q.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",K=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:K}}if($.length===1){let _=$[0];if(_==="top"||_==="bottom")j=_,K=_;else if(_==="left"||_==="right")q=_,K=_;else if(_==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:K}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let K,_;if(q==="left"||q==="right")return _=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,K=Q.top,{top:K,left:_};if(q==="top"||q==="bottom")return K=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,_=Q.left,{top:K,left:_};if(J==="top")K=Q.top-$.height-j.yPx;else if(J==="bottom")K=Q.bottom+j.yPx;else K=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")_=Q.left-$.width-j.xPx;else if(Z==="right")_=Q.right+j.xPx;else _=Q.left+(Q.width-$.width)/2;else if(Z==="left")_=Q.left+j.xPx;else if(Z==="right")_=Q.right-$.width-j.xPx;else _=Q.left+(Q.width-$.width)/2;return{top:K,left:_}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let X=Q.left+Q.width/2,Y=Q.top+Q.height/2,N=this.getBoundingClientRect(),G=N.width>0&&N.height>0?N:$,B=G.left,H=G.top,A=getComputedStyle(this),O=(M,T=0)=>{let E=String(M||"").trim(),S=parseFloat(E);if(!Number.isFinite(S))return T;if(E.endsWith("rem"))return S*parseFloat(getComputedStyle(document.documentElement).fontSize);if(E.endsWith("em"))return S*parseFloat(A.fontSize);return S},D=(M)=>{if(M==="top")return Math.max(O(A.borderTopLeftRadius),O(A.borderTopRightRadius));if(M==="bottom")return Math.max(O(A.borderBottomLeftRadius),O(A.borderBottomRightRadius));if(M==="left")return Math.max(O(A.borderTopLeftRadius),O(A.borderBottomLeftRadius));if(M==="right")return Math.max(O(A.borderTopRightRadius),O(A.borderBottomRightRadius));return 0},R=O(A.getPropertyValue("--fig-popup-beak-width"),16),L=Math.max(10,D(_)+R/2),U;if(_==="top"||_==="bottom"){U=X-B;let M=L,T=Math.max(M,G.width-L);U=Math.min(T,Math.max(M,U))}else{U=Y-H;let M=L,T=Math.max(M,G.height-L);U=Math.min(T,Math.max(M,U))}this.style.setProperty("--fig-popup-beak-offset",`${U}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,K=Q.top+$.height,_=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,q-(Z-J.right)),N=Math.max(0,K-(j-J.bottom));return _+X+Y+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),K=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(K,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),K=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:K.left+(window.innerWidth-K.right-K.left-Q.width)/2,top:K.top+(window.innerHeight-K.bottom-K.top-Q.height)/2},A=this.clamp(H,Q,K);this.style.left=`${A.left}px`,this.style.top=`${A.top}px`;return}let _=q.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j),Y=null,N="top",G=Number.POSITIVE_INFINITY;for(let{v:H,h:A,s:O}of X){let D=this.computeCoords(_,Q,H,A,$,O),R=this.getPlacementSide(H,A,O);if(O){let L=this.clamp(D,Q,K);if(O==="left"||O==="right"?D.left>=K.left&&D.left+Q.width<=window.innerWidth-K.right:D.top>=K.top&&D.top+Q.height<=window.innerHeight-K.bottom){this.style.left=`${L.left}px`,this.style.top=`${L.top}px`,this.updatePopoverBeak(_,Q,L.left,L.top,R);return}let M=this.overflowScore(D,Q,K);if(M<G)G=M,Y=L,N=R}else{if(this.fits(D,Q,K)){this.style.left=`${D.left}px`,this.style.top=`${D.top}px`,this.updatePopoverBeak(_,Q,D.left,D.top,R);return}let L=this.overflowScore(D,Q,K);if(L<G)G=L,Y=D,N=R}}let B=this.clamp(Y||{left:0,top:0},Q,K);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(_,Q,B.left,B.top,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}j0("fig-popup",z0,{extends:"dialog"});class D0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",D0);class H0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#j.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#q(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#j(Q){let $=Array.from(this.querySelectorAll("fig-tab")),J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){$.forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=$[Z].getAttribute("value");if(j)this.setAttribute("value",j);$[Z].focus()}}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#q(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected")}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#q(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z)}}customElements.define("fig-tabs",H0);class F0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",F0);class T0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#j=null;#q=0;#Z=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#z(),this.#L(),requestAnimationFrame(()=>{this.#M({enforceFallback:!0}),this.#A(),this.#Y({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#Z=!1,this.#_=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#Y()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#K(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#U(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#N(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#K(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#G(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#Y({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#Z;this.#Z=!1,this.#W({forceInstant:$})})}#W({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#G(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#U();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#_=!1;return}if(!Z){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let K=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${K}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#Y()}),this.#A()}#A(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#M({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#Y({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#N(Z))return}let j=this.#U();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#z(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#M({enforceFallback:!0})}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;let J=this.selectedSegment,Z=this.value;this.selectedSegment=$;let j=this.#K($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");let q=this.value;if(J!==$||Z!==q)this.#X(q)}#O(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")})}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#O(J!==null&&J!=="false"),this.#Y({forceInstant:!0});return}if(Q==="value"){this.#M({enforceFallback:!1});return}if(Q==="animated"){if(!this.#G())this.#_=!1;this.#Y({forceInstant:!0});return}if(Q==="sizing")this.#Y({forceInstant:!0})}}customElements.define("fig-segmented-control",T0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#J=null;#j=[];#q=null;#Z=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#K(),this.#W(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#j.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#X(),this.#N();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#Y("disabled");return}if(Q==="full"){this.#Y("full");return}if(Q==="sizing")this.#Y("sizing"),this.#N()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#j=JSON.parse(Q);return}catch{}let $=Q.includes(`
35
+ `,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",M0);class B0 extends HTMLElement{#$="Menu";#Q=null;#J;#j;#q=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#N.bind(this),this.#j=this.#L.bind(this),this.#_=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#K(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#Z=Z}#U(){if(!this.#Z)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#j)}#G(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#Y(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#K(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#A(this.value),this.#U(),this.type==="dropdown")this.select.selectedIndex=-1}#N(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#L(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#A(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#U()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#A(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#j)}}customElements.define("fig-dropdown",B0);class C extends HTMLElement{static#$=0;static#Q=500;#J;#j;#q;#Z;#_;#X;#K;#U;#W;#G=null;#Y;#N=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#B.bind(this),this.#j=this.hidePopupOutsideClick.bind(this),this.#q=this.showDelayedPopup.bind(this),this.#Z=this.#A.bind(this),this.#_=this.#M.bind(this),this.#X=this.#z.bind(this),this.#K=this.#O.bind(this),this.#U=this.#R.bind(this),this.#W=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#G=this.closest("dialog"),this.#G)this.#G.addEventListener("close",this.#W)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#G)this.#G.removeEventListener("close",this.#W),this.#G=null;if(this.action==="click")document.body.removeEventListener("click",this.#j);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#q),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#K),this.removeEventListener("touchcancel",this.#U);else if(this.action==="click")this.removeEventListener("click",this.#q),this.removeEventListener("touchstart",this.#q)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","none"),Q)this.popup.setAttribute("popover","manual");let J=c();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#j)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#K,{passive:!0}),this.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#q),document.body.addEventListener("click",this.#j),this.addEventListener("touchstart",this.#q,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}get#L(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#L)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-C.#$<C.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#G&&!this.#G.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,C.#$=Date.now()}hidePopup(){if(this.#L)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.popup)this.destroy();this.isOpen=!1,C.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#A(Q){if(!this.#N)this.hidePopup()}#M(Q){if(this.action==="hover")this.#N=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#z(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#N)this.#N=!1,clearTimeout(this.#Y),this.hidePopup()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#D(Q){if(!this.popup)return;let $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#D(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#B(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#H=new WeakMap;static show(Q,$,J={}){C.hide(Q);let Z=J.delay??500,q=Date.now()-C.#$<C.#Q?0:Z,K={timeout:null,popup:null};C.#H.set(Q,K),K.timeout=setTimeout(()=>{let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","none"),_)X.setAttribute("popover","manual");let Y=document.createElement("span");if(Y.innerText=$,X.append(Y),_)document.body.append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,K.popup=X,C.#$=Date.now()},q)}static hide(Q){let $=C.#H.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();C.#H.delete(Q)}}customElements.define("fig-tooltip",C);class O0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#J=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#j(),this.#q()})}disconnectedCallback(){this.#Z()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#j()}#j(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let K=$.lastIndexOf(J);Z=K>0?K:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;C.show(this,this.#$)},this.#J=()=>{C.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#Z(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);C.hide(this)}}customElements.define("fig-truncate",O0);class R0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this)}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),requestAnimationFrame(()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let K of this.children){let _=K.getBoundingClientRect();if(_.height===0)continue;if(q+=1,K===Q)continue;let X=window.getComputedStyle(K),Y=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");Z+=_.height+Y}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-dialog",""),Z.appendChild(b("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,K=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(K)this.style.left="0",this.style.right="0";if(q&&K)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(K)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog"}}}$0("fig-dialog",R0,{extends:"dialog"});class z0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(z1()+1);let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this.resolveAnchor();if(Q?.classList)Q.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",K=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:K}}if($.length===1){let _=$[0];if(_==="top"||_==="bottom")j=_,K=_;else if(_==="left"||_==="right")q=_,K=_;else if(_==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:K}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let K,_;if(q==="left"||q==="right")return _=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,K=Q.top,{top:K,left:_};if(q==="top"||q==="bottom")return K=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,_=Q.left,{top:K,left:_};if(J==="top")K=Q.top-$.height-j.yPx;else if(J==="bottom")K=Q.bottom+j.yPx;else K=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")_=Q.left-$.width-j.xPx;else if(Z==="right")_=Q.right+j.xPx;else _=Q.left+(Q.width-$.width)/2;else if(Z==="left")_=Q.left+j.xPx;else if(Z==="right")_=Q.right-$.width-j.xPx;else _=Q.left+(Q.width-$.width)/2;return{top:K,left:_}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let X=Q.left+Q.width/2,Y=Q.top+Q.height/2,N=this.getBoundingClientRect(),L=N.width>0&&N.height>0?N:$,B=L.left,H=L.top,M=getComputedStyle(this),G=(D,T=0)=>{let E=String(D||"").trim(),S=parseFloat(E);if(!Number.isFinite(S))return T;if(E.endsWith("rem"))return S*parseFloat(getComputedStyle(document.documentElement).fontSize);if(E.endsWith("em"))return S*parseFloat(M.fontSize);return S},z=(D)=>{if(D==="top")return Math.max(G(M.borderTopLeftRadius),G(M.borderTopRightRadius));if(D==="bottom")return Math.max(G(M.borderBottomLeftRadius),G(M.borderBottomRightRadius));if(D==="left")return Math.max(G(M.borderTopLeftRadius),G(M.borderBottomLeftRadius));if(D==="right")return Math.max(G(M.borderTopRightRadius),G(M.borderBottomRightRadius));return 0},R=G(M.getPropertyValue("--fig-popup-beak-width"),16),U=Math.max(10,z(_)+R/2),A;if(_==="top"||_==="bottom"){A=X-B;let D=U,T=Math.max(D,L.width-U);A=Math.min(T,Math.max(D,A))}else{A=Y-H;let D=U,T=Math.max(D,L.height-U);A=Math.min(T,Math.max(D,A))}this.style.setProperty("--fig-popup-beak-offset",`${A}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,K=Q.top+$.height,_=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,q-(Z-J.right)),N=Math.max(0,K-(j-J.bottom));return _+X+Y+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),K=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(K,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),K=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:K.left+(window.innerWidth-K.right-K.left-Q.width)/2,top:K.top+(window.innerHeight-K.bottom-K.top-Q.height)/2},M=this.clamp(H,Q,K);this.style.left=`${M.left}px`,this.style.top=`${M.top}px`;return}let _=q.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j),Y=null,N="top",L=Number.POSITIVE_INFINITY;for(let{v:H,h:M,s:G}of X){let z=this.computeCoords(_,Q,H,M,$,G),R=this.getPlacementSide(H,M,G);if(G){let U=this.clamp(z,Q,K);if(G==="left"||G==="right"?z.left>=K.left&&z.left+Q.width<=window.innerWidth-K.right:z.top>=K.top&&z.top+Q.height<=window.innerHeight-K.bottom){this.style.left=`${U.left}px`,this.style.top=`${U.top}px`,this.updatePopoverBeak(_,Q,U.left,U.top,R);return}let D=this.overflowScore(z,Q,K);if(D<L)L=D,Y=U,N=R}else{if(this.fits(z,Q,K)){this.style.left=`${z.left}px`,this.style.top=`${z.top}px`,this.updatePopoverBeak(_,Q,z.left,z.top,R);return}let U=this.overflowScore(z,Q,K);if(U<L)L=U,Y=z,N=R}}let B=this.clamp(Y||{left:0,top:0},Q,K);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(_,Q,B.left,B.top,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}$0("fig-popup",z0,{extends:"dialog"});class D0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",D0);class H0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#j.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#q(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#j(Q){let $=Array.from(this.querySelectorAll("fig-tab")),J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){$.forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=$[Z].getAttribute("value");if(j)this.setAttribute("value",j);$[Z].focus()}}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#q(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected")}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#q(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z)}}customElements.define("fig-tabs",H0);class F0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",F0);class T0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#j=null;#q=0;#Z=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#z(),this.#L(),requestAnimationFrame(()=>{this.#M({enforceFallback:!0}),this.#A(),this.#Y({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#Z=!1,this.#_=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#Y()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#K(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#U(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#K(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#G(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#Y({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#Z;this.#Z=!1,this.#N({forceInstant:$})})}#N({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#G(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#U();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#_=!1;return}if(!Z){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let K=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${K}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#Y()}),this.#A()}#A(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#M({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#Y({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#W(Z))return}let j=this.#U();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#z(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#M({enforceFallback:!0})}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;let J=this.selectedSegment,Z=this.value;this.selectedSegment=$;let j=this.#K($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");let q=this.value;if(J!==$||Z!==q)this.#X(q)}#O(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")})}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#O(J!==null&&J!=="false"),this.#Y({forceInstant:!0});return}if(Q==="value"){this.#M({enforceFallback:!1});return}if(Q==="animated"){if(!this.#G())this.#_=!1;this.#Y({forceInstant:!0});return}if(Q==="sizing")this.#Y({forceInstant:!0})}}customElements.define("fig-segmented-control",T0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#J=null;#j=[];#q=null;#Z=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#K(),this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#j.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#X(),this.#W();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#Y("disabled");return}if(Q==="full"){this.#Y("full");return}if(Q==="sizing")this.#Y("sizing"),this.#W()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#j=JSON.parse(Q);return}catch{}let $=Q.includes(`
36
36
  `)?`
37
- `:",";this.#j=Q.split($).map((J)=>J.trim()).filter(Boolean)}#K(){if(this.innerHTML="",this.#j.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#j){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(Z===null)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#q=Q,this.#$="segments"}#U(){if(this.innerHTML="",this.#j.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#j){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(!Z)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#q=Q,this.#$="dropdown"}#N(){if(this.#$==="segments")this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#U()}#G(){if(!this.#q||this.#Z)return;let Q=this.getAttribute("value")||"";this.#q.value=Q}#Y(Q){if(!this.#q)return;if(this.hasAttribute(Q))this.#q.setAttribute(Q,this.getAttribute(Q)||"");else this.#q.removeAttribute(Q)}#W(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#M()}),this.#J.observe(this)}#L(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),K=parseFloat(q.paddingLeft)||0,_=parseFloat(q.paddingRight)||0,X=j-K-_;return J>X+0.5}#A(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#L($))return!0;return!1}#M(){if(this.#j.length<=1)return;if(this.#$==="segments"){let Q=this.#q;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#A())this.#Q=this.clientWidth,this.#U()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#q;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#A())this.#U()})})}}customElements.define("fig-options",E0);class P0 extends HTMLElement{#$=!1;#Q=!1;#J=!1;#j="";#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#Z;#_;#X;#K;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#Z=(Q)=>{Q.stopPropagation(),this.#R()},this.#_=(Q)=>{Q.stopPropagation(),this.#D()},this.#X=(Q)=>{Q.stopPropagation(),this.#N()},this.#K=(Q)=>{Q.stopPropagation(),this.#B()}}#U(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=Q===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#M(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
37
+ `:",";this.#j=Q.split($).map((J)=>J.trim()).filter(Boolean)}#K(){if(this.innerHTML="",this.#j.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#j){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(Z===null)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#q=Q,this.#$="segments"}#U(){if(this.innerHTML="",this.#j.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#j){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(!Z)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#q=Q,this.#$="dropdown"}#W(){if(this.#$==="segments")this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#U()}#G(){if(!this.#q||this.#Z)return;let Q=this.getAttribute("value")||"";this.#q.value=Q}#Y(Q){if(!this.#q)return;if(this.hasAttribute(Q))this.#q.setAttribute(Q,this.getAttribute(Q)||"");else this.#q.removeAttribute(Q)}#N(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#M()}),this.#J.observe(this)}#L(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),K=parseFloat(q.paddingLeft)||0,_=parseFloat(q.paddingRight)||0,X=j-K-_;return J>X+0.5}#A(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#L($))return!0;return!1}#M(){if(this.#j.length<=1)return;if(this.#$==="segments"){let Q=this.#q;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#A())this.#Q=this.clientWidth,this.#U()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#q;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#A())this.#U()})})}}customElements.define("fig-options",E0);class P0 extends HTMLElement{#$=!1;#Q=!1;#J=!1;#j="";#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#Z;#_;#X;#K;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#Z=(Q)=>{Q.stopPropagation(),this.#R()},this.#_=(Q)=>{Q.stopPropagation(),this.#D()},this.#X=(Q)=>{Q.stopPropagation(),this.#W()},this.#K=(Q)=>{Q.stopPropagation(),this.#B()}}#U(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=Q===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#M(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
38
38
  <input
39
39
  type="range"
40
40
  ${this.text?'tabindex="-1"':""}
@@ -58,17 +58,17 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
58
58
  value="${this.#Q?"":this.value}"
59
59
  ${this.units?`units="${this.units}"`:""}
60
60
  ${this.precision!==null?`precision="${this.precision}"`:""}>
61
- </fig-input-number>`;else J=Z;this.innerHTML=J,requestAnimationFrame(()=>{if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.addEventListener("pointerdown",()=>{this.#$=!0}),this.input.addEventListener("pointerup",()=>{this.#$=!1}),this.default)this.style.setProperty("--default",this.#G(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||s()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",s());let j=(this.max-this.min)/this.step+1;for(let q=0;q<j;q++){let K=document.createElement("option");K.setAttribute("value",this.min+q*this.step),this.datalist.append(K)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",s());let j=document.createElement("option");j.setAttribute("value",this.default),this.datalist.append(j),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let j=this.datalist.querySelector(`option[value='${this.default}']`);if(j)j.setAttribute("default","true")}if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#K),this.figInputNumber.addEventListener("change",this.#K);this.#O()})}connectedCallback(){this.#U()}get value(){if(this.#j!=="")return this.#j;let Q=this.getAttribute("value");if(Q!==null)return String(this.#M(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#M($)):$;if(this.#j=Z,this.getAttribute("value")!==Z)this.#J=!0,this.setAttribute("value",Z),this.#J=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#z()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("change",this.#_);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#K)}#N(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#M(Q);this.value=$,this.input.value=String($),this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#G(Q){let{min:$,max:J}=this.#W(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#Y(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#W(){let Q=this.#Y(this.min),$=this.#Y(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#L(Q){let{min:$,max:J}=this.#W();return Math.min(J,Math.max($,Q))}#A(){if(this.type==="delta"){let $=this.#Y(this.default);if($!==null)return this.#L($);return this.#L(0)}let{min:Q}=this.#W();return Q}#M(Q){let $=this.#Y(Q);if($===null)return this.#A();return this.#L($)}#z(){let Q=this.#G(this.value);this.style.setProperty("--slider-complete",Q);let $=this.#G(this.default);this.style.setProperty("--default",$),this.style.setProperty("--unchanged",Q===$?1:0)}#O(){let Q=this.input.value;if(this.value=Q,this.#z(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#R(){this.#Q=!1,this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#D(){this.#$=!1,this.#Q=!1,this.#O(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#B(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#M(Q);this.value=$,this.input.value=String($),this.#O(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision"]}focus(){this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#J)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#M(J),this.input.value=String(this.value),this.#O(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#z();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#U();break;case"text":this.text=J!=="false",this.#U();break;default:this[Q]=this.input[Q]=J,this.#O();break}}}customElements.define("fig-slider",P0);class S0 extends HTMLElement{#$=!1;#Q=!1;#J;#j;#q;#Z;#_;#X;constructor(){super();this.#J=this.#A.bind(this),this.#j=this.#z.bind(this),this.#q=this.#z.bind(this),this.#Z=this.#M.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#L(Q)},this.#X=()=>{this.#N()}}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.input.setAttribute("min",String(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",String(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",String(this.step));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}let Q=`<input
61
+ </fig-input-number>`;else J=Z;this.innerHTML=J,requestAnimationFrame(()=>{if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.addEventListener("pointerdown",()=>{this.#$=!0}),this.input.addEventListener("pointerup",()=>{this.#$=!1}),this.default)this.style.setProperty("--default",this.#G(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||c()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",c());let j=(this.max-this.min)/this.step+1;for(let q=0;q<j;q++){let K=document.createElement("option");K.setAttribute("value",this.min+q*this.step),this.datalist.append(K)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",c());let j=document.createElement("option");j.setAttribute("value",this.default),this.datalist.append(j),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let j=this.datalist.querySelector(`option[value='${this.default}']`);if(j)j.setAttribute("default","true")}if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#K),this.figInputNumber.addEventListener("change",this.#K);this.#O()})}connectedCallback(){this.#U()}get value(){if(this.#j!=="")return this.#j;let Q=this.getAttribute("value");if(Q!==null)return String(this.#M(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#M($)):$;if(this.#j=Z,this.getAttribute("value")!==Z)this.#J=!0,this.setAttribute("value",Z),this.#J=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#z()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("change",this.#_);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#K)}#W(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#M(Q);this.value=$,this.input.value=String($),this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#G(Q){let{min:$,max:J}=this.#N(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#Y(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#N(){let Q=this.#Y(this.min),$=this.#Y(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#L(Q){let{min:$,max:J}=this.#N();return Math.min(J,Math.max($,Q))}#A(){if(this.type==="delta"){let $=this.#Y(this.default);if($!==null)return this.#L($);return this.#L(0)}let{min:Q}=this.#N();return Q}#M(Q){let $=this.#Y(Q);if($===null)return this.#A();return this.#L($)}#z(){let Q=this.#G(this.value);this.style.setProperty("--slider-complete",Q);let $=this.#G(this.default);this.style.setProperty("--default",$),this.style.setProperty("--unchanged",Q===$?1:0)}#O(){let Q=this.input.value;if(this.value=Q,this.#z(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#R(){this.#Q=!1,this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#D(){this.#$=!1,this.#Q=!1,this.#O(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#B(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#M(Q);this.value=$,this.input.value=String($),this.#O(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision"]}focus(){this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#J)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#M(J),this.input.value=String(this.value),this.#O(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#z();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#U();break;case"text":this.text=J!=="false",this.#U();break;default:this[Q]=this.input[Q]=J,this.#O();break}}}customElements.define("fig-slider",P0);class S0 extends HTMLElement{#$=!1;#Q=!1;#J;#j;#q;#Z;#_;#X;constructor(){super();this.#J=this.#A.bind(this),this.#j=this.#z.bind(this),this.#q=this.#z.bind(this),this.#Z=this.#M.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#L(Q)},this.#X=()=>{this.#W()}}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.input.setAttribute("min",String(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",String(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",String(this.step));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}let Q=`<input
62
62
  type="${this.type}"
63
63
  ${this.name?`name="${this.name}"`:""}
64
64
  placeholder="${this.placeholder}"
65
- value="${this.type==="number"?this.#W(this.value):this.value}" />`;if(this.multiline)Q=`<textarea
66
- placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if($)$.addEventListener("click",this.focus.bind(this)),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.#K(),this.#U(),this.#N(),this.#G(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#W(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#W(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#W(this.step));this.addEventListener("pointerdown",this.#Z)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}focus(){this.input.focus()}#K(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q)return;let J=w("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.focus.bind(this)),this.prepend(J)}#U(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q)return;let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=w("",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),q.style.setProperty("--icon","var(--icon-16-close)"),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#N(),this.focus()})}#N(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#G(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#Y(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=w("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#Y(J),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#Y(J),this.focus()})}#Y(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#W(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#R($),$}#L(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#O($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#N(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#z();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#O(J,!1);let Z=J*(this.transform||1);J=this.#R(J),Z=this.#R(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#M(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#j),window.addEventListener("blur",this.#q)}#z(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}#O(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#W(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#W(this.max):this.max,J);J=this.#R(J)}return J}#R(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#W(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#O(Z,!1),this.value=Z,this.input.value=this.#W(Z);else this.value=Z,this.input.value=Z;this.#N();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#K(),this.#U(),this.#N(),this.#G();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",S0);class Q0 extends HTMLElement{#$;#Q;#J;#j;#q;#Z;#_;#X;#K;#U;#N;#G;#Y;#W;#L=!1;#A=null;static#M="px";#z(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#O(Q){let $=(Q||"").trim();if(!$)return"";return(this.#G??[]).includes($.toLowerCase())?"":$}#R(){this.#U=this.#O(this.#N)}#D(Q){if(Q&&!this.#A)this.#A=document.createElement("span"),this.#A.className="fig-steppers",this.#A.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#A.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#H(Z),this.input.focus()}),this.append(this.#A);else if(!Q&&this.#A)this.#A.remove(),this.#A=null;this.#B()}#B(){if(!this.#A)return;let Q=this.#A.querySelector(".fig-stepper-up"),$=this.#A.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#T(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),K=j&&typeof this.min==="number"&&Z<=this.min,_=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||_,$.disabled=q||K}#H(Q){let $=this.step||1,J=this.#T(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#F(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#V.bind(this),this.#Q=this.#C.bind(this),this.#J=this.#C.bind(this),this.#j=this.#w.bind(this),this.#q=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#I(Q)},this.#_=(Q)=>{this.#k(Q)},this.#X=(Q)=>{this.#E(Q)},this.#K=(Q)=>{this.#S(Q)}}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#N=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#G=this.#z($===null?Q0.#M:$),this.#R(),this.#Y=this.getAttribute("unit-position")||"suffix",this.#W=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false",Z=`<input
65
+ value="${this.type==="number"?this.#N(this.value):this.value}" />`;if(this.multiline)Q=`<textarea
66
+ placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if($)$.addEventListener("click",this.focus.bind(this)),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.#K(),this.#U(),this.#W(),this.#G(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#N(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#N(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#N(this.step));this.addEventListener("pointerdown",this.#Z)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}focus(){this.input.focus()}#K(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q)return;let J=b("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.focus.bind(this)),this.prepend(J)}#U(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q)return;let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=b("",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),q.style.setProperty("--icon","var(--icon-16-close)"),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#W(),this.focus()})}#W(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#G(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#Y(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=b("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#Y(J),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#Y(J),this.focus()})}#Y(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#N(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#R($),$}#L(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#O($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#W(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#z();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#O(J,!1);let Z=J*(this.transform||1);J=this.#R(J),Z=this.#R(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#M(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#j),window.addEventListener("blur",this.#q)}#z(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}#O(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#N(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#N(this.max):this.max,J);J=this.#R(J)}return J}#R(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#N(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#O(Z,!1),this.value=Z,this.input.value=this.#N(Z);else this.value=Z,this.input.value=Z;this.#W();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#K(),this.#U(),this.#W(),this.#G();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",S0);class t extends HTMLElement{#$;#Q;#J;#j;#q;#Z;#_;#X;#K;#U;#W;#G;#Y;#N;#L=!1;#A=null;static#M="px";#z(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#O(Q){let $=(Q||"").trim();if(!$)return"";return(this.#G??[]).includes($.toLowerCase())?"":$}#R(){this.#U=this.#O(this.#W)}#D(Q){if(Q&&!this.#A)this.#A=document.createElement("span"),this.#A.className="fig-steppers",this.#A.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#A.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#H(Z),this.input.focus()}),this.append(this.#A);else if(!Q&&this.#A)this.#A.remove(),this.#A=null;this.#B()}#B(){if(!this.#A)return;let Q=this.#A.querySelector(".fig-stepper-up"),$=this.#A.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#F(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),K=j&&typeof this.min==="number"&&Z<=this.min,_=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||_,$.disabled=q||K}#H(Q){let $=this.step||1,J=this.#F(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#V.bind(this),this.#Q=this.#k.bind(this),this.#J=this.#k.bind(this),this.#j=this.#w.bind(this),this.#q=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#I(Q)},this.#_=(Q)=>{this.#C(Q)},this.#X=(Q)=>{this.#E(Q)},this.#K=(Q)=>{this.#S(Q)}}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#G=this.#z($===null?t.#M:$),this.#R(),this.#Y=this.getAttribute("unit-position")||"suffix",this.#N=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false",Z=`<input
67
67
  type="text"
68
68
  inputmode="decimal"
69
69
  ${this.name?`name="${this.name}"`:""}
70
70
  placeholder="${this.placeholder}"
71
- value="${this.#F(this.value)}" />`;requestAnimationFrame(()=>{let j=this.querySelector("[slot=append]"),q=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,q)q.addEventListener("click",this.focus.bind(this)),this.prepend(q);if(j)j.addEventListener("click",this.focus.bind(this)),this.append(j);if(this.input=this.querySelector("input"),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#D(J),this.hasAttribute("disabled")){let K=this.getAttribute("disabled");this.disabled=this.input.disabled=K!=="false"}this.#B(),this.addEventListener("pointerdown",this.#j),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#T(Q){if(!Q)return"";if(!this.#U){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#U,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#F(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#x($),!this.#U)return $.toString();if(this.#Y==="prefix")return this.#U+$;else return $+this.#U}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#k(Q){this.#L=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#U)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#U.length,$.length);else{let J=$.indexOf(this.#U);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#E(Q){this.#L=!1;let $=this.#T(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#F(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#S(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#T(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#f(q,!1),this.value=q,this.input.value=this.#F(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(Q){let $=this.#T(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){Q.stopPropagation();let $=this.#T(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#F(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled)return;if(Q.buttons===0){this.#C();return}let $=(this.step||1)*Q.movementX,J=this.#T(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#F(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#L=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#C(Q){this.#L=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#f(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#x(J),J}#x(Q){let $=this.#W??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#B();break;case"units":this.#N=J||"",this.#R(),this.input.value=this.#F(this.value);break;case"units-disallow":this.#G=this.#z(J===null?Q0.#M:J),this.#R(),this.input.value=this.#F(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#F(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#F(this.value);break;case"value":if(this.#L)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#f(Z,!1);this.value=Z,this.input.value=this.#F(this.value),this.#B();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#B();break}this[Q]=Number(J),this.#B();break;case"steppers":{let j=J!==null&&J!=="false";this.#D(j);break}case"precision":this.#W=J!==null?Number(J):2,this.input.value=this.#F(this.value);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",Q0);class k0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",k0);class C0 extends HTMLElement{#$=!1;#Q=null;#J=null;constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label)this.#Q=w("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J);else if(this.input&&this.label)this.label.addEventListener("click",this.focus.bind(this));if(this.input&&this.label&&!this.#$){let Q=this.input.getAttribute("id")||s();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}if(this.label)this.label.addEventListener("pointerenter",this.#j.bind(this)),this.label.addEventListener("pointerleave",this.#q.bind(this))})}disconnectedCallback(){if(this.label)C.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#j(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;C.show(this.label,this.label.textContent.trim())}#q(){if(this.label)C.hide(this.label)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J;break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",C0);class I0 extends HTMLElement{rgba;hex;#$=100;#Q;#J;#j;#q;#Z=!1;#_=!1;#X=null;constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#K(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#U(){let Q=this.#K();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#N)cancelAnimationFrame(this.#N);this.#N=requestAnimationFrame(()=>{this.#N=null,this.#G()})}#N=null;#G(){this.#R(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#E?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
71
+ value="${this.#T(this.value)}" />`;requestAnimationFrame(()=>{let j=this.querySelector("[slot=append]"),q=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,q)q.addEventListener("click",this.focus.bind(this)),this.prepend(q);if(j)j.addEventListener("click",this.focus.bind(this)),this.append(j);if(this.input=this.querySelector("input"),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#D(J),this.hasAttribute("disabled")){let K=this.getAttribute("disabled");this.disabled=this.input.disabled=K!=="false"}this.#B(),this.addEventListener("pointerdown",this.#j),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#F(Q){if(!Q)return"";if(!this.#U){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#U,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#T(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#x($),!this.#U)return $.toString();if(this.#Y==="prefix")return this.#U+$;else return $+this.#U}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#C(Q){this.#L=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#U)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#U.length,$.length);else{let J=$.indexOf(this.#U);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#E(Q){this.#L=!1;let $=this.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#S(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#F(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#f(q,!1),this.value=q,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(Q){let $=this.#F(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){Q.stopPropagation();let $=this.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled)return;if(Q.buttons===0){this.#k();return}let $=(this.step||1)*Q.movementX,J=this.#F(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#L=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#k(Q){this.#L=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#f(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#x(J),J}#x(Q){let $=this.#N??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#B();break;case"units":this.#W=J||"",this.#R(),this.input.value=this.#T(this.value);break;case"units-disallow":this.#G=this.#z(J===null?t.#M:J),this.#R(),this.input.value=this.#T(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#T(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#T(this.value);break;case"value":if(this.#L)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#f(Z,!1);this.value=Z,this.input.value=this.#T(this.value),this.#B();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#B();break}this[Q]=Number(J),this.#B();break;case"steppers":{let j=J!==null&&J!=="false";this.#D(j);break}case"precision":this.#N=J!==null?Number(J):2,this.input.value=this.#T(this.value);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",t);class k0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",k0);class C0 extends HTMLElement{#$=!1;#Q=null;#J=null;constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label)this.#Q=b("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J);else if(this.input&&this.label)this.label.addEventListener("click",this.focus.bind(this));if(this.input&&this.label&&!this.#$){let Q=this.input.getAttribute("id")||c();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}if(this.label)this.label.addEventListener("pointerenter",this.#j.bind(this)),this.label.addEventListener("pointerleave",this.#q.bind(this))})}disconnectedCallback(){if(this.label)C.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#j(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;C.show(this.label,this.label.textContent.trim())}#q(){if(this.label)C.hide(this.label)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J;break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",C0);class I0 extends HTMLElement{rgba;hex;#$=100;#Q;#J;#j;#q;#Z=!1;#_=!1;#X=null;constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#K(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#U(){let Q=this.#K();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#W)cancelAnimationFrame(this.#W);this.#W=requestAnimationFrame(()=>{this.#W=null,this.#G()})}#W=null;#G(){this.#R(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#E?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
72
72
  type="text"
73
73
  placeholder="000000"
74
74
  value="${this.hexOpaque.slice(1).toUpperCase()}"${J}>
@@ -83,7 +83,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
83
83
  </fig-tooltip>`;let K="";K=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`,Z=`<div class="input-combo">
84
84
  ${K}
85
85
  ${q}
86
- </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;this.innerHTML=Z,requestAnimationFrame(()=>{if(this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#j=this.querySelector("fig-input-text:not([type=number])"),this.#q=this.querySelector("fig-input-number"),this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let q=this.#Q.querySelector('input[type="color"]');if(this.#j||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#M.bind(this),{capture:!0}),this.#Q.addEventListener("click",this.#z.bind(this),{capture:!0}),q?.addEventListener("keydown",this.#O.bind(this)),this.#Q.addEventListener("input",this.#T.bind(this))}if(this.#j){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#j.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q;this.#j.addEventListener("input",this.#D.bind(this)),this.#j.addEventListener("change",this.#H.bind(this))}if(this.#q)this.#q.addEventListener("input",this.#B.bind(this)),this.#q.addEventListener("change",this.#H.bind(this))})}#Y(){if(!this.#J)return;for(let[Q,$]of Object.entries(this.#K()))this.#J.setAttribute(Q,$);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#W(){if(!u())return null;if(this.#J?.isConnected)return this.#Y(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F.bind(this)),Q.addEventListener("change",this.#H.bind(this)),this.appendChild(Q),this.#J=Q,this.#Y(),Q}#L(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#W();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#A(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#M(Q){if(!u())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#Z=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#Z=!1,this.#_=!1,this.#X=null},500),this.#A(Q)}#z(Q){if(!this.#Z)return;if(this.#Z=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#A(Q),this.#_)this.#_=!1,this.#L()}#O(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!u())return;if(!this.#L())return;this.#A(Q)}#R(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#D(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#R("#"+$),this.#q)this.#q.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#P()}#B(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#R(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#P()}#H(Q){Q.stopPropagation(),this.#k()}focus(){if(this.#j){this.#j.focus();return}this.#Q?.focus()}#T(Q){if(Q.stopPropagation(),this.#R(Q.target.value),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#P()}#F(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#R(J),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#q&&$.alpha!==void 0)this.#q.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#P()}}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#k(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#R(J),this.#j)this.#j.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#q)this.#q.setAttribute("value",this.#$);break;case"mode":this.#Y();break;case"alpha":case"text":if(this.isConnected)this.#G();break;case"disabled":this.#S();break}}get#E(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#S(){let Q=this.#E;for(let $ of[this.#Q,this.#j,this.#q]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)this.#Y()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),K=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${K}`.toUpperCase();let X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${K}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let K=parseInt(q[1])/360,_=parseInt(q[2])/100,X=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,_===0)$=J=Z=X;else{let Y=(B,H,A)=>{if(A<0)A+=1;if(A>1)A-=1;if(A<0.16666666666666666)return B+(H-B)*6*A;if(A<0.5)return H;if(A<0.6666666666666666)return B+(H-B)*(0.6666666666666666-A)*6;return B},N=X<0.5?X*(1+_):X+_-X*_,G=2*X-N;$=Y(G,N,K+0.3333333333333333),J=Y(G,N,K),Z=Y(G,N,K-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",I0);var D1=["srgb","srgb-linear","display-p3","oklab","oklch"],H1=["shorter","longer","increasing","decreasing"];function p(Q){let $={...Q??{}},J=String($.interpolationSpace??"oklab").toLowerCase();if(!D1.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=H1.includes(Z)?Z:"shorter",$}function f0(Q){let $=p(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function y0(Q){let $=p(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function r(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function v(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function d(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function e(Q,$,J){let Z=v(Q),j=v($),q=v(J),K=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),_=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),X=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*K+0.793617785*_-0.0040720468*X,a:1.9779984951*K-2.428592205*_+0.4505937099*X,b:0.0259040371*K+0.7827717662*_-0.808675766*X}}function G0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,K=Z*Z*Z,_=j*j*j,X=q*q*q;return{r:d(4.0767416621*K-3.3077115913*_+0.2309699292*X),g:d(-1.2684380046*K+2.6097574011*_-0.3413193965*X),b:d(-0.0041960863*K-0.7034186147*_+1.707614701*X)}}function L0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function F1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function T1(Q,$,J,Z){let j=(Q%360+360)%360,K=($%360+360)%360-j;switch(Z){case"longer":if(K>0&&K<180)K-=360;else if(K<0&&K>-180)K+=360;else if(K===0)K=0;break;case"increasing":if(K<0)K+=360;break;case"decreasing":if(K>0)K-=360;break;default:if(K>180)K-=360;else if(K<-180)K+=360;break}return((j+K*J)%360+360)%360}function E1(Q,$,J,Z){let j=[...Q].sort((R,L)=>R.position-L.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let K=0;while(K<j.length-1&&j[K+1].position<q)K++;let _=j[K],X=j[K+1],Y=X.position-_.position,N=Y>0?(q-_.position)/Y:0,G=r(_.color),B=r(X.color),H,A,O,D=J||"oklab";if(D==="srgb-linear"){let R=v(G.r),L=v(G.g),U=v(G.b),M=v(B.r),T=v(B.g),E=v(B.b);H=d(R+(M-R)*N),A=d(L+(T-L)*N),O=d(U+(E-U)*N)}else if(D==="oklch"){let R=e(G.r,G.g,G.b),L=e(B.r,B.g,B.b),U=L0(R.l,R.a,R.b),M=L0(L.l,L.a,L.b),T=U.l+(M.l-U.l)*N,E=U.c+(M.c-U.c)*N,S=T1(U.h,M.h,N,Z||"shorter"),f=F1(T,E,S),c=G0(f.l,f.a,f.b);H=c.r,A=c.g,O=c.b}else{let R=e(G.r,G.g,G.b),L=e(B.r,B.g,B.b),U=R.l+(L.l-R.l)*N,M=R.a+(L.a-R.a)*N,T=R.b+(L.b-R.b)*N,E=G0(U,M,T);H=E.r,A=E.g,O=E.b}return`#${H.toString(16).padStart(2,"0")}${A.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}`.toUpperCase()}class x0 extends HTMLElement{#$="solid";#Q;#J;#j;#q={color:"#D9D9D9",alpha:1};#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#j=null}#U(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#q.color=$.color;if($.alpha!==void 0)this.#q.alpha=$.alpha;if($.opacity!==void 0)this.#q.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#Z=p({...this.#Z,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#q.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#q.alpha=parseInt(J,16)/255}}}}#N(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#G(){switch(this.#$){case"solid":return this.#q.color;case"gradient":{let $=[...this.#Z.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:K}=r(J.color);return`rgba(${j}, ${q}, ${K}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#Z.angle}deg ${y0(this.#Z)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#Y(){switch(this.#$){case"solid":return this.#q.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#W(){let Q=this.hasAttribute("disabled");for(let $ of[this.#Q,this.#J,this.#j]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#L(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(K)=>J?`<fig-tooltip text="Opacity">
86
+ </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;this.innerHTML=Z,requestAnimationFrame(()=>{if(this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#j=this.querySelector("fig-input-text:not([type=number])"),this.#q=this.querySelector("fig-input-number"),this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let q=this.#Q.querySelector('input[type="color"]');if(this.#j||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#M.bind(this),{capture:!0}),this.#Q.addEventListener("click",this.#z.bind(this),{capture:!0}),q?.addEventListener("keydown",this.#O.bind(this)),this.#Q.addEventListener("input",this.#F.bind(this))}if(this.#j){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#j.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q;this.#j.addEventListener("input",this.#D.bind(this)),this.#j.addEventListener("change",this.#H.bind(this))}if(this.#q)this.#q.addEventListener("input",this.#B.bind(this)),this.#q.addEventListener("change",this.#H.bind(this))})}#Y(){if(!this.#J)return;for(let[Q,$]of Object.entries(this.#K()))this.#J.setAttribute(Q,$);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#N(){if(!m())return null;if(this.#J?.isConnected)return this.#Y(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#T.bind(this)),Q.addEventListener("change",this.#H.bind(this)),this.appendChild(Q),this.#J=Q,this.#Y(),Q}#L(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#N();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#A(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#M(Q){if(!m())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#Z=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#Z=!1,this.#_=!1,this.#X=null},500),this.#A(Q)}#z(Q){if(!this.#Z)return;if(this.#Z=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#A(Q),this.#_)this.#_=!1,this.#L()}#O(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!m())return;if(!this.#L())return;this.#A(Q)}#R(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#D(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#R("#"+$),this.#q)this.#q.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#P()}#B(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#R(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#P()}#H(Q){Q.stopPropagation(),this.#C()}focus(){if(this.#j){this.#j.focus();return}this.#Q?.focus()}#F(Q){if(Q.stopPropagation(),this.#R(Q.target.value),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#P()}#T(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#R(J),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#q&&$.alpha!==void 0)this.#q.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#P()}}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#R(J),this.#j)this.#j.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#q)this.#q.setAttribute("value",this.#$);break;case"mode":this.#Y();break;case"alpha":case"text":if(this.isConnected)this.#G();break;case"disabled":this.#S();break}}get#E(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#S(){let Q=this.#E;for(let $ of[this.#Q,this.#j,this.#q]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)this.#Y()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),K=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${K}`.toUpperCase();let X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${K}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let K=parseInt(q[1])/360,_=parseInt(q[2])/100,X=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,_===0)$=J=Z=X;else{let Y=(B,H,M)=>{if(M<0)M+=1;if(M>1)M-=1;if(M<0.16666666666666666)return B+(H-B)*6*M;if(M<0.5)return H;if(M<0.6666666666666666)return B+(H-B)*(0.6666666666666666-M)*6;return B},N=X<0.5?X*(1+_):X+_-X*_,L=2*X-N;$=Y(L,N,K+0.3333333333333333),J=Y(L,N,K),Z=Y(L,N,K-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",I0);var D1=["srgb","srgb-linear","display-p3","oklab","oklch"],H1=["shorter","longer","increasing","decreasing"];function h(Q){let $={...Q??{}},J=String($.interpolationSpace??"oklab").toLowerCase();if(!D1.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=H1.includes(Z)?Z:"shorter",$}function f0(Q){let $=h(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function y0(Q){let $=h(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function u(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function v(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function p(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function l(Q,$,J){let Z=v(Q),j=v($),q=v(J),K=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),_=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),X=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*K+0.793617785*_-0.0040720468*X,a:1.9779984951*K-2.428592205*_+0.4505937099*X,b:0.0259040371*K+0.7827717662*_-0.808675766*X}}function G0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,K=Z*Z*Z,_=j*j*j,X=q*q*q;return{r:p(4.0767416621*K-3.3077115913*_+0.2309699292*X),g:p(-1.2684380046*K+2.6097574011*_-0.3413193965*X),b:p(-0.0041960863*K-0.7034186147*_+1.707614701*X)}}function L0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function F1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function T1(Q,$,J,Z){let j=(Q%360+360)%360,K=($%360+360)%360-j;switch(Z){case"longer":if(K>0&&K<180)K-=360;else if(K<0&&K>-180)K+=360;else if(K===0)K=0;break;case"increasing":if(K<0)K+=360;break;case"decreasing":if(K>0)K-=360;break;default:if(K>180)K-=360;else if(K<-180)K+=360;break}return((j+K*J)%360+360)%360}function E1(Q,$,J,Z){let j=[...Q].sort((R,U)=>R.position-U.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let K=0;while(K<j.length-1&&j[K+1].position<q)K++;let _=j[K],X=j[K+1],Y=X.position-_.position,N=Y>0?(q-_.position)/Y:0,L=u(_.color),B=u(X.color),H,M,G,z=J||"oklab";if(z==="srgb-linear"){let R=v(L.r),U=v(L.g),A=v(L.b),D=v(B.r),T=v(B.g),E=v(B.b);H=p(R+(D-R)*N),M=p(U+(T-U)*N),G=p(A+(E-A)*N)}else if(z==="oklch"){let R=l(L.r,L.g,L.b),U=l(B.r,B.g,B.b),A=L0(R.l,R.a,R.b),D=L0(U.l,U.a,U.b),T=A.l+(D.l-A.l)*N,E=A.c+(D.c-A.c)*N,S=T1(A.h,D.h,N,Z||"shorter"),I=F1(T,E,S),V=G0(I.l,I.a,I.b);H=V.r,M=V.g,G=V.b}else{let R=l(L.r,L.g,L.b),U=l(B.r,B.g,B.b),A=R.l+(U.l-R.l)*N,D=R.a+(U.a-R.a)*N,T=R.b+(U.b-R.b)*N,E=G0(A,D,T);H=E.r,M=E.g,G=E.b}return`#${H.toString(16).padStart(2,"0")}${M.toString(16).padStart(2,"0")}${G.toString(16).padStart(2,"0")}`.toUpperCase()}class x0 extends HTMLElement{#$="solid";#Q;#J;#j;#q={color:"#D9D9D9",alpha:1};#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#j=null}#U(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#q.color=$.color;if($.alpha!==void 0)this.#q.alpha=$.alpha;if($.opacity!==void 0)this.#q.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#Z=h({...this.#Z,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#q.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#q.alpha=parseInt(J,16)/255}}}}#W(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#G(){switch(this.#$){case"solid":return this.#q.color;case"gradient":{let $=[...this.#Z.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:K}=u(J.color);return`rgba(${j}, ${q}, ${K}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#Z.angle}deg ${y0(this.#Z)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#Y(){switch(this.#$){case"solid":return this.#q.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#N(){let Q=this.hasAttribute("disabled");for(let $ of[this.#Q,this.#J,this.#j]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#L(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(K)=>J?`<fig-tooltip text="Opacity">
87
87
  <fig-input-number
88
88
  class="fig-input-fill-opacity"
89
89
  placeholder="##"
@@ -109,13 +109,13 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
109
109
  <label class="fig-input-fill-label">Video</label>
110
110
  ${Z(Math.round((this.#X.opacity??1)*100))}`;break;case"webcam":j=`
111
111
  <label class="fig-input-fill-label">Webcam</label>
112
- ${Z(Math.round((this.#K.opacity??1)*100))}`;break}let q=this.#N();this.innerHTML=`
112
+ ${Z(Math.round((this.#K.opacity??1)*100))}`;break}let q=this.#W();this.innerHTML=`
113
113
  <div class="input-combo">
114
114
  <fig-fill-picker ${q} value='${$}' ${Q?"disabled":""}>
115
115
  <fig-chit background="${this.#G()}" alpha="${this.#Y()}"${Q?" disabled":""}></fig-chit>
116
116
  </fig-fill-picker>
117
117
  ${j}
118
- </div>`,this.#A()}#A(){requestAnimationFrame(()=>{this.#Q=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(Q&&this.#Q)Q.addEventListener("click",()=>{let $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{let J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,q=j!==this.#$;switch(this.#$=j,j){case"solid":this.#q.color=Z.color,this.#q.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#Z=p({...this.#Z,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(q)this.#z();else this.#M();this.#D()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#B()})}if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#q.color=J,this.#O(),this.#D()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#B()});if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#$){case"solid":this.#q.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#K.opacity=j;break}this.#O(),this.#R(j),this.#D()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#B()})})}#M(){switch(this.#$){case"solid":if(this.#j)this.#j.setAttribute("value",this.#q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#q.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#Z.type.charAt(0).toUpperCase()+this.#Z.type.slice(1);Q.textContent=$}break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#K.opacity??1)*100));break}}#z(){let Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),q=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),q.forEach((_)=>_.remove());let K="";switch(this.#$){case"solid":K=`
118
+ </div>`,this.#A()}#A(){requestAnimationFrame(()=>{this.#Q=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(Q&&this.#Q)Q.addEventListener("click",()=>{let $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{let J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,q=j!==this.#$;switch(this.#$=j,j){case"solid":this.#q.color=Z.color,this.#q.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#Z=h({...this.#Z,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(q)this.#z();else this.#M();this.#D()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#B()})}if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#q.color=J,this.#O(),this.#D()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#B()});if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#$){case"solid":this.#q.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#K.opacity=j;break}this.#O(),this.#R(j),this.#D()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#B()})})}#M(){switch(this.#$){case"solid":if(this.#j)this.#j.setAttribute("value",this.#q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#q.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#Z.type.charAt(0).toUpperCase()+this.#Z.type.slice(1);Q.textContent=$}break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#K.opacity??1)*100));break}}#z(){let Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),q=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),q.forEach((_)=>_.remove());let K="";switch(this.#$){case"solid":K=`
119
119
  <fig-input-text
120
120
  type="text"
121
121
  class="fig-input-fill-hex"
@@ -181,12 +181,12 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
181
181
  units="%"
182
182
  ${Q?"disabled":""}>
183
183
  </fig-input-number>
184
- </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",K),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(_&&this.#Q)_.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#j)this.#j.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#q.color=Y,this.#O(),this.#D()}),this.#j.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let Y=parseFloat(X.target.value),G=(isNaN(Y)?100:Y)/100;switch(this.#$){case"solid":this.#q.alpha=G;break;case"gradient":break;case"image":this.#_.opacity=G;break;case"video":this.#X.opacity=G;break;case"webcam":this.#K.opacity=G;break}this.#O(),this.#R(G),this.#D()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()})})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#R(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#q.color,alpha:this.#q.alpha,opacity:Math.round(this.#q.alpha*100)};case"gradient":return{type:"gradient",gradient:f0(this.#Z)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#U(),this.#Q)if(this.#$!==Z)this.#L();else this.#O(),this.#M();break;case"disabled":this.#W();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",x0);class V0 extends HTMLElement{#$=[];#Q=[];#J=[];#j=null;static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Z(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#_(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#j)cancelAnimationFrame(this.#j);this.#j=requestAnimationFrame(()=>{this.#j=null,this.#X(),this.#K()})}disconnectedCallback(){if(this.#j)cancelAnimationFrame(this.#j),this.#j=null;this.#Q=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#A();break;case"disabled":this.#M();break;case"min":case"max":case"fixed":this.#K();break;case"open":break}}#X(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline",$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0});let J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,q)=>{J.appendChild(this.#U(j,q,Q,{inline:!0}))}),$.appendChild(J),this.appendChild($),!this.#q)this.#Y(Q,this);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,q)=>{if(Z.appendChild(this.#U(j,q,Q)),!this.#q)Z.appendChild(this.#N(q,Q))}),this.appendChild(Z)}#U(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let K=Z?this.#J:this.#Q,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};let N=K[$];if(N){let G=this.#$[$],B=G.alpha<1?G.color+Math.round(G.alpha*255).toString(16).padStart(2,"0"):G.color;N.setAttribute("value",B)}};if(q.addEventListener("input",(X)=>{_(X),this.#O()}),q.addEventListener("change",(X)=>{_(X),this.#R()}),Z)this.#Q.push(q);else this.#J.push(q);return q}#N(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#Z)J.setAttribute("disabled","");J.appendChild(w("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#Z)return;this.#$.splice(Q,1),this.#Q=[],this.#J=[],this.#K(),this.#R()}#Y(Q,$=this){let J=this.#$.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(w("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#_)return;this.open=!0,this.#W({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#W(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#U(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#U(Q,J,$),K=this.querySelector(".palette-colors-expanded");if(K)K.appendChild(q),K.appendChild(this.#N(J,$));if(this.#$.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#z($),this.#R()}#L(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#A(){if(this.#Q.length!==this.#$.length){this.#K();return}this.#$.forEach((Q,$)=>{this.#L($)})}#M(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#_)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#z(Q)}#z(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#Z;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",V0);class i extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#J=!1;#j=null;#q=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#_(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#_==="true"}get#K(){return this.getAttribute("mode")==="tip"?"tip":"handle"}connectedCallback(){if(this.#N(),this.#M(),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.#q)this.#q.disconnect(),this.#q=null;clearTimeout(this.#j),this.removeEventListener("pointerenter",this.#H),this.removeEventListener("pointermove",this.#F),this.removeEventListener("pointerleave",this.#T),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#k)}#U=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let K=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],_=K.indexOf(q),X=Q.shiftKey?(_-1+K.length)%K.length:(_+1)%K.length;q.deselect(),K[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let K=parseInt(q.dataset.stopIndex,10);if(isNaN(K)||!this.#Z.stops[K])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?i.SHIFT_SNAP:1),X=this.#Z.stops[K];X.position=Math.max(0,Math.min(100,X.position+_)),q.setAttribute("value",`${X.position}% 50%`);let Y=q.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),q.hideColorTip(),clearTimeout(this.#j),this.#j=setTimeout(()=>{Y.removeAttribute("show"),q.showColorTip()},600);this.#C(),this.#x(),this.#b();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#I(),this.#C(),this.#x(),this.#b()};#N(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=p({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90;return}if($?.gradient)this.#Z=p({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90}catch($){}}#G(){let $=[...this.#Z.stops].sort((Z,j)=>Z.position-j.position).map((Z)=>{let j=(Z.opacity??100)/100;if(j>=1)return`${Z.color} ${Z.position}%`;let{r:q,g:K,b:_}=r(Z.color);return`rgba(${q}, ${K}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=y0(this.#Z);return`linear-gradient(${this.#Z.angle}deg ${J}, ${$})`}#Y(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=r(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#W(){let Q=this.hasAttribute("disabled"),$=this.#K==="tip"?' tip="color"':"";return this.#Z.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#Y(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#L=null;#A=!1;#M(){let Q=this.hasAttribute("disabled"),$=this.#_;if($==="picker"&&u()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
184
+ </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",K),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(_&&this.#Q)_.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#j)this.#j.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#q.color=Y,this.#O(),this.#D()}),this.#j.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let Y=parseFloat(X.target.value),L=(isNaN(Y)?100:Y)/100;switch(this.#$){case"solid":this.#q.alpha=L;break;case"gradient":break;case"image":this.#_.opacity=L;break;case"video":this.#X.opacity=L;break;case"webcam":this.#K.opacity=L;break}this.#O(),this.#R(L),this.#D()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()})})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#R(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#q.color,alpha:this.#q.alpha,opacity:Math.round(this.#q.alpha*100)};case"gradient":return{type:"gradient",gradient:f0(this.#Z)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#U(),this.#Q)if(this.#$!==Z)this.#L();else this.#O(),this.#M();break;case"disabled":this.#N();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",x0);class V0 extends HTMLElement{#$=[];#Q=[];#J=[];#j=null;static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Z(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#_(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#j)cancelAnimationFrame(this.#j);this.#j=requestAnimationFrame(()=>{this.#j=null,this.#X(),this.#K()})}disconnectedCallback(){if(this.#j)cancelAnimationFrame(this.#j),this.#j=null;this.#Q=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#A();break;case"disabled":this.#M();break;case"min":case"max":case"fixed":this.#K();break;case"open":break}}#X(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline",$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0});let J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,q)=>{J.appendChild(this.#U(j,q,Q,{inline:!0}))}),$.appendChild(J),this.appendChild($),!this.#q)this.#Y(Q,this);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,q)=>{if(Z.appendChild(this.#U(j,q,Q)),!this.#q)Z.appendChild(this.#W(q,Q))}),this.appendChild(Z)}#U(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let K=Z?this.#J:this.#Q,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};let N=K[$];if(N){let L=this.#$[$],B=L.alpha<1?L.color+Math.round(L.alpha*255).toString(16).padStart(2,"0"):L.color;N.setAttribute("value",B)}};if(q.addEventListener("input",(X)=>{_(X),this.#O()}),q.addEventListener("change",(X)=>{_(X),this.#R()}),Z)this.#Q.push(q);else this.#J.push(q);return q}#W(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#Z)J.setAttribute("disabled","");J.appendChild(b("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#Z)return;this.#$.splice(Q,1),this.#Q=[],this.#J=[],this.#K(),this.#R()}#Y(Q,$=this){let J=this.#$.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(b("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#_)return;this.open=!0,this.#N({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#N(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#U(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#U(Q,J,$),K=this.querySelector(".palette-colors-expanded");if(K)K.appendChild(q),K.appendChild(this.#W(J,$));if(this.#$.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#z($),this.#R()}#L(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#A(){if(this.#Q.length!==this.#$.length){this.#K();return}this.#$.forEach((Q,$)=>{this.#L($)})}#M(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#_)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#z(Q)}#z(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#Z;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",V0);class r extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#J=!1;#j=null;#q=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#_(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#_==="true"}get#K(){return this.getAttribute("mode")==="tip"?"tip":"handle"}connectedCallback(){if(this.#W(),this.#M(),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.#q)this.#q.disconnect(),this.#q=null;clearTimeout(this.#j),this.removeEventListener("pointerenter",this.#H),this.removeEventListener("pointermove",this.#T),this.removeEventListener("pointerleave",this.#F),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#C)}#U=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let K=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],_=K.indexOf(q),X=Q.shiftKey?(_-1+K.length)%K.length:(_+1)%K.length;q.deselect(),K[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let K=parseInt(q.dataset.stopIndex,10);if(isNaN(K)||!this.#Z.stops[K])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#Z.stops[K];X.position=Math.max(0,Math.min(100,X.position+_)),q.setAttribute("value",`${X.position}% 50%`);let Y=q.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),q.hideColorTip(),clearTimeout(this.#j),this.#j=setTimeout(()=>{Y.removeAttribute("show"),q.showColorTip()},600);this.#k(),this.#x(),this.#b();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#I(),this.#k(),this.#x(),this.#b()};#W(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=h({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90;return}if($?.gradient)this.#Z=h({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90}catch($){}}#G(){let $=[...this.#Z.stops].sort((Z,j)=>Z.position-j.position).map((Z)=>{let j=(Z.opacity??100)/100;if(j>=1)return`${Z.color} ${Z.position}%`;let{r:q,g:K,b:_}=u(Z.color);return`rgba(${q}, ${K}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=y0(this.#Z);return`linear-gradient(${this.#Z.angle}deg ${J}, ${$})`}#Y(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=u(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#N(){let Q=this.hasAttribute("disabled"),$=this.#K==="tip"?' tip="color"':"";return this.#Z.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#Y(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#L=null;#A=!1;#M(){let Q=this.hasAttribute("disabled"),$=this.#_;if($==="picker"&&m()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
185
185
  <fig-fill-picker mode="gradient"${Z} value='${j}'${Q?" disabled":""}>
186
186
  <fig-chit background="${this.#G()}"${Q?" disabled":""}></fig-chit>
187
187
  </fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#z();return}if(this.innerHTML=`
188
188
  <fig-chit background="${this.#G()}"${Q?" disabled":""}></fig-chit>
189
- ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#W()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#R(),this.#f(),requestAnimationFrame(()=>this.#S())}#z(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#Z=p({...this.#Z,...Z.gradient}),this.#C()};Q.addEventListener("input",(J)=>{$(J),this.#x()}),Q.addEventListener("change",(J)=>{$(J),this.#b()})}#O(Q){return E1(this.#Z.stops,Q,this.#Z.interpolationSpace,this.#Z.hueInterpolation)}#R(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#K==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#H),this.addEventListener("pointermove",this.#F),this.addEventListener("pointerleave",this.#T),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#k)}#D(){if(!this.#L)return;this.#L.style.opacity="1"}#B(){if(!this.#L)return;this.#L.style.opacity="0"}#H=()=>{if(this.#J)return;this.#D()};#T=()=>{this.#B()};#F=(Q)=>{if(this.#J){this.#B();return}if(!this.#L||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#B();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#O(J);this.#L.setAttribute("color",Z),this.#D()};#P(){let Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#I(),this.#C(),this.#x(),this.#b()}#k=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#E=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#A){this.#A=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let K=Q.target.closest("fig-handle"),_=parseInt(K?.dataset.stopIndex,10);if(this.#P(),!isNaN(_))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===_)X.select();else X.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((K,_)=>K.position-_.position);let q=this.#Z.stops.findIndex((K)=>K.position===Z&&K.color===j);this.#I(),this.#C(),this.#x(),this.#b(),requestAnimationFrame(()=>{let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)_.click()})};#S(){if(!this.#Q)return;let Q=this.#Z.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#S()}#I(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){let J=this.#L;if(this.#Q.innerHTML=this.#W(),J)this.#Q.appendChild(J);this.#y(),this.#V(),requestAnimationFrame(()=>this.#S());return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#Y(j)),this.#K==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#y()}#y(){if(!this.#Q)return;let Q=this.#K==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#L)if(Q)this.#L.setAttribute("tip","add");else this.#L.removeAttribute("tip")}#V(){if(!this.#q||!this.#Q)return;this.#q.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),K=-1;for(let _=0;_<$.length;_++){if(J.has(_))continue;if($[_].position===j&&$[_].color.toUpperCase()===q){K=_;break}}if(K===-1){let _=1/0;for(let X=0;X<$.length;X++){if(J.has(X))continue;let Y=Math.abs($[X].position-j);if(Y<_)_=Y,K=X}}if(K!==-1)J.add(K),Z.dataset.stopIndex=K})}#C(){if(!this.#$)return;this.#$.setAttribute("background",this.#G())}#f(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);let q=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#A=!0,this.#I(),this.#C(),this.#x(),this.#B();let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==_)X.deselect()}),_.select(),_.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#C(),this.#x()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,K=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/i.SHIFT_SNAP)*i.SHIFT_SNAP;else{let X=K>0?5/K*100:0;for(let Y=0;Y<this.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-q)<=X){q=this.#Z.stops[Y].position;break}}}if(this.#Z.stops[J].position=q,q!==j)$.style.left=`${q/100*K-$.offsetWidth/2}px`;let _=$.closest("fig-tooltip");if(_){if(_.text=`${Math.round(q)}%`,!_.hasAttribute("show"))_.setAttribute("show","true"),$.hideColorTip()}this.#C(),this.#x()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#C(),this.#b()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),K=this.#Q.getBoundingClientRect().width,_=K>0?5/K*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-q)<=_){q=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=q,$.style.left=`${q/100*K-$.offsetWidth/2}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#C(),this.#b(),requestAnimationFrame(()=>{this.#J=!1})}),this.#q=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#C(),this.#x()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:f0(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#N(),this.#C(),this.#I();break;case"disabled":this.#s();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#y();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",i);class $0 extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",s()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",$0);class w0 extends $0{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",w0);class b0 extends $0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",b0);class v0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}getOffset(){return parseInt(this.getAttribute("offset")??this._defaultOffset)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");let Q=this.getAttribute("open")==="true"||this.getAttribute("open")==="";if(this.hasAttribute("open")&&!Q)this.removeAttribute("open");if(!Q)this.close();requestAnimationFrame(()=>{if(this.addCloseListeners(),this.applyPosition(),Q)this.showToast()})}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${this.getOffset()}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>{this.hideToast()},Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let $=(getComputedStyle(document.documentElement).colorScheme||"").includes("dark");this.style.colorScheme=$?"light":"dark"}showToast(){this._resolveAutoTheme(),this.show(),this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){this.clearAutoClose(),this.close(),this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme")if(J==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme")}}j0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#$=!1;#Q=null;#J=null;#j=null;#q=null;#Z=!1;#_=this.#Y.bind(this);#X=this.#W.bind(this);#K=this.#L.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#q=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#q!==null,this.#q)this.#q.remove();if(this.#U(),this.#N(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#G()}#U(){let Q=this.#z(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#$?"":`<fig-dropdown type="dropdown"${j}>${Q.map((K)=>`<option>${K.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
189
+ ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#N()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#R(),this.#f(),requestAnimationFrame(()=>this.#S())}#z(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#Z=h({...this.#Z,...Z.gradient}),this.#k()};Q.addEventListener("input",(J)=>{$(J),this.#x()}),Q.addEventListener("change",(J)=>{$(J),this.#b()})}#O(Q){return E1(this.#Z.stops,Q,this.#Z.interpolationSpace,this.#Z.hueInterpolation)}#R(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#K==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#H),this.addEventListener("pointermove",this.#T),this.addEventListener("pointerleave",this.#F),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#C)}#D(){if(!this.#L)return;this.#L.style.opacity="1"}#B(){if(!this.#L)return;this.#L.style.opacity="0"}#H=()=>{if(this.#J)return;this.#D()};#F=()=>{this.#B()};#T=(Q)=>{if(this.#J){this.#B();return}if(!this.#L||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#B();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#O(J);this.#L.setAttribute("color",Z),this.#D()};#P(){let Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#I(),this.#k(),this.#x(),this.#b()}#C=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#E=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#A){this.#A=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let K=Q.target.closest("fig-handle"),_=parseInt(K?.dataset.stopIndex,10);if(this.#P(),!isNaN(_))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===_)X.select();else X.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((K,_)=>K.position-_.position);let q=this.#Z.stops.findIndex((K)=>K.position===Z&&K.color===j);this.#I(),this.#k(),this.#x(),this.#b(),requestAnimationFrame(()=>{let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)_.click()})};#S(){if(!this.#Q)return;let Q=this.#Z.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#S()}#I(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){let J=this.#L;if(this.#Q.innerHTML=this.#N(),J)this.#Q.appendChild(J);this.#y(),this.#V(),requestAnimationFrame(()=>this.#S());return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#Y(j)),this.#K==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#y()}#y(){if(!this.#Q)return;let Q=this.#K==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#L)if(Q)this.#L.setAttribute("tip","add");else this.#L.removeAttribute("tip")}#V(){if(!this.#q||!this.#Q)return;this.#q.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),K=-1;for(let _=0;_<$.length;_++){if(J.has(_))continue;if($[_].position===j&&$[_].color.toUpperCase()===q){K=_;break}}if(K===-1){let _=1/0;for(let X=0;X<$.length;X++){if(J.has(X))continue;let Y=Math.abs($[X].position-j);if(Y<_)_=Y,K=X}}if(K!==-1)J.add(K),Z.dataset.stopIndex=K})}#k(){if(!this.#$)return;this.#$.setAttribute("background",this.#G())}#f(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);let q=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#A=!0,this.#I(),this.#k(),this.#x(),this.#B();let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==_)X.deselect()}),_.select(),_.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#k(),this.#x()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,K=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let X=K>0?5/K*100:0;for(let Y=0;Y<this.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-q)<=X){q=this.#Z.stops[Y].position;break}}}if(this.#Z.stops[J].position=q,q!==j)$.style.left=`${q/100*K}px`;let _=$.closest("fig-tooltip");if(_){if(_.text=`${Math.round(q)}%`,!_.hasAttribute("show"))_.setAttribute("show","true"),$.hideColorTip()}this.#k(),this.#x()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#k(),this.#b()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),K=this.#Q.getBoundingClientRect().width,_=K>0?5/K*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-q)<=_){q=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=q,$.style.left=`${q/100*K}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#k(),this.#b(),requestAnimationFrame(()=>{this.#J=!1})}),this.#q=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#k(),this.#x()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:f0(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#W(),this.#k(),this.#I();break;case"disabled":this.#d();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#y();break}}#d(){let Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class a extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",c()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",a);class w0 extends a{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",w0);class b0 extends a{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",b0);class v0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}getOffset(){return parseInt(this.getAttribute("offset")??this._defaultOffset)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");let Q=this.getAttribute("open")==="true"||this.getAttribute("open")==="";if(this.hasAttribute("open")&&!Q)this.removeAttribute("open");if(!Q)this.close();requestAnimationFrame(()=>{if(this.addCloseListeners(),this.applyPosition(),Q)this.showToast()})}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${this.getOffset()}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>{this.hideToast()},Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let $=(getComputedStyle(document.documentElement).colorScheme||"").includes("dark");this.style.colorScheme=$?"light":"dark"}showToast(){this._resolveAutoTheme(),this.show(),this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){this.clearAutoClose(),this.close(),this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme")if(J==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme")}}$0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#$=!1;#Q=null;#J=null;#j=null;#q=null;#Z=!1;#_=this.#Y.bind(this);#X=this.#N.bind(this);#K=this.#L.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#q=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#q!==null,this.#q)this.#q.remove();if(this.#U(),this.#W(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#G()}#U(){let Q=this.#z(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#$?"":`<fig-dropdown type="dropdown"${j}>${Q.map((K)=>`<option>${K.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
190
190
  <fig-input-text placeholder="${$}" value="${J}"></fig-input-text>
191
191
  <fig-button type="select" variant="input" icon>
192
192
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -194,7 +194,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
194
194
  </svg>
195
195
  ${q}
196
196
  </fig-button>
197
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#j=this.querySelector("fig-button"),this.#$&&this.#q&&this.#j){if(!this.#q.hasAttribute("type"))this.#q.setAttribute("type","dropdown");if(Z)this.#q.setAttribute("experimental",Z);this.#j.append(this.#q)}this.#J=this.querySelector("fig-dropdown")}#N(){this.#J?.addEventListener("input",this.#_),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#K)}#G(){this.#J?.removeEventListener("input",this.#_),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#K)}#Y(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#Q)this.#Q.setAttribute("value",$);this.#A(),this.#M()}#W(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#A()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#M()}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#M(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#z(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#$){let Z=this.#z();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");break;case"value":if(!this.#Z&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#O(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#$)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",g0);class K0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#K.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#j()}#j(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#q(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=q0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#q(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#Z(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="<div></div>",this.input=null}else if(this.#$==="color"&&this.input){let q=this.#Z(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#J){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#j()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",K0);class h0 extends K0{}customElements.define("fig-swatch",h0);class J0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;#_=this.#y.bind(this);#X=this.#w.bind(this);#K=this.#C.bind(this);#U=this.#f.bind(this);#N=null;#G=null;#Y=null;#W=null;#L=null;#A=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#Z}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#D(),this.#H(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#S()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#_),this.#O(),this.#E(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#K),this.#Q.removeEventListener("ended",this.#U)}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#D(){let Q=this.#R();if(Q){if(this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}this.#Q=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.prepend(J),this.#Q=J,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#K),this.#Q.addEventListener("ended",this.#U);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.prepend(J),this.#Q=J}}#B(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#H(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#Q.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#B("autoplay",!1),this.#Q.loop=this.#B("loop",!1),this.#Q.muted=this.#B("muted",!1),this.#Q.playsInline=!0,this.#T()}get mediaEl(){return this.#Q}#T(){if(this.mediaKind!=="video"){this.#E();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#N!==Q)this.#E(),this.#N=Q;this.#P();return}if(this.#B("controls",!1))this.#F();else this.#E()}#F(){if(this.#N&&this.#N.isConnected){this.#P();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),Q.setAttribute("overlay",""),this.append(Q),this.#N=Q,this.#P()}#P(){if(!this.#N||!this.#Q)return;if(this.#G===this.#Q&&this.#Y===this.#N)return;this.#k();let Q=this.#N,$=this.#Q;this.#G=$,this.#Y=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let _=$.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})},q=()=>$.pause?.(),K=(_)=>{let X=Number(_?.detail?.time);if(!Number.isFinite(X))return;J=X;try{$.currentTime=X}catch{}};this.#W=Z,this.#L=j,this.#A=q,this.#M=K,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",K),Z()}#k(){let Q=this.#G,$=this.#Y;if(Q&&this.#W)Q.removeEventListener("play",this.#W),Q.removeEventListener("pause",this.#W),Q.removeEventListener("ended",this.#W),Q.removeEventListener("timeupdate",this.#W),Q.removeEventListener("loadedmetadata",this.#W),Q.removeEventListener("durationchange",this.#W),Q.removeEventListener("seeked",this.#W);if($){if(this.#L)$.removeEventListener("play",this.#L);if(this.#A)$.removeEventListener("pause",this.#A);if(this.#M)$.removeEventListener("seek",this.#M)}this.#G=null,this.#Y=null,this.#W=null,this.#L=null,this.#A=null,this.#M=null}#E(){if(this.#k(),!this.#N)return;if(this.#N.hasAttribute("data-generated"))this.#N.remove();this.#N=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#S(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#Z?.name)Q.setAttribute("filename",this.#Z.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#_),this.append(Q),this.#J=Q}#I(){if(this.#J)this.#J.removeEventListener("change",this.#_),this.#J.remove(),this.#J=null}#y(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#Z=null,this.#q=null,J)this.src="";if(this.#H(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#Z=$,this.#j=URL.createObjectURL($),this.#q=this.#j,this.#H(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#V(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#V("play")}#C(){this.#V("pause")}#f(){this.#V("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#j);if(this.#$=Z,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#Z=null;if(this.#H(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#Z?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#Z.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#D(),this.#H(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#Q&&this.#Q.tagName==="IMG")this.#Q.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#S();else if(!Z)this.#I()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#H()}}customElements.define("fig-media",J0);class m0 extends J0{get mediaKind(){return"image"}}customElements.define("fig-image",m0);class c0 extends J0{get mediaKind(){return"video"}}customElements.define("fig-video",c0);class p0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=!1;#Z=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#K(),this.#U()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#Z)return;if(Q==="playing")this.#K();if(Q==="duration"||Q==="time")this.#U()}#_(){if(this.#Z)return;this.#Z=!0;let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=w("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(K)=>{K.preventDefault(),K.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","0.1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full","");let j=document.createElement("label");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(K)=>{let _=K.currentTarget,X=Number(_?.value);if(!Number.isFinite(X))return;this.#q=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#q=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#J=Z,this.#j=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#U(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let $=this.time;if(!this.#q)this.#J.setAttribute("value",String($));if(this.#j)this.#j.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",p0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;get files(){return this.#Z}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#Z&&this.#Z.length>0){if(this.#Z.length===1)return this.#Z[0].name;return`${this.#Z.length} files`}return this.#_}connectedCallback(){this.#W(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#G),this.addEventListener("drop",this.#Y)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#J?.removeEventListener("click",this.#U),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#G),this.removeEventListener("drop",this.#Y)}attributeChangedCallback(Q,$,J){if($===J)return;this.#W()}clear(){if(this.#Z=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#W(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#Z,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#Z=this.#$.files,this.removeAttribute("url"),this.#W(),this.#X()};#U=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#q)this.#q.dataset.prevText=this.#q.textContent,this.#q.textContent="Drop file"}};#G=()=>{if(this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText};#Y=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let K="."+q.name.split(".").pop().toLowerCase(),_=q.type.toLowerCase();return j.some((X)=>X===K||X===_||X.endsWith("/*")&&_.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#Z=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#W(),this.#X()};#W(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#Z&&this.#Z.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let K=Q?`Accepts ${Q.split(",").map((G)=>G.trim()).join(", ")}`:"";if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.className="fig-input-file-filename",J)this.#q.setAttribute("disabled","");let _=document.createElement("fig-truncate");_.setAttribute("position","middle"),_.setAttribute("tooltip","");let X=this.value,Y=X.lastIndexOf(".");if(Y>0)_.setAttribute("tail",X.slice(Y));if(_.textContent=X,this.#q.appendChild(_),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K),this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");this.#J.replaceChildren(w("minus")),this.#J.addEventListener("click",this.#U),N.appendChild(this.#J),this.appendChild(N)}else{let K=Q?`Accepts ${Q.split(",").map((_)=>_.trim()).join(", ")}`:"";if(K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K);if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.textContent=$,J)this.#q.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),this.#j)this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q)}}}customElements.define("fig-input-file",u0);class V extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#j="bezier";#q=2;#Z=null;#_=null;#X=null;#K=null;#U=null;#N=null;#G=null;#Y=null;#W=null;#L=null;#A=null;#M=null;#z=null;#O=0.8;#R=200;#D=200;#B=null;#H=null;#T=null;#F=5;#P=2;#k=10;#E=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#q=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#M=this.#y(),this.#f(),this.#t()}disconnectedCallback(){if(this.#Z=null,this.#T)this.#T.disconnect(),this.#T=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(x(this,"--aspect-ratio",J),this.#_)this.#h(),this.#g();return}if(Q==="edit"){if(this.isConnected)this.#f();return}if(Q==="value"&&J){let Z=this.#j;if(this.#I(J),this.#M=this.#y(),Z!==this.#j&&this.#C())this.#f();else{if(this.#_)this.#g();this.#c(),this.#v()}}if(Q==="precision")this.#q=parseInt(J||"2")}get value(){if(this.#j==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#q;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#j==="spring"){let $=this.#V(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#q;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#I(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#j="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#y(){if(this.#j==="bezier"){for(let $ of V.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of V.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#V(){let{stiffness:Q,damping:$,mass:J}=this.#J,Z=0.004,j=5,q=[],K=0,_=0;for(let X=0;X<=5;X+=0.004){let Y=-Q*(K-1)-$*_;if(_+=Y/J*0.004,K+=_*0.004,q.push({t:X,value:K}),X>0.1&&Math.abs(K-1)<0.0005&&Math.abs(_)<0.0005)break}return q}static#w(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,K=5,_=[],X=0,Y=0;for(let L=0;L<=5;L+=0.004){let U=-J*(X-1)-Z*Y;if(Y+=U/j*0.004,X+=Y*0.004,_.push({t:L,value:X}),L>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}let N=_[_.length-1].t||1,G=1;for(let L of _)if(L.value>G)G=L.value;let B=0;for(let L of _)if(L.value<B)B=L.value;let H=Math.max(G-B,1),A=6,O=$-A*2,D=Math.max(1,Math.floor(_.length/30)),R="";for(let L=0;L<_.length;L+=D){let U=A+_[L].t/N*O,M=A+(1-(_[L].value-B)/H)*O;R+=(L===0?"M":"L")+U.toFixed(1)+","+M.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let K=(j-12)/2,_=48,X=[],Y=(U,M,T,E,S)=>{let f=1-S;return f*f*f*U+3*f*f*S*M+3*f*S*S*T+S*S*S*E};for(let U=0;U<=48;U++){let M=U/48;X.push({x:Y(0,Q,J,1,M),y:Y(0,$,Z,1,M)})}let N=1/0,G=-1/0,B=1/0,H=-1/0;for(let U of X){if(U.x<N)N=U.x;if(U.x>G)G=U.x;if(U.y<B)B=U.y;if(U.y>H)H=U.y}let A=Math.max(G-N,0.000001),O=Math.max(H-B,0.000001),D=(U)=>K+(U-N)/A*12,R=(U)=>K+(1-(U-B)/O)*12,L="";for(let U=0;U<X.length;U++){let M=D(X[U].x),T=R(X[U].y);L+=`${U===0?"M":"L"}${M.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${L}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#C(){return this.getAttribute("edit")!=="false"}#f(){if(this.classList.toggle("spring-mode",this.#j==="spring"),this.classList.toggle("bezier-mode",this.#j!=="spring"),this.#J0(),this.innerHTML=this.#s(),this.#d(),this.#_)this.#l(),this.#h(),this.#g();this.#v(),this.#Y0()}static#x(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",$=void 0;for(let J of V.PRESETS){if(!this.#C()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#J;Z=V.#w(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=V.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#s(){let $=this.#b();if(!this.#C())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${V.#x(this.value)}" full></fig-input-text>`;if(this.#j==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
197
+ </div>`,this.#Q=this.querySelector("fig-input-text"),this.#j=this.querySelector("fig-button"),this.#$&&this.#q&&this.#j){if(!this.#q.hasAttribute("type"))this.#q.setAttribute("type","dropdown");if(Z)this.#q.setAttribute("experimental",Z);this.#j.append(this.#q)}this.#J=this.querySelector("fig-dropdown")}#W(){this.#J?.addEventListener("input",this.#_),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#K)}#G(){this.#J?.removeEventListener("input",this.#_),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#K)}#Y(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#Q)this.#Q.setAttribute("value",$);this.#A(),this.#M()}#N(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#A()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#M()}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#M(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#z(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#$){let Z=this.#z();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");break;case"value":if(!this.#Z&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#O(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#$)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",g0);class Z0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#K.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#j()}#j(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#q(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=J0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#q(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#Z(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="<div></div>",this.input=null}else if(this.#$==="color"&&this.input){let q=this.#Z(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#J){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#j()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",Z0);class h0 extends Z0{}customElements.define("fig-swatch",h0);class n extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;#_=this.#y.bind(this);#X=this.#w.bind(this);#K=this.#k.bind(this);#U=this.#f.bind(this);#W=null;#G=null;#Y=null;#N=null;#L=null;#A=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#Z}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#D(),this.#H(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#S()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#_),this.#O(),this.#E(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#K),this.#Q.removeEventListener("ended",this.#U)}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#D(){let Q=this.#R();if(Q){if(this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}this.#Q=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.prepend(J),this.#Q=J,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#K),this.#Q.addEventListener("ended",this.#U);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.prepend(J),this.#Q=J}}#B(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#H(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#Q.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#B("autoplay",!1),this.#Q.loop=this.#B("loop",!1),this.#Q.muted=this.#B("muted",!1),this.#Q.playsInline=!0,this.#F()}get mediaEl(){return this.#Q}#F(){if(this.mediaKind!=="video"){this.#E();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#E(),this.#W=Q;this.#P();return}if(this.#B("controls",!1))this.#T();else this.#E()}#T(){if(this.#W&&this.#W.isConnected){this.#P();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),Q.setAttribute("overlay",""),this.append(Q),this.#W=Q,this.#P()}#P(){if(!this.#W||!this.#Q)return;if(this.#G===this.#Q&&this.#Y===this.#W)return;this.#C();let Q=this.#W,$=this.#Q;this.#G=$,this.#Y=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let _=$.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})},q=()=>$.pause?.(),K=(_)=>{let X=Number(_?.detail?.time);if(!Number.isFinite(X))return;J=X;try{$.currentTime=X}catch{}};this.#N=Z,this.#L=j,this.#A=q,this.#M=K,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",K),Z()}#C(){let Q=this.#G,$=this.#Y;if(Q&&this.#N)Q.removeEventListener("play",this.#N),Q.removeEventListener("pause",this.#N),Q.removeEventListener("ended",this.#N),Q.removeEventListener("timeupdate",this.#N),Q.removeEventListener("loadedmetadata",this.#N),Q.removeEventListener("durationchange",this.#N),Q.removeEventListener("seeked",this.#N);if($){if(this.#L)$.removeEventListener("play",this.#L);if(this.#A)$.removeEventListener("pause",this.#A);if(this.#M)$.removeEventListener("seek",this.#M)}this.#G=null,this.#Y=null,this.#N=null,this.#L=null,this.#A=null,this.#M=null}#E(){if(this.#C(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#S(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#Z?.name)Q.setAttribute("filename",this.#Z.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#_),this.append(Q),this.#J=Q}#I(){if(this.#J)this.#J.removeEventListener("change",this.#_),this.#J.remove(),this.#J=null}#y(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#Z=null,this.#q=null,J)this.src="";if(this.#H(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#Z=$,this.#j=URL.createObjectURL($),this.#q=this.#j,this.#H(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#V(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#V("play")}#k(){this.#V("pause")}#f(){this.#V("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#j);if(this.#$=Z,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#Z=null;if(this.#H(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#Z?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#Z.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#D(),this.#H(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#Q&&this.#Q.tagName==="IMG")this.#Q.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#S();else if(!Z)this.#I()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#H()}}customElements.define("fig-media",n);class m0 extends n{get mediaKind(){return"image"}}customElements.define("fig-image",m0);class c0 extends n{get mediaKind(){return"video"}}customElements.define("fig-video",c0);class p0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=!1;#Z=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#K(),this.#U()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#Z)return;if(Q==="playing")this.#K();if(Q==="duration"||Q==="time")this.#U()}#_(){if(this.#Z)return;this.#Z=!0;let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=b("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(K)=>{K.preventDefault(),K.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","0.1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full","");let j=document.createElement("label");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(K)=>{let _=K.currentTarget,X=Number(_?.value);if(!Number.isFinite(X))return;this.#q=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#q=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#J=Z,this.#j=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#U(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let $=this.time;if(!this.#q)this.#J.setAttribute("value",String($));if(this.#j)this.#j.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",p0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;get files(){return this.#Z}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#Z&&this.#Z.length>0){if(this.#Z.length===1)return this.#Z[0].name;return`${this.#Z.length} files`}return this.#_}connectedCallback(){this.#N(),this.addEventListener("dragover",this.#W),this.addEventListener("dragleave",this.#G),this.addEventListener("drop",this.#Y)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#J?.removeEventListener("click",this.#U),this.removeEventListener("dragover",this.#W),this.removeEventListener("dragleave",this.#G),this.removeEventListener("drop",this.#Y)}attributeChangedCallback(Q,$,J){if($===J)return;this.#N()}clear(){if(this.#Z=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#N(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#Z,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#Z=this.#$.files,this.removeAttribute("url"),this.#N(),this.#X()};#U=(Q)=>{Q.stopPropagation(),this.clear()};#W=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#q)this.#q.dataset.prevText=this.#q.textContent,this.#q.textContent="Drop file"}};#G=()=>{if(this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText};#Y=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let K="."+q.name.split(".").pop().toLowerCase(),_=q.type.toLowerCase();return j.some((X)=>X===K||X===_||X.endsWith("/*")&&_.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#Z=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#N(),this.#X()};#N(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#Z&&this.#Z.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let K=Q?`Accepts ${Q.split(",").map((L)=>L.trim()).join(", ")}`:"";if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.className="fig-input-file-filename",J)this.#q.setAttribute("disabled","");let _=document.createElement("fig-truncate");_.setAttribute("position","middle"),_.setAttribute("tooltip","");let X=this.value,Y=X.lastIndexOf(".");if(Y>0)_.setAttribute("tail",X.slice(Y));if(_.textContent=X,this.#q.appendChild(_),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K),this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");this.#J.replaceChildren(b("minus")),this.#J.addEventListener("click",this.#U),N.appendChild(this.#J),this.appendChild(N)}else{let K=Q?`Accepts ${Q.split(",").map((_)=>_.trim()).join(", ")}`:"";if(K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K);if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.textContent=$,J)this.#q.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),this.#j)this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q)}}}customElements.define("fig-input-file",u0);class w extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#j="bezier";#q=2;#Z=null;#_=null;#X=null;#K=null;#U=null;#W=null;#G=null;#Y=null;#N=null;#L=null;#A=null;#M=null;#z=null;#O=0.8;#R=200;#D=200;#B=null;#H=null;#F=null;#T=5;#P=2;#C=10;#E=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#q=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#M=this.#y(),this.#f(),this.#t()}disconnectedCallback(){if(this.#Z=null,this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(x(this,"--aspect-ratio",J),this.#_)this.#c(),this.#g();return}if(Q==="edit"){if(this.isConnected)this.#f();return}if(Q==="value"&&J){let Z=this.#j;if(this.#I(J),this.#M=this.#y(),Z!==this.#j&&this.#k())this.#f();else{if(this.#_)this.#g();this.#p(),this.#v()}}if(Q==="precision")this.#q=parseInt(J||"2")}get value(){if(this.#j==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#q;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#j==="spring"){let $=this.#V(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#q;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#I(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#j="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#y(){if(this.#j==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of w.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#V(){let{stiffness:Q,damping:$,mass:J}=this.#J,Z=0.004,j=5,q=[],K=0,_=0;for(let X=0;X<=5;X+=0.004){let Y=-Q*(K-1)-$*_;if(_+=Y/J*0.004,K+=_*0.004,q.push({t:X,value:K}),X>0.1&&Math.abs(K-1)<0.0005&&Math.abs(_)<0.0005)break}return q}static#w(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,K=5,_=[],X=0,Y=0;for(let U=0;U<=5;U+=0.004){let A=-J*(X-1)-Z*Y;if(Y+=A/j*0.004,X+=Y*0.004,_.push({t:U,value:X}),U>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}let N=_[_.length-1].t||1,L=1;for(let U of _)if(U.value>L)L=U.value;let B=0;for(let U of _)if(U.value<B)B=U.value;let H=Math.max(L-B,1),M=6,G=$-M*2,z=Math.max(1,Math.floor(_.length/30)),R="";for(let U=0;U<_.length;U+=z){let A=M+_[U].t/N*G,D=M+(1-(_[U].value-B)/H)*G;R+=(U===0?"M":"L")+A.toFixed(1)+","+D.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let K=(j-12)/2,_=48,X=[],Y=(A,D,T,E,S)=>{let I=1-S;return I*I*I*A+3*I*I*S*D+3*I*S*S*T+S*S*S*E};for(let A=0;A<=48;A++){let D=A/48;X.push({x:Y(0,Q,J,1,D),y:Y(0,$,Z,1,D)})}let N=1/0,L=-1/0,B=1/0,H=-1/0;for(let A of X){if(A.x<N)N=A.x;if(A.x>L)L=A.x;if(A.y<B)B=A.y;if(A.y>H)H=A.y}let M=Math.max(L-N,0.000001),G=Math.max(H-B,0.000001),z=(A)=>K+(A-N)/M*12,R=(A)=>K+(1-(A-B)/G)*12,U="";for(let A=0;A<X.length;A++){let D=z(X[A].x),T=R(X[A].y);U+=`${A===0?"M":"L"}${D.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${U}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#k(){return this.getAttribute("edit")!=="false"}#f(){if(this.classList.toggle("spring-mode",this.#j==="spring"),this.classList.toggle("bezier-mode",this.#j!=="spring"),this.#J0(),this.innerHTML=this.#d(),this.#Z0(),this.#_)this.#r(),this.#c(),this.#g();this.#v(),this.#Y0()}static#x(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",$=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#J;Z=w.#w(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=w.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#d(){let $=this.#b();if(!this.#k())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#x(this.value)}" full></fig-input-text>`;if(this.#j==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
198
198
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
199
199
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
200
200
  <line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
@@ -211,7 +211,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
211
211
  <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#P}"/>
212
212
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
213
213
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
214
- </svg></div>${J}`}#i(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#J0(){this.#P=this.#i("--easing-bezier-endpoint-radius",this.#P),this.#S=this.#i("--easing-duration-bar-radius",this.#S)}#d(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#U=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#G=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector('[data-endpoint="start"]'),this.#W=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#A=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#B=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#l(){let Q=this.#N?.querySelector("fig-handle"),$=this.#G?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#F*2,Z=Q.offsetHeight||this.#F*2;this.#F=Math.max(J,Z)/2,this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#k,Z=$.offsetHeight||this.#E;if(this.#j==="spring")this.#k=J,this.#E=Z;this.#G.setAttribute("width",J),this.#G.setAttribute("height",Z)}}#t(){if(this.#T||!window.ResizeObserver)return;this.#T=new ResizeObserver(()=>{if(this.#h())this.#g()}),this.#T.observe(this)}#h(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#R||J!==this.#D;return this.#R=$,this.#D=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#p(Q,$){return{x:Q*this.#R,y:(1-$)*this.#D}}#a(Q,$){return{x:Q/this.#R,y:1-$/this.#D}}#r={minVal:0,maxVal:1.2,totalTime:1};#m(Q,$){let Z=this.#D-40,{minVal:j,maxVal:q}=this.#r,K=q-j||1;return{x:Q*this.#R,y:20+(1-($-j)/K)*Z}}#g(){if(this.#h(),this.#j==="spring")this.#e();else this.#n()}#o(){this.#K?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===1),this.#U?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===2)}#n(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#D),this.#H.setAttribute("x2",this.#R),this.#H.setAttribute("y2","0");let Q=this.#p(0,0),$=this.#p(this.#$.x,this.#$.y),J=this.#p(this.#Q.x,this.#Q.y),Z=this.#p(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#U.setAttribute("x1",Z.x),this.#U.setAttribute("y1",Z.y),this.#U.setAttribute("x2",J.x),this.#U.setAttribute("y2",J.y);let j=this.#F;if(this.#N.setAttribute("x",$.x-j),this.#N.setAttribute("y",$.y-j),this.#G.setAttribute("x",J.x-j),this.#G.setAttribute("y",J.y-j),this.#Y)this.#Y.setAttribute("cx",Q.x),this.#Y.setAttribute("cy",Q.y);if(this.#W)this.#W.setAttribute("cx",Z.x),this.#W.setAttribute("cy",Z.y)}#e(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);let Q=this.#V();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let O of Q){if(O.value<J)J=O.value;if(O.value>Z)Z=O.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#r={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let K=Math.max(0.05,Math.min(0.95,this.#O)),_="";for(let O=0;O<Q.length;O++){let D=Q[O].t/$*K,R=this.#m(D,Q[O].value);_+=(O===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let X=this.#m(K,1),Y=this.#m(1,1);if(_+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${Y.x.toFixed(1)},${Y.y.toFixed(1)}`,this.#X.setAttribute("d",_),this.#z){let O=this.#m(0,1),D=this.#m(1,1);this.#z.setAttribute("x1",O.x),this.#z.setAttribute("y1",O.y),this.#z.setAttribute("x2",D.x),this.#z.setAttribute("y2",D.y)}let N=this.#Q0(Q),G=N.t/$*K,B=this.#m(G,N.value),H=this.#F;this.#N.setAttribute("x",B.x-H),this.#N.setAttribute("y",B.y-H);let A=this.#m(K,1);this.#G.setAttribute("x",A.x-this.#k/2),this.#G.setAttribute("y",A.y-this.#E/2)}#Q0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#c(){if(!this.#L)return;this.#L.value=this.#M,this.#X0()}#v(){if(!this.#A)return;this.#A.setAttribute("value",this.value)}#_0(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#q0(Q,$){let J=this.#_0(Q);if(!J){if($==="change")this.#v();return}let Z=this.#j;if(this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#y(),Z!==this.#j)this.#f();else if(this.#g(),this.#c(),$==="change")this.#v();this.#u($)}#$0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#X0(){if(!this.#L)return;if(!this.#C())return;let Q=V.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=V.#w(this.#J);this.#$0(this.#L,"Custom bezier",Q),this.#$0(this.#L,"Custom spring",$),this.#$0(this.#L.select,"Custom bezier",Q),this.#$0(this.#L.select,"Custom spring",$)}#u(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#j,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#Y0(){if(this.#_&&this.#j==="bezier"){this.#N.addEventListener("pointerdown",($)=>this.#Z0($,1)),this.#G.addEventListener("pointerdown",($)=>this.#Z0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Z0($,this.#N0($))})}else if(this.#_){this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#j0($,"bounce")}),this.#G.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#j0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#j0($,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let $=Q.detail,J=V.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#j!=="bezier")this.#j="bezier",this.#f();else if(this.#_)this.#g(),this.#v()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#M=$,this.#j!=="spring")this.#j="spring",this.#f();else if(this.#_)this.#g(),this.#v()}this.#u("input"),this.#u("change")});if(this.#A)this.#A.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#q0($,"input")}),this.#A.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#q0($,"change")})}#K0(Q){let $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#N0(Q){return this.#K0(Q).x<=this.#R/2?1:2}#Z0(Q,$){Q.preventDefault(),this.#Z=$,this.#o();let J=(j)=>{if(!this.#Z)return;let q=this.#K0(j),K=this.#a(q.x,q.y);if(K.x=Math.round(K.x*100)/100,K.y=Math.round(K.y*100)/100,K.x=Math.max(0,Math.min(1,K.x)),this.#Z===1)this.#$.x=K.x,this.#$.y=K.y;else this.#Q.x=K.x,this.#Q.y=K.y;this.#g(),this.#M=this.#y(),this.#c(),this.#v(),this.#u("input")},Z=()=>{this.#Z=null,this.#o(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#u("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#j0(Q,$){Q.preventDefault(),this.#Z=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#O,q=Q.clientY,K=Q.clientX,_=(Y)=>{if(!this.#Z)return;if($==="bounce"){let N=Y.clientY-q;this.#J.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=Y.clientX-K;this.#O=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#g(),this.#M=this.#y(),this.#c(),this.#v(),this.#u("input")},X=()=>{this.#Z=null,document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",X),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",V);class s0 extends HTMLElement{#$=0;#Q=0;#J=0;#j=1;#q=!1;#Z=!1;#_=null;#X=null;#K=null;#U=null;#N=[];#G={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"1"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),x(this,"--perspective",this.getAttribute("perspective")),x(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#Y(this.getAttribute("transform-origin")),this.#A(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#M(Q);this.#z(),this.#L(this.getAttribute("selected")),this.#W()}disconnectedCallback(){if(this.#q=!1,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#U)}#Y(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#W(){if(!this.#X)return;this.#X.style.cursor=this.#T?"":"default"}#L(Q){if(!this.#_)return;let $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#A(Q){if(!Q||!Q.trim()){this.#N=[];return}let $=["rotateX","rotateY","rotateZ"];this.#N=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="perspective"){x(this,"--perspective",J);return}if(Q==="perspective-origin"){x(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#Y(J);return}if(Q==="selected"){this.#L(J);return}if(Q==="drag"){this.#W();return}if(Q==="fields"){if(this.#A(J),this.#_)this.#z();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#q)return;this.#M(J),this.#R(),this.#O()}if(Q==="precision")this.#j=parseInt(J||"1")}get value(){let Q=this.#j;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#M(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#z(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#N.map((Z)=>`<fig-input-number
214
+ </svg></div>${J}`}#l(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#J0(){this.#P=this.#l("--easing-bezier-endpoint-radius",this.#P),this.#S=this.#l("--easing-duration-bar-radius",this.#S)}#Z0(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#U=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#G=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector('[data-endpoint="start"]'),this.#N=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#A=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#B=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#r(){let Q=this.#W?.querySelector("fig-handle"),$=this.#G?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#T*2,Z=Q.offsetHeight||this.#T*2;this.#T=Math.max(J,Z)/2,this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#C,Z=$.offsetHeight||this.#E;if(this.#j==="spring")this.#C=J,this.#E=Z;this.#G.setAttribute("width",J),this.#G.setAttribute("height",Z)}}#t(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#c())this.#g()}),this.#F.observe(this)}#c(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#R||J!==this.#D;return this.#R=$,this.#D=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#h(Q,$){return{x:Q*this.#R,y:(1-$)*this.#D}}#a(Q,$){return{x:Q/this.#R,y:1-$/this.#D}}#o={minVal:0,maxVal:1.2,totalTime:1};#m(Q,$){let Z=this.#D-40,{minVal:j,maxVal:q}=this.#o,K=q-j||1;return{x:Q*this.#R,y:20+(1-($-j)/K)*Z}}#g(){if(this.#c(),this.#j==="spring")this.#e();else this.#n()}#i(){this.#K?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===1),this.#U?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===2)}#n(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#D),this.#H.setAttribute("x2",this.#R),this.#H.setAttribute("y2","0");let Q=this.#h(0,0),$=this.#h(this.#$.x,this.#$.y),J=this.#h(this.#Q.x,this.#Q.y),Z=this.#h(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#U.setAttribute("x1",Z.x),this.#U.setAttribute("y1",Z.y),this.#U.setAttribute("x2",J.x),this.#U.setAttribute("y2",J.y);let j=this.#T;if(this.#W.setAttribute("x",$.x-j),this.#W.setAttribute("y",$.y-j),this.#G.setAttribute("x",J.x-j),this.#G.setAttribute("y",J.y-j),this.#Y)this.#Y.setAttribute("cx",Q.x),this.#Y.setAttribute("cy",Q.y);if(this.#N)this.#N.setAttribute("cx",Z.x),this.#N.setAttribute("cy",Z.y)}#e(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);let Q=this.#V();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let G of Q){if(G.value<J)J=G.value;if(G.value>Z)Z=G.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let K=Math.max(0.05,Math.min(0.95,this.#O)),_="";for(let G=0;G<Q.length;G++){let z=Q[G].t/$*K,R=this.#m(z,Q[G].value);_+=(G===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let X=this.#m(K,1),Y=this.#m(1,1);if(_+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${Y.x.toFixed(1)},${Y.y.toFixed(1)}`,this.#X.setAttribute("d",_),this.#z){let G=this.#m(0,1),z=this.#m(1,1);this.#z.setAttribute("x1",G.x),this.#z.setAttribute("y1",G.y),this.#z.setAttribute("x2",z.x),this.#z.setAttribute("y2",z.y)}let N=this.#Q0(Q),L=N.t/$*K,B=this.#m(L,N.value),H=this.#T;this.#W.setAttribute("x",B.x-H),this.#W.setAttribute("y",B.y-H);let M=this.#m(K,1);this.#G.setAttribute("x",M.x-this.#C/2),this.#G.setAttribute("y",M.y-this.#E/2)}#Q0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#p(){if(!this.#L)return;this.#L.value=this.#M,this.#X0()}#v(){if(!this.#A)return;this.#A.setAttribute("value",this.value)}#s(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#K0(Q,$){let J=this.#s(Q);if(!J){if($==="change")this.#v();return}let Z=this.#j;if(this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#y(),Z!==this.#j)this.#f();else if(this.#g(),this.#p(),$==="change")this.#v();this.#u($)}#$0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#X0(){if(!this.#L)return;if(!this.#k())return;let Q=w.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=w.#w(this.#J);this.#$0(this.#L,"Custom bezier",Q),this.#$0(this.#L,"Custom spring",$),this.#$0(this.#L.select,"Custom bezier",Q),this.#$0(this.#L.select,"Custom spring",$)}#u(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#j,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#Y0(){if(this.#_&&this.#j==="bezier"){this.#W.addEventListener("pointerdown",($)=>this.#j0($,1)),this.#G.addEventListener("pointerdown",($)=>this.#j0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#j0($,this.#W0($))})}else if(this.#_){this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#q0($,"bounce")}),this.#G.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#q0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#q0($,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let $=Q.detail,J=w.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#j!=="bezier")this.#j="bezier",this.#f();else if(this.#_)this.#g(),this.#v()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#M=$,this.#j!=="spring")this.#j="spring",this.#f();else if(this.#_)this.#g(),this.#v()}this.#u("input"),this.#u("change")});if(this.#A)this.#A.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#K0($,"input")}),this.#A.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#K0($,"change")})}#_0(Q){let $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#W0(Q){return this.#_0(Q).x<=this.#R/2?1:2}#j0(Q,$){Q.preventDefault(),this.#Z=$,this.#i();let J=(j)=>{if(!this.#Z)return;let q=this.#_0(j),K=this.#a(q.x,q.y);if(K.x=Math.round(K.x*100)/100,K.y=Math.round(K.y*100)/100,K.x=Math.max(0,Math.min(1,K.x)),this.#Z===1)this.#$.x=K.x,this.#$.y=K.y;else this.#Q.x=K.x,this.#Q.y=K.y;this.#g(),this.#M=this.#y(),this.#p(),this.#v(),this.#u("input")},Z=()=>{this.#Z=null,this.#i(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#u("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#q0(Q,$){Q.preventDefault(),this.#Z=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#O,q=Q.clientY,K=Q.clientX,_=(Y)=>{if(!this.#Z)return;if($==="bounce"){let N=Y.clientY-q;this.#J.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=Y.clientX-K;this.#O=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#g(),this.#M=this.#y(),this.#p(),this.#v(),this.#u("input")},X=()=>{this.#Z=null,document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",X),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",w);class s0 extends HTMLElement{#$=0;#Q=0;#J=0;#j=1;#q=!1;#Z=!1;#_=null;#X=null;#K=null;#U=null;#W=[];#G={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"1"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),x(this,"--perspective",this.getAttribute("perspective")),x(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#Y(this.getAttribute("transform-origin")),this.#A(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#M(Q);this.#z(),this.#L(this.getAttribute("selected")),this.#N()}disconnectedCallback(){if(this.#q=!1,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#U)}#Y(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#N(){if(!this.#X)return;this.#X.style.cursor=this.#F?"":"default"}#L(Q){if(!this.#_)return;let $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#A(Q){if(!Q||!Q.trim()){this.#W=[];return}let $=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="perspective"){x(this,"--perspective",J);return}if(Q==="perspective-origin"){x(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#Y(J);return}if(Q==="selected"){this.#L(J);return}if(Q==="drag"){this.#N();return}if(Q==="fields"){if(this.#A(J),this.#_)this.#z();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#q)return;this.#M(J),this.#R(),this.#O()}if(Q==="precision")this.#j=parseInt(J||"1")}get value(){let Q=this.#j;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#M(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#z(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#W.map((Z)=>`<fig-input-number
215
215
  name="${Z}"
216
216
  step="1"
217
217
  precision="1"
@@ -229,7 +229,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
229
229
  <div class="fig-3d-rotate-face bottom"></div>
230
230
  </div>
231
231
  </div>
232
- </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#G={};for(let Z of this.#N){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#G[Z]=j;let q=(K)=>{K.stopPropagation();let _=parseFloat(K.target.value);if(isNaN(_))return;if(Z==="rotateX")this.#$=_;else if(Z==="rotateY")this.#Q=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#D(K.type)};j.addEventListener("input",q),j.addEventListener("change",q)}}this.#R(),this.#H()}#O(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J};for(let $ of this.#N){let J=this.#G[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#j))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#D(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J}}))}#B(Q){if(!this.#Z)return Q;return Math.round(Q/15)*15}#H(){this.#X.addEventListener("pointerdown",(Q)=>this.#F(Q)),this.#K=(Q)=>{if(Q.key==="Shift")this.#Z=!0},this.#U=(Q)=>{if(Q.key==="Shift")this.#Z=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#U)}get#T(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#F(Q){if(!this.#T)return;Q.preventDefault(),this.#q=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(_)=>{if(!this.#q)return;if(_.buttons===0){K();return}let X=_.clientX-$,Y=_.clientY-J;this.#Q=this.#B(j+X*0.5),this.#$=this.#B(Z-Y*0.5),this.#R(),this.#O(),this.setAttribute("value",this.value),this.#D("input")},K=()=>{if(!this.#q)return;this.setAttribute("value",this.value),this.#q=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",K),this.#X.removeEventListener("pointercancel",K),this.#X.removeEventListener("lostpointercapture",K),this.#D("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",K),this.#X.addEventListener("pointercancel",K),this.#X.addEventListener("lostpointercapture",K)}}customElements.define("fig-3d-rotate",s0);class _0 extends HTMLElement{#$=50;#Q=50;#J=0;#j=null;#q=[];#Z=null;#_=null;#X=null;#K=!1;#U=!1;#N=null;#G=null;#Y=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"0"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#R(this.getAttribute("value")),this.#D(),this.#A(),this.#H()}disconnectedCallback(){this.#K=!1,this.#f()}get value(){let Q=this.#J;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#A();return}if(Q==="fields"){this.#D(),this.#A(),this.#H();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#B(),this.#H();return}if(Q==="value"){if(this.#U||this.#K)return;this.#R(J),this.#F(),this.#P(),this.#B()}}get#W(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#L(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#A(){if(!this.#j)return;this.#j.classList.toggle("drag-disabled",!this.#W)}#M(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#O(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#O($)}#D(){let Q=Array.from({length:9},(j,q)=>{let K=q%3,_=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${K}" data-row="${_}">
232
+ </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#G={};for(let Z of this.#W){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#G[Z]=j;let q=(K)=>{K.stopPropagation();let _=parseFloat(K.target.value);if(isNaN(_))return;if(Z==="rotateX")this.#$=_;else if(Z==="rotateY")this.#Q=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#D(K.type)};j.addEventListener("input",q),j.addEventListener("change",q)}}this.#R(),this.#H()}#O(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J};for(let $ of this.#W){let J=this.#G[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#j))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#D(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J}}))}#B(Q){if(!this.#Z)return Q;return Math.round(Q/15)*15}#H(){this.#X.addEventListener("pointerdown",(Q)=>this.#T(Q)),this.#K=(Q)=>{if(Q.key==="Shift")this.#Z=!0},this.#U=(Q)=>{if(Q.key==="Shift")this.#Z=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#U)}get#F(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#T(Q){if(!this.#F)return;Q.preventDefault(),this.#q=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(_)=>{if(!this.#q)return;if(_.buttons===0){K();return}let X=_.clientX-$,Y=_.clientY-J;this.#Q=this.#B(j+X*0.5),this.#$=this.#B(Z-Y*0.5),this.#R(),this.#O(),this.setAttribute("value",this.value),this.#D("input")},K=()=>{if(!this.#q)return;this.setAttribute("value",this.value),this.#q=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",K),this.#X.removeEventListener("pointercancel",K),this.#X.removeEventListener("lostpointercapture",K),this.#D("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",K),this.#X.addEventListener("pointercancel",K),this.#X.addEventListener("lostpointercapture",K)}}customElements.define("fig-3d-rotate",s0);class j0 extends HTMLElement{#$=50;#Q=50;#J=0;#j=null;#q=[];#Z=null;#_=null;#X=null;#K=!1;#U=!1;#W=null;#G=null;#Y=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"0"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#R(this.getAttribute("value")),this.#D(),this.#A(),this.#H()}disconnectedCallback(){this.#K=!1,this.#f()}get value(){let Q=this.#J;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#A();return}if(Q==="fields"){this.#D(),this.#A(),this.#H();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#B(),this.#H();return}if(Q==="value"){if(this.#U||this.#K)return;this.#R(J),this.#T(),this.#P(),this.#B()}}get#N(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#L(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#A(){if(!this.#j)return;this.#j.classList.toggle("drag-disabled",!this.#N)}#M(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#O(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#O($)}#D(){let Q=Array.from({length:9},(j,q)=>{let K=q%3,_=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${K}" data-row="${_}">
233
233
  <span class="origin-grid-dot"></span>
234
234
  </span>`}).join(""),$=this.#$.toFixed(this.#J),J=this.#Q.toFixed(this.#J),Z=this.#L?`<div class="origin-values">
235
235
  <fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
@@ -240,7 +240,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
240
240
  <fig-handle></fig-handle>
241
241
  </div>
242
242
  </div>
243
- ${Z}`,this.#j=this.querySelector(".origin-grid"),this.#q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#Z=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#F(),this.#P(),this.#B(),this.#b()}#B(){let Q=this.#$.toFixed(this.#J),$=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#H(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#U=!0,this.setAttribute("value",Q),this.#U=!1}#T(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#F(){if(!this.#Z)return;let Q=($)=>16.6667+this.#M($)/100*66.6667;this.#Z.style.left=`${Q(this.#$)}%`,this.#Z.style.top=`${Q(this.#Q)}%`}#P(){if(!this.#Z)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#Z.classList.toggle("beyond-bounds-x",Q),this.#Z.classList.toggle("beyond-bounds-y",$),this.#Z.classList.toggle("overflow-left",J),this.#Z.classList.toggle("overflow-right",Z),this.#Z.classList.toggle("overflow-up",j),this.#Z.classList.toggle("overflow-down",q)}#k(Q,$){if(!this.#j)return null;let J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),K=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#q.find((_)=>Number(_.getAttribute("data-col"))===q&&Number(_.getAttribute("data-row"))===K)}#E(){for(let Q of this.#q)Q.classList.remove("is-hovered")}#S(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#I(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#F(),this.#P(),this.#B(),this.#H(),this.#T(J)}#y(Q,$){if(!this.#j)return{x:this.#$,y:this.#Q};let J=this.#j.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),K=Math.max(1,J.height-j*2),_=(Q-(J.left+Z))/q,X=($-(J.top+j))/K;return{x:_*100,y:X*100}}#V(Q,$){if(!this.#j)return{x:50,y:50};let J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),K=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:K*50}}#w(Q){let J=Q,Z=1/0;for(let j of _0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#C(Q,$){if(!$)return Q;return{x:this.#w(Q.x),y:this.#w(Q.y)}}#f(){if(!this.#j||!this.#G||!this.#Y)return;this.#j.removeEventListener("pointermove",this.#G),this.#j.removeEventListener("pointerup",this.#Y),this.#j.removeEventListener("pointercancel",this.#Y),this.#j.removeEventListener("lostpointercapture",this.#Y),this.#G=null,this.#Y=null}#x(Q){if(!this.#j||!this.#W)return;Q.preventDefault(),this.#K=!0,this.#N=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#j.setPointerCapture(Q.pointerId),this.#G=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;let K=q.clientX-$,_=q.clientY-J,X=Math.hypot(K,_);if(!j&&X<Z)return;if(!j)j=!0,this.#j.classList.add("is-dragging"),this.#E();let Y=this.#C(this.#y(q.clientX,q.clientY),q.shiftKey);this.#I(Y.x,Y.y,"input")},this.#Y=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;if(this.#K=!1,this.#N=null,this.#j.classList.remove("is-dragging"),this.#E(),this.#f(),!j){let K=this.#V($,J);this.#I(K.x,K.y,"input")}this.#T("change")},this.#j.addEventListener("pointermove",this.#G),this.#j.addEventListener("pointerup",this.#Y),this.#j.addEventListener("pointercancel",this.#Y),this.#j.addEventListener("lostpointercapture",this.#Y)}#b(){if(!this.#j||!this.#Z)return;this.#j.addEventListener("pointerdown",($)=>{let J=this.#k($.clientX,$.clientY);if(this.#S(J),this.#W){this.#x($);return}let Z=this.#V($.clientX,$.clientY);this.#I(Z.x,Z.y,"input"),this.#T("change")}),this.#j.addEventListener("pointermove",($)=>{if(this.#K)return;let J=this.#k($.clientX,$.clientY);this.#S(J)}),this.#j.addEventListener("pointerleave",()=>{this.#E()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#I(q,this.#Q,"input");else this.#I(this.#$,q,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#T("change")})};Q(this.#_,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",_0);class d0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;#_=null;#X=null;#K=!1;#U={x:0.5,y:0.5};#N=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#H(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#T(Q),this.#j=()=>this.#F(),this.#q=(Q)=>this.#O(Q),this.#Z=(Q)=>this.#R(Q),this.#_=()=>this.#D(),this.#X=()=>this.#D()}connectedCallback(){requestAnimationFrame(()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");this.#W(),this.#M(),this.#E(),this.#S(),this.#I(),this.#N=!0})}#G(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#Y(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#W(){this.innerHTML=this.#A()}#L(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/\s+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#A(){let Q=this.#L();return`
243
+ ${Z}`,this.#j=this.querySelector(".origin-grid"),this.#q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#Z=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#T(),this.#P(),this.#B(),this.#b()}#B(){let Q=this.#$.toFixed(this.#J),$=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#H(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#U=!0,this.setAttribute("value",Q),this.#U=!1}#F(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#T(){if(!this.#Z)return;let Q=($)=>16.6667+this.#M($)/100*66.6667;this.#Z.style.left=`${Q(this.#$)}%`,this.#Z.style.top=`${Q(this.#Q)}%`}#P(){if(!this.#Z)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#Z.classList.toggle("beyond-bounds-x",Q),this.#Z.classList.toggle("beyond-bounds-y",$),this.#Z.classList.toggle("overflow-left",J),this.#Z.classList.toggle("overflow-right",Z),this.#Z.classList.toggle("overflow-up",j),this.#Z.classList.toggle("overflow-down",q)}#C(Q,$){if(!this.#j)return null;let J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),K=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#q.find((_)=>Number(_.getAttribute("data-col"))===q&&Number(_.getAttribute("data-row"))===K)}#E(){for(let Q of this.#q)Q.classList.remove("is-hovered")}#S(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#I(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#T(),this.#P(),this.#B(),this.#H(),this.#F(J)}#y(Q,$){if(!this.#j)return{x:this.#$,y:this.#Q};let J=this.#j.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),K=Math.max(1,J.height-j*2),_=(Q-(J.left+Z))/q,X=($-(J.top+j))/K;return{x:_*100,y:X*100}}#V(Q,$){if(!this.#j)return{x:50,y:50};let J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),K=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:K*50}}#w(Q){let J=Q,Z=1/0;for(let j of j0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#k(Q,$){if(!$)return Q;return{x:this.#w(Q.x),y:this.#w(Q.y)}}#f(){if(!this.#j||!this.#G||!this.#Y)return;this.#j.removeEventListener("pointermove",this.#G),this.#j.removeEventListener("pointerup",this.#Y),this.#j.removeEventListener("pointercancel",this.#Y),this.#j.removeEventListener("lostpointercapture",this.#Y),this.#G=null,this.#Y=null}#x(Q){if(!this.#j||!this.#N)return;Q.preventDefault(),this.#K=!0,this.#W=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#j.setPointerCapture(Q.pointerId),this.#G=(q)=>{if(!this.#K||q.pointerId!==this.#W)return;let K=q.clientX-$,_=q.clientY-J,X=Math.hypot(K,_);if(!j&&X<Z)return;if(!j)j=!0,this.#j.classList.add("is-dragging"),this.#E();let Y=this.#k(this.#y(q.clientX,q.clientY),q.shiftKey);this.#I(Y.x,Y.y,"input")},this.#Y=(q)=>{if(!this.#K||q.pointerId!==this.#W)return;if(this.#K=!1,this.#W=null,this.#j.classList.remove("is-dragging"),this.#E(),this.#f(),!j){let K=this.#V($,J);this.#I(K.x,K.y,"input")}this.#F("change")},this.#j.addEventListener("pointermove",this.#G),this.#j.addEventListener("pointerup",this.#Y),this.#j.addEventListener("pointercancel",this.#Y),this.#j.addEventListener("lostpointercapture",this.#Y)}#b(){if(!this.#j||!this.#Z)return;this.#j.addEventListener("pointerdown",($)=>{let J=this.#C($.clientX,$.clientY);if(this.#S(J),this.#N){this.#x($);return}let Z=this.#V($.clientX,$.clientY);this.#I(Z.x,Z.y,"input"),this.#F("change")}),this.#j.addEventListener("pointermove",($)=>{if(this.#K)return;let J=this.#C($.clientX,$.clientY);this.#S(J)}),this.#j.addEventListener("pointerleave",()=>{this.#E()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#I(q,this.#Q,"input");else this.#I(this.#$,q,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#F("change")})};Q(this.#_,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",j0);class d0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;#_=null;#X=null;#K=!1;#U={x:0.5,y:0.5};#W=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#H(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#F(Q),this.#j=()=>this.#T(),this.#q=(Q)=>this.#O(Q),this.#Z=(Q)=>this.#R(Q),this.#_=()=>this.#D(),this.#X=()=>this.#D()}connectedCallback(){requestAnimationFrame(()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");this.#N(),this.#M(),this.#E(),this.#S(),this.#I(),this.#W=!0})}#G(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#Y(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#N(){this.innerHTML=this.#A()}#L(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/\s+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#A(){let Q=this.#L();return`
244
244
  <div class="fig-input-joystick-plane-container" tabindex="0">
245
245
  ${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
246
246
  <div class="fig-input-joystick-plane">
@@ -273,6 +273,6 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var W0=L1(()=>{/*! Vendored from @
273
273
  <span slot="prepend">Y</span>
274
274
  </fig-input-number>
275
275
  </div>`:""}
276
- `}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#j);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#q),this.xInput.addEventListener("change",this.#q),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#j),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#q),this.xInput.removeEventListener("change",this.#q),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#D(){this.#S(),this.#k()}#B(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#S()}#H(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#B(J,Z,{syncHandle:!1}),this.#P(),this.#k()}#T(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#B($.px,$.py,{syncHandle:!1}),this.#P()}#F(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#S(),this.#k()}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#k(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#Y&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#S(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#I()}#I(){let Q=this.#U,$=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",$),this.style.setProperty("--is-not-default",$?"0":"1")}#y(){this.position={...this.#U},this.#E(),this.#S(),this.#P(),this.#k()}focus(){this.querySelector(".fig-input-joystick-plane-container")?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0.5;let _=K.includes("%"),X=Number.parseFloat(K.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let Y=_||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,Y))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#N)this.#E(),this.#I()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#W(),this.#M(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#W(),this.#M(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",d0);class X0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q)}static get observedAttributes(){return["duration","playing"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s")}}customElements.define("fig-shimmer",X0);class r0 extends X0{}customElements.define("fig-skeleton",r0);class o0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#j.bind(this),this.#$.addEventListener("click",this.#Q)}#j(Q){Q.stopPropagation(),this.open=!this.open}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0}))}get visible(){return this.getAttribute("visible")!=="false"}set visible(Q){let $=this.visible;if(Q)this.setAttribute("visible","true");else this.setAttribute("visible","false");if($!==Q)this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Q},bubbles:!0}))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){let Z=J!==null&&J!=="false";this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Z},bubbles:!0}))}if(Q==="visible"){let Z=J!=="false";this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Z},bubbles:!0}))}}}customElements.define("fig-layer",o0);class i0 extends HTMLElement{static observedAttributes=["name","collapsible"];#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>this.#j())}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#J)}attributeChangedCallback(Q,$,J){if($===J)return;this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(this.#$.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let q=w("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",i0);class l0 extends HTMLElement{}customElements.define("fig-header",l0);class t0 extends HTMLElement{}customElements.define("fig-footer",t0);class a0 extends HTMLElement{}customElements.define("fig-spinner",a0);class n0 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",n0);var P1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function S1(Q,$="medium"){let J=Q&&P1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class e0 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=S1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",e0);class Q1 extends HTMLElement{}customElements.define("fig-content",Q1);class $1 extends HTMLElement{}customElements.define("fig-tab-content",$1);class J1 extends HTMLElement{}customElements.define("fig-button-combo",J1);class Z1 extends HTMLElement{}customElements.define("fig-input-combo",Z1);class j1 extends HTMLElement{#$=null;#Q=null;#J=null;#j=this.#M.bind(this);#q=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#j),this.#$.removeEventListener("change",this.#q);if(this.#Q)this.#Q.removeEventListener("input",this.#j),this.#Q.removeEventListener("change",this.#q);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#U(){let Q=this.#Z;if(Q==="add"||Q==="remove"){let _=Q==="add"?"add":"minus";this.innerHTML=`<fig-button icon variant="ghost"><fig-icon name="${_}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#N);return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#W($),Z=this.#Y($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),K=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=u()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
276
+ `}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#j);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#q),this.xInput.addEventListener("change",this.#q),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#j),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#q),this.xInput.removeEventListener("change",this.#q),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#D(){this.#S(),this.#C()}#B(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#S()}#H(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#B(J,Z,{syncHandle:!1}),this.#P(),this.#C()}#F(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#B($.px,$.py,{syncHandle:!1}),this.#P()}#T(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#S(),this.#C()}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#Y&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#S(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#I()}#I(){let Q=this.#U,$=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",$),this.style.setProperty("--is-not-default",$?"0":"1")}#y(){this.position={...this.#U},this.#E(),this.#S(),this.#P(),this.#C()}focus(){this.querySelector(".fig-input-joystick-plane-container")?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0.5;let _=K.includes("%"),X=Number.parseFloat(K.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let Y=_||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,Y))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#W)this.#E(),this.#I()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#N(),this.#M(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#N(),this.#M(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",d0);class q0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q)}static get observedAttributes(){return["duration","playing"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s")}}customElements.define("fig-shimmer",q0);class r0 extends q0{}customElements.define("fig-skeleton",r0);class o0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#j.bind(this),this.#$.addEventListener("click",this.#Q)}#j(Q){Q.stopPropagation(),this.open=!this.open}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0}))}get visible(){return this.getAttribute("visible")!=="false"}set visible(Q){let $=this.visible;if(Q)this.setAttribute("visible","true");else this.setAttribute("visible","false");if($!==Q)this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Q},bubbles:!0}))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){let Z=J!==null&&J!=="false";this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Z},bubbles:!0}))}if(Q==="visible"){let Z=J!=="false";this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Z},bubbles:!0}))}}}customElements.define("fig-layer",o0);class i0 extends HTMLElement{static observedAttributes=["name","collapsible"];#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>this.#j())}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#J)}attributeChangedCallback(Q,$,J){if($===J)return;this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(this.#$.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let q=b("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",i0);class l0 extends HTMLElement{}customElements.define("fig-header",l0);class t0 extends HTMLElement{}customElements.define("fig-footer",t0);class a0 extends HTMLElement{}customElements.define("fig-spinner",a0);class n0 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",n0);var P1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function S1(Q,$="medium"){let J=Q&&P1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class e0 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=S1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",e0);class Q1 extends HTMLElement{}customElements.define("fig-content",Q1);class $1 extends HTMLElement{}customElements.define("fig-tab-content",$1);class J1 extends HTMLElement{}customElements.define("fig-button-combo",J1);class Z1 extends HTMLElement{}customElements.define("fig-input-combo",Z1);class j1 extends HTMLElement{#$=null;#Q=null;#J=null;#j=this.#M.bind(this);#q=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#W)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#j),this.#$.removeEventListener("change",this.#q);if(this.#Q)this.#Q.removeEventListener("input",this.#j),this.#Q.removeEventListener("change",this.#q);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#U(){let Q=this.#Z;if(Q==="add"||Q==="remove"){let _=Q==="add"?"add":"minus";this.innerHTML=`<fig-button icon variant="ghost"><fig-icon name="${_}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#W);return}this.removeEventListener("click",this.#W);let $=(this.getAttribute("value")||"").trim(),J=this.#N($),Z=this.#Y($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),K=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=m()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
277
277
  <fig-chit background="${J}"${K}></fig-chit>
278
- </fig-fill-picker>`:`<fig-chit background="${J}"${K}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#j),this.#$?.addEventListener("change",this.#q),!this.#$)this.#Q?.addEventListener("input",this.#j),this.#Q?.addEventListener("change",this.#q);this.#X()}#N=()=>{let Q=this.#Z;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#G(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#Y(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#W(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#W(J.color)}catch{}if($.startsWith("#"))return this.#G($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#G($);try{let{ctx:J}=q0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#G(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(K)=>Math.max(0,Math.min(255,Number(K))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),$=this.#W(Q),J=this.#Y(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#A(Q,$){let J=this.#W(Q?.color),Z=this.#W(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#L();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#M(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#U();break;case"value":case"selected":case"disabled":this.#L();break}}get value(){return this.#W(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#W(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",j1);class q1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",q1);class K1 extends HTMLElement{#$=null;#Q=this.#M.bind(this);#J=this.#z.bind(this);#j=this.#R.bind(this);#q=null;#Z=null;#_=null;#X=null;#K=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#U(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#N(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#G))}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#E(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#j),this.#T(),this.#B(),this.#S(),this.#D(),requestAnimationFrame(()=>{this.#W(),this.#R(),this.#Y()})}#Y(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#E(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#j),this.#H(),this.#q?.disconnect(),this.#q=null,this.#Z?.disconnect(),this.#Z=null,this.#F()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#L(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#W());if(Q==="drag")if(this.#N)this.#B();else this.#H();if(Q==="overflow")this.#T()}#W(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#L($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#L(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#A(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#M(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#A(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#O()}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#A(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#O()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#O()}#O(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#R(){if(this.#U==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollWidth-this.clientWidth>$,Z=!J||this.scrollLeft<=$,j=!J||this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}else{let J=this.scrollHeight-this.clientHeight>$,Z=!J||this.scrollTop<=$,j=!J||this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}}#D(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#B(){if(this.#K?.bound)return;if(!this.#N)return;let Q=(q)=>{if(q.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#K.active=!0,this.#K.didDrag=!1,this.#K.startX=q.clientX,this.#K.startY=q.clientY,this.#K.scrollLeft=this.scrollLeft,this.#K.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(q)=>{if(!this.#K.active)return;let K=this.getAttribute("layout")==="horizontal",_=q.clientX-this.#K.startX,X=q.clientY-this.#K.startY;if(!this.#K.didDrag&&Math.abs(K?_:X)>3)this.#K.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#K.didDrag)return;if(K)this.scrollLeft=this.#K.scrollLeft-_;else this.scrollTop=this.#K.scrollTop-X},J=(q)=>{if(!this.#K.active)return;let K=this.#K.didDrag;if(this.#K.active=!1,this.#K.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(K)q.preventDefault(),q.stopPropagation()},Z=(q)=>{if(this.#K?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#K.suppressClick=!1},j=(q)=>{if(this.#K?.didDrag)this.#K.suppressClick=!0,setTimeout(()=>{if(this.#K)this.#K.suppressClick=!1},0)};this.#K={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#H(){if(!this.#K?.bound)return;this.removeEventListener("pointerdown",this.#K.onPointerDown),window.removeEventListener("pointermove",this.#K.onPointerMove),window.removeEventListener("pointerup",this.#K.onPointerUp),this.removeEventListener("pointerup",this.#K.onPointerUpCapture,!0),this.removeEventListener("click",this.#K.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#K=null}#T(){if(this.#U==="scrollbar")this.#F();else this.#P()}#F(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#P(){if(this.#_)return;let Q=()=>{return w("chevron",{size:"small",className:"fig-chooser-nav-chevron"})};this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),this.#_.appendChild(Q()),this.#X=document.createElement("button"),this.#X.className="fig-chooser-nav-end",this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-label","Scroll forward"),this.#X.appendChild(Q()),this.#_.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#k(-1)}),this.#X.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#k(1)}),this.prepend(this.#_),this.append(this.#X)}#k(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#E(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.scrollHeight>this.clientHeight,Z=this.scrollWidth>this.clientWidth;if(!Z&&!J)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),K={behavior:$};if(J){let _=j.top-q.top+this.scrollTop+j.height/2;K.top=_-this.clientHeight/2}if(Z){let _=j.left-q.left+this.scrollLeft+j.width/2;K.left=_-this.clientWidth/2}this.scrollTo(K)})}#S(){this.#q?.disconnect(),this.#q=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#W();else if(!this.#$&&Q.length)this.#W()}),this.#q.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",K1);class _1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode"];#$=!1;#Q=!1;#J=null;#j=!1;#q=null;#Z=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#U(){return!this.hasAttribute("data-no-color-picker")}get#N(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#Y(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#W(Q){let $=this.#Y;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#A(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#v(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#z(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0;let _=K.includes("px"),X=K.includes("%"),Y=parseFloat(K.replace(/[%px]/g,""));if(!Number.isFinite(Y))return 0;if(_)return{px:Y};if(X||Math.abs(Y)>1)return Math.max(0,Math.min(100,Y));return Math.max(0,Math.min(100,Y*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#O(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#z(Q),j=$.getBoundingClientRect(),q=this.offsetWidth/2,K=this.offsetHeight/2,_=(N,G,B)=>{if(N&&typeof N==="object"&&"px"in N)return Math.max(-B,Math.min(G-B,N.px-B));return null},X=(N,G)=>{return`calc(${typeof N==="number"?N:0}% - ${G}px)`},Y=this.#G;if(Y.x){let N=_(J,j.width,q);this.style.left=N===null?X(J,q):`${Math.round(N)}px`}if(Y.y){let N=_(Z,j.height,K);this.style.top=N===null?X(Z,K):`${Math.round(N)}px`}}#R(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#D(){return this.getAttribute("hit-area-mode")||"handle"}#B(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let K of $){if(K==="circle"){j=!0;continue}let _=parseFloat(K);if(Number.isFinite(_))q.push(_)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#H(){let Q=this.#B();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#T(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#T(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#D==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#I(Q)}connectedCallback(){this.#E(),this.#H(),this.addEventListener("click",this.#F),document.addEventListener("pointerdown",this.#P),document.addEventListener("keydown",this.#k);let Q=this.getAttribute("value");if(Q)this.#O(Q);if(this.#K)this.#d()}disconnectedCallback(){if(this.#S(),this.#l(),this.#x(),this.#i(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#F),document.removeEventListener("pointerdown",this.#P),document.removeEventListener("keydown",this.#k)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#F=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#U&&!this.#K){this.#f();return}this.select()};#P=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#Z)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#k=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#U)return;if(Q.preventDefault(),!this.#K)this.#f()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#q&&this.#K==="color"&&J)this.#q.setAttribute("value",J);this.#w()}if(Q==="drag")this.#E();if(Q==="hit-area")this.#H();if(Q==="selected")this.#t();if(Q==="value"&&!this.#j&&!this.#$)this.#O(J);if(Q==="tip"){if(this.#l(),this.#K)this.#x(),this.#d()}}#E(){if(this.#N&&!this.#J)this.#J=(Q)=>this.#I(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#N&&this.#J)this.#S()}#S(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#I(Q){if(!this.#N||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#G,Z=this.offsetWidth,j=this.offsetHeight,q=null,K=this.getBoundingClientRect(),_=K.left+K.width/2,X=K.top+K.height/2,Y=Q.clientX-_,N=Q.clientY-X,G=Q.clientX,B=Q.clientY,H=3,A=(R,L,U=!1)=>{let M=$.getBoundingClientRect();q=M;let T=this.#v(M),E=T.x,S=T.y,f=R-Y-M.left-Z/2,c=L-N-M.top-j/2,l=Math.max(-Z/2,Math.min(M.width-Z/2,f)),t=Math.max(-j/2,Math.min(M.height-j/2,c)),g=M.width>0?((J.x?l:E)+Z/2)/M.width:0.5,h=M.height>0?((J.y?t:S)+j/2)/M.height:0.5;if(this.#W(U)){if(J.x)g=this.#L(g);if(J.y)h=this.#L(h);if(J.x&&J.y){let b=this.#A(g,h);g=b.x,h=b.y}}if(J.x){let b=g*M.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(M.width-Z/2,b)))}px`}if(J.y){let b=h*M.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(M.height-j/2,b)))}px`}},O=(R)=>{if(!this.#$)return;if(!this.#Q){let L=R.clientX-G,U=R.clientY-B;if(L*L+U*U<H*H)return;if(this.#J0(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,A(R.clientX,R.clientY,R.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#v(q),shiftKey:R.shiftKey}}))},D=(R)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",D),this.#Q){A(R.clientX,R.clientY,R.shiftKey),this.#R(),this.#O(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#v(q)}));let L=(U)=>{U.stopPropagation(),U.preventDefault()};this.addEventListener("click",L,{capture:!0,once:!0})}else this.#R();this.#Q=!1};window.addEventListener("pointermove",O),window.addEventListener("pointerup",D)}showColorTip(){if(!this.#K)return;if(this.#q){this.#q.style.display="";return}this.#d()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#y(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let K=q.replace("#","").trim();if(K.length===3||K.length===4){let[_,X,Y,N]=K;return{color:`#${_}${_}${X}${X}${Y}${Y}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(K.length===6||K.length===8)return{color:`#${K.slice(0,6)}`.toUpperCase(),opacity:K.length===8?Math.round(parseInt(K.slice(6,8),16)/255*100):100};return $},j=(q,K,_)=>{let X=(Y)=>Math.max(0,Math.min(255,Math.round(Number(Y)))).toString(16).padStart(2,"0");return`#${X(q)}${X(K)}${X(_)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=q0(1,1);q.fillStyle="#000000",q.fillStyle=J;let K=q.fillStyle;if(K.startsWith("#"))return Z(K);let _=K.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(_)return{color:j(_[1],_[2],_[3]),opacity:_[4]!==void 0?Math.round(parseFloat(_[4])*100):100}}catch{}return $}#V(){let{color:Q,opacity:$}=this.#y();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#w(){if(!this.#Z)return;this.#Z.setAttribute("value",this.#V())}#C(){if(!u())return null;if(this.#Z)return this.#Z;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#V()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#a),Q.addEventListener("change",this.#r),Q.addEventListener("close",this.#n),this.appendChild(Q),this.#Z=Q,Q}#f(){if(this.hasAttribute("disabled"))return;let Q=this.#C();if(!Q){this.#s();return}this.setAttribute("selected",""),this.#w(),Q.open()}#x(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#a),this.#Z.removeEventListener("change",this.#r),this.#Z.removeEventListener("close",this.#n),this.#Z.close(),this.#Z.remove(),this.#Z=null,this.removeAttribute("selected")}#b(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#g),Q.addEventListener("change",this.#o),this.appendChild(Q),this.#_=Q,Q}#s(){let Q=this.#b(),{color:$}=this.#y();Q.value=$,this.setAttribute("selected",""),Q.click()}#i(){if(!this.#_)return;this.#_.removeEventListener("input",this.#g),this.#_.removeEventListener("change",this.#o),this.#_.remove(),this.#_=null}#J0(){if(this.getAttribute("type")!=="color")return;this.#Z?.close()}#d(){let Q=this.#K;if(!Q)return;if(this.#q)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#e),$.addEventListener("change",this.#Q0),$.addEventListener("add",this.#c),$.addEventListener("remove",this.#c),this.appendChild($),this.#q=$,this.#t()}#l(){if(!this.#q)return;this.#q.removeEventListener("input",this.#e),this.#q.removeEventListener("change",this.#Q0),this.#q.removeEventListener("add",this.#c),this.#q.removeEventListener("remove",this.#c),this.#q.remove(),this.#q=null}#t(){if(!this.#q||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#h(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=r(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#p(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#a=(Q)=>{Q.stopPropagation();let $=this.#p(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#r=(Q)=>{Q.stopPropagation();let $=this.#p(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#m(Q){let{opacity:$}=this.#y();return $<100?{color:Q,opacity:$}:{color:Q}}#g=(Q)=>{Q.stopPropagation();let $=this.#m(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#o=(Q)=>{Q.stopPropagation();let $=this.#m(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#n=()=>{this.removeAttribute("selected")};#e=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#Q0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#c=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#v(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,K=J.top-$.top,_=q+Z,X=K+j,Y=$.width>0?_/$.width:0,N=$.height>0?X/$.height:0;return{x:q,y:K,px:Y,py:N}}}customElements.define("fig-handle",_1);class X1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}attributeChangedCallback(){}}customElements.define("fig-menu-item",X1);class Y1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",Y1);class N1 extends HTMLElement{#$=null;#Q=null;#J=null;#j;#q;#Z;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#j=this.#O.bind(this),this.#q=this.#R.bind(this),this.#Z=this.#D.bind(this),this.#_=this.#B.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#K(),this.#U(),this.#N(),this.#G(),this.#W(),this.#z(),this.open)this.#T()}disconnectedCallback(){if(this.#Y(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#F();else this.#T();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#U(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#N(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#G(){if(this.addEventListener("keydown",this.#Z),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false");if(this.#$)this.#$.addEventListener("click",this.#q)}#Y(){if(this.removeEventListener("keydown",this.#Z),this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#q)}#W(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#$.anchor=this.#Q,this.#z()}}}),this.#J.observe(this,{childList:!0})}#L(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#A(){let Q=this.#L();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#L();if(!$.length)return;let J=Math.max(0,Math.min(Q,$.length-1));this.#X=J,$[J].focus()}#z(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#R(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#D(Q){if(!this.open||!this.#$?.matches?.(":open"))return;let $=this.#L();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Enter":case" ":{this.#A();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(J);break}}}#B(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#X=-1}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#T(){if(!this.#$)return;if(this.#$.open=!0,this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#F(){if(!this.#$)return;this.#$.open=!1}}customElements.define("fig-menu",N1);
278
+ </fig-fill-picker>`:`<fig-chit background="${J}"${K}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#j),this.#$?.addEventListener("change",this.#q),!this.#$)this.#Q?.addEventListener("input",this.#j),this.#Q?.addEventListener("change",this.#q);this.#X()}#W=()=>{let Q=this.#Z;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#G(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#Y(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#N(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#N(J.color)}catch{}if($.startsWith("#"))return this.#G($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#G($);try{let{ctx:J}=J0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#G(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(K)=>Math.max(0,Math.min(255,Number(K))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),$=this.#N(Q),J=this.#Y(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#A(Q,$){let J=this.#N(Q?.color),Z=this.#N(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#L();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#M(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#U();break;case"value":case"selected":case"disabled":this.#L();break}}get value(){return this.#N(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#N(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",j1);class q1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",q1);class K1 extends HTMLElement{#$=null;#Q=this.#M.bind(this);#J=this.#z.bind(this);#j=this.#R.bind(this);#q=null;#Z=null;#_=null;#X=null;#K=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#U(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#W(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#G))}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#E(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#j),this.#F(),this.#B(),this.#S(),this.#D(),requestAnimationFrame(()=>{this.#N(),this.#R(),this.#Y()})}#Y(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#E(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#j),this.#H(),this.#q?.disconnect(),this.#q=null,this.#Z?.disconnect(),this.#Z=null,this.#T()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#L(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#N());if(Q==="drag")if(this.#W)this.#B();else this.#H();if(Q==="overflow")this.#F()}#N(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#L($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#L(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#A(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#M(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#A(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#O()}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#A(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#O()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#O()}#O(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#R(){if(this.#U==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollWidth-this.clientWidth>$,Z=!J||this.scrollLeft<=$,j=!J||this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}else{let J=this.scrollHeight-this.clientHeight>$,Z=!J||this.scrollTop<=$,j=!J||this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}}#D(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#B(){if(this.#K?.bound)return;if(!this.#W)return;let Q=(q)=>{if(q.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#K.active=!0,this.#K.didDrag=!1,this.#K.startX=q.clientX,this.#K.startY=q.clientY,this.#K.scrollLeft=this.scrollLeft,this.#K.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(q)=>{if(!this.#K.active)return;let K=this.getAttribute("layout")==="horizontal",_=q.clientX-this.#K.startX,X=q.clientY-this.#K.startY;if(!this.#K.didDrag&&Math.abs(K?_:X)>3)this.#K.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#K.didDrag)return;if(K)this.scrollLeft=this.#K.scrollLeft-_;else this.scrollTop=this.#K.scrollTop-X},J=(q)=>{if(!this.#K.active)return;let K=this.#K.didDrag;if(this.#K.active=!1,this.#K.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(K)q.preventDefault(),q.stopPropagation()},Z=(q)=>{if(this.#K?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#K.suppressClick=!1},j=(q)=>{if(this.#K?.didDrag)this.#K.suppressClick=!0,setTimeout(()=>{if(this.#K)this.#K.suppressClick=!1},0)};this.#K={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#H(){if(!this.#K?.bound)return;this.removeEventListener("pointerdown",this.#K.onPointerDown),window.removeEventListener("pointermove",this.#K.onPointerMove),window.removeEventListener("pointerup",this.#K.onPointerUp),this.removeEventListener("pointerup",this.#K.onPointerUpCapture,!0),this.removeEventListener("click",this.#K.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#K=null}#F(){if(this.#U==="scrollbar")this.#T();else this.#P()}#T(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#P(){if(this.#_)return;let Q=()=>{return b("chevron",{size:"small",className:"fig-chooser-nav-chevron"})};this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),this.#_.appendChild(Q()),this.#X=document.createElement("button"),this.#X.className="fig-chooser-nav-end",this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-label","Scroll forward"),this.#X.appendChild(Q()),this.#_.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#C(-1)}),this.#X.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#C(1)}),this.prepend(this.#_),this.append(this.#X)}#C(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#E(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.scrollHeight>this.clientHeight,Z=this.scrollWidth>this.clientWidth;if(!Z&&!J)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),K={behavior:$};if(J){let _=j.top-q.top+this.scrollTop+j.height/2;K.top=_-this.clientHeight/2}if(Z){let _=j.left-q.left+this.scrollLeft+j.width/2;K.left=_-this.clientWidth/2}this.scrollTo(K)})}#S(){this.#q?.disconnect(),this.#q=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#N();else if(!this.#$&&Q.length)this.#N()}),this.#q.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",K1);class _1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode"];#$=!1;#Q=!1;#J=null;#j=!1;#q=null;#Z=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#U(){return!this.hasAttribute("data-no-color-picker")}get#W(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#Y(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#N(Q){let $=this.#Y;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#A(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#s(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#z(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0;let _=K.includes("px"),X=K.includes("%"),Y=parseFloat(K.replace(/[%px]/g,""));if(!Number.isFinite(Y))return 0;if(_)return{px:Y};if(X||Math.abs(Y)>1)return Math.max(0,Math.min(100,Y));return Math.max(0,Math.min(100,Y*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#O(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#z(Q),j=$.getBoundingClientRect(),q=(X,Y)=>{if(X&&typeof X==="object"&&"px"in X)return Math.max(0,Math.min(Y,X.px));return null},K=(X)=>{return`${typeof X==="number"?X:0}%`},_=this.#G;if(this.#R(_),_.x){let X=q(J,j.width);this.style.left=X===null?K(J):`${Math.round(X)}px`}if(_.y){let X=q(Z,j.height);this.style.top=X===null?K(Z):`${Math.round(X)}px`}}#R(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#D(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#B(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let K of $){if(K==="circle"){j=!0;continue}let _=parseFloat(K);if(Number.isFinite(_))q.push(_)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#F(){let Q=this.#H();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#T(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#T(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#B==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#y(Q)}connectedCallback(){this.#S(),this.#F(),this.addEventListener("click",this.#P),document.addEventListener("pointerdown",this.#C),document.addEventListener("keydown",this.#E);let Q=this.getAttribute("value");if(Q)this.#O(Q);if(this.#K)this.#r()}disconnectedCallback(){if(this.#I(),this.#t(),this.#b(),this.#J0(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#P),document.removeEventListener("pointerdown",this.#C),document.removeEventListener("keydown",this.#E)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#P=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#U&&!this.#K){this.#x();return}this.select()};#C=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#Z)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#E=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#U)return;if(Q.preventDefault(),!this.#K)this.#x()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#q&&this.#K==="color"&&J)this.#q.setAttribute("value",J);this.#k()}if(Q==="drag")this.#S();if(Q==="hit-area")this.#F();if(Q==="selected")this.#c();if(Q==="value"&&!this.#j&&!this.#$)this.#O(J);if(Q==="tip"){if(this.#t(),this.#K)this.#b(),this.#r()}}#S(){if(this.#W&&!this.#J)this.#J=(Q)=>this.#y(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#W&&this.#J)this.#I()}#I(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#y(Q){if(!this.#W||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#G,Z=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,K=j.top+j.height/2,_=Q.clientX-q,X=Q.clientY-K,Y=Q.clientX,N=Q.clientY,L=3,B=(G,z,R=!1)=>{let U=$.getBoundingClientRect();Z=U;let A=this.#s(U),D=G-_-U.left,T=z-X-U.top,E=Math.max(0,Math.min(U.width,D)),S=Math.max(0,Math.min(U.height,T)),I=U.width>0?J.x?E/U.width:A.px:0.5,V=U.height>0?J.y?S/U.height:A.py:0.5;if(this.#N(R)){if(J.x)I=this.#L(I);if(J.y)V=this.#L(V);if(J.x&&J.y){let s=this.#A(I,V);I=s.x,V=s.y}}if(this.#R(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(U.width,I*U.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(U.height,V*U.height)))}px`},H=(G)=>{if(!this.#$)return;if(!this.#Q){let z=G.clientX-Y,R=G.clientY-N;if(z*z+R*R<L*L)return;if(this.#Z0(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,B(G.clientX,G.clientY,G.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#s(Z),shiftKey:G.shiftKey}}))},M=(G)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",M),this.#Q){B(G.clientX,G.clientY,G.shiftKey),this.#D(),this.#O(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#s(Z)}));let z=(R)=>{R.stopPropagation(),R.preventDefault()};this.addEventListener("click",z,{capture:!0,once:!0})}else this.#D();this.#Q=!1};window.addEventListener("pointermove",H),window.addEventListener("pointerup",M)}showColorTip(){if(!this.#K)return;if(this.#q){this.#q.style.display="";return}this.#r()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#V(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let K=q.replace("#","").trim();if(K.length===3||K.length===4){let[_,X,Y,N]=K;return{color:`#${_}${_}${X}${X}${Y}${Y}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(K.length===6||K.length===8)return{color:`#${K.slice(0,6)}`.toUpperCase(),opacity:K.length===8?Math.round(parseInt(K.slice(6,8),16)/255*100):100};return $},j=(q,K,_)=>{let X=(Y)=>Math.max(0,Math.min(255,Math.round(Number(Y)))).toString(16).padStart(2,"0");return`#${X(q)}${X(K)}${X(_)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=J0(1,1);q.fillStyle="#000000",q.fillStyle=J;let K=q.fillStyle;if(K.startsWith("#"))return Z(K);let _=K.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(_)return{color:j(_[1],_[2],_[3]),opacity:_[4]!==void 0?Math.round(parseFloat(_[4])*100):100}}catch{}return $}#w(){let{color:Q,opacity:$}=this.#V();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#k(){if(!this.#Z)return;this.#Z.setAttribute("value",this.#w())}#f(){if(!m())return null;if(this.#Z)return this.#Z;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#o),Q.addEventListener("change",this.#m),Q.addEventListener("close",this.#e),this.appendChild(Q),this.#Z=Q,Q}#x(){if(this.hasAttribute("disabled"))return;let Q=this.#f();if(!Q){this.#l();return}this.setAttribute("selected",""),this.#k(),Q.open()}#b(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#o),this.#Z.removeEventListener("change",this.#m),this.#Z.removeEventListener("close",this.#e),this.#Z.close(),this.#Z.remove(),this.#Z=null,this.removeAttribute("selected")}#d(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#n),this.appendChild(Q),this.#_=Q,Q}#l(){let Q=this.#d(),{color:$}=this.#V();Q.value=$,this.setAttribute("selected",""),Q.click()}#J0(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#n),this.#_.remove(),this.#_=null}#Z0(){if(this.getAttribute("type")!=="color")return;this.#Z?.close()}#r(){let Q=this.#K;if(!Q)return;if(this.#q)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#Q0),$.addEventListener("change",this.#p),$.addEventListener("add",this.#v),$.addEventListener("remove",this.#v),this.appendChild($),this.#q=$,this.#c()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#Q0),this.#q.removeEventListener("change",this.#p),this.#q.removeEventListener("add",this.#v),this.#q.removeEventListener("remove",this.#v),this.#q.remove(),this.#q=null}#c(){if(!this.#q||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#h(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=u(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#a(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#o=(Q)=>{Q.stopPropagation();let $=this.#a(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#m=(Q)=>{Q.stopPropagation();let $=this.#a(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#g(Q){let{opacity:$}=this.#V();return $<100?{color:Q,opacity:$}:{color:Q}}#i=(Q)=>{Q.stopPropagation();let $=this.#g(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#n=(Q)=>{Q.stopPropagation();let $=this.#g(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#e=()=>{this.removeAttribute("selected")};#Q0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#p=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#v=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#s(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,K=J.top-$.top,_=q+Z,X=K+j,Y=$.width>0?_/$.width:0,N=$.height>0?X/$.height:0;return{x:q,y:K,px:Y,py:N}}}customElements.define("fig-handle",_1);class X1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}attributeChangedCallback(){}}customElements.define("fig-menu-item",X1);class Y1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",Y1);class W1 extends HTMLElement{#$=null;#Q=null;#J=null;#j;#q;#Z;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#j=this.#O.bind(this),this.#q=this.#R.bind(this),this.#Z=this.#D.bind(this),this.#_=this.#B.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#K(),this.#U(),this.#W(),this.#G(),this.#N(),this.#z(),this.open)this.#F()}disconnectedCallback(){if(this.#Y(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#T();else this.#F();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#U(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#W(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#G(){if(this.addEventListener("keydown",this.#Z),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false");if(this.#$)this.#$.addEventListener("click",this.#q)}#Y(){if(this.removeEventListener("keydown",this.#Z),this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#q)}#N(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#$.anchor=this.#Q,this.#z()}}}),this.#J.observe(this,{childList:!0})}#L(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#A(){let Q=this.#L();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#L();if(!$.length)return;let J=Math.max(0,Math.min(Q,$.length-1));this.#X=J,$[J].focus()}#z(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#R(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#D(Q){if(!this.open||!this.#$?.matches?.(":open"))return;let $=this.#L();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Enter":case" ":{this.#A();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(J);break}}}#B(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#X=-1}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#F(){if(!this.#$)return;if(this.#$.open=!0,this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#T(){if(!this.#$)return;this.#$.open=!1}}customElements.define("fig-menu",W1);