@rogieking/figui3 4.8.1 → 4.8.3

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 N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! 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 K=HTMLLIElement,q=function(){return Reflect.construct(K,[],q)};if(q.prototype=J.create(K.prototype),$.define("ungap-li",q,j),!/is="ungap-li"/.test(new q().outerHTML))throw j}catch(_){(function(){var X="attributeChangedCallback",Y="connectedCallback",W="disconnectedCallback",N=Element.prototype,G=J.assign,D=J.create,R=J.defineProperties,L=J.getOwnPropertyDescriptor,B=J.setPrototypeOf,M=$.define,O=$.get,A=$.upgrade,F=$.whenDefined,T=D(null),S=new WeakMap,y={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function z(){}var H=self[U];B(z,H),(z.prototype=H.prototype).constructor=z,H={},H[U]={value:z},R(self,H)}),new MutationObserver(h).observe(Q,y),Y0(Document.prototype,"importNode"),Y0(Node.prototype,"cloneNode"),R($,{define:{value:function(U,z,H){if(U=U.toLowerCase(),H&&Z in H){T[U]=G({},H,{Class:z});var E=H[Z]+'[is="'+U+'"]',P=Q.querySelectorAll(E);for(var C=0,f=P.length;C<f;C++)s(P[C])}else M.apply($,arguments)}},get:{value:function(U){return U in T?T[U].Class:O.call($,U)}},upgrade:{value:function(U){var z=J0(U);if(z&&!(U instanceof z.Class))X0(U,z);else A.call($,U)}},whenDefined:{value:function(U){return U in T?Promise.resolve():F.call($,U)}}});var I=Q.createElement;R(Q,{createElement:{value:function(U,z){var H=I.call(Q,U);if(z&&"is"in z)H.setAttribute("is",z.is),$.upgrade(H);return H}}});var c=L(N,"attachShadow").value,o=L(N,"innerHTML");R(N,{attachShadow:{value:function(){var U=c.apply(this,arguments);return new MutationObserver(h).observe(U,y),U}},innerHTML:{get:o.get,set:function(U){if(o.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))l(this,s)}}});function h(U){for(var z=0,H=U.length;z<H;z++){var E=U[z],P=E.addedNodes,C=E.removedNodes;for(var f=0,t=P.length;f<t;f++)s(P[f]);for(var Z0=0,W1=C.length;Z0<W1;Z0++)v(C[Z0])}}function g(U){for(var z=0,H=U.length;z<H;z++){var E=U[z],P=E.attributeName,C=E.oldValue,f=E.target,t=f.getAttribute(P);if(X in f&&!(C==t&&t==null))f[X](P,C,f.getAttribute(P),null)}}function v(U){if(U.nodeType!==1)return;var z=J0(U);if(z&&U instanceof z.Class&&W in U&&S.get(U)!==W)S.set(U,W),Promise.resolve(U).then(Y1);l(U,v)}function J0(U){var z=U.getAttribute("is");if(z){if(z=z.toLowerCase(),z in T)return T[z]}return null}function X1(U){U[Y]()}function Y1(U){U[W]()}function X0(U,z){var H=z.Class,E=H.observedAttributes||[];if(B(U,H.prototype),E.length){new MutationObserver(g).observe(U,{attributes:!0,attributeFilter:E,attributeOldValue:!0});var P=[];for(var C=0,f=E.length;C<f;C++)P.push({attributeName:E[C],oldValue:null,target:U});g(P)}}function s(U){if(U.nodeType!==1)return;var z=J0(U);if(z){if(!(U instanceof z.Class))X0(U,z);if(Y in U&&U.isConnected&&S.get(U)!==Y)S.set(U,Y),Promise.resolve(U).then(X1)}l(U,s)}function l(U,z){for(var H=U.content,E=(H&&H.nodeType==11?H:U).querySelectorAll("[is]"),P=0,C=E.length;P<C;P++)z(E[P])}function Y0(U,z){var H=U[z],E={};E[z]={value:function(){var P=H.apply(this,arguments);switch(P.nodeType){case 1:case 11:l(P,s)}return P}},R(U,E)}})()}})(document,customElements,Object)});function L1(){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 G1(){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 G0=L1()&&!G1(),M1=(G0?Promise.resolve().then(() => (W0(),U1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function j0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!G0){Z();return}M1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function p(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var B1=1e4;function O1(){return B1++}function x(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var m=null,N0=null;function M0(Q=1,$=1){if(!m)m=document.createElement("canvas"),N0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==$)m.height=$;return{canvas:m,ctx:N0}}class B0 extends HTMLElement{type;#Q;constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button",this.shadowRoot.innerHTML=`
1
+ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! 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 K=HTMLLIElement,q=function(){return Reflect.construct(K,[],q)};if(q.prototype=J.create(K.prototype),$.define("ungap-li",q,j),!/is="ungap-li"/.test(new q().outerHTML))throw j}catch(_){(function(){var X="attributeChangedCallback",Y="connectedCallback",W="disconnectedCallback",N=Element.prototype,G=J.assign,D=J.create,R=J.defineProperties,L=J.getOwnPropertyDescriptor,O=J.setPrototypeOf,M=$.define,B=$.get,A=$.upgrade,F=$.whenDefined,T=D(null),S=new WeakMap,f={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function z(){}var H=self[U];O(z,H),(z.prototype=H.prototype).constructor=z,H={},H[U]={value:z},R(self,H)}),new MutationObserver(h).observe(Q,f),Y0(Document.prototype,"importNode"),Y0(Node.prototype,"cloneNode"),R($,{define:{value:function(U,z,H){if(U=U.toLowerCase(),H&&Z in H){T[U]=G({},H,{Class:z});var E=H[Z]+'[is="'+U+'"]',P=Q.querySelectorAll(E);for(var C=0,y=P.length;C<y;C++)s(P[C])}else M.apply($,arguments)}},get:{value:function(U){return U in T?T[U].Class:B.call($,U)}},upgrade:{value:function(U){var z=J0(U);if(z&&!(U instanceof z.Class))X0(U,z);else A.call($,U)}},whenDefined:{value:function(U){return U in T?Promise.resolve():F.call($,U)}}});var I=Q.createElement;R(Q,{createElement:{value:function(U,z){var H=I.call(Q,U);if(z&&"is"in z)H.setAttribute("is",z.is),$.upgrade(H);return H}}});var c=L(N,"attachShadow").value,o=L(N,"innerHTML");R(N,{attachShadow:{value:function(){var U=c.apply(this,arguments);return new MutationObserver(h).observe(U,f),U}},innerHTML:{get:o.get,set:function(U){if(o.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))l(this,s)}}});function h(U){for(var z=0,H=U.length;z<H;z++){var E=U[z],P=E.addedNodes,C=E.removedNodes;for(var y=0,t=P.length;y<t;y++)s(P[y]);for(var Z0=0,W1=C.length;Z0<W1;Z0++)v(C[Z0])}}function g(U){for(var z=0,H=U.length;z<H;z++){var E=U[z],P=E.attributeName,C=E.oldValue,y=E.target,t=y.getAttribute(P);if(X in y&&!(C==t&&t==null))y[X](P,C,y.getAttribute(P),null)}}function v(U){if(U.nodeType!==1)return;var z=J0(U);if(z&&U instanceof z.Class&&W in U&&S.get(U)!==W)S.set(U,W),Promise.resolve(U).then(Y1);l(U,v)}function J0(U){var z=U.getAttribute("is");if(z){if(z=z.toLowerCase(),z in T)return T[z]}return null}function X1(U){U[Y]()}function Y1(U){U[W]()}function X0(U,z){var H=z.Class,E=H.observedAttributes||[];if(O(U,H.prototype),E.length){new MutationObserver(g).observe(U,{attributes:!0,attributeFilter:E,attributeOldValue:!0});var P=[];for(var C=0,y=E.length;C<y;C++)P.push({attributeName:E[C],oldValue:null,target:U});g(P)}}function s(U){if(U.nodeType!==1)return;var z=J0(U);if(z){if(!(U instanceof z.Class))X0(U,z);if(Y in U&&U.isConnected&&S.get(U)!==Y)S.set(U,Y),Promise.resolve(U).then(X1)}l(U,s)}function l(U,z){for(var H=U.content,E=(H&&H.nodeType==11?H:U).querySelectorAll("[is]"),P=0,C=E.length;P<C;P++)z(E[P])}function Y0(U,z){var H=U[z],E={};E[z]={value:function(){var P=H.apply(this,arguments);switch(P.nodeType){case 1:case 11:l(P,s)}return P}},R(U,E)}})()}})(document,customElements,Object)});function L1(){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 G1(){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 G0=L1()&&!G1(),M1=(G0?Promise.resolve().then(() => (W0(),U1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function j0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!G0){Z();return}M1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function u(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var O1=1e4;function B1(){return O1++}function x(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var m=null,N0=null;function M0(Q=1,$=1){if(!m)m=document.createElement("canvas"),N0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==$)m.height=$;return{canvas:m,ctx:N0}}class O0 extends HTMLElement{type;#Q;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 N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
32
32
  <button type="${this.type}">
33
33
  <slot></slot>
34
34
  </button>
35
- `,this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#$.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.#Q}set selected(Q){this.setAttribute("selected",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.#Q=J==="true";break}}}customElements.define("fig-button",B0);class O0 extends HTMLElement{#Q="Menu";#$=null;#J;#K;#Z=!1;#j=null;get label(){return this.#Q}set label(Q){this.#Q=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#L.bind(this),this.#K=this.#G.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}}#q(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#Z=!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.#Z=!0,this.#j=Z}#N(){if(!this.#j)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#j.textContent="";return}this.#j.innerHTML=Q.innerHTML}#U(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#K)}#W(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.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#U()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#q(),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.#M(this.value),this.#N(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){let $=Q.target.selectedOptions?.[0];if(this.#W($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=Q.target.value;if(this.type==="dropdown")this.#$=J;this.setAttribute("value",J),this.#N(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#G(Q){let $=Q.target.selectedOptions?.[0];if(this.#W($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=this.type==="dropdown"?this.#$:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N(),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.#$;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#$=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#M(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.#N()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#M(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#Q=J,this.select.setAttribute("aria-label",this.#Q)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#K)}}customElements.define("fig-dropdown",O0);class k extends HTMLElement{static#Q=0;static#$=500;#J;#K;#Z;#j;#_;#X;#q;#N;#U;#W=null;#Y;#L=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#D.bind(this),this.#K=this.hidePopupOutsideClick.bind(this),this.#Z=this.showDelayedPopup.bind(this),this.#j=this.#M.bind(this),this.#_=this.#B.bind(this),this.#X=this.#A.bind(this),this.#q=this.#O.bind(this),this.#N=this.#R.bind(this),this.#U=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#W=this.closest("dialog"),this.#W)this.#W.addEventListener("close",this.#U)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#W)this.#W.removeEventListener("close",this.#U),this.#W=null;if(this.action==="click")document.body.removeEventListener("click",this.#K);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#Z),this.removeEventListener("pointerleave",this.#j),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#q),this.removeEventListener("touchcancel",this.#N);else if(this.action==="click")this.removeEventListener("click",this.#Z),this.removeEventListener("touchstart",this.#Z)}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=p();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 K=this.closest("dialog");if(K&&K.open)K.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.#K)}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.#Z),this.addEventListener("pointerleave",this.#j);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#q,{passive:!0}),this.addEventListener("touchcancel",this.#N,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#Z),document.body.addEventListener("click",this.#K),this.addEventListener("touchstart",this.#Z,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}get#G(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#G)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-k.#Q<k.#$?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#W&&!this.#W.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,k.#Q=Date.now()}hidePopup(){if(this.#G)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.popup)this.destroy();this.isOpen=!1,k.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#M(Q){if(!this.#L)this.hidePopup()}#B(Q){if(this.action==="hover")this.#L=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#A(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#L=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#L=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#L)this.#L=!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)}#z(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.#z(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")}}#D(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={}){k.hide(Q);let Z=J.delay??500,K=Date.now()-k.#Q<k.#$?0:Z,q={timeout:null,popup:null};k.#H.set(Q,q),q.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 W=Q.closest?.("dialog");if(W&&W.open)W.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,q.popup=X,k.#Q=Date.now()},K)}static hide(Q){let $=k.#H.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();k.#H.delete(Q)}}customElements.define("fig-tooltip",k);class A0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#$=null;#J=null;connectedCallback(){this.#Q=this.textContent,requestAnimationFrame(()=>{this.#K(),this.#Z()})}disconnectedCallback(){this.#j()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#Q===null)return;this.#K()}#K(){let Q=this.getAttribute("position")||"right",$=this.#Q||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let q=$.lastIndexOf(J);Z=q>0?q: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 K=document.createElement("span");K.className="end",K.textContent=$.slice(Z),this.appendChild(j),this.appendChild(K)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#$=()=>{if(this.scrollWidth<=this.clientWidth)return;k.show(this,this.#Q)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#$),this.addEventListener("pointerleave",this.#J)}#j(){if(this.#$)this.removeEventListener("pointerenter",this.#$);if(this.#J)this.removeEventListener("pointerleave",this.#J);k.hide(this)}}customElements.define("fig-truncate",A0);class R0 extends HTMLDialogElement{#Q=!1;#$=!1;#J={x:0,y:0};#K={x:0,y:0};#Z;#j;#_;#X;#q;#N;#U;#W=null;#Y=null;#L=0;#G=16;#M=!1;#B=3;static get observedAttributes(){return["autoresize"]}constructor(){super();this.#Z=this.#I.bind(this),this.#j=this.#y.bind(this),this.#_=this.#x.bind(this),this.#X=this.close.bind(this),this.#q=this.#A.bind(this),this.#N=this.#D.bind(this),this.#U=this.#D.bind(this)}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.#V(),requestAnimationFrame(()=>{this.#k(),this.#C(),this.#T(),this.#O()}),window.addEventListener("message",this.#q)}disconnectedCallback(){this.#w(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this.#X)}),window.removeEventListener("message",this.#q),this.#z()}attributeChangedCallback(Q){if(Q==="autoresize"&&this.isConnected)this.#O()}#A(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.#P(Z,$)}#O(){if(this.autoresize)this.#R(),this.#D();else this.#z()}#R(){if(!this.#W){this.#W=new ResizeObserver(this.#U);for(let Q of this.children)try{this.#W.observe(Q)}catch{}}if(!this.#Y)this.#Y=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this.#W?.observe(J)}catch{}});this.#D()}),this.#Y.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}#z(){if(this.#W)this.#W.disconnect(),this.#W=null;if(this.#Y)this.#Y.disconnect(),this.#Y=null;if(this.#L)cancelAnimationFrame(this.#L),this.#L=0}#D(){if(!this.autoresize)return;if(this.#L)return;this.#L=requestAnimationFrame(()=>{this.#L=0,this.#H()})}#H(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this.#S(null)}#F(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,K=0;for(let q of this.children){let _=q.getBoundingClientRect();if(_.height===0)continue;if(K+=1,q===Q)continue;let X=window.getComputedStyle(q),Y=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");Z+=_.height+Y}if(j&&K>1)Z+=j*(K-1);return J+Z}#P(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this.#F(Q);this.style.height=`${Math.ceil($.height+J)}px`}#S(){if(this.style.height)this.style.height=""}#V(){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","");let j=document.createElement("span");j.className="fig-mask-icon",j.style.setProperty("--icon","var(--icon-close)"),Z.appendChild(j),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}#k(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this.#X),Q.addEventListener("click",this.#X)})}#T(){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"),K=Q.includes("center")&&!$&&!J,q=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this.#G}px`;else if(J)this.style.bottom=`${this.#G}px`;else if(K)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this.#G}px`;else if(j)this.style.right=`${this.#G}px`;else if(q)this.style.left="0",this.style.right="0";if(K&&q)this.style.margin="auto";else if(K)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this.#M=!0}#C(){if(this.drag){this.addEventListener("pointerdown",this.#Z);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}#w(){this.removeEventListener("pointerdown",this.#Z),document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#_)}#E(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=(K)=>$.some((q)=>K.matches?.(q))||K.tagName?.startsWith("FIG-")&&!J.includes(K.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}#I(Q){if(!this.drag)return;if(this.#E(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this.#$=!0,this.#J.x=Q.clientX,this.#J.y=Q.clientY;let J=this.getBoundingClientRect();this.#K.x=Q.clientX-J.left,this.#K.y=Q.clientY-J.top,document.addEventListener("pointermove",this.#j),document.addEventListener("pointerup",this.#_)}#y(Q){if(this.#$&&!this.#Q){let $=Math.abs(Q.clientX-this.#J.x),J=Math.abs(Q.clientY-this.#J.y);if($>this.#B||J>this.#B){this.#Q=!0,this.#$=!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.#Q)return;this.style.left=`${Q.clientX-this.#K.x}px`,this.style.top=`${Q.clientY-this.#K.y}px`,Q.preventDefault()}#x(Q){if(this.#Q)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this.#Q=!1,this.#$=!1,document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#_),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby"]}attributeChangedCallback(Q,$,J){if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this.#C();else{this.#w();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this.#M)this.#T();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 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(O1()+1);let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open");if(Q)try{this.showPopover()}catch(J){}if(!Q&&!super.open)try{this.show()}catch(J){}this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($)$.classList.add("has-popup-open")}hidePopup(){let Q=this.resolveAnchor();if(Q)Q.classList.remove("has-popup-open");if(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(super.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&&"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&&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=(K)=>$.some((q)=>K.matches?.(q))||K.tagName?.startsWith("FIG-")&&!J.includes(K.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",K="center",q=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))K=$[1];return{vertical:j,horizontal:K,shorthand:q}}if($.length===1){let _=$[0];if(_==="top"||_==="bottom")j=_,q=_;else if(_==="left"||_==="right")K=_,q=_;else if(_==="center")j="center",K="center"}return{vertical:j,horizontal:K,shorthand:q}}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 K=parseFloat(J);return Number.isFinite(K)?K: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 K=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:K[0]},{v:Q,h:$,s:K[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,K){let q,_;if(K==="left"||K==="right")return _=K==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:_};if(K==="top"||K==="bottom")return q=K==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,_=Q.left,{top:q,left:_};if(J==="top")q=Q.top-$.height-j.yPx;else if(J==="bottom")q=Q.bottom+j.yPx;else q=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:q,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 K=this.getAttribute("variant");if(!(K==="popover"||K==="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,W=this.getBoundingClientRect(),N=W.width>0&&W.height>0?W:$,G=N.left,D=N.top,R=10,L;if(_==="top"||_==="bottom"){L=X-G;let B=R,M=Math.max(B,N.width-R);L=Math.min(M,Math.max(B,L))}else{L=Y-D;let B=R,M=Math.max(B,N.height-R);L=Math.min(M,Math.max(B,L))}this.style.setProperty("--fig-popup-beak-offset",`${L}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,K=Q.left+$.width,q=Q.top+$.height,_=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,K-(Z-J.right)),W=Math.max(0,q-(j-J.bottom));return _+X+Y+W}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,K=Math.max(J.left,window.innerWidth-$.width-J.right),q=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(K,Math.max(Z,Q.left)),top:Math.min(q,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!super.open)return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),K=this.resolveAnchor(),q=this.parseViewportMargins();if(!K){this.updatePopoverBeak(null,Q,0,0,"top");let D={left:q.left+(window.innerWidth-q.right-q.left-Q.width)/2,top:q.top+(window.innerHeight-q.bottom-q.top-Q.height)/2},R=this.clamp(D,Q,q);this.style.left=`${R.left}px`,this.style.top=`${R.top}px`;return}let _=K.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j),Y=null,W="top",N=Number.POSITIVE_INFINITY;for(let{v:D,h:R,s:L}of X){let B=this.computeCoords(_,Q,D,R,$,L),M=this.getPlacementSide(D,R,L);if(L){let O=this.clamp(B,Q,q);if(L==="left"||L==="right"?B.left>=q.left&&B.left+Q.width<=window.innerWidth-q.right:B.top>=q.top&&B.top+Q.height<=window.innerHeight-q.bottom){this.style.left=`${O.left}px`,this.style.top=`${O.top}px`,this.updatePopoverBeak(_,Q,O.left,O.top,M);return}let F=this.overflowScore(B,Q,q);if(F<N)N=F,Y=O,W=M}else{if(this.fits(B,Q,q)){this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(_,Q,B.left,B.top,M);return}let O=this.overflowScore(B,Q,q);if(O<N)N=O,Y=B,W=M}}let G=this.clamp(Y||{left:0,top:0},Q,q);this.style.left=`${G.left}px`,this.style.top=`${G.top}px`,this.updatePopoverBeak(_,Q,G.left,G.top,W)}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.#Q=!1,this.#$=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#$),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#Q)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.#Q}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#$)}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.#Q=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this?.content)this.content.style.display=this.#Q?"block":"none"}}}customElements.define("fig-tab",D0);class F0 extends HTMLElement{#Q;#$;constructor(){super();this.#Q=this.handleClick.bind(this),this.#$=this.#K.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#Z(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.#Q),this.removeEventListener("keydown",this.#$)}#K(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((K)=>K.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)}#Z(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.#Z(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",F0);class H0 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.#Q}set value(Q){this.#Q=Q,this.setAttribute("value",Q)}get selected(){return this.#$}set selected(Q){this.#$=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#Q=J;break;case"selected":this.#$=J;break}}}customElements.define("fig-segment",H0);class P0 extends HTMLElement{#Q=null;#$=this.handleClick.bind(this);#J=null;#K=null;#Z=0;#j=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#$),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#G(),requestAnimationFrame(()=>{this.#B({enforceFallback:!0}),this.#M(),this.#Y({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#$),this.#J?.disconnect(),this.#J=null,this.#K?.disconnect(),this.#K=null,this.#Z)cancelAnimationFrame(this.#Z),this.#Z=0;this.#j=!1,this.#_=!1}get selectedSegment(){return this.#Q}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=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}))}#q(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#N(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#U(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#q(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#W(){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.#j=this.#j||Q,this.#Z)return;this.#Z=requestAnimationFrame(()=>{this.#Z=0;let $=this.#j;this.#j=!1,this.#L({forceInstant:$})})}#L({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#W(),Z=this.#Q&&this.contains(this.#Q)?this.#Q:this.#N();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(),K=Z.getBoundingClientRect();if(j.width<=0||K.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 q=Math.max(0,K.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${K.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}#G(){this.#K?.disconnect(),this.#K=new ResizeObserver(()=>{this.#Y()}),this.#M()}#M(){if(!this.#K)return;this.#K.disconnect(),this.#K.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#K?.observe(Q)})}#B({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#Q=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.#U(Z))return}let j=this.#N();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#A(){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.#M(),this.#B({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.#q($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");let K=this.value;if(J!==$||Z!==K)this.#X(K)}#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.#B({enforceFallback:!1});return}if(Q==="animated"){if(!this.#W())this.#_=!1;this.#Y({forceInstant:!0});return}if(Q==="sizing")this.#Y({forceInstant:!0})}}customElements.define("fig-segmented-control",P0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#$=0;#J=null;#K=[];#Z=null;#j=!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.#q(),this.#L(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#B())})}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.#K.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.#U();return}if(Q==="value"){this.#W();return}if(Q==="disabled"){this.#Y("disabled");return}if(Q==="full"){this.#Y("full");return}if(Q==="sizing")this.#Y("sizing"),this.#U()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#K=JSON.parse(Q);return}catch{}let $=Q.includes(`
35
+ `,this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#$.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.#Q}set selected(Q){this.setAttribute("selected",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.#Q=J==="true";break}}}customElements.define("fig-button",O0);class B0 extends HTMLElement{#Q="Menu";#$=null;#J;#K;#Z=!1;#j=null;get label(){return this.#Q}set label(Q){this.#Q=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#L.bind(this),this.#K=this.#G.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}}#q(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#Z=!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.#Z=!0,this.#j=Z}#W(){if(!this.#j)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#j.textContent="";return}this.#j.innerHTML=Q.innerHTML}#N(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#K)}#U(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.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),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.#q(),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.#M(this.value),this.#W(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){let $=Q.target.selectedOptions?.[0];if(this.#U($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=Q.target.value;if(this.type==="dropdown")this.#$=J;this.setAttribute("value",J),this.#W(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#G(Q){let $=Q.target.selectedOptions?.[0];if(this.#U($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=this.type==="dropdown"?this.#$:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W(),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.#$;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#$=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#M(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.#W()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#M(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#Q=J,this.select.setAttribute("aria-label",this.#Q)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#K)}}customElements.define("fig-dropdown",B0);class k extends HTMLElement{static#Q=0;static#$=500;#J;#K;#Z;#j;#_;#X;#q;#W;#N;#U=null;#Y;#L=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#F.bind(this),this.#K=this.hidePopupOutsideClick.bind(this),this.#Z=this.showDelayedPopup.bind(this),this.#j=this.#M.bind(this),this.#_=this.#O.bind(this),this.#X=this.#B.bind(this),this.#q=this.#A.bind(this),this.#W=this.#R.bind(this),this.#N=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#U=this.closest("dialog"),this.#U)this.#U.addEventListener("close",this.#N)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#U)this.#U.removeEventListener("close",this.#N),this.#U=null;if(this.action==="click")document.body.removeEventListener("click",this.#K);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#Z),this.removeEventListener("pointerleave",this.#j),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#q),this.removeEventListener("touchcancel",this.#W);else if(this.action==="click")this.removeEventListener("click",this.#Z),this.removeEventListener("touchstart",this.#Z)}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=u();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 K=this.closest("dialog");if(K&&K.open)K.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.#K)}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.#Z),this.addEventListener("pointerleave",this.#j);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#q,{passive:!0}),this.addEventListener("touchcancel",this.#W,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#Z),document.body.addEventListener("click",this.#K),this.addEventListener("touchstart",this.#Z,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}get#G(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#G)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-k.#Q<k.#$?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#U&&!this.#U.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,k.#Q=Date.now()}hidePopup(){if(this.#G)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.popup)this.destroy();this.isOpen=!1,k.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#M(Q){if(!this.#L)this.hidePopup()}#O(Q){if(this.action==="hover")this.#L=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#B(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#L=!1,this.hidePopup()},150)}#A(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#L=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#L)this.#L=!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)}#z(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.#z(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")}}#F(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={}){k.hide(Q);let Z=J.delay??500,K=Date.now()-k.#Q<k.#$?0:Z,q={timeout:null,popup:null};k.#H.set(Q,q),q.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 W=Q.closest?.("dialog");if(W&&W.open)W.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,q.popup=X,k.#Q=Date.now()},K)}static hide(Q){let $=k.#H.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();k.#H.delete(Q)}}customElements.define("fig-tooltip",k);class A0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#$=null;#J=null;connectedCallback(){this.#Q=this.textContent,requestAnimationFrame(()=>{this.#K(),this.#Z()})}disconnectedCallback(){this.#j()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#Q===null)return;this.#K()}#K(){let Q=this.getAttribute("position")||"right",$=this.#Q||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let q=$.lastIndexOf(J);Z=q>0?q: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 K=document.createElement("span");K.className="end",K.textContent=$.slice(Z),this.appendChild(j),this.appendChild(K)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#$=()=>{if(this.scrollWidth<=this.clientWidth)return;k.show(this,this.#Q)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#$),this.addEventListener("pointerleave",this.#J)}#j(){if(this.#$)this.removeEventListener("pointerenter",this.#$);if(this.#J)this.removeEventListener("pointerleave",this.#J);k.hide(this)}}customElements.define("fig-truncate",A0);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,K=0;for(let q of this.children){let _=q.getBoundingClientRect();if(_.height===0)continue;if(K+=1,q===Q)continue;let X=window.getComputedStyle(q),Y=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");Z+=_.height+Y}if(j&&K>1)Z+=j*(K-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","");let j=document.createElement("span");j.className="fig-mask-icon",j.style.setProperty("--icon","var(--icon-close)"),Z.appendChild(j),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"),K=Q.includes("center")&&!$&&!J,q=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(K)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(q)this.style.left="0",this.style.right="0";if(K&&q)this.style.margin="auto";else if(K)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)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=(K)=>$.some((q)=>K.matches?.(q))||K.tagName?.startsWith("FIG-")&&!J.includes(K.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 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(B1()+1);let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open");if(Q)try{this.showPopover()}catch(J){}if(!Q&&!super.open)try{this.show()}catch(J){}this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($)$.classList.add("has-popup-open")}hidePopup(){let Q=this.resolveAnchor();if(Q)Q.classList.remove("has-popup-open");if(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(super.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&&"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&&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=(K)=>$.some((q)=>K.matches?.(q))||K.tagName?.startsWith("FIG-")&&!J.includes(K.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",K="center",q=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))K=$[1];return{vertical:j,horizontal:K,shorthand:q}}if($.length===1){let _=$[0];if(_==="top"||_==="bottom")j=_,q=_;else if(_==="left"||_==="right")K=_,q=_;else if(_==="center")j="center",K="center"}return{vertical:j,horizontal:K,shorthand:q}}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 K=parseFloat(J);return Number.isFinite(K)?K: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 K=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:K[0]},{v:Q,h:$,s:K[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,K){let q,_;if(K==="left"||K==="right")return _=K==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:_};if(K==="top"||K==="bottom")return q=K==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,_=Q.left,{top:q,left:_};if(J==="top")q=Q.top-$.height-j.yPx;else if(J==="bottom")q=Q.bottom+j.yPx;else q=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:q,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 K=this.getAttribute("variant");if(!(K==="popover"||K==="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,W=this.getBoundingClientRect(),N=W.width>0&&W.height>0?W:$,G=N.left,D=N.top,R=10,L;if(_==="top"||_==="bottom"){L=X-G;let O=R,M=Math.max(O,N.width-R);L=Math.min(M,Math.max(O,L))}else{L=Y-D;let O=R,M=Math.max(O,N.height-R);L=Math.min(M,Math.max(O,L))}this.style.setProperty("--fig-popup-beak-offset",`${L}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,K=Q.left+$.width,q=Q.top+$.height,_=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,K-(Z-J.right)),W=Math.max(0,q-(j-J.bottom));return _+X+Y+W}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,K=Math.max(J.left,window.innerWidth-$.width-J.right),q=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(K,Math.max(Z,Q.left)),top:Math.min(q,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!super.open)return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),K=this.resolveAnchor(),q=this.parseViewportMargins();if(!K){this.updatePopoverBeak(null,Q,0,0,"top");let D={left:q.left+(window.innerWidth-q.right-q.left-Q.width)/2,top:q.top+(window.innerHeight-q.bottom-q.top-Q.height)/2},R=this.clamp(D,Q,q);this.style.left=`${R.left}px`,this.style.top=`${R.top}px`;return}let _=K.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j),Y=null,W="top",N=Number.POSITIVE_INFINITY;for(let{v:D,h:R,s:L}of X){let O=this.computeCoords(_,Q,D,R,$,L),M=this.getPlacementSide(D,R,L);if(L){let B=this.clamp(O,Q,q);if(L==="left"||L==="right"?O.left>=q.left&&O.left+Q.width<=window.innerWidth-q.right:O.top>=q.top&&O.top+Q.height<=window.innerHeight-q.bottom){this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(_,Q,B.left,B.top,M);return}let F=this.overflowScore(O,Q,q);if(F<N)N=F,Y=B,W=M}else{if(this.fits(O,Q,q)){this.style.left=`${O.left}px`,this.style.top=`${O.top}px`,this.updatePopoverBeak(_,Q,O.left,O.top,M);return}let B=this.overflowScore(O,Q,q);if(B<N)N=B,Y=O,W=M}}let G=this.clamp(Y||{left:0,top:0},Q,q);this.style.left=`${G.left}px`,this.style.top=`${G.top}px`,this.updatePopoverBeak(_,Q,G.left,G.top,W)}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.#Q=!1,this.#$=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#$),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#Q)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.#Q}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#$)}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.#Q=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this?.content)this.content.style.display=this.#Q?"block":"none"}}}customElements.define("fig-tab",D0);class F0 extends HTMLElement{#Q;#$;constructor(){super();this.#Q=this.handleClick.bind(this),this.#$=this.#K.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#Z(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.#Q),this.removeEventListener("keydown",this.#$)}#K(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((K)=>K.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)}#Z(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.#Z(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",F0);class H0 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.#Q}set value(Q){this.#Q=Q,this.setAttribute("value",Q)}get selected(){return this.#$}set selected(Q){this.#$=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#Q=J;break;case"selected":this.#$=J;break}}}customElements.define("fig-segment",H0);class P0 extends HTMLElement{#Q=null;#$=this.handleClick.bind(this);#J=null;#K=null;#Z=0;#j=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#$),this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#B(),this.#G(),requestAnimationFrame(()=>{this.#O({enforceFallback:!0}),this.#M(),this.#Y({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#$),this.#J?.disconnect(),this.#J=null,this.#K?.disconnect(),this.#K=null,this.#Z)cancelAnimationFrame(this.#Z),this.#Z=0;this.#j=!1,this.#_=!1}get selectedSegment(){return this.#Q}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=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}))}#q(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#W(){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.#q(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#U(){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.#j=this.#j||Q,this.#Z)return;this.#Z=requestAnimationFrame(()=>{this.#Z=0;let $=this.#j;this.#j=!1,this.#L({forceInstant:$})})}#L({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#U(),Z=this.#Q&&this.contains(this.#Q)?this.#Q:this.#W();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(),K=Z.getBoundingClientRect();if(j.width<=0||K.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 q=Math.max(0,K.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${K.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}#G(){this.#K?.disconnect(),this.#K=new ResizeObserver(()=>{this.#Y()}),this.#M()}#M(){if(!this.#K)return;this.#K.disconnect(),this.#K.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#K?.observe(Q)})}#O({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#Q=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.#W();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#B(){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.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#M(),this.#O({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.#q($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");let K=this.value;if(J!==$||Z!==K)this.#X(K)}#A(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.#A(J!==null&&J!=="false"),this.#Y({forceInstant:!0});return}if(Q==="value"){this.#O({enforceFallback:!1});return}if(Q==="animated"){if(!this.#U())this.#_=!1;this.#Y({forceInstant:!0});return}if(Q==="sizing")this.#Y({forceInstant:!0})}}customElements.define("fig-segmented-control",P0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#$=0;#J=null;#K=[];#Z=null;#j=!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.#q(),this.#L(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#O())})}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.#K.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.#U();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.#K=JSON.parse(Q);return}catch{}let $=Q.includes(`
36
36
  `)?`
37
- `:",";this.#K=Q.split($).map((J)=>J.trim()).filter(Boolean)}#q(){if(this.innerHTML="",this.#K.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.#K){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.#j)return;let Z=this.#_(J);if(Z===null)return;this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#j)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#Q="segments"}#N(){if(this.innerHTML="",this.#K.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.#K){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.#j)return;let Z=this.#_(J);if(!Z)return;this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#j)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#Q="dropdown"}#U(){if(this.#Q==="segments")this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#B())});else this.#N()}#W(){if(!this.#Z||this.#j)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#Y(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#L(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#B()}),this.#J.observe(this)}#G(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,K=getComputedStyle(Q),q=parseFloat(K.paddingLeft)||0,_=parseFloat(K.paddingRight)||0,X=j-q-_;return J>X+0.5}#M(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#G($))return!0;return!1}#B(){if(this.#K.length<=1)return;if(this.#Q==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#$=this.clientWidth,this.#N()}else if(this.#$>0&&this.clientWidth>=this.#$)this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#N()})})}}customElements.define("fig-options",E0);class k0 extends HTMLElement{#Q=!1;#$=!1;#J={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"}};#K;#Z;#j;#_;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#K=(Q)=>{Q.stopPropagation(),this.#A()},this.#Z=(Q)=>{Q.stopPropagation(),this.#O()},this.#j=(Q)=>{Q.stopPropagation(),this.#q()},this.#_=(Q)=>{Q.stopPropagation(),this.#R()}}#X(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.hasAttribute("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.#J[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===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#G(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
37
+ `:",";this.#K=Q.split($).map((J)=>J.trim()).filter(Boolean)}#q(){if(this.innerHTML="",this.#K.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.#K){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.#j)return;let Z=this.#_(J);if(Z===null)return;this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#j)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#Q="segments"}#W(){if(this.innerHTML="",this.#K.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.#K){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.#j)return;let Z=this.#_(J);if(!Z)return;this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#j)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#Q="dropdown"}#N(){if(this.#Q==="segments")this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#O())});else this.#W()}#U(){if(!this.#Z||this.#j)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#Y(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#L(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#O()}),this.#J.observe(this)}#G(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,K=getComputedStyle(Q),q=parseFloat(K.paddingLeft)||0,_=parseFloat(K.paddingRight)||0,X=j-q-_;return J>X+0.5}#M(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#G($))return!0;return!1}#O(){if(this.#K.length<=1)return;if(this.#Q==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#$=this.clientWidth,this.#W()}else if(this.#$>0&&this.clientWidth>=this.#$)this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#W()})})}}customElements.define("fig-options",E0);class k0 extends HTMLElement{#Q=!1;#$=!1;#J={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"}};#K;#Z;#j;#_;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#K=(Q)=>{Q.stopPropagation(),this.#B()},this.#Z=(Q)=>{Q.stopPropagation(),this.#A()},this.#j=(Q)=>{Q.stopPropagation(),this.#q()},this.#_=(Q)=>{Q.stopPropagation(),this.#R()}}#X(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.hasAttribute("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.#J[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===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#G(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 N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
58
58
  value="${this.#$?"":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.#K),this.input.addEventListener("input",this.#K),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.addEventListener("pointerdown",()=>{this.#Q=!0}),this.input.addEventListener("pointerup",()=>{this.#Q=!1}),this.default)this.style.setProperty("--default",this.#N(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")||p()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",p());let j=(this.max-this.min)/this.step+1;for(let K=0;K<j;K++){let q=document.createElement("option");q.setAttribute("value",this.min+K*this.step),this.datalist.append(q)}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",p());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.#j),this.figInputNumber.addEventListener("input",this.#j),this.figInputNumber.removeEventListener("change",this.#_),this.figInputNumber.addEventListener("change",this.#_);this.#B()})}connectedCallback(){this.#X()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#K),this.input.removeEventListener("change",this.#Z);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#j),this.figInputNumber.removeEventListener("change",this.#_)}#q(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#G(Q);this.value=$,this.input.value=String($),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#N(Q){let{min:$,max:J}=this.#W(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#U(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.#U(this.min),$=this.#U(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#Y(Q){let{min:$,max:J}=this.#W();return Math.min(J,Math.max($,Q))}#L(){if(this.type==="delta"){let $=this.#U(this.default);if($!==null)return this.#Y($);return this.#Y(0)}let{min:Q}=this.#W();return Q}#G(Q){let $=this.#U(Q);if($===null)return this.#L();return this.#Y($)}#M(){let Q=this.#N(this.value);this.style.setProperty("--slider-complete",Q);let $=this.#N(this.default);this.style.setProperty("--default",$),this.style.setProperty("--unchanged",Q===$?1:0)}#B(){let Q=this.input.value;if(this.value=Q,this.#M(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":Q)}#A(){this.#$=!1,this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#O(){this.#Q=!1,this.#$=!1,this.#B(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#R(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#G(Q);this.value=$,this.input.value=String($),this.#B(),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(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.#Q)break;if(this.#$=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#G(J),this.input.value=String(this.value),this.#B(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":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.#M();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#X();break;case"text":this.text=J!==null&&J!=="false",this.#X();break;default:this[Q]=this.input[Q]=J,this.#B();break}}}customElements.define("fig-slider",k0);class T0 extends HTMLElement{#Q=!1;#$;#J;#K;#Z;#j;constructor(){super();this.#$=this.#q.bind(this),this.#J=this.#U.bind(this),this.#K=this.#U.bind(this),this.#Z=this.#N.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#X(Q)}}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.#K),this.input.addEventListener("input",this.#K),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.addEventListener("pointerdown",()=>{this.#Q=!0}),this.input.addEventListener("pointerup",()=>{this.#Q=!1}),this.default)this.style.setProperty("--default",this.#W(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")||u()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",u());let j=(this.max-this.min)/this.step+1;for(let K=0;K<j;K++){let q=document.createElement("option");q.setAttribute("value",this.min+K*this.step),this.datalist.append(q)}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",u());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.#j),this.figInputNumber.addEventListener("input",this.#j),this.figInputNumber.removeEventListener("change",this.#_),this.figInputNumber.addEventListener("change",this.#_);this.#O()})}connectedCallback(){this.#X()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#K),this.input.removeEventListener("change",this.#Z);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#j),this.figInputNumber.removeEventListener("change",this.#_)}#q(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#G(Q);this.value=$,this.input.value=String($),this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#W(Q){let{min:$,max:J}=this.#U(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#N(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#U(){let Q=this.#N(this.min),$=this.#N(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#Y(Q){let{min:$,max:J}=this.#U();return Math.min(J,Math.max($,Q))}#L(){if(this.type==="delta"){let $=this.#N(this.default);if($!==null)return this.#Y($);return this.#Y(0)}let{min:Q}=this.#U();return Q}#G(Q){let $=this.#N(Q);if($===null)return this.#L();return this.#Y($)}#M(){let Q=this.#W(this.value);this.style.setProperty("--slider-complete",Q);let $=this.#W(this.default);this.style.setProperty("--default",$),this.style.setProperty("--unchanged",Q===$?1:0)}#O(){let Q=this.input.value;if(this.value=Q,this.#M(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":Q)}#B(){this.#$=!1,this.#O(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#A(){this.#Q=!1,this.#$=!1,this.#O(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#R(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#G(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(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.#Q)break;if(this.#$=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#G(J),this.input.value=String(this.value),this.#O(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":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.#M();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#X();break;case"text":this.text=J!==null&&J!=="false",this.#X();break;default:this[Q]=this.input[Q]=J,this.#O();break}}}customElements.define("fig-slider",k0);class T0 extends HTMLElement{#Q=!1;#$;#J;#K;#Z;#j;constructor(){super();this.#$=this.#q.bind(this),this.#J=this.#N.bind(this),this.#K=this.#N.bind(this),this.#Z=this.#W.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#X(Q)}}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
65
  value="${this.type==="number"?this.#_(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.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#_(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#_(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#_(this.step));this.addEventListener("pointerdown",this.#Z)}this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#K)}focus(){this.input.focus()}#_(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#Y($),$}#X(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#W($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#q(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#U();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#W(J,!1);let Z=J*(this.transform||1);J=this.#Y(J),Z=this.#Y(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}))}#N(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Q=!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.#J),window.addEventListener("blur",this.#K)}#U(Q){if(this.type!=="number")return;this.#Q=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#K)}#W(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#_(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#_(this.max):this.max,J);J=this.#Y(J)}return J}#Y(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.#_(this.value);break;case"value":if(this.#Q)break;let Z=J;if(this.type==="number")Z=this.#W(Z,!1),this.value=Z,this.input.value=this.#_(Z);else this.value=Z,this.input.value=Z;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;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",T0);class a extends HTMLElement{#Q;#$;#J;#K;#Z;#j;#_;#X;#q;#N;#U;#W;#Y;#L;#G=!1;#M=null;static#B="px";#A(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#O(Q){let $=(Q||"").trim();if(!$)return"";return(this.#W??[]).includes($.toLowerCase())?"":$}#R(){this.#N=this.#O(this.#U)}#z(Q){if(Q&&!this.#M)this.#M=document.createElement("span"),this.#M.className="fig-steppers",this.#M.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#M.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#D(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null}#D(Q){let $=this.step||1,J=this.#H(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#y(Z,!1),this.value=Z,this.input.value=this.#F(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Q=this.#w.bind(this),this.#$=this.#I.bind(this),this.#J=this.#I.bind(this),this.#K=this.#E.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#C(Q)},this.#j=(Q)=>{Q.stopPropagation(),this.#T(Q)},this.#_=(Q)=>{this.#S(Q)},this.#X=(Q)=>{this.#V(Q)},this.#q=(Q)=>{this.#k(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.#U=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#W=this.#A($===null?a.#B:$),this.#R(),this.#Y=this.getAttribute("unit-position")||"suffix",this.#L=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
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.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#_(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#_(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#_(this.step));this.addEventListener("pointerdown",this.#Z)}this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#K)}focus(){this.input.focus()}#_(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#Y($),$}#X(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#U($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#q(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#N();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#U(J,!1);let Z=J*(this.transform||1);J=this.#Y(J),Z=this.#Y(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}))}#W(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Q=!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.#J),window.addEventListener("blur",this.#K)}#N(Q){if(this.type!=="number")return;this.#Q=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#K)}#U(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#_(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#_(this.max):this.max,J);J=this.#Y(J)}return J}#Y(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.#_(this.value);break;case"value":if(this.#Q)break;let Z=J;if(this.type==="number")Z=this.#U(Z,!1),this.value=Z,this.input.value=this.#_(Z);else this.value=Z,this.input.value=Z;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;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",T0);class a extends HTMLElement{#Q;#$;#J;#K;#Z;#j;#_;#X;#q;#W;#N;#U;#Y;#L;#G=!1;#M=null;static#O="px";#B(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#A(Q){let $=(Q||"").trim();if(!$)return"";return(this.#U??[]).includes($.toLowerCase())?"":$}#R(){this.#W=this.#A(this.#N)}#z(Q){if(Q&&!this.#M)this.#M=document.createElement("span"),this.#M.className="fig-steppers",this.#M.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#M.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#F(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null}#F(Q){let $=this.step||1,J=this.#H(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#C(Z,!1),this.value=Z,this.input.value=this.#D(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Q=this.#w.bind(this),this.#$=this.#y.bind(this),this.#J=this.#y.bind(this),this.#K=this.#E.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#I(Q)},this.#j=(Q)=>{Q.stopPropagation(),this.#T(Q)},this.#_=(Q)=>{this.#S(Q)},this.#X=(Q)=>{this.#V(Q)},this.#q=(Q)=>{this.#k(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.#U=this.#B($===null?a.#O:$),this.#R(),this.#Y=this.getAttribute("unit-position")||"suffix",this.#L=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]"),K=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,K)K.addEventListener("click",this.focus.bind(this)),this.prepend(K);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.#z(J),this.hasAttribute("disabled")){let q=this.getAttribute("disabled");this.disabled=this.input.disabled=q!=="false"}this.addEventListener("pointerdown",this.#K),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),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.#q),this.input.addEventListener("keydown",this.#q)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q);this.removeEventListener("pointerdown",this.#K),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#H(Q){if(!Q)return"";if(!this.#N){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.#N,"").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.#N)return $.toString();if(this.#Y==="prefix")return this.#N+$;else return $+this.#N}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#S(Q){this.#G=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#N)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#N.length,$.length);else{let J=$.indexOf(this.#N);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#V(Q){this.#G=!1;let $=this.#H(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#y(J,!1),this.value=J,Q.target.value=this.#F(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#k(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.#H(this.input.value),K=(j!==""?Number(j)/(this.transform||1):0)+Z;K=this.#y(K,!1),this.value=K,this.input.value=this.#F(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#T(Q){let $=this.#H(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#C(Q){Q.stopPropagation();let $=this.#H(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#y(J,!1),this.value=J,Q.target.value=this.#F(this.value)}else this.value="",Q.target.value="";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.buttons===0){this.#I();return}let $=(this.step||1)*Q.movementX,J=this.#H(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#y(Z,!1),this.value=Z,this.input.value=this.#F(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#E(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#G=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#$),window.addEventListener("blur",this.#J)}#I(Q){this.#G=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#J)}#y(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.#L??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";break;case"units":this.#U=J||"",this.#R(),this.input.value=this.#F(this.value);break;case"units-disallow":this.#W=this.#A(J===null?a.#B: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.#G)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#y(Z,!1);this.value=Z,this.input.value=this.#F(this.value);break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0;break}this[Q]=Number(J);break;case"steppers":{let j=J!==null&&J!=="false";this.#z(j);break}case"precision":this.#L=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",a);class S0 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",S0);class C0 extends HTMLElement{#Q=!1;#$=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.#Q=!!(this.input&&("open"in this.input)),this.#Q&&this.label)this.#$=document.createElement("span"),this.#$.className="fig-mask-icon fig-field-chevron",this.insertBefore(this.#$,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#$.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.#Q){let Q=this.input.getAttribute("id")||p();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}if(this.label)this.label.addEventListener("pointerenter",this.#K.bind(this)),this.label.addEventListener("pointerleave",this.#Z.bind(this))})}disconnectedCallback(){if(this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#$&&this.#J)this.#$.removeEventListener("click",this.#J)}#K(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;k.show(this.label,this.label.textContent.trim())}#Z(){if(this.label)k.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 y0 extends HTMLElement{rgba;hex;#Q=100;#$;#J;#K;#Z;constructor(){super()}get picker(){return this.getAttribute("picker")||"native"}set picker(Q){this.setAttribute("picker",Q)}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))}#j(){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 Object.entries(Q).map(([J,Z])=>`${J}="${Z}"`).join(" ")}connectedCallback(){if(this.#_)cancelAnimationFrame(this.#_);this.#_=requestAnimationFrame(()=>{this.#_=null,this.#X()})}#_=null;#X(){this.#q(this.getAttribute("value"));let Q=this.picker==="figma",$=this.picker==="false",J=this.getAttribute("alpha")==="true",Z=this.#j(),K=this.#B?" disabled":"",q="";if(this.getAttribute("text")!=="false"){let X=`<fig-input-text
71
+ value="${this.#D(this.value)}" />`;requestAnimationFrame(()=>{let j=this.querySelector("[slot=append]"),K=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,K)K.addEventListener("click",this.focus.bind(this)),this.prepend(K);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.#z(J),this.hasAttribute("disabled")){let q=this.getAttribute("disabled");this.disabled=this.input.disabled=q!=="false"}this.addEventListener("pointerdown",this.#K),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),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.#q),this.input.addEventListener("keydown",this.#q)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q);this.removeEventListener("pointerdown",this.#K),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#H(Q){if(!Q)return"";if(!this.#W){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.#W,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#D(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#x($),!this.#W)return $.toString();if(this.#Y==="prefix")return this.#W+$;else return $+this.#W}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#S(Q){this.#G=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#W)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#W.length,$.length);else{let J=$.indexOf(this.#W);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#V(Q){this.#G=!1;let $=this.#H(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#C(J,!1),this.value=J,Q.target.value=this.#D(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#k(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.#H(this.input.value),K=(j!==""?Number(j)/(this.transform||1):0)+Z;K=this.#C(K,!1),this.value=K,this.input.value=this.#D(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#T(Q){let $=this.#H(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#I(Q){Q.stopPropagation();let $=this.#H(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#C(J,!1),this.value=J,Q.target.value=this.#D(this.value)}else this.value="",Q.target.value="";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.buttons===0){this.#y();return}let $=(this.step||1)*Q.movementX,J=this.#H(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#C(Z,!1),this.value=Z,this.input.value=this.#D(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#E(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#G=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#$),window.addEventListener("blur",this.#J)}#y(Q){this.#G=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#J)}#C(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.#L??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";break;case"units":this.#N=J||"",this.#R(),this.input.value=this.#D(this.value);break;case"units-disallow":this.#U=this.#B(J===null?a.#O:J),this.#R(),this.input.value=this.#D(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#D(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#D(this.value);break;case"value":if(this.#G)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#C(Z,!1);this.value=Z,this.input.value=this.#D(this.value);break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0;break}this[Q]=Number(J);break;case"steppers":{let j=J!==null&&J!=="false";this.#z(j);break}case"precision":this.#L=J!==null?Number(J):2,this.input.value=this.#D(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",a);class S0 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",S0);class C0 extends HTMLElement{#Q=!1;#$=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.#Q=!!(this.input&&("open"in this.input)),this.#Q&&this.label)this.#$=document.createElement("span"),this.#$.className="fig-mask-icon fig-field-chevron",this.insertBefore(this.#$,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#$.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.#Q){let Q=this.input.getAttribute("id")||u();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}if(this.label)this.label.addEventListener("pointerenter",this.#K.bind(this)),this.label.addEventListener("pointerleave",this.#Z.bind(this))})}disconnectedCallback(){if(this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#$&&this.#J)this.#$.removeEventListener("click",this.#J)}#K(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;k.show(this.label,this.label.textContent.trim())}#Z(){if(this.label)k.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 f0 extends HTMLElement{rgba;hex;#Q=100;#$;#J;#K;#Z;constructor(){super()}get picker(){return this.getAttribute("picker")||"native"}set picker(Q){this.setAttribute("picker",Q)}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))}#j(){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 Object.entries(Q).map(([J,Z])=>`${J}="${Z}"`).join(" ")}connectedCallback(){if(this.#_)cancelAnimationFrame(this.#_);this.#_=requestAnimationFrame(()=>{this.#_=null,this.#X()})}#_=null;#X(){this.#q(this.getAttribute("value"));let Q=this.picker==="figma",$=this.picker==="false",J=this.getAttribute("alpha")==="true",Z=this.#j(),K=this.#O?" disabled":"",q="";if(this.getAttribute("text")!=="false"){let X=`<fig-input-text
72
72
  type="text"
73
73
  placeholder="000000"
74
74
  value="${this.hexOpaque.slice(1).toUpperCase()}"${K}>
@@ -83,7 +83,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
83
83
  </fig-tooltip>`;let Y="";if(!$)Y=Q?`<fig-fill-picker mode="solid" ${Z} ${J?"":'alpha="false"'} value='{"type":"solid","color":"${this.hexOpaque}","opacity":${this.#Q}}'${K}></fig-fill-picker>`:`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${K}></fig-chit>`;q=`<div class="input-combo">
84
84
  ${Y}
85
85
  ${X}
86
- </div>`}else if($)q="";else q=Q?`<fig-fill-picker mode="solid" ${Z} ${J?"":'alpha="false"'} value='{"type":"solid","color":"${this.hexOpaque}","opacity":${this.#Q}}'${K}></fig-fill-picker>`:`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${K}></fig-chit>`;this.innerHTML=q,requestAnimationFrame(()=>{if(this.#$=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#K=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#$)this.#$.disabled=this.hasAttribute("disabled"),this.#$.addEventListener("input",this.#Y.bind(this));if(this.#J){let X=this.getAttribute("picker-anchor");if(X==="self")this.#J.anchorElement=this;else if(X){let Y=document.querySelector(X);if(Y)this.#J.anchorElement=Y}if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");this.#J.addEventListener("input",this.#L.bind(this)),this.#J.addEventListener("change",this.#W.bind(this))}if(this.#K){let X=this.rgbAlphaToHex(this.rgba,1);if(this.#K.value=X.slice(1).toUpperCase(),this.#$)this.#$.background=X;this.#K.addEventListener("input",this.#N.bind(this)),this.#K.addEventListener("change",this.#W.bind(this))}if(this.#Z)this.#Z.addEventListener("input",this.#U.bind(this)),this.#Z.addEventListener("change",this.#W.bind(this))})}#q(Q){if(this.rgba=this.convertToRGBA(Q),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),Q.length>7)this.#Q=(this.rgba.a*100).toFixed(0);this.style.setProperty("--alpha",this.rgba.a)}#N(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#q("#"+$),this.#Z)this.#Z.setAttribute("value",this.#Q);if(this.#$)this.#$.setAttribute("background",this.hexOpaque);this.#G()}#U(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#q(this.hexOpaque+Z),this.#$)this.#$.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#G()}#W(Q){Q.stopPropagation(),this.#M()}focus(){this.#$.focus()}#Y(Q){if(Q.stopPropagation(),this.#q(Q.target.value),this.#K)this.#K.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#G()}#L(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.#q(J),this.#K)this.#K.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#$)this.#$.setAttribute("background",this.hexOpaque),this.#$.setAttribute("alpha",this.rgba.a);this.#G()}}#G(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#M(){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","picker","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.#q(J),this.#K)this.#K.setAttribute("value",this.value);if(this.#$)this.#$.setAttribute("background",this.hexOpaque),this.#$.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));if(this.#Z)this.#Z.setAttribute("value",this.#Q);break;case"mode":if(this.#J&&J)this.#J.setAttribute("mode",J);break;case"picker":break;case"alpha":case"text":if(this.isConnected)this.#X();break;case"disabled":this.#A();break}}get#B(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#A(){let Q=this.#B;for(let $ of[this.#$,this.#K,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}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"),K=$.toString(16).padStart(2,"0"),q=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${K}${q}`.toUpperCase();let X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${K}${q}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let K=Q.slice(1);if(K.length===8)j=parseInt(K.slice(6),16)/255,K=K.slice(0,6);$=parseInt(K.slice(0,2),16),J=parseInt(K.slice(2,4),16),Z=parseInt(K.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let K=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(K)$=parseInt(K[1]),J=parseInt(K[2]),Z=parseInt(K[3]),j=K[4]?parseFloat(K[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let K=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(K){let q=parseInt(K[1])/360,_=parseInt(K[2])/100,X=parseInt(K[3])/100;if(j=K[4]?parseFloat(K[4]):1,_===0)$=J=Z=X;else{let Y=(G,D,R)=>{if(R<0)R+=1;if(R>1)R-=1;if(R<0.16666666666666666)return G+(D-G)*6*R;if(R<0.5)return D;if(R<0.6666666666666666)return G+(D-G)*(0.6666666666666666-R)*6;return G},W=X<0.5?X*(1+_):X+_-X*_,N=2*X-W;$=Y(N,W,q+0.3333333333333333),J=Y(N,W,q),Z=Y(N,W,q-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",y0);var A1=["srgb","srgb-linear","display-p3","oklab","oklch"],R1=["shorter","longer","increasing","decreasing"];function V(Q){let $={...Q??{}},J=String($.interpolationSpace??"oklab").toLowerCase();if(!A1.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=R1.includes(Z)?Z:"shorter",$}function d(Q){let $=V(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function I0(Q){let $=V(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function i(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function b(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function u(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 n(Q,$,J){let Z=b(Q),j=b($),K=b(J),q=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*K),_=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*K),X=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*K);return{l:0.2104542553*q+0.793617785*_-0.0040720468*X,a:1.9779984951*q-2.428592205*_+0.4505937099*X,b:0.0259040371*q+0.7827717662*_-0.808675766*X}}function U0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,K=Q-0.0894841775*$-1.291485548*J,q=Z*Z*Z,_=j*j*j,X=K*K*K;return{r:u(4.0767416621*q-3.3077115913*_+0.2309699292*X),g:u(-1.2684380046*q+2.6097574011*_-0.3413193965*X),b:u(-0.0041960863*q-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 z1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function D1(Q,$,J,Z){let j=(Q%360+360)%360,q=($%360+360)%360-j;switch(Z){case"longer":if(q>0&&q<180)q-=360;else if(q<0&&q>-180)q+=360;else if(q===0)q=0;break;case"increasing":if(q<0)q+=360;break;case"decreasing":if(q>0)q-=360;break;default:if(q>180)q-=360;else if(q<-180)q+=360;break}return((j+q*J)%360+360)%360}function F1(Q,$,J,Z){let j=[...Q].sort((M,O)=>M.position-O.position),K=$*100;if(j.length===0)return"#888888";if(K<=j[0].position)return j[0].color;if(K>=j[j.length-1].position)return j[j.length-1].color;let q=0;while(q<j.length-1&&j[q+1].position<K)q++;let _=j[q],X=j[q+1],Y=X.position-_.position,W=Y>0?(K-_.position)/Y:0,N=i(_.color),G=i(X.color),D,R,L,B=J||"oklab";if(B==="srgb-linear"){let M=b(N.r),O=b(N.g),A=b(N.b),F=b(G.r),T=b(G.g),S=b(G.b);D=u(M+(F-M)*W),R=u(O+(T-O)*W),L=u(A+(S-A)*W)}else if(B==="oklch"){let M=n(N.r,N.g,N.b),O=n(G.r,G.g,G.b),A=L0(M.l,M.a,M.b),F=L0(O.l,O.a,O.b),T=A.l+(F.l-A.l)*W,S=A.c+(F.c-A.c)*W,y=D1(A.h,F.h,W,Z||"shorter"),I=z1(T,S,y),c=U0(I.l,I.a,I.b);D=c.r,R=c.g,L=c.b}else{let M=n(N.r,N.g,N.b),O=n(G.r,G.g,G.b),A=M.l+(O.l-M.l)*W,F=M.a+(O.a-M.a)*W,T=M.b+(O.b-M.b)*W,S=U0(A,F,T);D=S.r,R=S.g,L=S.b}return`#${D.toString(16).padStart(2,"0")}${R.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function H1(Q,$,J){return P1(Q,$,J).map((j)=>+(j/255).toFixed(4))}function P1(Q,$,J){$/=100,J/=100;let Z=(1-Math.abs(2*J-1))*$,j=Z*(1-Math.abs(Q/60%2-1)),K=J-Z/2,q,_,X;if(Q<60)q=Z,_=j,X=0;else if(Q<120)q=j,_=Z,X=0;else if(Q<180)q=0,_=Z,X=j;else if(Q<240)q=0,_=j,X=Z;else if(Q<300)q=j,_=0,X=Z;else q=Z,_=0,X=j;return[Math.round((q+K)*255),Math.round((_+K)*255),Math.round((X+K)*255)]}class f0 extends HTMLElement{#Q="solid";#$;#J;#K;#Z={color:"#D9D9D9",alpha:1};#j={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};#q={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#N(),this.#Y()}disconnectedCallback(){this.#$=null,this.#J=null,this.#K=null}#N(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#Q=$.type;switch(this.#Q){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#j=V({...this.#j,...$.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.#q={...this.#q,...$.webcam};if($.opacity!==void 0)this.#q.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#Q="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#U(){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:K}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=K;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,K])=>`${j}="${K}"`).join(" ")}#W(){let Q=this.hasAttribute("disabled");for(let $ of[this.#$,this.#J,this.#K]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#Y(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(q)=>J?`<fig-tooltip text="Opacity">
86
+ </div>`}else if($)q="";else q=Q?`<fig-fill-picker mode="solid" ${Z} ${J?"":'alpha="false"'} value='{"type":"solid","color":"${this.hexOpaque}","opacity":${this.#Q}}'${K}></fig-fill-picker>`:`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${K}></fig-chit>`;this.innerHTML=q,requestAnimationFrame(()=>{if(this.#$=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#K=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#$)this.#$.disabled=this.hasAttribute("disabled"),this.#$.addEventListener("input",this.#Y.bind(this));if(this.#J){let X=this.getAttribute("picker-anchor");if(X==="self")this.#J.anchorElement=this;else if(X){let Y=document.querySelector(X);if(Y)this.#J.anchorElement=Y}if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");this.#J.addEventListener("input",this.#L.bind(this)),this.#J.addEventListener("change",this.#U.bind(this))}if(this.#K){let X=this.rgbAlphaToHex(this.rgba,1);if(this.#K.value=X.slice(1).toUpperCase(),this.#$)this.#$.background=X;this.#K.addEventListener("input",this.#W.bind(this)),this.#K.addEventListener("change",this.#U.bind(this))}if(this.#Z)this.#Z.addEventListener("input",this.#N.bind(this)),this.#Z.addEventListener("change",this.#U.bind(this))})}#q(Q){if(this.rgba=this.convertToRGBA(Q),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),Q.length>7)this.#Q=(this.rgba.a*100).toFixed(0);this.style.setProperty("--alpha",this.rgba.a)}#W(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#q("#"+$),this.#Z)this.#Z.setAttribute("value",this.#Q);if(this.#$)this.#$.setAttribute("background",this.hexOpaque);this.#G()}#N(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#q(this.hexOpaque+Z),this.#$)this.#$.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#G()}#U(Q){Q.stopPropagation(),this.#M()}focus(){this.#$.focus()}#Y(Q){if(Q.stopPropagation(),this.#q(Q.target.value),this.#K)this.#K.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#G()}#L(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.#q(J),this.#K)this.#K.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#$)this.#$.setAttribute("background",this.hexOpaque),this.#$.setAttribute("alpha",this.rgba.a);this.#G()}}#G(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#M(){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","picker","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.#q(J),this.#K)this.#K.setAttribute("value",this.value);if(this.#$)this.#$.setAttribute("background",this.hexOpaque),this.#$.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));if(this.#Z)this.#Z.setAttribute("value",this.#Q);break;case"mode":if(this.#J&&J)this.#J.setAttribute("mode",J);break;case"picker":break;case"alpha":case"text":if(this.isConnected)this.#X();break;case"disabled":this.#B();break}}get#O(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#B(){let Q=this.#O;for(let $ of[this.#$,this.#K,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}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"),K=$.toString(16).padStart(2,"0"),q=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${K}${q}`.toUpperCase();let X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${K}${q}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let K=Q.slice(1);if(K.length===8)j=parseInt(K.slice(6),16)/255,K=K.slice(0,6);$=parseInt(K.slice(0,2),16),J=parseInt(K.slice(2,4),16),Z=parseInt(K.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let K=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(K)$=parseInt(K[1]),J=parseInt(K[2]),Z=parseInt(K[3]),j=K[4]?parseFloat(K[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let K=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(K){let q=parseInt(K[1])/360,_=parseInt(K[2])/100,X=parseInt(K[3])/100;if(j=K[4]?parseFloat(K[4]):1,_===0)$=J=Z=X;else{let Y=(G,D,R)=>{if(R<0)R+=1;if(R>1)R-=1;if(R<0.16666666666666666)return G+(D-G)*6*R;if(R<0.5)return D;if(R<0.6666666666666666)return G+(D-G)*(0.6666666666666666-R)*6;return G},W=X<0.5?X*(1+_):X+_-X*_,N=2*X-W;$=Y(N,W,q+0.3333333333333333),J=Y(N,W,q),Z=Y(N,W,q-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",f0);var A1=["srgb","srgb-linear","display-p3","oklab","oklch"],R1=["shorter","longer","increasing","decreasing"];function V(Q){let $={...Q??{}},J=String($.interpolationSpace??"oklab").toLowerCase();if(!A1.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=R1.includes(Z)?Z:"shorter",$}function d(Q){let $=V(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function I0(Q){let $=V(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function i(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function b(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 n(Q,$,J){let Z=b(Q),j=b($),K=b(J),q=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*K),_=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*K),X=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*K);return{l:0.2104542553*q+0.793617785*_-0.0040720468*X,a:1.9779984951*q-2.428592205*_+0.4505937099*X,b:0.0259040371*q+0.7827717662*_-0.808675766*X}}function U0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,K=Q-0.0894841775*$-1.291485548*J,q=Z*Z*Z,_=j*j*j,X=K*K*K;return{r:p(4.0767416621*q-3.3077115913*_+0.2309699292*X),g:p(-1.2684380046*q+2.6097574011*_-0.3413193965*X),b:p(-0.0041960863*q-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 z1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function D1(Q,$,J,Z){let j=(Q%360+360)%360,q=($%360+360)%360-j;switch(Z){case"longer":if(q>0&&q<180)q-=360;else if(q<0&&q>-180)q+=360;else if(q===0)q=0;break;case"increasing":if(q<0)q+=360;break;case"decreasing":if(q>0)q-=360;break;default:if(q>180)q-=360;else if(q<-180)q+=360;break}return((j+q*J)%360+360)%360}function F1(Q,$,J,Z){let j=[...Q].sort((M,B)=>M.position-B.position),K=$*100;if(j.length===0)return"#888888";if(K<=j[0].position)return j[0].color;if(K>=j[j.length-1].position)return j[j.length-1].color;let q=0;while(q<j.length-1&&j[q+1].position<K)q++;let _=j[q],X=j[q+1],Y=X.position-_.position,W=Y>0?(K-_.position)/Y:0,N=i(_.color),G=i(X.color),D,R,L,O=J||"oklab";if(O==="srgb-linear"){let M=b(N.r),B=b(N.g),A=b(N.b),F=b(G.r),T=b(G.g),S=b(G.b);D=p(M+(F-M)*W),R=p(B+(T-B)*W),L=p(A+(S-A)*W)}else if(O==="oklch"){let M=n(N.r,N.g,N.b),B=n(G.r,G.g,G.b),A=L0(M.l,M.a,M.b),F=L0(B.l,B.a,B.b),T=A.l+(F.l-A.l)*W,S=A.c+(F.c-A.c)*W,f=D1(A.h,F.h,W,Z||"shorter"),I=z1(T,S,f),c=U0(I.l,I.a,I.b);D=c.r,R=c.g,L=c.b}else{let M=n(N.r,N.g,N.b),B=n(G.r,G.g,G.b),A=M.l+(B.l-M.l)*W,F=M.a+(B.a-M.a)*W,T=M.b+(B.b-M.b)*W,S=U0(A,F,T);D=S.r,R=S.g,L=S.b}return`#${D.toString(16).padStart(2,"0")}${R.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function H1(Q,$,J){return P1(Q,$,J).map((j)=>+(j/255).toFixed(4))}function P1(Q,$,J){$/=100,J/=100;let Z=(1-Math.abs(2*J-1))*$,j=Z*(1-Math.abs(Q/60%2-1)),K=J-Z/2,q,_,X;if(Q<60)q=Z,_=j,X=0;else if(Q<120)q=j,_=Z,X=0;else if(Q<180)q=0,_=Z,X=j;else if(Q<240)q=0,_=j,X=Z;else if(Q<300)q=j,_=0,X=Z;else q=Z,_=0,X=j;return[Math.round((q+K)*255),Math.round((_+K)*255),Math.round((X+K)*255)]}class y0 extends HTMLElement{#Q="solid";#$;#J;#K;#Z={color:"#D9D9D9",alpha:1};#j={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};#q={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#W(),this.#Y()}disconnectedCallback(){this.#$=null,this.#J=null,this.#K=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#Q=$.type;switch(this.#Q){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#j=V({...this.#j,...$.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.#q={...this.#q,...$.webcam};if($.opacity!==void 0)this.#q.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#Q="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.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:K}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=K;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,K])=>`${j}="${K}"`).join(" ")}#U(){let Q=this.hasAttribute("disabled");for(let $ of[this.#$,this.#J,this.#K]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#Y(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(q)=>J?`<fig-tooltip text="Opacity">
87
87
  <fig-input-number
88
88
  class="fig-input-fill-opacity"
89
89
  placeholder="##"
@@ -109,11 +109,11 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! 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.#q.opacity??1)*100))}`;break}let K=this.#U();this.innerHTML=`
112
+ ${Z(Math.round((this.#q.opacity??1)*100))}`;break}let K=this.#N();this.innerHTML=`
113
113
  <div class="input-combo">
114
114
  <fig-fill-picker ${K} value='${$}' ${Q?"disabled":""}></fig-fill-picker>
115
115
  ${j}
116
- </div>`,this.#L()}#L(){requestAnimationFrame(()=>{this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#K=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(Q&&this.#$)Q.addEventListener("click",()=>{let $=this.#$.querySelector("fig-chit");if($)$.click()});if(this.#$){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#$.anchorElement=this;else{let J=document.querySelector($);if(J)this.#$.anchorElement=J}this.#$.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,K=j!==this.#Q;switch(this.#Q=j,j){case"solid":this.#Z.color=Z.color,this.#Z.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#j=V({...this.#j,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(K)this.#M();else this.#G();this.#O()}),this.#$.addEventListener("change",(J)=>{J.stopPropagation(),this.#R()})}if(this.#K)this.#K.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#Z.color=J,this.#B(),this.#O()}),this.#K.addEventListener("change",($)=>{$.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#Q){case"solid":this.#Z.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#q.opacity=j;break}this.#B(),this.#A(j),this.#O()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})})}#G(){switch(this.#Q){case"solid":if(this.#K)this.#K.setAttribute("value",this.#Z.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Z.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#j.type.charAt(0).toUpperCase()+this.#j.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.#q.opacity??1)*100));break}}#M(){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"),K=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),K.forEach((_)=>_.remove());let q="";switch(this.#Q){case"solid":q=`
116
+ </div>`,this.#L()}#L(){requestAnimationFrame(()=>{this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#K=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(Q&&this.#$)Q.addEventListener("click",()=>{let $=this.#$.querySelector("fig-chit");if($)$.click()});if(this.#$){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#$.anchorElement=this;else{let J=document.querySelector($);if(J)this.#$.anchorElement=J}this.#$.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,K=j!==this.#Q;switch(this.#Q=j,j){case"solid":this.#Z.color=Z.color,this.#Z.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#j=V({...this.#j,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(K)this.#M();else this.#G();this.#A()}),this.#$.addEventListener("change",(J)=>{J.stopPropagation(),this.#R()})}if(this.#K)this.#K.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#Z.color=J,this.#O(),this.#A()}),this.#K.addEventListener("change",($)=>{$.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#Q){case"solid":this.#Z.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#q.opacity=j;break}this.#O(),this.#B(j),this.#A()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})})}#G(){switch(this.#Q){case"solid":if(this.#K)this.#K.setAttribute("value",this.#Z.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Z.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#j.type.charAt(0).toUpperCase()+this.#j.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.#q.opacity??1)*100));break}}#M(){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"),K=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),K.forEach((_)=>_.remove());let q="";switch(this.#Q){case"solid":q=`
117
117
  <fig-input-text
118
118
  type="text"
119
119
  class="fig-input-fill-hex"
@@ -179,12 +179,12 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
179
179
  units="%"
180
180
  ${Q?"disabled":""}>
181
181
  </fig-input-number>
182
- </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",q),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#K=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(_&&this.#$)_.addEventListener("click",()=>{let X=this.#$.querySelector("fig-chit");if(X)X.click()});if(this.#K)this.#K.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#Z.color=Y,this.#B(),this.#O()}),this.#K.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let Y=parseFloat(X.target.value),N=(isNaN(Y)?100:Y)/100;switch(this.#Q){case"solid":this.#Z.alpha=N;break;case"gradient":break;case"image":this.#_.opacity=N;break;case"video":this.#X.opacity=N;break;case"webcam":this.#q.opacity=N;break}this.#B(),this.#A(N),this.#O()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#B(){if(this.#$)this.#$.setAttribute("value",JSON.stringify(this.value))}#A(Q){if(this.#$){let $=this.#$.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:d(this.#j)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#q}};default:return{type:this.#Q}}}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.#Q;if(this.#N(),this.#$)if(this.#Q!==Z)this.#Y();else this.#B(),this.#G();break;case"disabled":this.#W();break;case"mode":case"experimental":if(this.#$)if(J)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q);break}}}customElements.define("fig-input-fill",f0);class x0 extends HTMLElement{#Q=[];#$=[];#J=[];#K=null;static get observedAttributes(){return["value","disabled","min","max","open","add"]}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#Z(){return!this.hasAttribute("add")||this.getAttribute("add")!=="false"}get#j(){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.#K)cancelAnimationFrame(this.#K);this.#K=requestAnimationFrame(()=>{this.#K=null,this.#X(),this.#q()})}disconnectedCallback(){if(this.#K)cancelAnimationFrame(this.#K),this.#K=null;this.#$=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#M();break;case"disabled":this.#B();break;case"min":case"max":case"add":this.#q();break;case"open":break}}#X(){let Q=this.getAttribute("value");if(!Q){this.#Q=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#Q=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.#Q=$.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.#Q=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#Q=[]}get value(){return this.#Q.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#q(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#$=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline";let J=document.createElement("div");if(J.className="palette-colors",this.#Q.forEach((j,K)=>{J.appendChild(this.#N(j,K,Q,{inline:!0}))}),$.appendChild(J),this.#Z)this.#Y(Q,$);this.appendChild($);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#Q.forEach((j,K)=>{Z.appendChild(this.#N(j,K,Q)),Z.appendChild(this.#U(K,Q))}),this.appendChild(Z)}#N(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,K=document.createElement("fig-input-color");if(K.setAttribute("value",j),K.setAttribute("picker","figma"),K.setAttribute("picker-anchor","self"),Z)K.setAttribute("text","false"),K.setAttribute("alpha","true");else K.setAttribute("text","true"),K.setAttribute("alpha","true"),K.setAttribute("full","");if(J)K.setAttribute("disabled","");let q=Z?this.#J:this.#$,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#Q[$]={color:Y.hexOpaque||this.#Q[$].color,alpha:Y.rgba?Y.rgba.a:this.#Q[$].alpha};let W=q[$];if(W){let N=this.#Q[$],G=N.alpha<1?N.color+Math.round(N.alpha*255).toString(16).padStart(2,"0"):N.color;W.setAttribute("value",G)}};if(K.addEventListener("input",(X)=>{_(X),this.#A()}),K.addEventListener("change",(X)=>{_(X),this.#O()}),Z)this.#$.push(K);else this.#J.push(K);return K}#U(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.#Q.length<=this.#j)J.setAttribute("disabled","");return J.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-minus)"></span>',J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#W(Q)}),J}#W(Q){if(Q<0||Q>=this.#Q.length)return;if(this.#Q.length<=this.#j)return;this.#Q.splice(Q,1),this.#$=[],this.#J=[],this.#q(),this.#O()}#Y(Q,$=this){let J=this.#Q.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","input"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-add)"></span>',Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#_)return;this.#L({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#L(Q){this.#Q.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#Q.length-1,Z=this.#N(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let K=this.#N(Q,J,$),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(K),q.appendChild(this.#U(J,$));if(this.#Q.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#O()}#G(Q){let $=this.#Q[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#$[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#M(){if(this.#$.length!==this.#Q.length){this.#q();return}this.#Q.forEach((Q,$)=>{this.#G($)})}#B(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#$,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",x0);class r extends HTMLElement{static SHIFT_SNAP=5;#Q;#$;#J=!1;#K=null;#Z=null;#j={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"]}get#_(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#_==="true"}connectedCallback(){if(this.#N(),this.#M(),this.#X)document.addEventListener("keydown",this.#q)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#q),this.#Z)this.#Z.disconnect(),this.#Z=null;clearTimeout(this.#K),this.removeEventListener("pointerenter",this.#D),this.removeEventListener("pointermove",this.#F),this.removeEventListener("pointerleave",this.#H),this.removeEventListener("click",this.#V),this.removeEventListener("dblclick",this.#S)}#q=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#$)return;if(Q.key==="Tab"&&!J){let K=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;Q.preventDefault();let q=[...this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],_=q.indexOf(K),X=Q.shiftKey?(_-1+q.length)%q.length:(_+1)%q.length;K.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let K=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;let q=parseInt(K.dataset.stopIndex,10);if(isNaN(q)||!this.#j.stops[q])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#j.stops[q];X.position=Math.max(0,Math.min(100,X.position+_)),K.setAttribute("value",`${X.position}% 50%`);let Y=K.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),K.hideColorTip(),clearTimeout(this.#K),this.#K=setTimeout(()=>{Y.removeAttribute("show"),K.showColorTip()},600);this.#E(),this.#y(),this.#x();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#j.stops.length<=2)return;let Z=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#j.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#j.stops.splice(j,1),this.#T(),this.#E(),this.#y(),this.#x()};#N(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#j=V({...this.#j,...$.gradient}),this.#j.type="linear",this.#j.angle=90;return}if($?.gradient)this.#j=V({...this.#j,...$.gradient}),this.#j.type="linear",this.#j.angle=90}catch($){}}#U(){let $=[...this.#j.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:K,g:q,b:_}=i(Z.color);return`rgba(${K}, ${q}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=I0(this.#j);return`linear-gradient(${this.#j.angle}deg ${J}, ${$})`}#W(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=i(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#Y(){let Q=this.hasAttribute("disabled");return this.#j.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color" color="${this.#W($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#L=null;#G=!1;#M(){let Q=this.hasAttribute("disabled"),$=this.#_;if($==="picker"){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
182
+ </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",q),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#K=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(_&&this.#$)_.addEventListener("click",()=>{let X=this.#$.querySelector("fig-chit");if(X)X.click()});if(this.#K)this.#K.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#Z.color=Y,this.#O(),this.#A()}),this.#K.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let Y=parseFloat(X.target.value),N=(isNaN(Y)?100:Y)/100;switch(this.#Q){case"solid":this.#Z.alpha=N;break;case"gradient":break;case"image":this.#_.opacity=N;break;case"video":this.#X.opacity=N;break;case"webcam":this.#q.opacity=N;break}this.#O(),this.#B(N),this.#A()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#O(){if(this.#$)this.#$.setAttribute("value",JSON.stringify(this.value))}#B(Q){if(this.#$){let $=this.#$.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:d(this.#j)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#q}};default:return{type:this.#Q}}}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.#Q;if(this.#W(),this.#$)if(this.#Q!==Z)this.#Y();else this.#O(),this.#G();break;case"disabled":this.#U();break;case"mode":case"experimental":if(this.#$)if(J)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q);break}}}customElements.define("fig-input-fill",y0);class x0 extends HTMLElement{#Q=[];#$=[];#J=[];#K=null;static get observedAttributes(){return["value","disabled","min","max","open","add"]}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#Z(){return!this.hasAttribute("add")||this.getAttribute("add")!=="false"}get#j(){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.#K)cancelAnimationFrame(this.#K);this.#K=requestAnimationFrame(()=>{this.#K=null,this.#X(),this.#q()})}disconnectedCallback(){if(this.#K)cancelAnimationFrame(this.#K),this.#K=null;this.#$=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#M();break;case"disabled":this.#O();break;case"min":case"max":case"add":this.#q();break;case"open":break}}#X(){let Q=this.getAttribute("value");if(!Q){this.#Q=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#Q=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.#Q=$.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.#Q=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#Q=[]}get value(){return this.#Q.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#q(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#$=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline";let J=document.createElement("div");if(J.className="palette-colors",this.#Q.forEach((j,K)=>{J.appendChild(this.#W(j,K,Q,{inline:!0}))}),$.appendChild(J),this.#Z)this.#Y(Q,$);this.appendChild($);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#Q.forEach((j,K)=>{Z.appendChild(this.#W(j,K,Q)),Z.appendChild(this.#N(K,Q))}),this.appendChild(Z)}#W(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,K=document.createElement("fig-input-color");if(K.setAttribute("value",j),K.setAttribute("picker","figma"),K.setAttribute("picker-anchor","self"),Z)K.setAttribute("text","false"),K.setAttribute("alpha","true");else K.setAttribute("text","true"),K.setAttribute("alpha","true"),K.setAttribute("full","");if(J)K.setAttribute("disabled","");let q=Z?this.#J:this.#$,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#Q[$]={color:Y.hexOpaque||this.#Q[$].color,alpha:Y.rgba?Y.rgba.a:this.#Q[$].alpha};let W=q[$];if(W){let N=this.#Q[$],G=N.alpha<1?N.color+Math.round(N.alpha*255).toString(16).padStart(2,"0"):N.color;W.setAttribute("value",G)}};if(K.addEventListener("input",(X)=>{_(X),this.#B()}),K.addEventListener("change",(X)=>{_(X),this.#A()}),Z)this.#$.push(K);else this.#J.push(K);return K}#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.#Q.length<=this.#j)J.setAttribute("disabled","");return J.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-minus)"></span>',J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#U(Q)}),J}#U(Q){if(Q<0||Q>=this.#Q.length)return;if(this.#Q.length<=this.#j)return;this.#Q.splice(Q,1),this.#$=[],this.#J=[],this.#q(),this.#A()}#Y(Q,$=this){let J=this.#Q.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","input"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-add)"></span>',Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#_)return;this.#L({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#L(Q){this.#Q.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#Q.length-1,Z=this.#W(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let K=this.#W(Q,J,$),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(K),q.appendChild(this.#N(J,$));if(this.#Q.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#A()}#G(Q){let $=this.#Q[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#$[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#M(){if(this.#$.length!==this.#Q.length){this.#q();return}this.#Q.forEach((Q,$)=>{this.#G($)})}#O(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#$,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}#B(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",x0);class r extends HTMLElement{static SHIFT_SNAP=5;#Q;#$;#J=!1;#K=null;#Z=null;#j={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"]}get#_(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#_==="true"}connectedCallback(){if(this.#W(),this.#M(),this.#X)document.addEventListener("keydown",this.#q)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#q),this.#Z)this.#Z.disconnect(),this.#Z=null;clearTimeout(this.#K),this.removeEventListener("pointerenter",this.#F),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#H),this.removeEventListener("click",this.#V),this.removeEventListener("dblclick",this.#S)}#q=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#$)return;if(Q.key==="Tab"&&!J){let K=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;Q.preventDefault();let q=[...this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],_=q.indexOf(K),X=Q.shiftKey?(_-1+q.length)%q.length:(_+1)%q.length;K.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let K=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;let q=parseInt(K.dataset.stopIndex,10);if(isNaN(q)||!this.#j.stops[q])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#j.stops[q];X.position=Math.max(0,Math.min(100,X.position+_)),K.setAttribute("value",`${X.position}% 50%`);let Y=K.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),K.hideColorTip(),clearTimeout(this.#K),this.#K=setTimeout(()=>{Y.removeAttribute("show"),K.showColorTip()},600);this.#E(),this.#C(),this.#x();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#j.stops.length<=2)return;let Z=this.#$.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#j.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#j.stops.splice(j,1),this.#T(),this.#E(),this.#C(),this.#x()};#W(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#j=V({...this.#j,...$.gradient}),this.#j.type="linear",this.#j.angle=90;return}if($?.gradient)this.#j=V({...this.#j,...$.gradient}),this.#j.type="linear",this.#j.angle=90}catch($){}}#N(){let $=[...this.#j.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:K,g:q,b:_}=i(Z.color);return`rgba(${K}, ${q}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=I0(this.#j);return`linear-gradient(${this.#j.angle}deg ${J}, ${$})`}#U(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=i(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#Y(){let Q=this.hasAttribute("disabled");return this.#j.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color" color="${this.#U($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#L=null;#G=!1;#M(){let Q=this.hasAttribute("disabled"),$=this.#_;if($==="picker"){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
183
183
  <fig-fill-picker mode="gradient"${Z} value='${j}'${Q?" disabled":""}>
184
- <fig-chit size="medium" background="${this.#U()}"${Q?" disabled":""}></fig-chit>
185
- </fig-fill-picker>`,this.#Q=this.querySelector("fig-chit"),this.#$=null,this.#B();return}if(this.innerHTML=`
186
- <fig-chit size="medium" background="${this.#U()}"${Q?" disabled":""}></fig-chit>
187
- ${$==="true"?`<div class="fig-input-gradient-track">${this.#Y()}</div>`:""}`,this.#Q=this.querySelector("fig-chit"),this.#$=this.querySelector(".fig-input-gradient-track"),$==="true")this.#O(),this.#I(),requestAnimationFrame(()=>this.#k())}#B(){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.#j=V({...this.#j,...Z.gradient}),this.#E()};Q.addEventListener("input",(J)=>{$(J),this.#y()}),Q.addEventListener("change",(J)=>{$(J),this.#x()})}#A(Q){return F1(this.#j.stops,Q,this.#j.interpolationSpace,this.#j.hueInterpolation)}#O(){if(!this.#$||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),Q.setAttribute("control","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.#$.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#D),this.addEventListener("pointermove",this.#F),this.addEventListener("pointerleave",this.#H),this.addEventListener("click",this.#V),this.addEventListener("dblclick",this.#S)}#R(){if(!this.#L)return;this.#L.style.opacity="1"}#z(){if(!this.#L)return;this.#L.style.opacity="0"}#D=()=>{if(this.#J)return;this.#R()};#H=()=>{this.#z()};#F=(Q)=>{if(this.#J){this.#z();return}if(!this.#L||!this.#$)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#z();return}let $=this.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#A(J);this.#L.setAttribute("color",Z),this.#R()};#P(){let Q=this.#j.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#j.stops[$].position=Math.round($/(Q-1)*100);this.#T(),this.#E(),this.#y(),this.#x()}#S=(Q)=>{if(!this.#$)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#$.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#V=(Q)=>{if(!this.#$)return;if(this.#J)return;if(this.#G){this.#G=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let q=Q.target.closest("fig-handle"),_=parseInt(q?.dataset.stopIndex,10);if(this.#P(),!isNaN(_))this.#$.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.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#j.stops.push({position:Z,color:j,opacity:100}),this.#j.stops.sort((q,_)=>q.position-_.position);let K=this.#j.stops.findIndex((q)=>q.position===Z&&q.color===j);this.#T(),this.#E(),this.#y(),this.#x(),requestAnimationFrame(()=>{let _=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)_.click()})};#k(){if(!this.#$)return;let Q=this.#j.stops;this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}#T(){if(!this.#$)return;let Q=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#j.stops;if(Q.length!==$.length){let J=this.#L;if(this.#$.innerHTML=this.#Y(),J)this.#$.appendChild(J);this.#C(),requestAnimationFrame(()=>this.#k());return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#W(j));let K=Z.closest("fig-tooltip");if(K)K.setAttribute("text",`${Math.round(j.position)}%`)}}#C(){if(!this.#Z||!this.#$)return;this.#Z.disconnect(),this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#$)return;let Q=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#j.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),K=(Z.getAttribute("color")||"").toUpperCase(),q=-1;for(let _=0;_<$.length;_++){if(J.has(_))continue;if($[_].position===j&&$[_].color.toUpperCase()===K){q=_;break}}if(q===-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,q=X}}if(q!==-1)J.add(q),Z.dataset.stopIndex=q})}#E(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#U())}#I(){if(!this.#$)return;this.#$.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.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#j.stops.push({position:Z,color:j,opacity:100}),this.#j.stops.sort((X,Y)=>X.position-Y.position);let K=this.#j.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#G=!0,this.#T(),this.#E(),this.#y(),this.#z();let _=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)this.#$.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.#$.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.#j.stops[X]){if(this.#j.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#j.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#W(this.#j.stops[X])),this.#E(),this.#y()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#j.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),K=j,q=this.#$.getBoundingClientRect().width;if(Q.detail?.shiftKey)K=Math.round(K/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let X=q>0?5/q*100:0;for(let Y=0;Y<this.#j.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#j.stops[Y].position-K)<=X){K=this.#j.stops[Y].position;break}}}if(this.#j.stops[J].position=K,K!==j)$.style.left=`${K/100*q-$.offsetWidth/2}px`;let _=$.closest("fig-tooltip");if(_){if(_.text=`${Math.round(K)}%`,!_.hasAttribute("show"))_.setAttribute("show","true"),$.hideColorTip()}this.#E(),this.#y()}),this.#$.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.#j.stops[X]){if(this.#j.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#j.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#W(this.#j.stops[X])),this.#E(),this.#x()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#j.stops[Z])return;let j=Q.detail?.px??0,K=Math.round(j*100),q=this.#$.getBoundingClientRect().width,_=q>0?5/q*100:0;for(let X=0;X<this.#j.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#j.stops[X].position-K)<=_){K=this.#j.stops[X].position;break}}this.#j.stops[Z].position=K,$.style.left=`${K/100*q-$.offsetWidth/2}px`,this.#j.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#E(),this.#x(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Z=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.#j.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#j.stops[Z].color)this.#j.stops[Z].color=j,this.#E(),this.#y()}}),this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#y(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#x(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:d(this.#j)}}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.#E(),this.#T();break;case"disabled":this.#v();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#q);else document.removeEventListener("keydown",this.#q);break}}#v(){let Q=this.hasAttribute("disabled");if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)for(let $ of this.#$.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class Q0 extends HTMLElement{#Q=null;#$;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",p()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#$=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.#$),this.input.addEventListener("change",this.#$),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.#Q=$,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#Q.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#Q)this.#Q=document.createElement("label"),this.#Q.setAttribute("for",this.input.id);if(this.#Q&&!this.#Q.parentNode&&this.input.parentNode)this.input.after(this.#Q)}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.#$),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#Q.innerText=J;else if(this.#Q)this.#Q.remove(),this.#Q=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",Q0);class V0 extends Q0{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",V0);class w0 extends Q0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",w0);class v0 extends HTMLDialogElement{_defaultOffset=16;_autoCloseTimer=null;#Q;constructor(){super();this.#Q=this.handleClose.bind(this)}getOffset(){return parseInt(this.getAttribute("offset")??this._defaultOffset)}connectedCallback(){if(typeof this._defaultOffset!=="number")this._defaultOffset=16;if(typeof this._autoCloseTimer>"u")this._autoCloseTimer=null;if(!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.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{Q.removeEventListener("click",this.#Q),Q.addEventListener("click",this.#Q)})}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}#$(){if(this.getAttribute("theme")!=="auto")return;let $=(getComputedStyle(document.documentElement).colorScheme||"").includes("dark");this.style.colorScheme=$?"light":"dark"}showToast(){this.#$(),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(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme")if(J==="auto")this.#$();else this.style.removeProperty("color-scheme")}}j0("fig-toast",v0,{extends:"dialog"});class b0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#Q=!1;#$=null;#J=null;#K=null;#Z=null;#j=!1;#_=this.#Y.bind(this);#X=this.#L.bind(this);#q=this.#G.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Q=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#N(),this.#U(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#W()}#N(){let Q=this.#A(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",K=this.#Q?"":`<fig-dropdown type="dropdown"${j}>${Q.map((q)=>`<option>${q.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
184
+ <fig-chit size="medium" background="${this.#N()}"${Q?" disabled":""}></fig-chit>
185
+ </fig-fill-picker>`,this.#Q=this.querySelector("fig-chit"),this.#$=null,this.#O();return}if(this.innerHTML=`
186
+ <fig-chit size="medium" background="${this.#N()}"${Q?" disabled":""}></fig-chit>
187
+ ${$==="true"?`<div class="fig-input-gradient-track">${this.#Y()}</div>`:""}`,this.#Q=this.querySelector("fig-chit"),this.#$=this.querySelector(".fig-input-gradient-track"),$==="true")this.#A(),this.#y(),requestAnimationFrame(()=>this.#k())}#O(){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.#j=V({...this.#j,...Z.gradient}),this.#E()};Q.addEventListener("input",(J)=>{$(J),this.#C()}),Q.addEventListener("change",(J)=>{$(J),this.#x()})}#B(Q){return F1(this.#j.stops,Q,this.#j.interpolationSpace,this.#j.hueInterpolation)}#A(){if(!this.#$||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),Q.setAttribute("control","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.#$.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#F),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#H),this.addEventListener("click",this.#V),this.addEventListener("dblclick",this.#S)}#R(){if(!this.#L)return;this.#L.style.opacity="1"}#z(){if(!this.#L)return;this.#L.style.opacity="0"}#F=()=>{if(this.#J)return;this.#R()};#H=()=>{this.#z()};#D=(Q)=>{if(this.#J){this.#z();return}if(!this.#L||!this.#$)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#z();return}let $=this.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#B(J);this.#L.setAttribute("color",Z),this.#R()};#P(){let Q=this.#j.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#j.stops[$].position=Math.round($/(Q-1)*100);this.#T(),this.#E(),this.#C(),this.#x()}#S=(Q)=>{if(!this.#$)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#$.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#V=(Q)=>{if(!this.#$)return;if(this.#J)return;if(this.#G){this.#G=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let q=Q.target.closest("fig-handle"),_=parseInt(q?.dataset.stopIndex,10);if(this.#P(),!isNaN(_))this.#$.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.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#B(J);this.#j.stops.push({position:Z,color:j,opacity:100}),this.#j.stops.sort((q,_)=>q.position-_.position);let K=this.#j.stops.findIndex((q)=>q.position===Z&&q.color===j);this.#T(),this.#E(),this.#C(),this.#x(),requestAnimationFrame(()=>{let _=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)_.click()})};#k(){if(!this.#$)return;let Q=this.#j.stops;this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}#T(){if(!this.#$)return;let Q=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#j.stops;if(Q.length!==$.length){let J=this.#L;if(this.#$.innerHTML=this.#Y(),J)this.#$.appendChild(J);this.#I(),requestAnimationFrame(()=>this.#k());return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#U(j));let K=Z.closest("fig-tooltip");if(K)K.setAttribute("text",`${Math.round(j.position)}%`)}}#I(){if(!this.#Z||!this.#$)return;this.#Z.disconnect(),this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#$)return;let Q=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#j.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),K=(Z.getAttribute("color")||"").toUpperCase(),q=-1;for(let _=0;_<$.length;_++){if(J.has(_))continue;if($[_].position===j&&$[_].color.toUpperCase()===K){q=_;break}}if(q===-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,q=X}}if(q!==-1)J.add(q),Z.dataset.stopIndex=q})}#E(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#N())}#y(){if(!this.#$)return;this.#$.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.#$.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#B(J);this.#j.stops.push({position:Z,color:j,opacity:100}),this.#j.stops.sort((X,Y)=>X.position-Y.position);let K=this.#j.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#G=!0,this.#T(),this.#E(),this.#C(),this.#z();let _=this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)this.#$.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.#$.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.#j.stops[X]){if(this.#j.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#j.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#j.stops[X])),this.#E(),this.#C()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#j.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),K=j,q=this.#$.getBoundingClientRect().width;if(Q.detail?.shiftKey)K=Math.round(K/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let X=q>0?5/q*100:0;for(let Y=0;Y<this.#j.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#j.stops[Y].position-K)<=X){K=this.#j.stops[Y].position;break}}}if(this.#j.stops[J].position=K,K!==j)$.style.left=`${K/100*q-$.offsetWidth/2}px`;let _=$.closest("fig-tooltip");if(_){if(_.text=`${Math.round(K)}%`,!_.hasAttribute("show"))_.setAttribute("show","true"),$.hideColorTip()}this.#E(),this.#C()}),this.#$.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.#j.stops[X]){if(this.#j.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#j.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#j.stops[X])),this.#E(),this.#x()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#j.stops[Z])return;let j=Q.detail?.px??0,K=Math.round(j*100),q=this.#$.getBoundingClientRect().width,_=q>0?5/q*100:0;for(let X=0;X<this.#j.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#j.stops[X].position-K)<=_){K=this.#j.stops[X].position;break}}this.#j.stops[Z].position=K,$.style.left=`${K/100*q-$.offsetWidth/2}px`,this.#j.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#E(),this.#x(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Z=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.#j.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#j.stops[Z].color)this.#j.stops[Z].color=j,this.#E(),this.#C()}}),this.#$.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#C(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#x(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:d(this.#j)}}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.#E(),this.#T();break;case"disabled":this.#v();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#q);else document.removeEventListener("keydown",this.#q);break}}#v(){let Q=this.hasAttribute("disabled");if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)for(let $ of this.#$.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class Q0 extends HTMLElement{#Q=null;#$;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",u()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#$=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.#$),this.input.addEventListener("change",this.#$),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.#Q=$,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#Q.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#Q)this.#Q=document.createElement("label"),this.#Q.setAttribute("for",this.input.id);if(this.#Q&&!this.#Q.parentNode&&this.input.parentNode)this.input.after(this.#Q)}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.#$),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#Q.innerText=J;else if(this.#Q)this.#Q.remove(),this.#Q=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",Q0);class V0 extends Q0{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",V0);class w0 extends Q0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",w0);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 b0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#Q=!1;#$=null;#J=null;#K=null;#Z=null;#j=!1;#_=this.#Y.bind(this);#X=this.#L.bind(this);#q=this.#G.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Q=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#W(),this.#N(),this.hasAttribute("disabled"))this.#A(!0)}disconnectedCallback(){this.#U()}#W(){let Q=this.#B(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",K=this.#Q?"":`<fig-dropdown type="dropdown"${j}>${Q.map((q)=>`<option>${q.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
188
188
  <fig-input-text placeholder="${$}" value="${J}"></fig-input-text>
189
189
  <fig-button type="select" variant="input" icon>
190
190
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -192,7 +192,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
192
192
  </svg>
193
193
  ${K}
194
194
  </fig-button>
195
- </div>`,this.#$=this.querySelector("fig-input-text"),this.#K=this.querySelector("fig-button"),this.#Q&&this.#Z&&this.#K){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(Z)this.#Z.setAttribute("experimental",Z);this.#K.append(this.#Z)}this.#J=this.querySelector("fig-dropdown")}#U(){this.#J?.addEventListener("input",this.#_),this.#$?.addEventListener("input",this.#X),this.#$?.addEventListener("change",this.#q)}#W(){this.#J?.removeEventListener("input",this.#_),this.#$?.removeEventListener("input",this.#X),this.#$?.removeEventListener("change",this.#q)}#Y(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#$)this.#$.setAttribute("value",$);this.#M(),this.#B()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#M()}#G(Q){Q.stopPropagation();let $=Q.target.value??"";this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#B()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(Q){if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#K)if(Q)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled")}focus(){this.#$?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#Q){let Z=this.#A();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#$)this.#$.setAttribute("placeholder",J||"");break;case"value":if(!this.#j&&this.#$)this.#$.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.#Q)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",b0);class K0 extends HTMLElement{#Q="color";#$=null;#J=!1;constructor(){super();this.#$=this.#q.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#K()}#K(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#j(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=M0(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.#Z(J);if(Z!==this.#Q||!this.input){if(this.#Q=Z,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#$);if(this.#Q==="color"){let K=this.#j(J);if(this.innerHTML=`<div></div><input type="color" value="${K}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#$)}else this.innerHTML="<div></div>",this.input=null}else if(this.#Q==="color"&&this.input){let K=this.#j(J);if(this.input.value!==K)this.input.value=K}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})`)}#q(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.#K()}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 $0 extends HTMLElement{#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;#_=this.#R.bind(this);#X=this.#D.bind(this);#q=this.#H.bind(this);#N=this.#F.bind(this);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.#Q}set src(Q){if(this.#Q=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#j}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#Q)return null;if(!this.#J)return null;try{if(typeof this.#J.decode==="function")await this.#J.decode();else if(!this.#J.complete)await new Promise((Z,j)=>{this.#J.addEventListener("load",Z,{once:!0}),this.#J.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#J.naturalWidth,$=this.#J.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#J,0,0),J.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--aspect-ratio",Q);let $=this.getAttribute("fit");if($)this.style.setProperty("--fit",$);if(!this.querySelector("fig-chit")){let Z=document.createElement("fig-chit");if(Z.setAttribute("data-generated",""),Z.setAttribute("size","large"),Z.setAttribute("data-type",this.mediaKind),Z.setAttribute("disabled",""),this.#U(Z),this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false")Z.setAttribute("checkerboard","");this.prepend(Z)}if(this.#$=this.querySelector("fig-chit"),this.#W(),this.#G(),this.#B(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#A()}disconnectedCallback(){if(this.#K?.removeEventListener("change",this.#_),this.#Y(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null}#U(Q){let $=this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false";Q.setAttribute("background",$?"url()":"var(--figma-color-bg-secondary)")}#W(){if(!this.#$)return;this.#$.setAttribute("data-type",this.mediaKind)}#Y(){if(!this.#J)return;if(this.#J.tagName==="VIDEO")this.#J.removeEventListener("play",this.#X),this.#J.removeEventListener("pause",this.#q),this.#J.removeEventListener("ended",this.#N)}#L(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#G(){let Q=this.#L();if(Q){if(this.#J&&this.#J!==Q){if(this.#Y(),this.#J.hasAttribute("data-generated"))this.#J.remove()}this.#J=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#J&&this.#J.tagName!==$){if(this.#Y(),this.#J.hasAttribute("data-generated"))this.#J.remove();this.#J=null}if(this.#J)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="metadata",this.prepend(J),this.#J=J,this.#J.addEventListener("play",this.#X),this.#J.addEventListener("pause",this.#q),this.#J.addEventListener("ended",this.#N)}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.#J=J}}#M(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#B(){if(!this.#J)return;if(!this.#J.hasAttribute("data-generated"))return;let Q=this.#Q||"";if(this.#J.getAttribute("src")!==Q){if(Q)this.#J.setAttribute("src",Q);else if(this.#J.removeAttribute("src"),this.#J.tagName==="VIDEO")this.#J.load()}if(this.#J.tagName==="IMG"){this.#J.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#J.setAttribute("poster",$);else this.#J.removeAttribute("poster");this.#J.controls=this.#M("controls",!1),this.#J.autoplay=this.#M("autoplay",!1),this.#J.loop=this.#M("loop",!1),this.#J.muted=this.#M("muted",!1),this.#J.playsInline=!0}#A(){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.#Q?"Replace":$),this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#_),this.append(Q),this.#K=Q}#O(){if(this.#K)this.#K.removeEventListener("change",this.#_),this.#K.remove(),this.#K=null}#R(Q){if(Q.target!==this.#K)return;let $=Q.detail?.files?.[0];if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#j=null,this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#j=$,this.#Z=URL.createObjectURL($),this.setAttribute("src",this.#Z),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#K)this.#K.removeEventListener("change",this.#_),this.#K.clear(),this.#K.addEventListener("change",this.#_),this.#K.setAttribute("label","Replace")}#z(Q){if(!this.#J)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#J.currentTime,duration:this.#J.duration}}))}#D(){this.#z("play")}#H(){this.#z("pause")}#F(){this.#z("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){if(this.#Q=J||"",this.#Z&&this.#Q!==this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#j=null;if(this.#B(),this.#K){let Z=this.getAttribute("label")||"Upload";if(this.#K.setAttribute("label",this.#Q?"Replace":Z),this.#Q)this.#K.setAttribute("url",this.#Q);else this.#K.removeAttribute("url")}}if(Q==="type"){if(this.#W(),this.#G(),this.#B(),this.#K)this.#K.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#J&&this.#J.tagName==="IMG")this.#J.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#K)this.#A();else if(!Z)this.#O()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--aspect-ratio",J);else this.style.removeProperty("--aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fit",J);else this.style.removeProperty("--fit");if(Q==="checkerboard"){if(this.#$){if(J!==null&&J!=="false")this.#$.setAttribute("checkerboard","");else this.#$.removeAttribute("checkerboard");this.#U(this.#$)}}if(Q==="label"&&this.#K){let Z=this.getAttribute("label")||"Upload";this.#K.setAttribute("label",this.#Q?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#B()}}customElements.define("fig-media",$0);class g0 extends $0{get mediaKind(){return"image"}}customElements.define("fig-image",g0);class m0 extends $0{get mediaKind(){return"video"}}customElements.define("fig-video",m0);class c0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url"];#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;get files(){return this.#j}get#_(){let Q=this.getAttribute("url");if(!Q)return"";try{let J=new URL(Q,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Q}catch{return Q}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#_}connectedCallback(){this.#L(),this.addEventListener("dragover",this.#U),this.addEventListener("dragleave",this.#W),this.addEventListener("drop",this.#Y)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#q),this.#J?.removeEventListener("click",this.#N),this.removeEventListener("dragover",this.#U),this.removeEventListener("dragleave",this.#W),this.removeEventListener("drop",this.#Y)}attributeChangedCallback(Q,$,J){if($===J)return;this.#L()}clear(){if(this.#j=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.#L(),this.#X()}#X(){let Q={files:this.#j};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#q=()=>{if(this.#Q.files.length>0)this.#j=this.#Q.files,this.removeAttribute("url"),this.#L(),this.#X()};#N=(Q)=>{Q.stopPropagation(),this.clear()};#U=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#W=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#Y=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.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((K)=>K.trim().toLowerCase());J=J.filter((K)=>{let q="."+K.name.split(".").pop().toLowerCase(),_=K.type.toLowerCase();return j.some((X)=>X===q||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.#j=Z.files,this.#Q)this.#Q.files=Z.files;this.removeAttribute("url"),this.#L(),this.#X()};#L(){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",K=this.#j&&this.#j.length>0||!!this.getAttribute("url");if(this.innerHTML="",K){let q=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.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.#Z.appendChild(_),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",Q)this.#Q.setAttribute("accept",Q);if(Z)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#q),this.#Z.appendChild(this.#Q),q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q),this.#K.appendChild(this.#Z),this.appendChild(this.#K);else this.appendChild(this.#Z);let W=document.createElement("fig-tooltip");if(W.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant","ghost"),this.#J.setAttribute("icon","true"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");this.#J.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-minus);"></span>',this.#J.addEventListener("click",this.#N),W.appendChild(this.#J),this.appendChild(W)}else{let q=Q?`Accepts ${Q.split(",").map((_)=>_.trim()).join(", ")}`:"";if(q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",Q)this.#Q.setAttribute("accept",Q);if(Z)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#q),this.#Z.appendChild(this.#Q),this.#K)this.#K.appendChild(this.#Z),this.appendChild(this.#K);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",c0);class w extends HTMLElement{#Q={x:0.42,y:0};#$={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#K="bezier";#Z=2;#j=null;#_=null;#X=null;#q=null;#N=null;#U=null;#W=null;#Y=null;#L=null;#G=null;#M=null;#B=null;#A=0.8;#O=200;#R=200;#z=null;#D=null;#H=null;#F=5;#P=2;#S=10;#V=10;#k=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"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#T(Q);this.#M=this.#C(),this.#I(),this.#q0()}disconnectedCallback(){if(this.#j=null,this.#H)this.#H.disconnect(),this.#H=null}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){if(x(this,"--aspect-ratio",J),this.#_)this.#d(),this.#h();return}if(!this.#_)return;if(Q==="value"&&J){let Z=this.#K;if(this.#T(J),this.#M=this.#C(),Z!==this.#K)this.#I();else this.#h(),this.#n()}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#K==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}`}get cssValue(){if(this.#K==="spring"){let $=this.#w(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let K=0;K<$.length;K+=Z)j.push($[K].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;return`cubic-bezier(${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#T(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($){this.#K="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]);return}let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))this.#K="bezier",this.#Q.x=J[0],this.#Q.y=J[1],this.#$.x=J[2],this.#$.y=J[3]}#C(){if(this.#K==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#Q.x-$.value[0])<0.001&&Math.abs(this.#Q.y-$.value[1])<0.001&&Math.abs(this.#$.x-$.value[2])<0.001&&Math.abs(this.#$.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"}#w(){let{stiffness:Q,damping:$,mass:J}=this.#J,Z=0.004,j=5,K=[],q=0,_=0;for(let X=0;X<=5;X+=0.004){let Y=-Q*(q-1)-$*_;if(_+=Y/J*0.004,q+=_*0.004,K.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(_)<0.0005)break}return K}static#E(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,K=0.004,q=5,_=[],X=0,Y=0;for(let O=0;O<=5;O+=0.004){let A=-J*(X-1)-Z*Y;if(Y+=A/j*0.004,X+=Y*0.004,_.push({t:O,value:X}),O>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}let W=_[_.length-1].t||1,N=1;for(let O of _)if(O.value>N)N=O.value;let G=0;for(let O of _)if(O.value<G)G=O.value;let D=Math.max(N-G,1),R=6,L=$-R*2,B=Math.max(1,Math.floor(_.length/30)),M="";for(let O=0;O<_.length;O+=B){let A=R+_[O].t/W*L,F=R+(1-(_[O].value-G)/D)*L;M+=(O===0?"M":"L")+A.toFixed(1)+","+F.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${M}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let q=(j-12)/2,_=48,X=[],Y=(A,F,T,S,y)=>{let I=1-y;return I*I*I*A+3*I*I*y*F+3*I*y*y*T+y*y*y*S};for(let A=0;A<=48;A++){let F=A/48;X.push({x:Y(0,Q,J,1,F),y:Y(0,$,Z,1,F)})}let W=1/0,N=-1/0,G=1/0,D=-1/0;for(let A of X){if(A.x<W)W=A.x;if(A.x>N)N=A.x;if(A.y<G)G=A.y;if(A.y>D)D=A.y}let R=Math.max(N-W,0.000001),L=Math.max(D-G,0.000001),B=(A)=>q+(A-W)/R*12,M=(A)=>q+(1-(A-G)/L)*12,O="";for(let A=0;A<X.length;A++){let F=B(X[A].x),T=M(X[A].y);O+=`${A===0?"M":"L"}${F.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${O}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#I(){this.classList.toggle("spring-mode",this.#K==="spring"),this.classList.toggle("bezier-mode",this.#K!=="spring"),this.#l(),this.innerHTML=this.#x(),this.#K0(),this.#u(),this.#d(),this.#h(),this.#_0()}#y(){if(this.getAttribute("dropdown")!=="true")return"";let Q="",$=void 0;for(let J of w.PRESETS){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 K=J.spring||this.#J;Z=w.#E(K)}else{let K=J.value||[this.#Q.x,this.#Q.y,this.#$.x,this.#$.y];Z=w.curveIcon(...K)}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>`}#x(){let $=this.#y();if(this.#K==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
195
+ </div>`,this.#$=this.querySelector("fig-input-text"),this.#K=this.querySelector("fig-button"),this.#Q&&this.#Z&&this.#K){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(Z)this.#Z.setAttribute("experimental",Z);this.#K.append(this.#Z)}this.#J=this.querySelector("fig-dropdown")}#N(){this.#J?.addEventListener("input",this.#_),this.#$?.addEventListener("input",this.#X),this.#$?.addEventListener("change",this.#q)}#U(){this.#J?.removeEventListener("input",this.#_),this.#$?.removeEventListener("input",this.#X),this.#$?.removeEventListener("change",this.#q)}#Y(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#$)this.#$.setAttribute("value",$);this.#M(),this.#O()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#M()}#G(Q){Q.stopPropagation();let $=Q.target.value??"";this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.#O()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#B(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#A(Q){if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#K)if(Q)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled")}focus(){this.#$?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#Q){let Z=this.#B();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#$)this.#$.setAttribute("placeholder",J||"");break;case"value":if(!this.#j&&this.#$)this.#$.setAttribute("value",J||"");break;case"disabled":this.#A(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#Q)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",b0);class K0 extends HTMLElement{#Q="color";#$=null;#J=!1;constructor(){super();this.#$=this.#q.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#K()}#K(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#j(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=M0(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.#Z(J);if(Z!==this.#Q||!this.input){if(this.#Q=Z,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#$);if(this.#Q==="color"){let K=this.#j(J);if(this.innerHTML=`<div></div><input type="color" value="${K}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#$)}else this.innerHTML="<div></div>",this.input=null}else if(this.#Q==="color"&&this.input){let K=this.#j(J);if(this.input.value!==K)this.input.value=K}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})`)}#q(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.#K()}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 $0 extends HTMLElement{#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;#_=this.#R.bind(this);#X=this.#F.bind(this);#q=this.#H.bind(this);#W=this.#D.bind(this);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.#Q}set src(Q){if(this.#Q=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#j}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#Q)return null;if(!this.#J)return null;try{if(typeof this.#J.decode==="function")await this.#J.decode();else if(!this.#J.complete)await new Promise((Z,j)=>{this.#J.addEventListener("load",Z,{once:!0}),this.#J.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#J.naturalWidth,$=this.#J.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#J,0,0),J.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--aspect-ratio",Q);let $=this.getAttribute("fit");if($)this.style.setProperty("--fit",$);if(!this.querySelector("fig-chit")){let Z=document.createElement("fig-chit");if(Z.setAttribute("data-generated",""),Z.setAttribute("size","large"),Z.setAttribute("data-type",this.mediaKind),Z.setAttribute("disabled",""),this.#N(Z),this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false")Z.setAttribute("checkerboard","");this.prepend(Z)}if(this.#$=this.querySelector("fig-chit"),this.#U(),this.#G(),this.#O(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#B()}disconnectedCallback(){if(this.#K?.removeEventListener("change",this.#_),this.#Y(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null}#N(Q){let $=this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false";Q.setAttribute("background",$?"url()":"var(--figma-color-bg-secondary)")}#U(){if(!this.#$)return;this.#$.setAttribute("data-type",this.mediaKind)}#Y(){if(!this.#J)return;if(this.#J.tagName==="VIDEO")this.#J.removeEventListener("play",this.#X),this.#J.removeEventListener("pause",this.#q),this.#J.removeEventListener("ended",this.#W)}#L(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#G(){let Q=this.#L();if(Q){if(this.#J&&this.#J!==Q){if(this.#Y(),this.#J.hasAttribute("data-generated"))this.#J.remove()}this.#J=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#J&&this.#J.tagName!==$){if(this.#Y(),this.#J.hasAttribute("data-generated"))this.#J.remove();this.#J=null}if(this.#J)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="metadata",this.prepend(J),this.#J=J,this.#J.addEventListener("play",this.#X),this.#J.addEventListener("pause",this.#q),this.#J.addEventListener("ended",this.#W)}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.#J=J}}#M(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#O(){if(!this.#J)return;if(!this.#J.hasAttribute("data-generated"))return;let Q=this.#Q||"";if(this.#J.getAttribute("src")!==Q){if(Q)this.#J.setAttribute("src",Q);else if(this.#J.removeAttribute("src"),this.#J.tagName==="VIDEO")this.#J.load()}if(this.#J.tagName==="IMG"){this.#J.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#J.setAttribute("poster",$);else this.#J.removeAttribute("poster");this.#J.controls=this.#M("controls",!1),this.#J.autoplay=this.#M("autoplay",!1),this.#J.loop=this.#M("loop",!1),this.#J.muted=this.#M("muted",!1),this.#J.playsInline=!0}#B(){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.#Q?"Replace":$),this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#_),this.append(Q),this.#K=Q}#A(){if(this.#K)this.#K.removeEventListener("change",this.#_),this.#K.remove(),this.#K=null}#R(Q){if(Q.target!==this.#K)return;let $=Q.detail?.files?.[0];if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#j=null,this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#j=$,this.#Z=URL.createObjectURL($),this.setAttribute("src",this.#Z),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#K)this.#K.removeEventListener("change",this.#_),this.#K.clear(),this.#K.addEventListener("change",this.#_),this.#K.setAttribute("label","Replace")}#z(Q){if(!this.#J)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#J.currentTime,duration:this.#J.duration}}))}#F(){this.#z("play")}#H(){this.#z("pause")}#D(){this.#z("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){if(this.#Q=J||"",this.#Z&&this.#Q!==this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#j=null;if(this.#O(),this.#K){let Z=this.getAttribute("label")||"Upload";if(this.#K.setAttribute("label",this.#Q?"Replace":Z),this.#Q)this.#K.setAttribute("url",this.#Q);else this.#K.removeAttribute("url")}}if(Q==="type"){if(this.#U(),this.#G(),this.#O(),this.#K)this.#K.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#J&&this.#J.tagName==="IMG")this.#J.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#K)this.#B();else if(!Z)this.#A()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--aspect-ratio",J);else this.style.removeProperty("--aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fit",J);else this.style.removeProperty("--fit");if(Q==="checkerboard"){if(this.#$){if(J!==null&&J!=="false")this.#$.setAttribute("checkerboard","");else this.#$.removeAttribute("checkerboard");this.#N(this.#$)}}if(Q==="label"&&this.#K){let Z=this.getAttribute("label")||"Upload";this.#K.setAttribute("label",this.#Q?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#O()}}customElements.define("fig-media",$0);class g0 extends $0{get mediaKind(){return"image"}}customElements.define("fig-image",g0);class m0 extends $0{get mediaKind(){return"video"}}customElements.define("fig-video",m0);class c0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url"];#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;get files(){return this.#j}get#_(){let Q=this.getAttribute("url");if(!Q)return"";try{let J=new URL(Q,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Q}catch{return Q}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#_}connectedCallback(){this.#L(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#U),this.addEventListener("drop",this.#Y)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#q),this.#J?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#U),this.removeEventListener("drop",this.#Y)}attributeChangedCallback(Q,$,J){if($===J)return;this.#L()}clear(){if(this.#j=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.#L(),this.#X()}#X(){let Q={files:this.#j};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#q=()=>{if(this.#Q.files.length>0)this.#j=this.#Q.files,this.removeAttribute("url"),this.#L(),this.#X()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#U=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#Y=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.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((K)=>K.trim().toLowerCase());J=J.filter((K)=>{let q="."+K.name.split(".").pop().toLowerCase(),_=K.type.toLowerCase();return j.some((X)=>X===q||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.#j=Z.files,this.#Q)this.#Q.files=Z.files;this.removeAttribute("url"),this.#L(),this.#X()};#L(){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",K=this.#j&&this.#j.length>0||!!this.getAttribute("url");if(this.innerHTML="",K){let q=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.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.#Z.appendChild(_),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",Q)this.#Q.setAttribute("accept",Q);if(Z)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#q),this.#Z.appendChild(this.#Q),q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q),this.#K.appendChild(this.#Z),this.appendChild(this.#K);else this.appendChild(this.#Z);let W=document.createElement("fig-tooltip");if(W.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant","ghost"),this.#J.setAttribute("icon","true"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");this.#J.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-minus);"></span>',this.#J.addEventListener("click",this.#W),W.appendChild(this.#J),this.appendChild(W)}else{let q=Q?`Accepts ${Q.split(",").map((_)=>_.trim()).join(", ")}`:"";if(q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",Q)this.#Q.setAttribute("accept",Q);if(Z)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#q),this.#Z.appendChild(this.#Q),this.#K)this.#K.appendChild(this.#Z),this.appendChild(this.#K);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",c0);class w extends HTMLElement{#Q={x:0.42,y:0};#$={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#K="bezier";#Z=2;#j=null;#_=null;#X=null;#q=null;#W=null;#N=null;#U=null;#Y=null;#L=null;#G=null;#M=null;#O=null;#B=0.8;#A=200;#R=200;#z=null;#F=null;#H=null;#D=5;#P=2;#S=10;#V=10;#k=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"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#T(Q);this.#M=this.#I(),this.#y(),this.#q0()}disconnectedCallback(){if(this.#j=null,this.#H)this.#H.disconnect(),this.#H=null}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){if(x(this,"--aspect-ratio",J),this.#_)this.#d(),this.#h();return}if(!this.#_)return;if(Q==="value"&&J){let Z=this.#K;if(this.#T(J),this.#M=this.#I(),Z!==this.#K)this.#y();else this.#h(),this.#n()}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#K==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}`}get cssValue(){if(this.#K==="spring"){let $=this.#w(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let K=0;K<$.length;K+=Z)j.push($[K].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;return`cubic-bezier(${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#T(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($){this.#K="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]);return}let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))this.#K="bezier",this.#Q.x=J[0],this.#Q.y=J[1],this.#$.x=J[2],this.#$.y=J[3]}#I(){if(this.#K==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#Q.x-$.value[0])<0.001&&Math.abs(this.#Q.y-$.value[1])<0.001&&Math.abs(this.#$.x-$.value[2])<0.001&&Math.abs(this.#$.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"}#w(){let{stiffness:Q,damping:$,mass:J}=this.#J,Z=0.004,j=5,K=[],q=0,_=0;for(let X=0;X<=5;X+=0.004){let Y=-Q*(q-1)-$*_;if(_+=Y/J*0.004,q+=_*0.004,K.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(_)<0.0005)break}return K}static#E(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,K=0.004,q=5,_=[],X=0,Y=0;for(let B=0;B<=5;B+=0.004){let A=-J*(X-1)-Z*Y;if(Y+=A/j*0.004,X+=Y*0.004,_.push({t:B,value:X}),B>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}let W=_[_.length-1].t||1,N=1;for(let B of _)if(B.value>N)N=B.value;let G=0;for(let B of _)if(B.value<G)G=B.value;let D=Math.max(N-G,1),R=6,L=$-R*2,O=Math.max(1,Math.floor(_.length/30)),M="";for(let B=0;B<_.length;B+=O){let A=R+_[B].t/W*L,F=R+(1-(_[B].value-G)/D)*L;M+=(B===0?"M":"L")+A.toFixed(1)+","+F.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${M}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let q=(j-12)/2,_=48,X=[],Y=(A,F,T,S,f)=>{let I=1-f;return I*I*I*A+3*I*I*f*F+3*I*f*f*T+f*f*f*S};for(let A=0;A<=48;A++){let F=A/48;X.push({x:Y(0,Q,J,1,F),y:Y(0,$,Z,1,F)})}let W=1/0,N=-1/0,G=1/0,D=-1/0;for(let A of X){if(A.x<W)W=A.x;if(A.x>N)N=A.x;if(A.y<G)G=A.y;if(A.y>D)D=A.y}let R=Math.max(N-W,0.000001),L=Math.max(D-G,0.000001),O=(A)=>q+(A-W)/R*12,M=(A)=>q+(1-(A-G)/L)*12,B="";for(let A=0;A<X.length;A++){let F=O(X[A].x),T=M(X[A].y);B+=`${A===0?"M":"L"}${F.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${B}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#y(){this.classList.toggle("spring-mode",this.#K==="spring"),this.classList.toggle("bezier-mode",this.#K!=="spring"),this.#l(),this.innerHTML=this.#x(),this.#K0(),this.#p(),this.#d(),this.#h(),this.#_0()}#C(){if(this.getAttribute("dropdown")!=="true")return"";let Q="",$=void 0;for(let J of w.PRESETS){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 K=J.spring||this.#J;Z=w.#E(K)}else{let K=J.value||[this.#Q.x,this.#Q.y,this.#$.x,this.#$.y];Z=w.curveIcon(...K)}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>`}#x(){let $=this.#C();if(this.#K==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
196
196
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
197
197
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
198
198
  <line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
@@ -209,7 +209,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
209
209
  <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#P}"/>
210
210
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
211
211
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
212
- </svg></div>`}#v(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#l(){this.#P=this.#v("--easing-bezier-endpoint-radius",this.#P),this.#k=this.#v("--easing-duration-bar-radius",this.#k)}#K0(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#q=this.querySelector('[data-arm="1"]'),this.#N=this.querySelector('[data-arm="2"]'),this.#U=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#W=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector('[data-endpoint="start"]'),this.#L=this.querySelector('[data-endpoint="end"]'),this.#G=this.querySelector(".fig-easing-curve-dropdown"),this.#B=this.querySelector(".fig-easing-curve-target"),this.#z=this.querySelector(".fig-easing-curve-bounds"),this.#D=this.querySelector(".fig-easing-curve-diagonal")}#u(){let Q=this.#U?.querySelector("fig-handle"),$=this.#W?.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.#U.setAttribute("width",J),this.#U.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#S,Z=$.offsetHeight||this.#V;if(this.#K==="spring")this.#S=J,this.#V=Z;this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}}#q0(){if(this.#H||!window.ResizeObserver)return;this.#H=new ResizeObserver(()=>{if(this.#d())this.#h()}),this.#H.observe(this)}#d(){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.#O||J!==this.#R;return this.#O=$,this.#R=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#b(Q,$){return{x:Q*this.#O,y:(1-$)*this.#R}}#m(Q,$){return{x:Q/this.#O,y:1-$/this.#R}}#t={minVal:0,maxVal:1.2,totalTime:1};#c(Q,$){let Z=this.#R-40,{minVal:j,maxVal:K}=this.#t,q=K-j||1;return{x:Q*this.#O,y:20+(1-($-j)/q)*Z}}#h(){if(this.#d(),this.#K==="spring")this.#$0();else this.#Q0()}#Q0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#O),this.#z.setAttribute("height",this.#R);if(this.#D)this.#D.setAttribute("x1","0"),this.#D.setAttribute("y1",this.#R),this.#D.setAttribute("x2",this.#O),this.#D.setAttribute("y2","0");let Q=this.#b(0,0),$=this.#b(this.#Q.x,this.#Q.y),J=this.#b(this.#$.x,this.#$.y),Z=this.#b(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#q.setAttribute("x1",Q.x),this.#q.setAttribute("y1",Q.y),this.#q.setAttribute("x2",$.x),this.#q.setAttribute("y2",$.y),this.#N.setAttribute("x1",Z.x),this.#N.setAttribute("y1",Z.y),this.#N.setAttribute("x2",J.x),this.#N.setAttribute("y2",J.y);let j=this.#F;if(this.#U.setAttribute("x",$.x-j),this.#U.setAttribute("y",$.y-j),this.#W.setAttribute("x",J.x-j),this.#W.setAttribute("y",J.y-j),this.#Y)this.#Y.setAttribute("cx",Q.x),this.#Y.setAttribute("cy",Q.y);if(this.#L)this.#L.setAttribute("cx",Z.x),this.#L.setAttribute("cy",Z.y)}#$0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#O),this.#z.setAttribute("height",this.#R);let Q=this.#w();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let L of Q){if(L.value<J)J=L.value;if(L.value>Z)Z=L.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),K=0;this.#t={minVal:1-j-K,maxVal:1+j+K,totalTime:$};let q=Math.max(0.05,Math.min(0.95,this.#A)),_="";for(let L=0;L<Q.length;L++){let B=Q[L].t/$*q,M=this.#c(B,Q[L].value);_+=(L===0?"M":"L")+M.x.toFixed(1)+","+M.y.toFixed(1)}let X=this.#c(q,1),Y=this.#c(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.#B){let L=this.#c(0,1),B=this.#c(1,1);this.#B.setAttribute("x1",L.x),this.#B.setAttribute("y1",L.y),this.#B.setAttribute("x2",B.x),this.#B.setAttribute("y2",B.y)}let W=this.#J0(Q),N=W.t/$*q,G=this.#c(N,W.value),D=this.#F;this.#U.setAttribute("x",G.x-D),this.#U.setAttribute("y",G.y-D);let R=this.#c(q,1);this.#W.setAttribute("x",R.x-this.#S/2),this.#W.setAttribute("y",R.y-this.#V/2)}#J0(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 $}#n(){if(!this.#G)return;this.#G.value=this.#M,this.#i()}#r(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#i(){if(!this.#G)return;let Q=w.curveIcon(this.#Q.x,this.#Q.y,this.#$.x,this.#$.y),$=w.#E(this.#J);this.#r(this.#G,"Custom bezier",Q),this.#r(this.#G,"Custom spring",$),this.#r(this.#G.select,"Custom bezier",Q),this.#r(this.#G.select,"Custom spring",$)}#g(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#K,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#_0(){if(this.#K==="bezier"){this.#U.addEventListener("pointerdown",($)=>this.#a($,1)),this.#W.addEventListener("pointerdown",($)=>this.#a($,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.#a($,this.#X0($))})}else{this.#U.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#o($,"bounce")}),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#o($,"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.#o($,"duration")})}if(this.#G)this.#G.addEventListener("change",(Q)=>{let $=Q.detail,J=w.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#Q.x=J.value[0],this.#Q.y=J.value[1],this.#$.x=J.value[2],this.#$.y=J.value[3];if(this.#M=$,this.#K!=="bezier")this.#K="bezier",this.#I();else this.#h()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#M=$,this.#K!=="spring")this.#K="spring",this.#I();else this.#h()}this.#g("input"),this.#g("change")})}#Z0(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}}#X0(Q){return this.#Z0(Q).x<=this.#O/2?1:2}#a(Q,$){Q.preventDefault(),this.#j=$;let J=(j)=>{if(!this.#j)return;let K=this.#Z0(j),q=this.#m(K.x,K.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#j===1)this.#Q.x=q.x,this.#Q.y=q.y;else this.#$.x=q.x,this.#$.y=q.y;this.#h(),this.#M=this.#C(),this.#n(),this.#g("input")},Z=()=>{this.#j=null,document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#g("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#o(Q,$){Q.preventDefault(),this.#j=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#A,K=Q.clientY,q=Q.clientX,_=(Y)=>{if(!this.#j)return;if($==="bounce"){let W=Y.clientY-K;this.#J.damping=Math.max(1,Math.round(J+W*0.15))}else{let W=Y.clientX-q;this.#A=Math.max(0.05,Math.min(0.95,j+W/200)),this.#J.stiffness=Math.max(10,Math.round(Z-W*1.5))}this.#h(),this.#M=this.#C(),this.#n(),this.#g("input")},X=()=>{this.#j=null,document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",X),this.#g("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",w);class p0 extends HTMLElement{#Q=0;#$=0;#J=0;#K=1;#Z=!1;#j=!1;#_=null;#X=null;#q=null;#N=null;#U=[];#W={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#K=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.#M(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#B(Q);this.#A(),this.#G(this.getAttribute("selected")),this.#L()}disconnectedCallback(){if(this.#Z=!1,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#N)}#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())}#L(){if(!this.#X)return;this.#X.style.cursor=this.#F?"":"default"}#G(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))}#M(Q){if(!Q||!Q.trim()){this.#U=[];return}let $=["rotateX","rotateY","rotateZ"];this.#U=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.#G(J);return}if(Q==="drag"){this.#L();return}if(Q==="fields"){if(this.#M(J),this.#_)this.#A();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#B(J),this.#R(),this.#O()}if(Q==="precision")this.#K=parseInt(J||"1")}get value(){let Q=this.#K;return`rotateX(${this.#Q.toFixed(Q)}deg) rotateY(${this.#$.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Q}get rotateY(){return this.#$}get rotateZ(){return this.#J}#B(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.#Q=parseFloat($[1]);if(J)this.#$=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#A(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J},J=this.#U.map((Z)=>`<fig-input-number
212
+ </svg></div>`}#v(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#l(){this.#P=this.#v("--easing-bezier-endpoint-radius",this.#P),this.#k=this.#v("--easing-duration-bar-radius",this.#k)}#K0(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#q=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#U=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector('[data-endpoint="start"]'),this.#L=this.querySelector('[data-endpoint="end"]'),this.#G=this.querySelector(".fig-easing-curve-dropdown"),this.#O=this.querySelector(".fig-easing-curve-target"),this.#z=this.querySelector(".fig-easing-curve-bounds"),this.#F=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#N?.querySelector("fig-handle"),$=this.#U?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#D*2,Z=Q.offsetHeight||this.#D*2;this.#D=Math.max(J,Z)/2,this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#S,Z=$.offsetHeight||this.#V;if(this.#K==="spring")this.#S=J,this.#V=Z;this.#U.setAttribute("width",J),this.#U.setAttribute("height",Z)}}#q0(){if(this.#H||!window.ResizeObserver)return;this.#H=new ResizeObserver(()=>{if(this.#d())this.#h()}),this.#H.observe(this)}#d(){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.#A||J!==this.#R;return this.#A=$,this.#R=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#b(Q,$){return{x:Q*this.#A,y:(1-$)*this.#R}}#m(Q,$){return{x:Q/this.#A,y:1-$/this.#R}}#t={minVal:0,maxVal:1.2,totalTime:1};#c(Q,$){let Z=this.#R-40,{minVal:j,maxVal:K}=this.#t,q=K-j||1;return{x:Q*this.#A,y:20+(1-($-j)/q)*Z}}#h(){if(this.#d(),this.#K==="spring")this.#$0();else this.#Q0()}#Q0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#A),this.#z.setAttribute("height",this.#R);if(this.#F)this.#F.setAttribute("x1","0"),this.#F.setAttribute("y1",this.#R),this.#F.setAttribute("x2",this.#A),this.#F.setAttribute("y2","0");let Q=this.#b(0,0),$=this.#b(this.#Q.x,this.#Q.y),J=this.#b(this.#$.x,this.#$.y),Z=this.#b(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#q.setAttribute("x1",Q.x),this.#q.setAttribute("y1",Q.y),this.#q.setAttribute("x2",$.x),this.#q.setAttribute("y2",$.y),this.#W.setAttribute("x1",Z.x),this.#W.setAttribute("y1",Z.y),this.#W.setAttribute("x2",J.x),this.#W.setAttribute("y2",J.y);let j=this.#D;if(this.#N.setAttribute("x",$.x-j),this.#N.setAttribute("y",$.y-j),this.#U.setAttribute("x",J.x-j),this.#U.setAttribute("y",J.y-j),this.#Y)this.#Y.setAttribute("cx",Q.x),this.#Y.setAttribute("cy",Q.y);if(this.#L)this.#L.setAttribute("cx",Z.x),this.#L.setAttribute("cy",Z.y)}#$0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#A),this.#z.setAttribute("height",this.#R);let Q=this.#w();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let L of Q){if(L.value<J)J=L.value;if(L.value>Z)Z=L.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),K=0;this.#t={minVal:1-j-K,maxVal:1+j+K,totalTime:$};let q=Math.max(0.05,Math.min(0.95,this.#B)),_="";for(let L=0;L<Q.length;L++){let O=Q[L].t/$*q,M=this.#c(O,Q[L].value);_+=(L===0?"M":"L")+M.x.toFixed(1)+","+M.y.toFixed(1)}let X=this.#c(q,1),Y=this.#c(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.#O){let L=this.#c(0,1),O=this.#c(1,1);this.#O.setAttribute("x1",L.x),this.#O.setAttribute("y1",L.y),this.#O.setAttribute("x2",O.x),this.#O.setAttribute("y2",O.y)}let W=this.#J0(Q),N=W.t/$*q,G=this.#c(N,W.value),D=this.#D;this.#N.setAttribute("x",G.x-D),this.#N.setAttribute("y",G.y-D);let R=this.#c(q,1);this.#U.setAttribute("x",R.x-this.#S/2),this.#U.setAttribute("y",R.y-this.#V/2)}#J0(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 $}#n(){if(!this.#G)return;this.#G.value=this.#M,this.#i()}#r(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#i(){if(!this.#G)return;let Q=w.curveIcon(this.#Q.x,this.#Q.y,this.#$.x,this.#$.y),$=w.#E(this.#J);this.#r(this.#G,"Custom bezier",Q),this.#r(this.#G,"Custom spring",$),this.#r(this.#G.select,"Custom bezier",Q),this.#r(this.#G.select,"Custom spring",$)}#g(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#K,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#_0(){if(this.#K==="bezier"){this.#N.addEventListener("pointerdown",($)=>this.#a($,1)),this.#U.addEventListener("pointerdown",($)=>this.#a($,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.#a($,this.#X0($))})}else{this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#o($,"bounce")}),this.#U.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#o($,"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.#o($,"duration")})}if(this.#G)this.#G.addEventListener("change",(Q)=>{let $=Q.detail,J=w.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#Q.x=J.value[0],this.#Q.y=J.value[1],this.#$.x=J.value[2],this.#$.y=J.value[3];if(this.#M=$,this.#K!=="bezier")this.#K="bezier",this.#y();else this.#h()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#M=$,this.#K!=="spring")this.#K="spring",this.#y();else this.#h()}this.#g("input"),this.#g("change")})}#Z0(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}}#X0(Q){return this.#Z0(Q).x<=this.#A/2?1:2}#a(Q,$){Q.preventDefault(),this.#j=$;let J=(j)=>{if(!this.#j)return;let K=this.#Z0(j),q=this.#m(K.x,K.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#j===1)this.#Q.x=q.x,this.#Q.y=q.y;else this.#$.x=q.x,this.#$.y=q.y;this.#h(),this.#M=this.#I(),this.#n(),this.#g("input")},Z=()=>{this.#j=null,document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#g("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#o(Q,$){Q.preventDefault(),this.#j=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#B,K=Q.clientY,q=Q.clientX,_=(Y)=>{if(!this.#j)return;if($==="bounce"){let W=Y.clientY-K;this.#J.damping=Math.max(1,Math.round(J+W*0.15))}else{let W=Y.clientX-q;this.#B=Math.max(0.05,Math.min(0.95,j+W/200)),this.#J.stiffness=Math.max(10,Math.round(Z-W*1.5))}this.#h(),this.#M=this.#I(),this.#n(),this.#g("input")},X=()=>{this.#j=null,document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",X),this.#g("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",w);class u0 extends HTMLElement{#Q=0;#$=0;#J=0;#K=1;#Z=!1;#j=!1;#_=null;#X=null;#q=null;#W=null;#N=[];#U={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#K=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.#M(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#O(Q);this.#B(),this.#G(this.getAttribute("selected")),this.#L()}disconnectedCallback(){if(this.#Z=!1,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#W)}#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())}#L(){if(!this.#X)return;this.#X.style.cursor=this.#D?"":"default"}#G(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))}#M(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.#G(J);return}if(Q==="drag"){this.#L();return}if(Q==="fields"){if(this.#M(J),this.#_)this.#B();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#O(J),this.#R(),this.#A()}if(Q==="precision")this.#K=parseInt(J||"1")}get value(){let Q=this.#K;return`rotateX(${this.#Q.toFixed(Q)}deg) rotateY(${this.#$.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Q}get rotateY(){return this.#$}get rotateZ(){return this.#J}#O(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.#Q=parseFloat($[1]);if(J)this.#$=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#B(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J},J=this.#N.map((Z)=>`<fig-input-number
213
213
  name="${Z}"
214
214
  step="1"
215
215
  precision="1"
@@ -227,7 +227,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
227
227
  <div class="fig-3d-rotate-face bottom"></div>
228
228
  </div>
229
229
  </div>
230
- </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#W={};for(let Z of this.#U){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#W[Z]=j;let K=(q)=>{q.stopPropagation();let _=parseFloat(q.target.value);if(isNaN(_))return;if(Z==="rotateX")this.#Q=_;else if(Z==="rotateY")this.#$=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#z(q.type)};j.addEventListener("input",K),j.addEventListener("change",K)}}this.#R(),this.#H()}#O(){let Q={rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J};for(let $ of this.#U){let J=this.#W[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#K))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#$}deg) rotateZ(${this.#J}deg)`}#z(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J}}))}#D(Q){if(!this.#j)return Q;return Math.round(Q/15)*15}#H(){this.#X.addEventListener("pointerdown",(Q)=>this.#P(Q)),this.#q=(Q)=>{if(Q.key==="Shift")this.#j=!0},this.#N=(Q)=>{if(Q.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#N)}get#F(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#P(Q){if(!this.#F)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#Q,j=this.#$,K=(_)=>{if(!this.#Z)return;if(_.buttons===0){q();return}let X=_.clientX-$,Y=_.clientY-J;this.#$=this.#D(j+X*0.5),this.#Q=this.#D(Z-Y*0.5),this.#R(),this.#O(),this.setAttribute("value",this.value),this.#z("input")},q=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",K),this.#X.removeEventListener("pointerup",q),this.#X.removeEventListener("pointercancel",q),this.#X.removeEventListener("lostpointercapture",q),this.#z("change")};this.#X.addEventListener("pointermove",K),this.#X.addEventListener("pointerup",q),this.#X.addEventListener("pointercancel",q),this.#X.addEventListener("lostpointercapture",q)}}customElements.define("fig-3d-rotate",p0);class q0 extends HTMLElement{#Q=50;#$=50;#J=0;#K=null;#Z=[];#j=null;#_=null;#X=null;#q=!1;#N=!1;#U=null;#W=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.#z(),this.#M(),this.#H()}disconnectedCallback(){this.#q=!1,this.#x()}get value(){let Q=this.#J;return`${this.#Q.toFixed(Q)}% ${this.#$.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.#M();return}if(Q==="fields"){this.#z(),this.#M(),this.#H();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#D(),this.#H();return}if(Q==="value"){if(this.#N||this.#q)return;this.#R(J),this.#P(),this.#S(),this.#D()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#G(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#K)return;this.#K.classList.toggle("drag-disabled",!this.#L)}#B(Q){return Math.max(0,Math.min(100,Q))}#A(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#Q:this.#$;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.#Q:this.#$}#O(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#A($[0],"x");this.#Q=J,this.#$=J;return}this.#Q=this.#A($[0],"x"),this.#$=this.#A($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#Q=50,this.#$=50;return}this.#O($)}#z(){let Q=Array.from({length:9},(j,K)=>{let q=K%3,_=Math.floor(K/3);return`<span class="origin-grid-cell" data-col="${q}" data-row="${_}">
230
+ </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#U={};for(let Z of this.#N){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#U[Z]=j;let K=(q)=>{q.stopPropagation();let _=parseFloat(q.target.value);if(isNaN(_))return;if(Z==="rotateX")this.#Q=_;else if(Z==="rotateY")this.#$=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#z(q.type)};j.addEventListener("input",K),j.addEventListener("change",K)}}this.#R(),this.#H()}#A(){let Q={rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J};for(let $ of this.#N){let J=this.#U[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#K))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#$}deg) rotateZ(${this.#J}deg)`}#z(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#$,rotateZ:this.#J}}))}#F(Q){if(!this.#j)return Q;return Math.round(Q/15)*15}#H(){this.#X.addEventListener("pointerdown",(Q)=>this.#P(Q)),this.#q=(Q)=>{if(Q.key==="Shift")this.#j=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#W)}get#D(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#P(Q){if(!this.#D)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#Q,j=this.#$,K=(_)=>{if(!this.#Z)return;if(_.buttons===0){q();return}let X=_.clientX-$,Y=_.clientY-J;this.#$=this.#F(j+X*0.5),this.#Q=this.#F(Z-Y*0.5),this.#R(),this.#A(),this.setAttribute("value",this.value),this.#z("input")},q=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",K),this.#X.removeEventListener("pointerup",q),this.#X.removeEventListener("pointercancel",q),this.#X.removeEventListener("lostpointercapture",q),this.#z("change")};this.#X.addEventListener("pointermove",K),this.#X.addEventListener("pointerup",q),this.#X.addEventListener("pointercancel",q),this.#X.addEventListener("lostpointercapture",q)}}customElements.define("fig-3d-rotate",u0);class q0 extends HTMLElement{#Q=50;#$=50;#J=0;#K=null;#Z=[];#j=null;#_=null;#X=null;#q=!1;#W=!1;#N=null;#U=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.#z(),this.#M(),this.#H()}disconnectedCallback(){this.#q=!1,this.#x()}get value(){let Q=this.#J;return`${this.#Q.toFixed(Q)}% ${this.#$.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.#M();return}if(Q==="fields"){this.#z(),this.#M(),this.#H();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#F(),this.#H();return}if(Q==="value"){if(this.#W||this.#q)return;this.#R(J),this.#P(),this.#S(),this.#F()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#G(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#K)return;this.#K.classList.toggle("drag-disabled",!this.#L)}#O(Q){return Math.max(0,Math.min(100,Q))}#B(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#Q:this.#$;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.#Q:this.#$}#A(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#B($[0],"x");this.#Q=J,this.#$=J;return}this.#Q=this.#B($[0],"x"),this.#$=this.#B($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#Q=50,this.#$=50;return}this.#A($)}#z(){let Q=Array.from({length:9},(j,K)=>{let q=K%3,_=Math.floor(K/3);return`<span class="origin-grid-cell" data-col="${q}" data-row="${_}">
231
231
  <span class="origin-grid-dot"></span>
232
232
  </span>`}).join(""),$=this.#Q.toFixed(this.#J),J=this.#$.toFixed(this.#J),Z=this.#G?`<div class="origin-values">
233
233
  <fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
@@ -238,7 +238,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
238
238
  <fig-handle></fig-handle>
239
239
  </div>
240
240
  </div>
241
- ${Z}`,this.#K=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#P(),this.#S(),this.#D(),this.#l()}#D(){let Q=this.#Q.toFixed(this.#J),$=this.#$.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.#N=!0,this.setAttribute("value",Q),this.#N=!1}#F(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Q,y:this.#$}}))}#P(){if(!this.#j)return;let Q=($)=>16.6667+this.#B($)/100*66.6667;this.#j.style.left=`${Q(this.#Q)}%`,this.#j.style.top=`${Q(this.#$)}%`}#S(){if(!this.#j)return;let Q=this.#Q<0||this.#Q>100,$=this.#$<0||this.#$>100,J=this.#Q<0,Z=this.#Q>100,j=this.#$<0,K=this.#$>100;this.#j.classList.toggle("beyond-bounds-x",Q),this.#j.classList.toggle("beyond-bounds-y",$),this.#j.classList.toggle("overflow-left",J),this.#j.classList.toggle("overflow-right",Z),this.#j.classList.toggle("overflow-up",j),this.#j.classList.toggle("overflow-down",K)}#V(Q,$){if(!this.#K)return null;let J=this.#K.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 K=Math.max(0,Math.min(2,Math.floor(Z*3))),q=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((_)=>Number(_.getAttribute("data-col"))===K&&Number(_.getAttribute("data-row"))===q)}#k(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#T(Q){if(this.#k(),Q)Q.classList.add("is-hovered")}#C(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#Q&&j===this.#$&&J==="input")return;this.#Q=Z,this.#$=j,this.#P(),this.#S(),this.#D(),this.#H(),this.#F(J)}#w(Q,$){if(!this.#K)return{x:this.#Q,y:this.#$};let J=this.#K.getBoundingClientRect(),Z=J.width/6,j=J.height/6,K=Math.max(1,J.width-Z*2),q=Math.max(1,J.height-j*2),_=(Q-(J.left+Z))/K,X=($-(J.top+j))/q;return{x:_*100,y:X*100}}#E(Q,$){if(!this.#K)return{x:50,y:50};let J=this.#K.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,K=Math.max(0,Math.min(2,Math.floor(Z))),q=Math.max(0,Math.min(2,Math.floor(j)));return{x:K*50,y:q*50}}#I(Q){let J=Q,Z=1/0;for(let j of q0.SNAP_POINTS){let K=Math.abs(Q-j);if(K<Z)Z=K,J=j}return Z<=2.5?J:Q}#y(Q,$){if(!$)return Q;return{x:this.#I(Q.x),y:this.#I(Q.y)}}#x(){if(!this.#K||!this.#W||!this.#Y)return;this.#K.removeEventListener("pointermove",this.#W),this.#K.removeEventListener("pointerup",this.#Y),this.#K.removeEventListener("pointercancel",this.#Y),this.#K.removeEventListener("lostpointercapture",this.#Y),this.#W=null,this.#Y=null}#v(Q){if(!this.#K||!this.#L)return;Q.preventDefault(),this.#q=!0,this.#U=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#K.setPointerCapture(Q.pointerId),this.#W=(K)=>{if(!this.#q||K.pointerId!==this.#U)return;let q=K.clientX-$,_=K.clientY-J,X=Math.hypot(q,_);if(!j&&X<Z)return;if(!j)j=!0,this.#K.classList.add("is-dragging"),this.#k();let Y=this.#y(this.#w(K.clientX,K.clientY),K.shiftKey);this.#C(Y.x,Y.y,"input")},this.#Y=(K)=>{if(!this.#q||K.pointerId!==this.#U)return;if(this.#q=!1,this.#U=null,this.#K.classList.remove("is-dragging"),this.#k(),this.#x(),!j){let q=this.#E($,J);this.#C(q.x,q.y,"input")}this.#F("change")},this.#K.addEventListener("pointermove",this.#W),this.#K.addEventListener("pointerup",this.#Y),this.#K.addEventListener("pointercancel",this.#Y),this.#K.addEventListener("lostpointercapture",this.#Y)}#l(){if(!this.#K||!this.#j)return;this.#K.addEventListener("pointerdown",($)=>{let J=this.#V($.clientX,$.clientY);if(this.#T(J),this.#L){this.#v($);return}let Z=this.#E($.clientX,$.clientY);this.#C(Z.x,Z.y,"input"),this.#F("change")}),this.#K.addEventListener("pointermove",($)=>{if(this.#q)return;let J=this.#V($.clientX,$.clientY);this.#T(J)}),this.#K.addEventListener("pointerleave",()=>{this.#k()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let K=Number.parseFloat(j.target.value);if(!Number.isFinite(K))return;if(J==="x")this.#C(K,this.#$,"input");else this.#C(this.#Q,K,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#F("change")})};Q(this.#_,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",q0);class u0 extends HTMLElement{#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;#_=null;#X=null;#q=!1;#N={x:0.5,y:0.5};#U=!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=(Q)=>this.#H(Q),this.#$=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#F(Q),this.#K=()=>this.#P(),this.#Z=(Q)=>this.#O(Q),this.#j=(Q)=>this.#R(Q),this.#_=()=>this.#z(),this.#X=()=>this.#z()}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.#L(),this.#B(),this.#k(),this.#T(),this.#C(),this.#U=!0})}#W(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#A()}get#Y(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#M()}#G(){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,K]=$;return{left:J,right:Z,top:j,bottom:K,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#G();return`
241
+ ${Z}`,this.#K=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#P(),this.#S(),this.#F(),this.#l()}#F(){let Q=this.#Q.toFixed(this.#J),$=this.#$.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.#W=!0,this.setAttribute("value",Q),this.#W=!1}#D(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Q,y:this.#$}}))}#P(){if(!this.#j)return;let Q=($)=>16.6667+this.#O($)/100*66.6667;this.#j.style.left=`${Q(this.#Q)}%`,this.#j.style.top=`${Q(this.#$)}%`}#S(){if(!this.#j)return;let Q=this.#Q<0||this.#Q>100,$=this.#$<0||this.#$>100,J=this.#Q<0,Z=this.#Q>100,j=this.#$<0,K=this.#$>100;this.#j.classList.toggle("beyond-bounds-x",Q),this.#j.classList.toggle("beyond-bounds-y",$),this.#j.classList.toggle("overflow-left",J),this.#j.classList.toggle("overflow-right",Z),this.#j.classList.toggle("overflow-up",j),this.#j.classList.toggle("overflow-down",K)}#V(Q,$){if(!this.#K)return null;let J=this.#K.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 K=Math.max(0,Math.min(2,Math.floor(Z*3))),q=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((_)=>Number(_.getAttribute("data-col"))===K&&Number(_.getAttribute("data-row"))===q)}#k(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#T(Q){if(this.#k(),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.#Q&&j===this.#$&&J==="input")return;this.#Q=Z,this.#$=j,this.#P(),this.#S(),this.#F(),this.#H(),this.#D(J)}#w(Q,$){if(!this.#K)return{x:this.#Q,y:this.#$};let J=this.#K.getBoundingClientRect(),Z=J.width/6,j=J.height/6,K=Math.max(1,J.width-Z*2),q=Math.max(1,J.height-j*2),_=(Q-(J.left+Z))/K,X=($-(J.top+j))/q;return{x:_*100,y:X*100}}#E(Q,$){if(!this.#K)return{x:50,y:50};let J=this.#K.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,K=Math.max(0,Math.min(2,Math.floor(Z))),q=Math.max(0,Math.min(2,Math.floor(j)));return{x:K*50,y:q*50}}#y(Q){let J=Q,Z=1/0;for(let j of q0.SNAP_POINTS){let K=Math.abs(Q-j);if(K<Z)Z=K,J=j}return Z<=2.5?J:Q}#C(Q,$){if(!$)return Q;return{x:this.#y(Q.x),y:this.#y(Q.y)}}#x(){if(!this.#K||!this.#U||!this.#Y)return;this.#K.removeEventListener("pointermove",this.#U),this.#K.removeEventListener("pointerup",this.#Y),this.#K.removeEventListener("pointercancel",this.#Y),this.#K.removeEventListener("lostpointercapture",this.#Y),this.#U=null,this.#Y=null}#v(Q){if(!this.#K||!this.#L)return;Q.preventDefault(),this.#q=!0,this.#N=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#K.setPointerCapture(Q.pointerId),this.#U=(K)=>{if(!this.#q||K.pointerId!==this.#N)return;let q=K.clientX-$,_=K.clientY-J,X=Math.hypot(q,_);if(!j&&X<Z)return;if(!j)j=!0,this.#K.classList.add("is-dragging"),this.#k();let Y=this.#C(this.#w(K.clientX,K.clientY),K.shiftKey);this.#I(Y.x,Y.y,"input")},this.#Y=(K)=>{if(!this.#q||K.pointerId!==this.#N)return;if(this.#q=!1,this.#N=null,this.#K.classList.remove("is-dragging"),this.#k(),this.#x(),!j){let q=this.#E($,J);this.#I(q.x,q.y,"input")}this.#D("change")},this.#K.addEventListener("pointermove",this.#U),this.#K.addEventListener("pointerup",this.#Y),this.#K.addEventListener("pointercancel",this.#Y),this.#K.addEventListener("lostpointercapture",this.#Y)}#l(){if(!this.#K||!this.#j)return;this.#K.addEventListener("pointerdown",($)=>{let J=this.#V($.clientX,$.clientY);if(this.#T(J),this.#L){this.#v($);return}let Z=this.#E($.clientX,$.clientY);this.#I(Z.x,Z.y,"input"),this.#D("change")}),this.#K.addEventListener("pointermove",($)=>{if(this.#q)return;let J=this.#V($.clientX,$.clientY);this.#T(J)}),this.#K.addEventListener("pointerleave",()=>{this.#k()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let K=Number.parseFloat(j.target.value);if(!Number.isFinite(K))return;if(J==="x")this.#I(K,this.#$,"input");else this.#I(this.#Q,K,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#D("change")})};Q(this.#_,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",q0);class p0 extends HTMLElement{#Q=null;#$=null;#J=null;#K=null;#Z=null;#j=null;#_=null;#X=null;#q=!1;#W={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=(Q)=>this.#H(Q),this.#$=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#D(Q),this.#K=()=>this.#P(),this.#Z=(Q)=>this.#A(Q),this.#j=(Q)=>this.#R(Q),this.#_=()=>this.#z(),this.#X=()=>this.#z()}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.#L(),this.#O(),this.#k(),this.#T(),this.#I(),this.#N=!0})}#U(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#B()}get#Y(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#M()}#G(){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,K]=$;return{left:J,right:Z,top:j,bottom:K,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#G();return`
242
242
  <div class="fig-input-joystick-plane-container" tabindex="0">
243
243
  ${[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("")}
244
244
  <div class="fig-input-joystick-plane">
@@ -271,7 +271,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
271
271
  <span slot="prepend">Y</span>
272
272
  </fig-input-number>
273
273
  </div>`:""}
274
- `}#B(){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.#Q),this.cursor?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#K);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#w());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#X)}#A(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#K),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),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.#k(),this.#T(),this.#S()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#k(),this.#T(),this.#S()}#z(){this.#T(),this.#V()}#D(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),K=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:K},J)this.#k();this.#T()}#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.#D(J,Z,{syncHandle:!1}),this.#S(),this.#V()}#F(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#D($.px,$.py,{syncHandle:!1}),this.#S()}#P(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#T(),this.#V()}#S(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#k(){let Q=this.#W(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))}#T(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#q=!0,this.setAttribute("value",Q),this.#q=!1;this.#C()}#C(){let Q=this.#N,$=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")}#w(){this.position={...this.#N},this.#k(),this.#T(),this.#S(),this.#V()}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=(q)=>{if(!q)return 0.5;let _=q.includes("%"),X=Number.parseFloat(q.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]),K=Z(J[1]??J[0]);this.position={x:j,y:K}}if(this.#U)this.#k(),this.#C()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#q||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.#A(),this.#L(),this.#B(),this.#k();if(Q==="axis-labels"&&J!==$)this.#A(),this.#L(),this.#B(),this.#k();if(Q==="coordinates")this.coordinates=J||"screen",this.#k()}}customElements.define("fig-joystick",u0);class _0 extends HTMLElement{connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty("--shimmer-duration",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("--shimmer-duration",J||"1.5s")}}customElements.define("fig-shimmer",_0);class s0 extends _0{}customElements.define("fig-skeleton",s0);class d0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#Q=null;#$=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#Q&&this.#$)this.#Q.removeEventListener("click",this.#$)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#Q=document.createElement("span"),this.#Q.className="fig-layer-chevron",Q.prepend(this.#Q),this.#$=this.#K.bind(this),this.#Q.addEventListener("click",this.#$)}#K(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",d0);class r0 extends HTMLElement{static observedAttributes=["name","collapsible"];#Q=null;#$=null;connectedCallback(){requestAnimationFrame(()=>this.#K())}disconnectedCallback(){if(this.#$)this.#$.removeEventListener("click",this.#J);if(this.#Q)this.#Q.removeEventListener("click",this.#J)}attributeChangedCallback(Q,$,J){if($===J)return;this.#K()}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};#K(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#$=null;return}if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let j=this.#Q.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Q.prepend(j);if(this.#Q.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let K=document.createElement("span");K.className="fig-mask-icon fig-group-chevron",j.prepend(K)}if(this.#$=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#$)this.#$.remove(),this.#$=null;this.removeAttribute("open")}}}customElements.define("fig-group",r0);class i0 extends HTMLElement{}customElements.define("fig-header",i0);class o0 extends HTMLElement{}customElements.define("fig-footer",o0);class l0 extends HTMLElement{}customElements.define("fig-spinner",l0);class t0 extends HTMLElement{}customElements.define("fig-icon",t0);class n0 extends HTMLElement{}customElements.define("fig-content",n0);class a0 extends HTMLElement{}customElements.define("fig-tab-content",a0);class e0 extends HTMLElement{}customElements.define("fig-button-combo",e0);class Q1 extends HTMLElement{}customElements.define("fig-input-combo",Q1);class e extends HTMLElement{#Q=null;#$=null;#J=null;#K="solid";anchorElement=null;#Z="solid";#j="srgb";#_={h:0,s:0,v:85,a:1};#X="hex";#q={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#N={url:null,scaleMode:"fill",scale:50};#U={url:null,scaleMode:"fill",scale:50};#W={stream:null,snapshot:null};#Y={};#L={};#G=null;#M=null;#B=null;#A=null;#O=!1;#R=null;#z=null;#D=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#H(),this.#F(),this.#P()})}disconnectedCallback(){if(this.#R)this.#R(),this.#R=null;if(this.#z)this.#z.disconnect(),this.#z=null;if(this.#D)this.#D.disconnect(),this.#D=null;if(this.#W.stream)this.#W.stream.getTracks().forEach((Q)=>Q.stop()),this.#W.stream=null;if(this.#U.url&&this.#U.url.startsWith("blob:"))URL.revokeObjectURL(this.#U.url);if(this.#$)this.#$.removeAttribute("selected");if(this.#J)this.#J.close(),this.#J.remove(),this.#J=null}#H(){let Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#$=document.createElement("fig-chit"),this.#$.setAttribute("background","#D9D9D9"),this.appendChild(this.#$),this.#Q=this.#$;else if(Q.tagName==="FIG-CHIT")this.#$=Q,this.#Q=Q;else this.#Q=Q,this.#$=null;if(this.#Q.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#V()}),this.#$)requestAnimationFrame(()=>{let $=this.#$.querySelector('input[type="color"]');if($)$.style.pointerEvents="none"})}#F(){let Q=this.getAttribute("value");if(!Q)return;let $=["solid","gradient","image","video","webcam"];try{let J=JSON.parse(Q);if(J.type)this.#Z=J.type;if(J.color){if(typeof J.color==="string")this.#_=this.#j0(J.color);else if(typeof J.color==="object"&&J.color.h!==void 0)this.#_=J.color}if(J.opacity!==void 0)this.#_.a=J.opacity/100;if(J.colorSpace==="display-p3"||J.colorSpace==="srgb")this.#j=J.colorSpace;if(J.gradient)this.#q=V({...this.#q,...J.gradient});if(J.image)this.#N={...this.#N,...J.image};if(J.video)this.#U={...this.#U,...J.video};if(J.type&&!$.includes(J.type)){let{type:Z,...j}=J;this.#L[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#Z="solid",this.#_=this.#j0(Q)}}#P(){if(!this.#$)return;let Q,$="cover",J="center";switch(this.#Z){case"solid":Q=this.#s(this.#_);break;case"gradient":Q=this.#J0();break;case"image":if(this.#N.url){Q=`url(${this.#N.url})`;let j=this.#S(this.#N.scaleMode,this.#N.scale);$=j.size,J=j.position}else Q="";break;case"video":if(this.#U.url){Q=`url(${this.#U.url})`;let j=this.#S(this.#U.scaleMode,this.#U.scale);$=j.size,J=j.position}else Q="";break;default:Q=this.#Y[this.#Z]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#$.setAttribute("background",Q),this.#$.style.setProperty("--chit-bg-size",$),this.#$.style.setProperty("--chit-bg-position",J),this.#Z==="solid")this.#$.setAttribute("alpha",this.#_.a);else this.#$.removeAttribute("alpha")}#S(Q,$){switch(Q){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${$}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#V(){if(!this.#J)this.#k();this.#T(this.#Z);let Q=this.#J.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#j;if(this.#$)this.#$.setAttribute("selected","true");this.#J.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#E(),this.#I()})})}#k(){this.#Y={},this.querySelectorAll('[slot^="mode-"]').forEach((L)=>{let B=L.getAttribute("slot").slice(5);this.#Y[B]={element:L,label:L.getAttribute("label")||B.charAt(0).toUpperCase()+B.slice(1)}}),this.#J=document.createElement("dialog",{is:"fig-popup"}),this.#J.setAttribute("is","fig-popup"),this.#J.setAttribute("drag","true"),this.#J.setAttribute("handle","fig-header"),this.#J.setAttribute("autoresize","false"),this.#J.classList.add("fig-fill-picker-dialog"),this.#J.anchor=this.anchorElement||this.#Q;let Q=this.getAttribute("dialog-position")||"left";this.#J.setAttribute("position",Q);let $=["solid","gradient","image","video","webcam"],J={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},Z=this.getAttribute("mode"),j;if(Z){if(j=Z.split(",").map((B)=>B.trim().toLowerCase()).filter((B)=>$.includes(B)||this.#Y[B]),j.length===0)j=[...$]}else j=[...$];let K={...J};for(let[L,{label:B}]of Object.entries(this.#Y))K[L]=B;if(!j.includes(this.#Z))this.#Z=j[0],this.#K=j[0];let q=this.getAttribute("experimental"),_=q?`experimental="${q}"`:"",X;if(j.length===1)X=`<h3 class="fig-fill-picker-type-label">${K[j[0]]}</h3>`;else{let L=j.map((B)=>`<option value="${B}">${K[B]}</option>`).join(`
274
+ `}#O(){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.#Q),this.cursor?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#K);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#w());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#X)}#B(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#K),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#X)}#A(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#k(),this.#T(),this.#S()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#k(),this.#T(),this.#S()}#z(){this.#T(),this.#V()}#F(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),K=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:K},J)this.#k();this.#T()}#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.#F(J,Z,{syncHandle:!1}),this.#S(),this.#V()}#D(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#F($.px,$.py,{syncHandle:!1}),this.#S()}#P(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#T(),this.#V()}#S(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#k(){let Q=this.#U(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))}#T(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#q=!0,this.setAttribute("value",Q),this.#q=!1;this.#I()}#I(){let Q=this.#W,$=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")}#w(){this.position={...this.#W},this.#k(),this.#T(),this.#S(),this.#V()}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=(q)=>{if(!q)return 0.5;let _=q.includes("%"),X=Number.parseFloat(q.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]),K=Z(J[1]??J[0]);this.position={x:j,y:K}}if(this.#N)this.#k(),this.#I()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#q||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.#B(),this.#L(),this.#O(),this.#k();if(Q==="axis-labels"&&J!==$)this.#B(),this.#L(),this.#O(),this.#k();if(Q==="coordinates")this.coordinates=J||"screen",this.#k()}}customElements.define("fig-joystick",p0);class _0 extends HTMLElement{connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty("--shimmer-duration",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("--shimmer-duration",J||"1.5s")}}customElements.define("fig-shimmer",_0);class s0 extends _0{}customElements.define("fig-skeleton",s0);class d0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#Q=null;#$=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#Q&&this.#$)this.#Q.removeEventListener("click",this.#$)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#Q=document.createElement("span"),this.#Q.className="fig-layer-chevron",Q.prepend(this.#Q),this.#$=this.#K.bind(this),this.#Q.addEventListener("click",this.#$)}#K(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",d0);class r0 extends HTMLElement{static observedAttributes=["name","collapsible"];#Q=null;#$=null;connectedCallback(){requestAnimationFrame(()=>this.#K())}disconnectedCallback(){if(this.#$)this.#$.removeEventListener("click",this.#J);if(this.#Q)this.#Q.removeEventListener("click",this.#J)}attributeChangedCallback(Q,$,J){if($===J)return;this.#K()}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};#K(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#$=null;return}if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let j=this.#Q.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Q.prepend(j);if(this.#Q.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let K=document.createElement("span");K.className="fig-mask-icon fig-group-chevron",j.prepend(K)}if(this.#$=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#$)this.#$.remove(),this.#$=null;this.removeAttribute("open")}}}customElements.define("fig-group",r0);class i0 extends HTMLElement{}customElements.define("fig-header",i0);class o0 extends HTMLElement{}customElements.define("fig-footer",o0);class l0 extends HTMLElement{}customElements.define("fig-spinner",l0);class t0 extends HTMLElement{}customElements.define("fig-icon",t0);class n0 extends HTMLElement{}customElements.define("fig-content",n0);class a0 extends HTMLElement{}customElements.define("fig-tab-content",a0);class e0 extends HTMLElement{}customElements.define("fig-button-combo",e0);class Q1 extends HTMLElement{}customElements.define("fig-input-combo",Q1);class e extends HTMLElement{#Q=null;#$=null;#J=null;#K="solid";anchorElement=null;#Z="solid";#j="srgb";#_={h:0,s:0,v:85,a:1};#X="hex";#q={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#W={url:null,scaleMode:"fill",scale:50};#N={url:null,scaleMode:"fill",scale:50};#U={stream:null,snapshot:null};#Y={};#L={};#G=null;#M=null;#O=null;#B=null;#A=!1;#R=null;#z=null;#F=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#H(),this.#D(),this.#P()})}disconnectedCallback(){if(this.#R)this.#R(),this.#R=null;if(this.#z)this.#z.disconnect(),this.#z=null;if(this.#F)this.#F.disconnect(),this.#F=null;if(this.#U.stream)this.#U.stream.getTracks().forEach((Q)=>Q.stop()),this.#U.stream=null;if(this.#N.url&&this.#N.url.startsWith("blob:"))URL.revokeObjectURL(this.#N.url);if(this.#$)this.#$.removeAttribute("selected");if(this.#J)this.#J.close(),this.#J.remove(),this.#J=null}#H(){let Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#$=document.createElement("fig-chit"),this.#$.setAttribute("background","#D9D9D9"),this.appendChild(this.#$),this.#Q=this.#$;else if(Q.tagName==="FIG-CHIT")this.#$=Q,this.#Q=Q;else this.#Q=Q,this.#$=null;if(this.#Q.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#V()}),this.#$)requestAnimationFrame(()=>{let $=this.#$.querySelector('input[type="color"]');if($)$.style.pointerEvents="none"})}#D(){let Q=this.getAttribute("value");if(!Q)return;let $=["solid","gradient","image","video","webcam"];try{let J=JSON.parse(Q);if(J.type)this.#Z=J.type;if(J.color){if(typeof J.color==="string")this.#_=this.#j0(J.color);else if(typeof J.color==="object"&&J.color.h!==void 0)this.#_=J.color}if(J.opacity!==void 0)this.#_.a=J.opacity/100;if(J.colorSpace==="display-p3"||J.colorSpace==="srgb")this.#j=J.colorSpace;if(J.gradient)this.#q=V({...this.#q,...J.gradient});if(J.image)this.#W={...this.#W,...J.image};if(J.video)this.#N={...this.#N,...J.video};if(J.type&&!$.includes(J.type)){let{type:Z,...j}=J;this.#L[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#Z="solid",this.#_=this.#j0(Q)}}#P(){if(!this.#$)return;let Q,$="cover",J="center";switch(this.#Z){case"solid":Q=this.#s(this.#_);break;case"gradient":Q=this.#J0();break;case"image":if(this.#W.url){Q=`url(${this.#W.url})`;let j=this.#S(this.#W.scaleMode,this.#W.scale);$=j.size,J=j.position}else Q="";break;case"video":if(this.#N.url){Q=`url(${this.#N.url})`;let j=this.#S(this.#N.scaleMode,this.#N.scale);$=j.size,J=j.position}else Q="";break;default:Q=this.#Y[this.#Z]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#$.setAttribute("background",Q),this.#$.style.setProperty("--chit-bg-size",$),this.#$.style.setProperty("--chit-bg-position",J),this.#Z==="solid")this.#$.setAttribute("alpha",this.#_.a);else this.#$.removeAttribute("alpha")}#S(Q,$){switch(Q){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${$}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#V(){if(!this.#J)this.#k();this.#T(this.#Z);let Q=this.#J.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#j;if(this.#$)this.#$.setAttribute("selected","true");this.#J.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#E(),this.#y()})})}#k(){this.#Y={},this.querySelectorAll('[slot^="mode-"]').forEach((L)=>{let O=L.getAttribute("slot").slice(5);this.#Y[O]={element:L,label:L.getAttribute("label")||O.charAt(0).toUpperCase()+O.slice(1)}}),this.#J=document.createElement("dialog",{is:"fig-popup"}),this.#J.setAttribute("is","fig-popup"),this.#J.setAttribute("drag","true"),this.#J.setAttribute("handle","fig-header"),this.#J.setAttribute("autoresize","false"),this.#J.classList.add("fig-fill-picker-dialog"),this.#J.anchor=this.anchorElement||this.#Q;let Q=this.getAttribute("dialog-position")||"left";this.#J.setAttribute("position",Q);let $=["solid","gradient","image","video","webcam"],J={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},Z=this.getAttribute("mode"),j;if(Z){if(j=Z.split(",").map((O)=>O.trim().toLowerCase()).filter((O)=>$.includes(O)||this.#Y[O]),j.length===0)j=[...$]}else j=[...$];let K={...J};for(let[L,{label:O}]of Object.entries(this.#Y))K[L]=O;if(!j.includes(this.#Z))this.#Z=j[0],this.#K=j[0];let q=this.getAttribute("experimental"),_=q?`experimental="${q}"`:"",X;if(j.length===1)X=`<h3 class="fig-fill-picker-type-label">${K[j[0]]}</h3>`;else{let L=j.map((O)=>`<option value="${O}">${K[O]}</option>`).join(`
275
275
  `);X=`<fig-dropdown class="fig-fill-picker-type" ${_} value="${this.#Z}">
276
276
  ${L}
277
277
  </fig-dropdown>`}let Y=j.map((L)=>`<div class="fig-fill-picker-tab" data-tab="${L}"></div>`).join(`
@@ -289,7 +289,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
289
289
  <fig-content>
290
290
  ${Y}
291
291
  </fig-content>
292
- `,document.body.appendChild(this.#J);for(let[L,{element:B}]of Object.entries(this.#Y)){let M=this.#J.querySelector(`[data-tab="${L}"]`);if(!M)continue;while(B.firstChild)M.appendChild(B.firstChild);this.dispatchEvent(new CustomEvent("modeready",{bubbles:!0,detail:{mode:L,container:M}}))}let N=this.#J.querySelector(".fig-fill-picker-type");if(N)N.addEventListener("change",(L)=>{this.#T(L.target.value)});let G=this.#J.querySelector(".fig-fill-picker-gamut");if(G){let L=(B)=>{let M=B.currentTarget?.value??B.target?.value??B.detail;if(M&&M!==this.#j)this.#j=M,this.#w()};G.addEventListener("input",L),G.addEventListener("change",L)}this.#J.querySelector(".fig-fill-picker-close").addEventListener("click",()=>{this.#J.open=!1});let D=()=>{if(this.#$)this.#$.removeAttribute("selected");this.#p()};this.#J.addEventListener("close",D),this.#z=new MutationObserver(()=>{if(!(this.#J.hasAttribute("open")&&this.#J.getAttribute("open")!=="false"))D()}),this.#z.observe(this.#J,{attributes:!0,attributeFilter:["open"]});let R={solid:()=>this.#C(),gradient:()=>this.#q0(),image:()=>this.#n(),video:()=>this.#_0(),webcam:()=>this.#X0()};for(let[L,B]of Object.entries(R))if(!this.#Y[L]&&j.includes(L))B();for(let L of Object.keys(this.#Y)){if($.includes(L))continue;let B=this.#J.querySelector(`[data-tab="${L}"]`);if(!B)continue;B.addEventListener("input",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#f()}),B.addEventListener("change",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#p()})}}#T(Q){if(!this.#J?.querySelector(`.fig-fill-picker-tab[data-tab="${Q}"]`))return;this.#K=Q,this.#Z=Q;let J=this.#J.querySelector(".fig-fill-picker-type");if(J&&J.value!==Q)J.value=Q;this.#J.querySelectorAll(".fig-fill-picker-tab").forEach((K)=>{if(K.dataset.tab===Q)K.style.display="block";else K.style.display="none"});let j=this.#J.querySelector("fig-content");if(j)j.style.padding=this.#Y[Q]?"0":"";if(Q==="gradient")requestAnimationFrame(()=>{this.#b()});this.#P(),this.#f()}#C(){let Q=this.#J.querySelector('[data-tab="solid"]'),$=this.getAttribute("alpha")!=="false",J=this.getAttribute("experimental"),Z=J?`experimental="${J}"`:"";if(Q.innerHTML=`
292
+ `,document.body.appendChild(this.#J);for(let[L,{element:O}]of Object.entries(this.#Y)){let M=this.#J.querySelector(`[data-tab="${L}"]`);if(!M)continue;while(O.firstChild)M.appendChild(O.firstChild);this.dispatchEvent(new CustomEvent("modeready",{bubbles:!0,detail:{mode:L,container:M}}))}let N=this.#J.querySelector(".fig-fill-picker-type");if(N)N.addEventListener("change",(L)=>{this.#T(L.target.value)});let G=this.#J.querySelector(".fig-fill-picker-gamut");if(G){let L=(O)=>{let M=O.currentTarget?.value??O.target?.value??O.detail;if(M&&M!==this.#j)this.#j=M,this.#w()};G.addEventListener("input",L),G.addEventListener("change",L)}this.#J.querySelector(".fig-fill-picker-close").addEventListener("click",()=>{this.#J.open=!1});let D=()=>{if(this.#$)this.#$.removeAttribute("selected");this.#u()};this.#J.addEventListener("close",D),this.#z=new MutationObserver(()=>{if(!(this.#J.hasAttribute("open")&&this.#J.getAttribute("open")!=="false"))D()}),this.#z.observe(this.#J,{attributes:!0,attributeFilter:["open"]});let R={solid:()=>this.#I(),gradient:()=>this.#q0(),image:()=>this.#n(),video:()=>this.#_0(),webcam:()=>this.#X0()};for(let[L,O]of Object.entries(R))if(!this.#Y[L]&&j.includes(L))O();for(let L of Object.keys(this.#Y)){if($.includes(L))continue;let O=this.#J.querySelector(`[data-tab="${L}"]`);if(!O)continue;O.addEventListener("input",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#f()}),O.addEventListener("change",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#u()})}}#T(Q){if(!this.#J?.querySelector(`.fig-fill-picker-tab[data-tab="${Q}"]`))return;this.#K=Q,this.#Z=Q;let J=this.#J.querySelector(".fig-fill-picker-type");if(J&&J.value!==Q)J.value=Q;this.#J.querySelectorAll(".fig-fill-picker-tab").forEach((K)=>{if(K.dataset.tab===Q)K.style.display="block";else K.style.display="none"});let j=this.#J.querySelector("fig-content");if(j)j.style.padding=this.#Y[Q]?"0":"";if(Q==="gradient")requestAnimationFrame(()=>{this.#b()});this.#P(),this.#f()}#I(){let Q=this.#J.querySelector('[data-tab="solid"]'),$=this.getAttribute("alpha")!=="false",J=this.getAttribute("experimental"),Z=J?`experimental="${J}"`:"";if(Q.innerHTML=`
293
293
  <fig-preview class="fig-fill-picker-color-area">
294
294
  <canvas width="200" height="200"></canvas>
295
295
  <fig-handle
@@ -317,7 +317,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
317
317
  </fig-dropdown>
318
318
  <span class="fig-fill-picker-input-fields"></span>
319
319
  </fig-field>
320
- `,this.#G=Q.querySelector("canvas"),this.#M=Q.querySelector("fig-handle"),this.#E(),this.#I(),this.#x(),this.#B=Q.querySelector('fig-slider[type="hue"]'),this.#B.addEventListener("input",(q)=>{this.#_.h=parseFloat(q.target.value),this.#E(),this.#I(),this.#u(),this.#f()}),this.#B.addEventListener("change",()=>{this.#p()}),$)this.#A=Q.querySelector('fig-slider[type="opacity"]'),this.#A.addEventListener("input",(q)=>{this.#_.a=parseFloat(q.target.value)/100,this.#u(),this.#f()}),this.#A.addEventListener("change",()=>{this.#p()});Q.querySelector(".fig-fill-picker-input-mode").addEventListener("input",(q)=>{this.#X=q.target.value,this.#v()}),this.#v();let K=Q.querySelector(".fig-fill-picker-eyedropper");if("EyeDropper"in window)K.addEventListener("click",async()=>{try{let _=await new EyeDropper().open();this.#_={...this.#j0(_.sRGBHex),a:this.#_.a},this.#E(),this.#I(),this.#u(),this.#f()}catch(q){}});else K.setAttribute("disabled",""),K.title="EyeDropper not supported in this browser"}#w(){let Q=this.#J?.querySelector('[data-tab="solid"]');if(Q){let $=Q.querySelector("canvas");if($){let J=document.createElement("canvas");J.width=$.width,J.height=$.height,$.replaceWith(J),this.#G=J,this.#x()}this.#E(),this.#I()}this.#m(),this.#f()}#E(){if(!this.#G&&this.#J)this.#G=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#G)return;let Q=this.#j==="display-p3"?"display-p3":"srgb",$=this.#G.getContext("2d",{colorSpace:Q});if(!$)return;let J=this.#G.width,Z=this.#G.height;$.clearRect(0,0,J,Z);let j=this.#_.h,K=this.#j==="display-p3",q=$.createLinearGradient(0,0,J,0);if(K){q.addColorStop(0,"color(display-p3 1 1 1)");let[X,Y,W]=H1(j,100,50);q.addColorStop(1,`color(display-p3 ${X} ${Y} ${W})`)}else q.addColorStop(0,"#FFFFFF"),q.addColorStop(1,`hsl(${j}, 100%, 50%)`);$.fillStyle=q,$.fillRect(0,0,J,Z);let _=$.createLinearGradient(0,0,0,Z);_.addColorStop(0,"rgba(0,0,0,0)"),_.addColorStop(1,"rgba(0,0,0,1)"),$.fillStyle=_,$.fillRect(0,0,J,Z)}#I(Q=0){if(!this.#M||!this.#G)return;let $=this.#G.getBoundingClientRect();if(($.width===0||$.height===0)&&Q<5){requestAnimationFrame(()=>this.#I(Q+1));return}let J=Math.max(0,Math.min(100,this.#_.s)),Z=Math.max(0,Math.min(100,100-this.#_.v));this.#M.setAttribute("value",`${J}% ${Z}%`),this.#M.setAttribute("color",this.#s({...this.#_,a:1}))}#y(Q,$,J={}){let{updateHandle:Z=!0,emitInput:j=!0,emitChange:K=!1}=J;if(this.#_.s=Math.max(0,Math.min(100,Q*100)),this.#_.v=Math.max(0,Math.min(100,(1-$)*100)),this.#M)this.#M.setAttribute("color",this.#s({...this.#_,a:1}));if(Z)this.#I();if(this.#u(),j)this.#f();if(K)this.#p()}#x(){if(this.#R)this.#R(),this.#R=null;if(!this.#G||!this.#M)return;let Q=this.#G.parentElement||this.#G,$=this.#M,J=!1,Z=(Y,W={})=>{let N=Q.getBoundingClientRect();if(N.width===0||N.height===0)return;let G=Math.max(0,Math.min(Y.clientX-N.left,N.width)),D=Math.max(0,Math.min(Y.clientY-N.top,N.height));this.#y(G/N.width,D/N.height,W)},j=(Y)=>{if(Y.button!==0)return;if(Y.target===$||$.contains(Y.target))return;J=!0,this.#O=!0,Q.setPointerCapture(Y.pointerId),Z(Y,{updateHandle:!0,emitInput:!0})},K=(Y)=>{if(!J)return;if(Y.buttons===0){q();return}Z(Y,{updateHandle:!0,emitInput:!0})},q=()=>{if(!J)return;J=!1,this.#O=!1,this.#p()},_=(Y)=>{this.#O=!0;let W=Y.detail?.px,N=Y.detail?.py;if(!Number.isFinite(W)||!Number.isFinite(N))return;$.setAttribute("value",`${W*100}% ${N*100}%`),this.#y(W,N,{updateHandle:!1,emitInput:!0})},X=(Y)=>{let W=Y.detail?.px,N=Y.detail?.py;if(Number.isFinite(W)&&Number.isFinite(N))$.setAttribute("value",`${W*100}% ${N*100}%`),this.#y(W,N,{updateHandle:!1,emitInput:!1});this.#O=!1,this.#p()};Q.addEventListener("pointerdown",j),Q.addEventListener("pointermove",K),Q.addEventListener("pointerup",q),Q.addEventListener("pointercancel",q),Q.addEventListener("lostpointercapture",q),$.addEventListener("input",_),$.addEventListener("change",X),this.#R=()=>{Q.removeEventListener("pointerdown",j),Q.removeEventListener("pointermove",K),Q.removeEventListener("pointerup",q),Q.removeEventListener("pointercancel",q),Q.removeEventListener("lostpointercapture",q),$.removeEventListener("input",_),$.removeEventListener("change",X),this.#O=!1}}#v(){let Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;let $=(j,K)=>`<fig-tooltip text="${j}">${K}</fig-tooltip>`,J=(j,K,q,_)=>`<fig-input-number class="${j}" min="${K}" max="${q}"${_!=null?` step="${_}"`:""}></fig-input-number>`,Z;switch(this.#X){case"rgb":Z=`<div class="input-combo">
320
+ `,this.#G=Q.querySelector("canvas"),this.#M=Q.querySelector("fig-handle"),this.#E(),this.#y(),this.#x(),this.#O=Q.querySelector('fig-slider[type="hue"]'),this.#O.addEventListener("input",(q)=>{this.#_.h=parseFloat(q.target.value),this.#E(),this.#y(),this.#p(),this.#f()}),this.#O.addEventListener("change",()=>{this.#u()}),$)this.#B=Q.querySelector('fig-slider[type="opacity"]'),this.#B.addEventListener("input",(q)=>{this.#_.a=parseFloat(q.target.value)/100,this.#p(),this.#f()}),this.#B.addEventListener("change",()=>{this.#u()});Q.querySelector(".fig-fill-picker-input-mode").addEventListener("input",(q)=>{this.#X=q.target.value,this.#v()}),this.#v();let K=Q.querySelector(".fig-fill-picker-eyedropper");if("EyeDropper"in window)K.addEventListener("click",async()=>{try{let _=await new EyeDropper().open();this.#_={...this.#j0(_.sRGBHex),a:this.#_.a},this.#E(),this.#y(),this.#p(),this.#f()}catch(q){}});else K.setAttribute("disabled",""),K.title="EyeDropper not supported in this browser"}#w(){let Q=this.#J?.querySelector('[data-tab="solid"]');if(Q){let $=Q.querySelector("canvas");if($){let J=document.createElement("canvas");J.width=$.width,J.height=$.height,$.replaceWith(J),this.#G=J,this.#x()}this.#E(),this.#y()}this.#m(),this.#f()}#E(){if(!this.#G&&this.#J)this.#G=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#G)return;let Q=this.#j==="display-p3"?"display-p3":"srgb",$=this.#G.getContext("2d",{colorSpace:Q});if(!$)return;let J=this.#G.width,Z=this.#G.height;$.clearRect(0,0,J,Z);let j=this.#_.h,K=this.#j==="display-p3",q=$.createLinearGradient(0,0,J,0);if(K){q.addColorStop(0,"color(display-p3 1 1 1)");let[X,Y,W]=H1(j,100,50);q.addColorStop(1,`color(display-p3 ${X} ${Y} ${W})`)}else q.addColorStop(0,"#FFFFFF"),q.addColorStop(1,`hsl(${j}, 100%, 50%)`);$.fillStyle=q,$.fillRect(0,0,J,Z);let _=$.createLinearGradient(0,0,0,Z);_.addColorStop(0,"rgba(0,0,0,0)"),_.addColorStop(1,"rgba(0,0,0,1)"),$.fillStyle=_,$.fillRect(0,0,J,Z)}#y(Q=0){if(!this.#M||!this.#G)return;let $=this.#G.getBoundingClientRect();if(($.width===0||$.height===0)&&Q<5){requestAnimationFrame(()=>this.#y(Q+1));return}let J=Math.max(0,Math.min(100,this.#_.s)),Z=Math.max(0,Math.min(100,100-this.#_.v));this.#M.setAttribute("value",`${J}% ${Z}%`),this.#M.setAttribute("color",this.#s({...this.#_,a:1}))}#C(Q,$,J={}){let{updateHandle:Z=!0,emitInput:j=!0,emitChange:K=!1}=J;if(this.#_.s=Math.max(0,Math.min(100,Q*100)),this.#_.v=Math.max(0,Math.min(100,(1-$)*100)),this.#M)this.#M.setAttribute("color",this.#s({...this.#_,a:1}));if(Z)this.#y();if(this.#p(),j)this.#f();if(K)this.#u()}#x(){if(this.#R)this.#R(),this.#R=null;if(!this.#G||!this.#M)return;let Q=this.#G.parentElement||this.#G,$=this.#M,J=!1,Z=(Y,W={})=>{let N=Q.getBoundingClientRect();if(N.width===0||N.height===0)return;let G=Math.max(0,Math.min(Y.clientX-N.left,N.width)),D=Math.max(0,Math.min(Y.clientY-N.top,N.height));this.#C(G/N.width,D/N.height,W)},j=(Y)=>{if(Y.button!==0)return;if(Y.target===$||$.contains(Y.target))return;J=!0,this.#A=!0,Q.setPointerCapture(Y.pointerId),Z(Y,{updateHandle:!0,emitInput:!0})},K=(Y)=>{if(!J)return;if(Y.buttons===0){q();return}Z(Y,{updateHandle:!0,emitInput:!0})},q=()=>{if(!J)return;J=!1,this.#A=!1,this.#u()},_=(Y)=>{this.#A=!0;let W=Y.detail?.px,N=Y.detail?.py;if(!Number.isFinite(W)||!Number.isFinite(N))return;$.setAttribute("value",`${W*100}% ${N*100}%`),this.#C(W,N,{updateHandle:!1,emitInput:!0})},X=(Y)=>{let W=Y.detail?.px,N=Y.detail?.py;if(Number.isFinite(W)&&Number.isFinite(N))$.setAttribute("value",`${W*100}% ${N*100}%`),this.#C(W,N,{updateHandle:!1,emitInput:!1});this.#A=!1,this.#u()};Q.addEventListener("pointerdown",j),Q.addEventListener("pointermove",K),Q.addEventListener("pointerup",q),Q.addEventListener("pointercancel",q),Q.addEventListener("lostpointercapture",q),$.addEventListener("input",_),$.addEventListener("change",X),this.#R=()=>{Q.removeEventListener("pointerdown",j),Q.removeEventListener("pointermove",K),Q.removeEventListener("pointerup",q),Q.removeEventListener("pointercancel",q),Q.removeEventListener("lostpointercapture",q),$.removeEventListener("input",_),$.removeEventListener("change",X),this.#A=!1}}#v(){let Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;let $=(j,K)=>`<fig-tooltip text="${j}">${K}</fig-tooltip>`,J=(j,K,q,_)=>`<fig-input-number class="${j}" min="${K}" max="${q}"${_!=null?` step="${_}"`:""}></fig-input-number>`,Z;switch(this.#X){case"rgb":Z=`<div class="input-combo">
321
321
  ${$("Red",J("fig-fill-picker-ci-r",0,255))}
322
322
  ${$("Green",J("fig-fill-picker-ci-g",0,255))}
323
323
  ${$("Blue",J("fig-fill-picker-ci-b",0,255))}
@@ -337,7 +337,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
337
337
  ${$("Lightness",J("fig-fill-picker-ci-okl",0,100))}
338
338
  ${$("Chroma",J("fig-fill-picker-ci-okc",0,0.4,0.001))}
339
339
  ${$("Hue",J("fig-fill-picker-ci-okh",0,360))}
340
- </div>`;break;default:Z='<fig-input-text class="fig-fill-picker-ci-hex" placeholder="FFFFFF"></fig-input-text>';break}Q.innerHTML=Z,this.#l(),requestAnimationFrame(()=>this.#u())}#l(){let Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;let $=()=>{if(this.#O)return;let j=this.#K0();if(!j)return;if(this.#_={...j,a:this.#_.a},this.#E(),this.#I(),this.#B)this.#B.setAttribute("value",this.#_.h);this.#f()},J=()=>this.#p();Q.querySelectorAll("fig-input-number, fig-input-text").forEach((j)=>{j.addEventListener("input",$),j.addEventListener("change",J)})}#K0(){let Q=(J)=>this.#J?.querySelector(`.${J}`),$=(J)=>parseFloat(Q(J)?.value??0);switch(this.#X){case"rgb":return this.#e({r:$("fig-fill-picker-ci-r"),g:$("fig-fill-picker-ci-g"),b:$("fig-fill-picker-ci-b")});case"hsl":{let J=this.#G0({h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),l:$("fig-fill-picker-ci-l")});return this.#e(J)}case"hsb":return{h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),v:$("fig-fill-picker-ci-v"),a:1};case"lab":{let J=this.#W0({l:$("fig-fill-picker-ci-okl")/100,a:$("fig-fill-picker-ci-oka"),b:$("fig-fill-picker-ci-okb")});return this.#e(J)}case"lch":{let J=this.#B0({l:$("fig-fill-picker-ci-okl")/100,c:$("fig-fill-picker-ci-okc"),h:$("fig-fill-picker-ci-okh")});return this.#e(J)}default:{let J=Q("fig-fill-picker-ci-hex");if(!J)return null;let Z=J.value.replace(/^#/,"");if(Z.length===3)Z=Z[0]+Z[0]+Z[1]+Z[1]+Z[2]+Z[2];if(Z.length!==6||!/^[0-9a-fA-F]{6}$/.test(Z))return null;return this.#j0(`#${Z}`)}}}#u(){if(!this.#J)return;let Q=this.#s(this.#_),$=this.#o(this.#_),J=(j)=>this.#J.querySelector(`.${j}`),Z=(j,K)=>{let q=J(j);if(q)q.setAttribute("value",K)};switch(this.#X){case"rgb":Z("fig-fill-picker-ci-r",$.r),Z("fig-fill-picker-ci-g",$.g),Z("fig-fill-picker-ci-b",$.b);break;case"hsl":{let j=this.#L0($);Z("fig-fill-picker-ci-h",Math.round(j.h)),Z("fig-fill-picker-ci-s",Math.round(j.s)),Z("fig-fill-picker-ci-l",Math.round(j.l));break}case"hsb":Z("fig-fill-picker-ci-h",Math.round(this.#_.h)),Z("fig-fill-picker-ci-s",Math.round(this.#_.s)),Z("fig-fill-picker-ci-v",Math.round(this.#_.v));break;case"lab":{let j=this.#Y0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-oka",+j.a.toFixed(3)),Z("fig-fill-picker-ci-okb",+j.b.toFixed(3));break}case"lch":{let j=this.#M0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-okc",+j.c.toFixed(3)),Z("fig-fill-picker-ci-okh",Math.round(j.h));break}default:Z("fig-fill-picker-ci-hex",Q.replace(/^#/,"").toUpperCase());break}if(this.#A)this.#A.setAttribute("color",Q);this.#P()}#q0(){let Q=this.#J.querySelector('[data-tab="gradient"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
340
+ </div>`;break;default:Z='<fig-input-text class="fig-fill-picker-ci-hex" placeholder="FFFFFF"></fig-input-text>';break}Q.innerHTML=Z,this.#l(),requestAnimationFrame(()=>this.#p())}#l(){let Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;let $=()=>{if(this.#A)return;let j=this.#K0();if(!j)return;if(this.#_={...j,a:this.#_.a},this.#E(),this.#y(),this.#O)this.#O.setAttribute("value",this.#_.h);this.#f()},J=()=>this.#u();Q.querySelectorAll("fig-input-number, fig-input-text").forEach((j)=>{j.addEventListener("input",$),j.addEventListener("change",J)})}#K0(){let Q=(J)=>this.#J?.querySelector(`.${J}`),$=(J)=>parseFloat(Q(J)?.value??0);switch(this.#X){case"rgb":return this.#e({r:$("fig-fill-picker-ci-r"),g:$("fig-fill-picker-ci-g"),b:$("fig-fill-picker-ci-b")});case"hsl":{let J=this.#G0({h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),l:$("fig-fill-picker-ci-l")});return this.#e(J)}case"hsb":return{h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),v:$("fig-fill-picker-ci-v"),a:1};case"lab":{let J=this.#W0({l:$("fig-fill-picker-ci-okl")/100,a:$("fig-fill-picker-ci-oka"),b:$("fig-fill-picker-ci-okb")});return this.#e(J)}case"lch":{let J=this.#O0({l:$("fig-fill-picker-ci-okl")/100,c:$("fig-fill-picker-ci-okc"),h:$("fig-fill-picker-ci-okh")});return this.#e(J)}default:{let J=Q("fig-fill-picker-ci-hex");if(!J)return null;let Z=J.value.replace(/^#/,"");if(Z.length===3)Z=Z[0]+Z[0]+Z[1]+Z[1]+Z[2]+Z[2];if(Z.length!==6||!/^[0-9a-fA-F]{6}$/.test(Z))return null;return this.#j0(`#${Z}`)}}}#p(){if(!this.#J)return;let Q=this.#s(this.#_),$=this.#o(this.#_),J=(j)=>this.#J.querySelector(`.${j}`),Z=(j,K)=>{let q=J(j);if(q)q.setAttribute("value",K)};switch(this.#X){case"rgb":Z("fig-fill-picker-ci-r",$.r),Z("fig-fill-picker-ci-g",$.g),Z("fig-fill-picker-ci-b",$.b);break;case"hsl":{let j=this.#L0($);Z("fig-fill-picker-ci-h",Math.round(j.h)),Z("fig-fill-picker-ci-s",Math.round(j.s)),Z("fig-fill-picker-ci-l",Math.round(j.l));break}case"hsb":Z("fig-fill-picker-ci-h",Math.round(this.#_.h)),Z("fig-fill-picker-ci-s",Math.round(this.#_.s)),Z("fig-fill-picker-ci-v",Math.round(this.#_.v));break;case"lab":{let j=this.#Y0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-oka",+j.a.toFixed(3)),Z("fig-fill-picker-ci-okb",+j.b.toFixed(3));break}case"lch":{let j=this.#M0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-okc",+j.c.toFixed(3)),Z("fig-fill-picker-ci-okh",Math.round(j.h));break}default:Z("fig-fill-picker-ci-hex",Q.replace(/^#/,"").toUpperCase());break}if(this.#B)this.#B.setAttribute("color",Q);this.#P()}#q0(){let Q=this.#J.querySelector('[data-tab="gradient"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
341
341
  <fig-field class="fig-fill-picker-gradient-header" direction="horizontal">
342
342
  <fig-dropdown class="fig-fill-picker-gradient-type" ${J} value="${this.#q.type}">
343
343
  <option value="linear" selected>Linear</option>
@@ -386,7 +386,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
386
386
  </fig-header>
387
387
  <div class="fig-fill-picker-gradient-stops-list"></div>
388
388
  </div>
389
- `,this.#b(),this.#d(Q)}#d(Q){let $=Q.querySelector(".fig-fill-picker-gradient-type"),J=(W)=>W.currentTarget?.value??W.target?.value??W.detail,Z=(W)=>{this.#q.type=J(W),this.#b(),this.#f()};$.addEventListener("input",Z),$.addEventListener("change",Z);let j=Q.querySelector(".fig-fill-picker-gradient-space"),K=(W)=>{let N=J(W),G=N,D="shorter";if(N.startsWith("oklch-"))G="oklch",D=N.slice(6);this.#q=V({...this.#q,interpolationSpace:G,hueInterpolation:D}),this.#b(),this.#f()};j?.addEventListener("input",K),j?.addEventListener("change",K),Q.querySelector(".fig-fill-picker-gradient-angle").addEventListener("input",(W)=>{let N=parseFloat(W.target.value)||0;this.#q.angle=(N+90)%360,this.#m(),this.#f()});let _=Q.querySelector(".fig-fill-picker-gradient-cx"),X=Q.querySelector(".fig-fill-picker-gradient-cy");_?.addEventListener("input",(W)=>{this.#q.centerX=parseFloat(W.target.value)||50,this.#m(),this.#f()}),X?.addEventListener("input",(W)=>{this.#q.centerY=parseFloat(W.target.value)||50,this.#m(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#q.stops.forEach((W)=>{W.position=100-W.position}),this.#q.stops.sort((W,N)=>W.position-N.position),this.#b(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#q.stops.push({position:50,color:"#888888",opacity:100}),this.#q.stops.sort((N,G)=>N.position-G.position),this.#b(),this.#f()});let Y=Q.querySelector(".fig-fill-picker-gradient-bar-input");if(Y){let W=(N)=>{N.stopPropagation();let G=N.detail;if(!G?.gradient)return;this.#q=V({...this.#q,...G.gradient}),this.#P(),this.#t()};Y.addEventListener("input",(N)=>{W(N),this.#f()}),Y.addEventListener("change",(N)=>{W(N),this.#p()})}}#b(){if(!this.#J)return;let Q=this.#J.querySelector('[data-tab="gradient"]');if(!Q)return;this.#q=V(this.#q);let $=Q.querySelector(".fig-fill-picker-gradient-angle"),J=Q.querySelector(".fig-fill-picker-gradient-center");if(this.#q.type==="radial")$.style.display="none",J.style.display="flex";else{$.style.display="block",J.style.display="none";let j=(this.#q.angle-90+360)%360;$.setAttribute("value",j)}let Z=Q.querySelector(".fig-fill-picker-gradient-space");if(Z)Z.value=this.#q.interpolationSpace==="oklch"?`oklch-${this.#q.hueInterpolation||"shorter"}`:this.#q.interpolationSpace;this.#m(),this.#t()}#m(){if(!this.#J)return;let Q=this.#J.querySelector(".fig-fill-picker-gradient-bar-input");if(Q)Q.setAttribute("value",JSON.stringify({type:"gradient",gradient:d(this.#q)}));this.#P()}#t(){if(!this.#J)return;let Q=this.#J.querySelector(".fig-fill-picker-gradient-stops-list");if(!Q)return;let $=Q.querySelectorAll(".fig-fill-picker-gradient-stop-row");if($.length===this.#q.stops.length){this.#q.stops.forEach((J,Z)=>{let j=$[Z];j.dataset.index=Z;let K=j.querySelector(".fig-fill-picker-stop-position");if(K)K.setAttribute("value",J.position);let q=j.querySelector(".fig-fill-picker-stop-color");if(q)q.setAttribute("value",J.color);let _=j.querySelector(".fig-fill-picker-stop-remove");if(_)if(this.#q.stops.length<=2)_.setAttribute("disabled","");else _.removeAttribute("disabled")});return}this.#c(Q)}#c(Q){Q.innerHTML=this.#q.stops.map(($,J)=>`
389
+ `,this.#b(),this.#d(Q)}#d(Q){let $=Q.querySelector(".fig-fill-picker-gradient-type"),J=(W)=>W.currentTarget?.value??W.target?.value??W.detail,Z=(W)=>{this.#q.type=J(W),this.#b(),this.#f()};$.addEventListener("input",Z),$.addEventListener("change",Z);let j=Q.querySelector(".fig-fill-picker-gradient-space"),K=(W)=>{let N=J(W),G=N,D="shorter";if(N.startsWith("oklch-"))G="oklch",D=N.slice(6);this.#q=V({...this.#q,interpolationSpace:G,hueInterpolation:D}),this.#b(),this.#f()};j?.addEventListener("input",K),j?.addEventListener("change",K),Q.querySelector(".fig-fill-picker-gradient-angle").addEventListener("input",(W)=>{let N=parseFloat(W.target.value)||0;this.#q.angle=(N+90)%360,this.#m(),this.#f()});let _=Q.querySelector(".fig-fill-picker-gradient-cx"),X=Q.querySelector(".fig-fill-picker-gradient-cy");_?.addEventListener("input",(W)=>{this.#q.centerX=parseFloat(W.target.value)||50,this.#m(),this.#f()}),X?.addEventListener("input",(W)=>{this.#q.centerY=parseFloat(W.target.value)||50,this.#m(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#q.stops.forEach((W)=>{W.position=100-W.position}),this.#q.stops.sort((W,N)=>W.position-N.position),this.#b(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#q.stops.push({position:50,color:"#888888",opacity:100}),this.#q.stops.sort((N,G)=>N.position-G.position),this.#b(),this.#f()});let Y=Q.querySelector(".fig-fill-picker-gradient-bar-input");if(Y){let W=(N)=>{N.stopPropagation();let G=N.detail;if(!G?.gradient)return;this.#q=V({...this.#q,...G.gradient}),this.#P(),this.#t()};Y.addEventListener("input",(N)=>{W(N),this.#f()}),Y.addEventListener("change",(N)=>{W(N),this.#u()})}}#b(){if(!this.#J)return;let Q=this.#J.querySelector('[data-tab="gradient"]');if(!Q)return;this.#q=V(this.#q);let $=Q.querySelector(".fig-fill-picker-gradient-angle"),J=Q.querySelector(".fig-fill-picker-gradient-center");if(this.#q.type==="radial")$.style.display="none",J.style.display="flex";else{$.style.display="block",J.style.display="none";let j=(this.#q.angle-90+360)%360;$.setAttribute("value",j)}let Z=Q.querySelector(".fig-fill-picker-gradient-space");if(Z)Z.value=this.#q.interpolationSpace==="oklch"?`oklch-${this.#q.hueInterpolation||"shorter"}`:this.#q.interpolationSpace;this.#m(),this.#t()}#m(){if(!this.#J)return;let Q=this.#J.querySelector(".fig-fill-picker-gradient-bar-input");if(Q)Q.setAttribute("value",JSON.stringify({type:"gradient",gradient:d(this.#q)}));this.#P()}#t(){if(!this.#J)return;let Q=this.#J.querySelector(".fig-fill-picker-gradient-stops-list");if(!Q)return;let $=Q.querySelectorAll(".fig-fill-picker-gradient-stop-row");if($.length===this.#q.stops.length){this.#q.stops.forEach((J,Z)=>{let j=$[Z];j.dataset.index=Z;let K=j.querySelector(".fig-fill-picker-stop-position");if(K)K.setAttribute("value",J.position);let q=j.querySelector(".fig-fill-picker-stop-color");if(q)q.setAttribute("value",J.color);let _=j.querySelector(".fig-fill-picker-stop-remove");if(_)if(this.#q.stops.length<=2)_.setAttribute("disabled","");else _.removeAttribute("disabled")});return}this.#c(Q)}#c(Q){Q.innerHTML=this.#q.stops.map(($,J)=>`
390
390
  <fig-field class="fig-fill-picker-gradient-stop-row" direction="horizontal" data-index="${J}">
391
391
  <fig-input-number class="fig-fill-picker-stop-position" min="0" max="100" value="${$.position}" units="%"></fig-input-number>
392
392
  <fig-input-color class="fig-fill-picker-stop-color" text="true" alpha="true" picker="figma" picker-dialog-position="right" value="${$.color}"></fig-input-color>
@@ -396,13 +396,13 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
396
396
  </fig-field>
397
397
  `).join(""),Q.querySelectorAll(".fig-fill-picker-gradient-stop-row").forEach(($)=>{let J=parseInt($.dataset.index);$.querySelector(".fig-fill-picker-stop-position").addEventListener("input",(K)=>{this.#q.stops[J].position=parseFloat(K.target.value)||0,this.#m(),this.#f()});let Z=$.querySelector(".fig-fill-picker-stop-color"),j=Z.querySelector("fig-fill-picker");if(j)j.anchorElement=this.#J;else requestAnimationFrame(()=>{let K=Z.querySelector("fig-fill-picker");if(K)K.anchorElement=this.#J});Z.addEventListener("input",(K)=>{this.#q.stops[J].color=K.target.hexOpaque||K.target.value;let q=K.detail?.rgba?.a;if(q!==void 0)this.#q.stops[J].opacity=Math.round(q*100);this.#m(),this.#f()}),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{if(this.#q.stops.length>2)this.#q.stops.splice(J,1),this.#b(),this.#f()})})}#h(Q,$=!0){let J=V({...this.#q,interpolationSpace:Q??this.#q.interpolationSpace}),Z=this.#j==="display-p3",j=J.stops.map((q)=>{let _=(q.opacity??100)/100;return`${Z?this.#U0(q.color,_):this.#N0(q.color,_)} ${q.position}%`}).join(", "),K=$?` ${I0(J)}`:"";switch(J.type){case"linear":return`linear-gradient(${J.angle}deg${K}, ${j})`;case"radial":return`radial-gradient(circle at ${J.centerX}% ${J.centerY}%${K}, ${j})`;case"angular":return`conic-gradient(from ${J.angle}deg${K}, ${j})`;default:return`linear-gradient(${J.angle}deg${K}, ${j})`}}static#Q0=new Map;#$0(Q){let $=e.#Q0.get(Q);if($!==void 0)return $;let J=document.createElement("div");J.style.background=Q;let Z=!!J.style.background;return e.#Q0.set(Q,Z),Z}#J0(){let Q=this.#h(void 0,!0);if(this.#$0(Q))return Q;let $=this.#h("oklab",!0);if(this.#$0($))return $;return this.#h("oklab",!1)}#n(){let Q=this.#J.querySelector('[data-tab="image"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
398
398
  <fig-field class="fig-fill-picker-media-header" direction="horizontal">
399
- <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#N.scaleMode}">
399
+ <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#W.scaleMode}">
400
400
  <option value="fill" selected>Fill</option>
401
401
  <option value="fit">Fit</option>
402
402
  <option value="crop">Crop</option>
403
403
  <option value="tile">Tile</option>
404
404
  </fig-dropdown>
405
- <fig-input-number class="fig-fill-picker-scale" min="1" max="200" value="${this.#N.scale}" units="%" style="display: none;"></fig-input-number>
405
+ <fig-input-number class="fig-fill-picker-scale" min="1" max="200" value="${this.#W.scale}" units="%" style="display: none;"></fig-input-number>
406
406
  </fig-field>
407
407
  <div class="fig-fill-picker-media-preview">
408
408
  <div class="fig-fill-picker-checkerboard"></div>
@@ -412,9 +412,9 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
412
412
  <input type="file" accept="image/*" style="display: none;" />
413
413
  </fig-button>
414
414
  </div>
415
- `,this.#r(Q)}#r(Q){let $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-scale"),Z=Q.querySelector(".fig-fill-picker-upload"),j=Q.querySelector('input[type="file"]'),K=Q.querySelector(".fig-fill-picker-image-preview");$.addEventListener("change",(_)=>{this.#N.scaleMode=_.target.value,J.style.display=_.target.value==="tile"?"block":"none",this.#i(K),this.#P(),this.#f()}),J.addEventListener("input",(_)=>{this.#N.scale=parseFloat(_.target.value)||100,this.#i(K),this.#P(),this.#f()}),Z.addEventListener("click",()=>{j.click()}),j.addEventListener("change",(_)=>{let X=_.target.files[0];if(X){let Y=new FileReader;Y.onload=(W)=>{this.#N.url=W.target.result,this.#i(K),this.#P(),this.#f()},Y.readAsDataURL(X)}});let q=Q.querySelector(".fig-fill-picker-media-preview");q.addEventListener("dragover",(_)=>{_.preventDefault(),q.classList.add("dragover")}),q.addEventListener("dragleave",()=>{q.classList.remove("dragover")}),q.addEventListener("drop",(_)=>{_.preventDefault(),q.classList.remove("dragover");let X=_.dataTransfer.files[0];if(X&&X.type.startsWith("image/")){let Y=new FileReader;Y.onload=(W)=>{this.#N.url=W.target.result,this.#i(K),this.#P(),this.#f()},Y.readAsDataURL(X)}})}#i(Q){let $=Q.closest(".fig-fill-picker-media-preview");if(!this.#N.url){Q.style.display="none",$?.classList.remove("has-media");return}switch(Q.style.display="block",$?.classList.add("has-media"),Q.style.backgroundImage=`url(${this.#N.url})`,Q.style.backgroundPosition="center",this.#N.scaleMode){case"fill":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"fit":Q.style.backgroundSize="contain",Q.style.backgroundRepeat="no-repeat";break;case"crop":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"tile":Q.style.backgroundSize=`${this.#N.scale}%`,Q.style.backgroundRepeat="repeat",Q.style.backgroundPosition="top left";break}}#g(Q){switch(Q.style.objectPosition="center",Q.style.width="100%",Q.style.height="100%",this.#U.scaleMode){case"fill":case"crop":Q.style.objectFit="cover";break;case"fit":Q.style.objectFit="contain";break}}#_0(){let Q=this.#J.querySelector('[data-tab="video"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
415
+ `,this.#r(Q)}#r(Q){let $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-scale"),Z=Q.querySelector(".fig-fill-picker-upload"),j=Q.querySelector('input[type="file"]'),K=Q.querySelector(".fig-fill-picker-image-preview");$.addEventListener("change",(_)=>{this.#W.scaleMode=_.target.value,J.style.display=_.target.value==="tile"?"block":"none",this.#i(K),this.#P(),this.#f()}),J.addEventListener("input",(_)=>{this.#W.scale=parseFloat(_.target.value)||100,this.#i(K),this.#P(),this.#f()}),Z.addEventListener("click",()=>{j.click()}),j.addEventListener("change",(_)=>{let X=_.target.files[0];if(X){let Y=new FileReader;Y.onload=(W)=>{this.#W.url=W.target.result,this.#i(K),this.#P(),this.#f()},Y.readAsDataURL(X)}});let q=Q.querySelector(".fig-fill-picker-media-preview");q.addEventListener("dragover",(_)=>{_.preventDefault(),q.classList.add("dragover")}),q.addEventListener("dragleave",()=>{q.classList.remove("dragover")}),q.addEventListener("drop",(_)=>{_.preventDefault(),q.classList.remove("dragover");let X=_.dataTransfer.files[0];if(X&&X.type.startsWith("image/")){let Y=new FileReader;Y.onload=(W)=>{this.#W.url=W.target.result,this.#i(K),this.#P(),this.#f()},Y.readAsDataURL(X)}})}#i(Q){let $=Q.closest(".fig-fill-picker-media-preview");if(!this.#W.url){Q.style.display="none",$?.classList.remove("has-media");return}switch(Q.style.display="block",$?.classList.add("has-media"),Q.style.backgroundImage=`url(${this.#W.url})`,Q.style.backgroundPosition="center",this.#W.scaleMode){case"fill":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"fit":Q.style.backgroundSize="contain",Q.style.backgroundRepeat="no-repeat";break;case"crop":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"tile":Q.style.backgroundSize=`${this.#W.scale}%`,Q.style.backgroundRepeat="repeat",Q.style.backgroundPosition="top left";break}}#g(Q){switch(Q.style.objectPosition="center",Q.style.width="100%",Q.style.height="100%",this.#N.scaleMode){case"fill":case"crop":Q.style.objectFit="cover";break;case"fit":Q.style.objectFit="contain";break}}#_0(){let Q=this.#J.querySelector('[data-tab="video"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
416
416
  <fig-field class="fig-fill-picker-media-header" direction="horizontal">
417
- <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#U.scaleMode}">
417
+ <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#N.scaleMode}">
418
418
  <option value="fill" selected>Fill</option>
419
419
  <option value="fit">Fit</option>
420
420
  <option value="crop">Crop</option>
@@ -428,7 +428,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
428
428
  <input type="file" accept="video/*" style="display: none;" />
429
429
  </fig-button>
430
430
  </div>
431
- `,this.#Z0(Q)}#Z0(Q){let $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-upload"),Z=Q.querySelector('input[type="file"]'),j=Q.querySelector(".fig-fill-picker-video-preview");$.addEventListener("change",(q)=>{this.#U.scaleMode=q.target.value,this.#g(j),this.#P(),this.#f()}),J.addEventListener("click",()=>{Z.click()});let K=Q.querySelector(".fig-fill-picker-media-preview");Z.addEventListener("change",(q)=>{let _=q.target.files[0];if(_)this.#U.url=URL.createObjectURL(_),j.src=this.#U.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#f()}),K.addEventListener("dragover",(q)=>{q.preventDefault(),K.classList.add("dragover")}),K.addEventListener("dragleave",()=>{K.classList.remove("dragover")}),K.addEventListener("drop",(q)=>{q.preventDefault(),K.classList.remove("dragover");let _=q.dataTransfer.files[0];if(_&&_.type.startsWith("video/"))this.#U.url=URL.createObjectURL(_),j.src=this.#U.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#f()})}#X0(){let Q=this.#J.querySelector('[data-tab="webcam"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
431
+ `,this.#Z0(Q)}#Z0(Q){let $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-upload"),Z=Q.querySelector('input[type="file"]'),j=Q.querySelector(".fig-fill-picker-video-preview");$.addEventListener("change",(q)=>{this.#N.scaleMode=q.target.value,this.#g(j),this.#P(),this.#f()}),J.addEventListener("click",()=>{Z.click()});let K=Q.querySelector(".fig-fill-picker-media-preview");Z.addEventListener("change",(q)=>{let _=q.target.files[0];if(_)this.#N.url=URL.createObjectURL(_),j.src=this.#N.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#f()}),K.addEventListener("dragover",(q)=>{q.preventDefault(),K.classList.add("dragover")}),K.addEventListener("dragleave",()=>{K.classList.remove("dragover")}),K.addEventListener("drop",(q)=>{q.preventDefault(),K.classList.remove("dragover");let _=q.dataTransfer.files[0];if(_&&_.type.startsWith("video/"))this.#N.url=URL.createObjectURL(_),j.src=this.#N.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#f()})}#X0(){let Q=this.#J.querySelector('[data-tab="webcam"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
432
432
  <div class="fig-fill-picker-webcam-preview">
433
433
  <div class="fig-fill-picker-checkerboard"></div>
434
434
  <video class="fig-fill-picker-webcam-video" autoplay muted playsinline></video>
@@ -443,7 +443,7 @@ var N1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var U1={};var W0=N1(()=>{/*! Vendored from @
443
443
  Capture
444
444
  </fig-button>
445
445
  </fig-field>
446
- `,this.#a(Q)}#a(Q){let $=Q.querySelector(".fig-fill-picker-webcam-video"),J=Q.querySelector(".fig-fill-picker-webcam-status"),Z=Q.querySelector(".fig-fill-picker-webcam-capture"),j=Q.querySelector(".fig-fill-picker-camera-select"),K=async(q=null)=>{try{let _={video:q?{deviceId:{exact:q}}:!0};if(this.#W.stream)this.#W.stream.getTracks().forEach((W)=>W.stop());this.#W.stream=await navigator.mediaDevices.getUserMedia(_),$.srcObject=this.#W.stream,$.style.display="block",J.style.display="none";let Y=(await navigator.mediaDevices.enumerateDevices()).filter((W)=>W.kind==="videoinput");if(Y.length>1)j.style.display="block",j.innerHTML=Y.map((W,N)=>`<option value="${W.deviceId}">${W.label||`Camera ${N+1}`}</option>`).join("")}catch(_){console.error("Webcam error:",_.name,_.message);let X="Camera access denied";if(_.name==="NotAllowedError")X="Camera permission denied";else if(_.name==="NotFoundError")X="No camera found";else if(_.name==="NotReadableError")X="Camera in use by another app";else if(_.name==="OverconstrainedError")X="Camera constraints not supported";else if(!window.isSecureContext)X="Camera requires secure context";J.innerHTML=`<span>${X}</span>`,J.style.display="flex",$.style.display="none"}};this.#D=new MutationObserver(()=>{if(Q.style.display!=="none"&&!this.#W.stream)K()}),this.#D.observe(Q,{attributes:!0,attributeFilter:["style"]}),j.addEventListener("change",(q)=>{K(q.target.value)}),Z.addEventListener("click",()=>{if(!this.#W.stream)return;let q=document.createElement("canvas");q.width=$.videoWidth,q.height=$.videoHeight,q.getContext("2d").drawImage($,0,0),this.#W.snapshot=q.toDataURL("image/png"),this.#N.url=this.#W.snapshot,this.#Z="image",this.#P(),this.#f(),this.#T("image");let _=this.#J.querySelector("fig-tabs");_.value="image"})}#o(Q){let $=Q.h/360,J=Q.s/100,Z=Q.v/100,j,K,q,_=Math.floor($*6),X=$*6-_,Y=Z*(1-J),W=Z*(1-X*J),N=Z*(1-(1-X)*J);switch(_%6){case 0:j=Z,K=N,q=Y;break;case 1:j=W,K=Z,q=Y;break;case 2:j=Y,K=Z,q=N;break;case 3:j=Y,K=W,q=Z;break;case 4:j=N,K=Y,q=Z;break;case 5:j=Z,K=Y,q=W;break}return{r:Math.round(j*255),g:Math.round(K*255),b:Math.round(q*255)}}#e(Q){let $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),K=Math.min($,J,Z),q=j-K,_=0,X=j===0?0:q/j,Y=j;if(j!==K){switch(j){case $:_=(J-Z)/q+(J<Z?6:0);break;case J:_=(Z-$)/q+2;break;case Z:_=($-J)/q+4;break}_/=6}return{h:_*360,s:X*100,v:Y*100,a:1}}#s(Q){if(!Q||typeof Q.h!=="number"||typeof Q.s!=="number"||typeof Q.v!=="number")return"#D9D9D9";let $=this.#o(Q),J=(Z)=>{return(isNaN(Z)?217:Math.max(0,Math.min(255,Math.round(Z)))).toString(16).padStart(2,"0")};return`#${J($.r)}${J($.g)}${J($.b)}`}#j0(Q){let $=parseInt(Q.slice(1,3),16),J=parseInt(Q.slice(3,5),16),Z=parseInt(Q.slice(5,7),16);return this.#e({r:$,g:J,b:Z})}#N0(Q,$=1){let J=parseInt(Q.slice(1,3),16),Z=parseInt(Q.slice(3,5),16),j=parseInt(Q.slice(5,7),16);return`rgba(${J}, ${Z}, ${j}, ${$})`}#U0(Q,$=1){let J=+(parseInt(Q.slice(1,3),16)/255).toFixed(4),Z=+(parseInt(Q.slice(3,5),16)/255).toFixed(4),j=+(parseInt(Q.slice(5,7),16)/255).toFixed(4);return`color(display-p3 ${J} ${Z} ${j} / ${$})`}#L0(Q){let $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),K=Math.min($,J,Z),q,_,X=(j+K)/2;if(j===K)q=_=0;else{let Y=j-K;switch(_=X>0.5?Y/(2-j-K):Y/(j+K),j){case $:q=((J-Z)/Y+(J<Z?6:0))/6;break;case J:q=((Z-$)/Y+2)/6;break;case Z:q=(($-J)/Y+4)/6;break}}return{h:q*360,s:_*100,l:X*100}}#G0(Q){let $=Q.h/360,J=Q.s/100,Z=Q.l/100,j,K,q;if(J===0)j=K=q=Z;else{let _=(W,N,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return W+(N-W)*6*G;if(G<0.5)return N;if(G<0.6666666666666666)return W+(N-W)*(0.6666666666666666-G)*6;return W},X=Z<0.5?Z*(1+J):Z+J-Z*J,Y=2*Z-X;j=_(Y,X,$+0.3333333333333333),K=_(Y,X,$),q=_(Y,X,$-0.3333333333333333)}return{r:Math.round(j*255),g:Math.round(K*255),b:Math.round(q*255)}}#Y0(Q){let $=(N)=>{return N=N/255,N<=0.04045?N/12.92:Math.pow((N+0.055)/1.055,2.4)},J=$(Q.r),Z=$(Q.g),j=$(Q.b),K=0.4122214708*J+0.5363325363*Z+0.0514459929*j,q=0.2119034982*J+0.6806995451*Z+0.1073969566*j,_=0.0883024619*J+0.2817188376*Z+0.6299787005*j,X=Math.cbrt(K),Y=Math.cbrt(q),W=Math.cbrt(_);return{l:0.2104542553*X+0.793617785*Y-0.0040720468*W,a:1.9779984951*X-2.428592205*Y+0.4505937099*W,b:0.0259040371*X+0.7827717662*Y-0.808675766*W}}#M0(Q){let $=this.#Y0(Q);return{l:$.l,c:Math.sqrt($.a*$.a+$.b*$.b),h:(Math.atan2($.b,$.a)*180/Math.PI+360)%360}}#W0(Q){let $=Q.l+0.3963377774*Q.a+0.2158037573*Q.b,J=Q.l-0.1055613458*Q.a-0.0638541728*Q.b,Z=Q.l-0.0894841775*Q.a-1.291485548*Q.b,j=$*$*$,K=J*J*J,q=Z*Z*Z,_=(X)=>{let Y=X<=0.0031308?12.92*X:1.055*Math.pow(X,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Y))*255)};return{r:_(4.0767416621*j-3.3077115913*K+0.2309699292*q),g:_(-1.2684380046*j+2.6097574011*K-0.3413193965*q),b:_(-0.0041960863*j-0.7034186147*K+1.707614701*q)}}#B0(Q){let $=Q.h*Math.PI/180;return this.#W0({l:Q.l,a:Q.c*Math.cos($),b:Q.c*Math.sin($)})}#f(){this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#p(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){let Q={type:this.#Z,colorSpace:this.#j};switch(this.#Z){case"solid":return{...Q,color:this.#s(this.#_),alpha:this.#_.a,hsv:{...this.#_}};case"gradient":return{...Q,gradient:d(this.#q),css:this.#J0()};case"image":return{...Q,image:{...this.#N}};case"video":return{...Q,video:{...this.#U}};case"webcam":return{...Q,image:{url:this.#W.snapshot,scaleMode:"fill",scale:50}};default:return{...Q,...this.#L[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":if(this.#F(),this.#P(),this.#J){if(!this.#O){if(this.#I(),this.#u(),this.#B)this.#B.setAttribute("value",this.#_.h);if(this.#A)this.#A.setAttribute("value",this.#_.a*100),this.#A.setAttribute("color",this.#s(this.#_))}}break;case"disabled":break}}}customElements.define("fig-fill-picker",e);class $1 extends HTMLElement{#Q=null;#$=null;#J=this.#M.bind(this);#K=this.#B.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#q(),this.#L()}disconnectedCallback(){this.#j(),this.removeEventListener("click",this.#N)}#j(){if(!this.#Q)return;this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#K)}#_=()=>{requestAnimationFrame(()=>{let Q=document.querySelector(".fig-fill-picker-dialog[open]");if(!Q)return;Q.addEventListener("close",()=>this.removeAttribute("selected"),{once:!0})})};get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#q(){let Q=this.#Z;if(Q==="add"||Q==="remove"){let q=Q==="add"?"var(--icon-add)":"var(--icon-minus)";this.innerHTML=`<fig-button icon variant="ghost"><span class="fig-mask-icon" style="--icon: ${q}"></span></fig-button>`,this.#Q=null,this.#$=null,this.addEventListener("click",this.#N);return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#Y($),Z=this.#W($),j=this.#X?"":'alpha="false"',K=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J});this.innerHTML=`
446
+ `,this.#a(Q)}#a(Q){let $=Q.querySelector(".fig-fill-picker-webcam-video"),J=Q.querySelector(".fig-fill-picker-webcam-status"),Z=Q.querySelector(".fig-fill-picker-webcam-capture"),j=Q.querySelector(".fig-fill-picker-camera-select"),K=async(q=null)=>{try{let _={video:q?{deviceId:{exact:q}}:!0};if(this.#U.stream)this.#U.stream.getTracks().forEach((W)=>W.stop());this.#U.stream=await navigator.mediaDevices.getUserMedia(_),$.srcObject=this.#U.stream,$.style.display="block",J.style.display="none";let Y=(await navigator.mediaDevices.enumerateDevices()).filter((W)=>W.kind==="videoinput");if(Y.length>1)j.style.display="block",j.innerHTML=Y.map((W,N)=>`<option value="${W.deviceId}">${W.label||`Camera ${N+1}`}</option>`).join("")}catch(_){console.error("Webcam error:",_.name,_.message);let X="Camera access denied";if(_.name==="NotAllowedError")X="Camera permission denied";else if(_.name==="NotFoundError")X="No camera found";else if(_.name==="NotReadableError")X="Camera in use by another app";else if(_.name==="OverconstrainedError")X="Camera constraints not supported";else if(!window.isSecureContext)X="Camera requires secure context";J.innerHTML=`<span>${X}</span>`,J.style.display="flex",$.style.display="none"}};this.#F=new MutationObserver(()=>{if(Q.style.display!=="none"&&!this.#U.stream)K()}),this.#F.observe(Q,{attributes:!0,attributeFilter:["style"]}),j.addEventListener("change",(q)=>{K(q.target.value)}),Z.addEventListener("click",()=>{if(!this.#U.stream)return;let q=document.createElement("canvas");q.width=$.videoWidth,q.height=$.videoHeight,q.getContext("2d").drawImage($,0,0),this.#U.snapshot=q.toDataURL("image/png"),this.#W.url=this.#U.snapshot,this.#Z="image",this.#P(),this.#f(),this.#T("image");let _=this.#J.querySelector("fig-tabs");_.value="image"})}#o(Q){let $=Q.h/360,J=Q.s/100,Z=Q.v/100,j,K,q,_=Math.floor($*6),X=$*6-_,Y=Z*(1-J),W=Z*(1-X*J),N=Z*(1-(1-X)*J);switch(_%6){case 0:j=Z,K=N,q=Y;break;case 1:j=W,K=Z,q=Y;break;case 2:j=Y,K=Z,q=N;break;case 3:j=Y,K=W,q=Z;break;case 4:j=N,K=Y,q=Z;break;case 5:j=Z,K=Y,q=W;break}return{r:Math.round(j*255),g:Math.round(K*255),b:Math.round(q*255)}}#e(Q){let $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),K=Math.min($,J,Z),q=j-K,_=0,X=j===0?0:q/j,Y=j;if(j!==K){switch(j){case $:_=(J-Z)/q+(J<Z?6:0);break;case J:_=(Z-$)/q+2;break;case Z:_=($-J)/q+4;break}_/=6}return{h:_*360,s:X*100,v:Y*100,a:1}}#s(Q){if(!Q||typeof Q.h!=="number"||typeof Q.s!=="number"||typeof Q.v!=="number")return"#D9D9D9";let $=this.#o(Q),J=(Z)=>{return(isNaN(Z)?217:Math.max(0,Math.min(255,Math.round(Z)))).toString(16).padStart(2,"0")};return`#${J($.r)}${J($.g)}${J($.b)}`}#j0(Q){let $=parseInt(Q.slice(1,3),16),J=parseInt(Q.slice(3,5),16),Z=parseInt(Q.slice(5,7),16);return this.#e({r:$,g:J,b:Z})}#N0(Q,$=1){let J=parseInt(Q.slice(1,3),16),Z=parseInt(Q.slice(3,5),16),j=parseInt(Q.slice(5,7),16);return`rgba(${J}, ${Z}, ${j}, ${$})`}#U0(Q,$=1){let J=+(parseInt(Q.slice(1,3),16)/255).toFixed(4),Z=+(parseInt(Q.slice(3,5),16)/255).toFixed(4),j=+(parseInt(Q.slice(5,7),16)/255).toFixed(4);return`color(display-p3 ${J} ${Z} ${j} / ${$})`}#L0(Q){let $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),K=Math.min($,J,Z),q,_,X=(j+K)/2;if(j===K)q=_=0;else{let Y=j-K;switch(_=X>0.5?Y/(2-j-K):Y/(j+K),j){case $:q=((J-Z)/Y+(J<Z?6:0))/6;break;case J:q=((Z-$)/Y+2)/6;break;case Z:q=(($-J)/Y+4)/6;break}}return{h:q*360,s:_*100,l:X*100}}#G0(Q){let $=Q.h/360,J=Q.s/100,Z=Q.l/100,j,K,q;if(J===0)j=K=q=Z;else{let _=(W,N,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return W+(N-W)*6*G;if(G<0.5)return N;if(G<0.6666666666666666)return W+(N-W)*(0.6666666666666666-G)*6;return W},X=Z<0.5?Z*(1+J):Z+J-Z*J,Y=2*Z-X;j=_(Y,X,$+0.3333333333333333),K=_(Y,X,$),q=_(Y,X,$-0.3333333333333333)}return{r:Math.round(j*255),g:Math.round(K*255),b:Math.round(q*255)}}#Y0(Q){let $=(N)=>{return N=N/255,N<=0.04045?N/12.92:Math.pow((N+0.055)/1.055,2.4)},J=$(Q.r),Z=$(Q.g),j=$(Q.b),K=0.4122214708*J+0.5363325363*Z+0.0514459929*j,q=0.2119034982*J+0.6806995451*Z+0.1073969566*j,_=0.0883024619*J+0.2817188376*Z+0.6299787005*j,X=Math.cbrt(K),Y=Math.cbrt(q),W=Math.cbrt(_);return{l:0.2104542553*X+0.793617785*Y-0.0040720468*W,a:1.9779984951*X-2.428592205*Y+0.4505937099*W,b:0.0259040371*X+0.7827717662*Y-0.808675766*W}}#M0(Q){let $=this.#Y0(Q);return{l:$.l,c:Math.sqrt($.a*$.a+$.b*$.b),h:(Math.atan2($.b,$.a)*180/Math.PI+360)%360}}#W0(Q){let $=Q.l+0.3963377774*Q.a+0.2158037573*Q.b,J=Q.l-0.1055613458*Q.a-0.0638541728*Q.b,Z=Q.l-0.0894841775*Q.a-1.291485548*Q.b,j=$*$*$,K=J*J*J,q=Z*Z*Z,_=(X)=>{let Y=X<=0.0031308?12.92*X:1.055*Math.pow(X,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Y))*255)};return{r:_(4.0767416621*j-3.3077115913*K+0.2309699292*q),g:_(-1.2684380046*j+2.6097574011*K-0.3413193965*q),b:_(-0.0041960863*j-0.7034186147*K+1.707614701*q)}}#O0(Q){let $=Q.h*Math.PI/180;return this.#W0({l:Q.l,a:Q.c*Math.cos($),b:Q.c*Math.sin($)})}#f(){this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){let Q={type:this.#Z,colorSpace:this.#j};switch(this.#Z){case"solid":return{...Q,color:this.#s(this.#_),alpha:this.#_.a,hsv:{...this.#_}};case"gradient":return{...Q,gradient:d(this.#q),css:this.#J0()};case"image":return{...Q,image:{...this.#W}};case"video":return{...Q,video:{...this.#N}};case"webcam":return{...Q,image:{url:this.#U.snapshot,scaleMode:"fill",scale:50}};default:return{...Q,...this.#L[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":if(this.#D(),this.#P(),this.#J){if(!this.#A){if(this.#y(),this.#p(),this.#O)this.#O.setAttribute("value",this.#_.h);if(this.#B)this.#B.setAttribute("value",this.#_.a*100),this.#B.setAttribute("color",this.#s(this.#_))}}break;case"disabled":break}}}customElements.define("fig-fill-picker",e);class $1 extends HTMLElement{#Q=null;#$=null;#J=null;#K=this.#O.bind(this);#Z=this.#B.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#G()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#Q)this.#Q.removeEventListener("input",this.#K),this.#Q.removeEventListener("change",this.#Z);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#$)return;this.#J=new MutationObserver(()=>{if(this.#$?.hasAttribute("selected")&&this.#$.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#$,{attributes:!0,attributeFilter:["selected"]})}get#q(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#j;if(Q==="add"||Q==="remove"){let q=Q==="add"?"var(--icon-add)":"var(--icon-minus)";this.innerHTML=`<fig-button icon variant="ghost"><span class="fig-mask-icon" style="--icon: ${q}"></span></fig-button>`,this.#Q=null,this.#$=null,this.addEventListener("click",this.#N);return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#L($),Z=this.#Y($),j=this.#q?"":'alpha="false"',K=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J});this.innerHTML=`
447
447
  <fig-fill-picker mode="solid" ${j} value='${K}'>
448
448
  <fig-chit background="${J}"></fig-chit>
449
- </fig-fill-picker>`,this.#Q=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-chit"),this.#j(),this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#K),this.#$?.addEventListener("click",()=>{this.setAttribute("selected",""),this.#_()})}#N=()=>{let Q=this.#Z;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#U(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"}#W(Q){if(!Q)return 1;let $=String(Q).trim();if($.startsWith("#")&&$.length===9)return parseInt($.slice(7,9),16)/255;let J=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#Y(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#Y(J.color)}catch{}if($.startsWith("#"))return this.#U($);try{let{ctx:J}=M0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#U(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let K=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${K(j[1])}${K(j[2])}${K(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),$=this.#Y(Q),J=this.#W(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#Q){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#Q.setAttribute("value",JSON.stringify(Z)),this.#X)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#$)if(this.#$.setAttribute("background",$),this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#G(Q,$){let J=this.#Y(Q?.color),Z=this.#Y(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#L();let j={color:this.value};if(this.#X){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.#G(Q.detail,"input")}#B(Q){Q.stopPropagation(),this.#G(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#q();break;case"value":case"selected":case"disabled":this.#L();break}}get value(){return this.#Y(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#Y(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",$1);class J1 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",J1);class Z1 extends HTMLElement{#Q=null;#$=this.#M.bind(this);#J=this.#B.bind(this);#K=this.#O.bind(this);#Z=null;#j=null;#_=null;#X=null;#q=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop","padding"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#U(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#W(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#W))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,K=Z.hasAttribute("selected");if(j&&!K)Z.setAttribute("selected","");else if(!j&&K)Z.removeAttribute("selected")}this.#Q=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#V(Q)}get value(){return this.#Q?.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.#$),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#K),this.#H(),this.#z(),this.#k(),this.#R(),requestAnimationFrame(()=>{this.#Y(),this.#O()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#K),this.#D(),this.#Z?.disconnect(),this.#Z=null,this.#j?.disconnect(),this.#j=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 K of j)if(Z)K.setAttribute("aria-disabled","true"),K.setAttribute("tabindex","-1");else K.removeAttribute("aria-disabled"),K.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#Y());if(Q==="drag")if(this.#U)this.#z();else this.#D();if(Q==="overflow")this.#H()}#Y(){let Q=this.choices;if(!Q.length){this.#Q=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}#G(Q){let $=this.#W,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.#G(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#A()}#B(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((K)=>!K.hasAttribute("disabled")||K.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#Q),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.#W)){let K=this.#G(document.activeElement);if(K&&K!==this.#Q)this.selectedChoice=K,this.#A()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#A()}#A(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollLeft<=$,Z=this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}else{let J=this.scrollTop<=$,Z=this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}}#R(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#O()}),this.#j.observe(this)}#z(){if(this.#q?.bound)return;if(!this.#U)return;let Q=(K)=>{if(K.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#q.active=!0,this.#q.didDrag=!1,this.#q.startX=K.clientX,this.#q.startY=K.clientY,this.#q.scrollLeft=this.scrollLeft,this.#q.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(K)=>{if(!this.#q.active)return;let q=this.getAttribute("layout")==="horizontal",_=K.clientX-this.#q.startX,X=K.clientY-this.#q.startY;if(!this.#q.didDrag&&Math.abs(q?_:X)>3)this.#q.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(K.pointerId);if(!this.#q.didDrag)return;if(q)this.scrollLeft=this.#q.scrollLeft-_;else this.scrollTop=this.#q.scrollTop-X},J=(K)=>{if(!this.#q.active)return;let q=this.#q.didDrag;if(this.#q.active=!1,this.#q.didDrag=!1,this.style.cursor="",this.style.userSelect="",K.pointerId!==void 0)try{this.releasePointerCapture(K.pointerId)}catch{}if(q)K.preventDefault(),K.stopPropagation()},Z=(K)=>{if(this.#q?.suppressClick)K.stopPropagation(),K.preventDefault(),this.#q.suppressClick=!1},j=(K)=>{if(this.#q?.didDrag)this.#q.suppressClick=!0,setTimeout(()=>{if(this.#q)this.#q.suppressClick=!1},0)};this.#q={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)}#D(){if(!this.#q?.bound)return;this.removeEventListener("pointerdown",this.#q.onPointerDown),window.removeEventListener("pointermove",this.#q.onPointerMove),window.removeEventListener("pointerup",this.#q.onPointerUp),this.removeEventListener("pointerup",this.#q.onPointerUpCapture,!0),this.removeEventListener("click",this.#q.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#q=null}#H(){if(this.#N==="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;this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),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.#_.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#S(-1)}),this.#X.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#S(1)}),this.prepend(this.#_),this.append(this.#X)}#S(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#V(Q){if(!Q)return;requestAnimationFrame(()=>{let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let Z={behavior:"smooth"};if($){let j=Q.offsetTop-this.clientHeight/2+Q.offsetHeight/2;Z.top=j}if(J){let j=Q.offsetLeft-this.clientWidth/2+Q.offsetWidth/2;Z.left=j}this.scrollTo(Z)})}#k(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{let Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#Y();else if(!this.#Q&&Q.length)this.#Y()}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",Z1);class j1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","control","hit-area","hit-area-mode"];#Q=!1;#$=!1;#J=null;#K=!1;#Z=null;#j=null;get#_(){return this.getAttribute("control")||null}get#X(){return this.#_==="add"||this.#_==="remove"}get#q(){return this.classList.contains("fig-input-gradient-ghost")}get#N(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#U(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#W(){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"}#Y(Q){let $=this.#W;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}#G(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 $=Q.getBoundingClientRect(),J=this.offsetWidth/2,Z=this.offsetHeight/2,j=parseFloat(this.style.left)||0,K=parseFloat(this.style.top)||0,q=$.width>0?(j+J)/$.width*100:0,_=$.height>0?(K+Z)/$.height*100:0;return`${Math.round(q)}% ${Math.round(_)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#B(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(q)=>{if(!q)return 0;let _=q.includes("px"),X=q.includes("%"),Y=parseFloat(q.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]),K=Z(J[1]??J[0]);return{xToken:j,yToken:K}}#A(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#B(Q),j=$.getBoundingClientRect(),K=this.offsetWidth/2,q=this.offsetHeight/2,_=(Y,W,N)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(-N,Math.min(W-N,Y.px-N));let D=(typeof Y==="number"?Y:0)/100*W;return Math.max(-N,Math.min(W-N,D-N))},X=this.#U;if(X.x)this.style.left=`${Math.round(_(J,j.width,K))}px`;if(X.y)this.style.top=`${Math.round(_(Z,j.height,q))}px`}#O(){this.#K=!0,this.setAttribute("value",this.value),this.#K=!1}get#R(){return this.getAttribute("hit-area-mode")||"handle"}#z(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,K=[];for(let q of $){if(q==="circle"){j=!0;continue}let _=parseFloat(q);if(Number.isFinite(_))K.push(_)}if(K.length>=2)J=K[0],Z=K[1];else if(K.length===1)J=K[0],Z=K[0];else return null;return{vPad:J,hPad:Z,circle:j}}#D(){let Q=this.#z();if(!Q){if(this.#j)this.#j.remove(),this.#j=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#j){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#H(J)),this.prepend($),this.#j=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#j.style.borderRadius="50%";else this.#j.style.borderRadius="inherit"}#H(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#j)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#T(Q)}connectedCallback(){this.#V(),this.#D(),this.addEventListener("click",this.#F),document.addEventListener("pointerdown",this.#P),document.addEventListener("keydown",this.#S);let Q=this.getAttribute("value");if(Q)this.#A(Q);if(this.#X)this.#C()}disconnectedCallback(){if(this.#k(),this.#w(),this.#j)this.#j.remove(),this.#j=null;this.removeEventListener("click",this.#F),document.removeEventListener("pointerdown",this.#P),document.removeEventListener("keydown",this.#S)}select(){if(this.hasAttribute("disabled"))return;if(this.setAttribute("selected",""),this.getAttribute("type")==="color"&&!this.#Q)this.#C()}deselect(){this.removeAttribute("selected"),this.#w()}#F=(Q)=>{if(this.#X)return;if(this.#$){this.#$=!1;return}this.select()};#P=(Q)=>{if(this.#X)return;if(this.contains(Q.target))return;if(this.#Z&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#S=(Q)=>{if(Q.key!=="Enter")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(this.#Z)return;Q.preventDefault(),this.#C()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&J)this.#Z.setAttribute("value",J)}if(Q==="drag")this.#V();if(Q==="hit-area")this.#D();if(Q==="value"&&!this.#K&&!this.#Q)this.#A(J);if(Q==="control")if(this.#X)this.#w(),this.#C();else this.#w()}#V(){if(this.#N&&!this.#J)this.#J=(Q)=>this.#T(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#N&&this.#J)this.#k()}#k(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Q=!1}#T(Q){if(!this.#N||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#Q=!0;let J=this.#U,Z=this.offsetWidth,j=this.offsetHeight,K=null,q=this.getBoundingClientRect(),_=q.left+q.width/2,X=q.top+q.height/2,Y=Q.clientX-_,W=Q.clientY-X,N=Q.clientX,G=Q.clientY,D=3,R=(M,O,A=!1)=>{let F=$.getBoundingClientRect();K=F;let T=parseFloat(this.style.left)||0,S=parseFloat(this.style.top)||0,y=M-Y-F.left-Z/2,I=O-W-F.top-j/2,c=Math.max(-Z/2,Math.min(F.width-Z/2,y)),o=Math.max(-j/2,Math.min(F.height-j/2,I)),h=F.width>0?((J.x?c:T)+Z/2)/F.width:0.5,g=F.height>0?((J.y?o:S)+j/2)/F.height:0.5;if(this.#Y(A)){if(J.x)h=this.#L(h);if(J.y)g=this.#L(g);if(J.x&&J.y){let v=this.#G(h,g);h=v.x,g=v.y}}if(J.x){let v=h*F.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(F.width-Z/2,v)))}px`}if(J.y){let v=g*F.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(F.height-j/2,v)))}px`}},L=(M)=>{if(!this.#Q)return;if(!this.#$){let O=M.clientX-N,A=M.clientY-G;if(O*O+A*A<D*D)return;if(this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#$=!0,R(M.clientX,M.clientY,M.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#v(K),shiftKey:M.shiftKey}}))},B=(M)=>{if(this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",B),this.#$){R(M.clientX,M.clientY,M.shiftKey),this.#O(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#v(K)}));let O=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",O,{capture:!0,once:!0})}else this.#O();this.#$=!1};window.addEventListener("pointermove",L),window.addEventListener("pointerup",B)}showColorTip(){if(this.#Z){this.#Z.style.display="";return}this.#C()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#C(){if(this.#Z)return;let Q=document.createElement("fig-color-tip");if(this.#X)Q.setAttribute("control",this.#_);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true"),Q.setAttribute("selected","");Q.addEventListener("input",this.#I),Q.addEventListener("change",this.#y),Q.addEventListener("add",this.#x),Q.addEventListener("remove",this.#x),this.appendChild(Q),this.#Z=Q}#w(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#I),this.#Z.removeEventListener("change",this.#y),this.#Z.removeEventListener("add",this.#x),this.#Z.removeEventListener("remove",this.#x),this.#Z.remove(),this.#Z=null}#E(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=i(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#I=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#E(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#y=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#E(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#x=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#v(Q){let $=this.offsetWidth/2,J=this.offsetHeight/2,Z=parseFloat(this.style.left)||0,j=parseFloat(this.style.top)||0,K=Q.width>0?(Z+$)/Q.width:0,q=Q.height>0?(j+J)/Q.height:0;return{x:Z,y:j,px:K,py:q}}}customElements.define("fig-handle",j1);class K1 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",K1);class q1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",q1);class _1 extends HTMLElement{#Q=null;#$=null;#J=null;#K;#Z;#j;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#K=this.#B.bind(this),this.#Z=this.#A.bind(this),this.#j=this.#O.bind(this),this.#_=this.#R.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.#q(),this.#N(),this.#U(),this.#W(),this.#L(),this.#M(),this.open)this.#D()}disconnectedCallback(){if(this.#Y(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Q)this.#Q.removeEventListener("close",this.#_),this.#Q.remove(),this.#Q=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#H();else this.#D();return}if(Q==="disabled"){if(this.#$)if(J!==null&&J!=="false")this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q)}#q(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#N(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#Q.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#Q.setAttribute("closedby",J);if(this.#$)this.#Q.anchor=this.#$;this.#Q.addEventListener("close",this.#_),this.appendChild(this.#Q)}#U(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#Q.appendChild($)}#W(){if(this.#$)this.#$.addEventListener("click",this.#K),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false");if(this.#Q)this.#Q.addEventListener("click",this.#Z),this.#Q.addEventListener("keydown",this.#j)}#Y(){if(this.#$)this.#$.removeEventListener("click",this.#K);if(this.#Q)this.#Q.removeEventListener("click",this.#Z),this.#Q.removeEventListener("keydown",this.#j)}#L(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#Q)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#Q.appendChild(J);else if(!this.#$&&J.parentElement===this){if(this.#q(),this.#$)this.#$.addEventListener("click",this.#K),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#Q.anchor=this.#$,this.#M()}}}),this.#J.observe(this,{childList:!0})}#G(){if(!this.#Q)return[];return Array.from(this.#Q.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#M(){if(!this.#$)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#B(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.stopPropagation(),this.open)this.open=!1;else this.open=!0}#A(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#z($)}#O(Q){let $=this.#G();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#X=Math.min(this.#X+1,$.length-1),$[this.#X]?.focus();break}case"ArrowUp":{Q.preventDefault(),this.#X=Math.max(this.#X-1,0),$[this.#X]?.focus();break}case"Home":{Q.preventDefault(),this.#X=0,$[0]?.focus();break}case"End":{Q.preventDefault(),this.#X=$.length-1,$[this.#X]?.focus();break}case"Enter":case" ":{Q.preventDefault();let J=$[this.#X];if(J)this.#z(J);break}}}#R(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#X=-1}#z(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}#D(){if(!this.#Q)return;if(this.#Q.open=!0,this.#$)this.#$.setAttribute("aria-expanded","true");this.#X=0,requestAnimationFrame(()=>{let Q=this.#G();if(Q.length)Q[0].focus()})}#H(){if(!this.#Q)return;this.#Q.open=!1}}customElements.define("fig-menu",_1);
449
+ </fig-fill-picker>`,this.#Q=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-chit"),this.#_(),this.#Q?.addEventListener("input",this.#K),this.#Q?.addEventListener("change",this.#Z),this.#X()}#N=()=>{let Q=this.#j;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#U(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();if($.startsWith("#")&&$.length===9)return parseInt($.slice(7,9),16)/255;let J=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#L(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#L(J.color)}catch{}if($.startsWith("#"))return this.#U($);try{let{ctx:J}=M0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#U(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let K=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${K(j[1])}${K(j[2])}${K(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#G(){let Q=this.getAttribute("value"),$=this.#L(Q),J=this.#Y(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#Q){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#Q.setAttribute("value",JSON.stringify(Z)),this.#q)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#$)if(this.#$.setAttribute("background",$),this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#M(Q,$){let J=this.#L(Q?.color),Z=this.#L(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#G();let j={color:this.value};if(this.#q){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}))}#O(Q){Q.stopPropagation(),this.#M(Q.detail,"input")}#B(Q){Q.stopPropagation(),this.#M(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":this.#G();break}}get value(){return this.#L(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#L(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",$1);class J1 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",J1);class Z1 extends HTMLElement{#Q=null;#$=this.#M.bind(this);#J=this.#O.bind(this);#K=this.#A.bind(this);#Z=null;#j=null;#_=null;#X=null;#q=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop","padding"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#N(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#U(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#U))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,K=Z.hasAttribute("selected");if(j&&!K)Z.setAttribute("selected","");else if(!j&&K)Z.removeAttribute("selected")}this.#Q=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#V(Q)}get value(){return this.#Q?.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.#$),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#K),this.#H(),this.#z(),this.#k(),this.#R(),requestAnimationFrame(()=>{this.#Y(),this.#A()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#K),this.#F(),this.#Z?.disconnect(),this.#Z=null,this.#j?.disconnect(),this.#j=null,this.#D()}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 K of j)if(Z)K.setAttribute("aria-disabled","true"),K.setAttribute("tabindex","-1");else K.removeAttribute("aria-disabled"),K.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#Y());if(Q==="drag")if(this.#N)this.#z();else this.#F();if(Q==="overflow")this.#H()}#Y(){let Q=this.choices;if(!Q.length){this.#Q=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}#G(Q){let $=this.#U,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.#G(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#B()}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((K)=>!K.hasAttribute("disabled")||K.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#Q),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.#U)){let K=this.#G(document.activeElement);if(K&&K!==this.#Q)this.selectedChoice=K,this.#B()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#B()}#B(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#A(){if(this.#W==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollLeft<=$,Z=this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}else{let J=this.scrollTop<=$,Z=this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}}#R(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#A()}),this.#j.observe(this)}#z(){if(this.#q?.bound)return;if(!this.#N)return;let Q=(K)=>{if(K.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#q.active=!0,this.#q.didDrag=!1,this.#q.startX=K.clientX,this.#q.startY=K.clientY,this.#q.scrollLeft=this.scrollLeft,this.#q.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(K)=>{if(!this.#q.active)return;let q=this.getAttribute("layout")==="horizontal",_=K.clientX-this.#q.startX,X=K.clientY-this.#q.startY;if(!this.#q.didDrag&&Math.abs(q?_:X)>3)this.#q.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(K.pointerId);if(!this.#q.didDrag)return;if(q)this.scrollLeft=this.#q.scrollLeft-_;else this.scrollTop=this.#q.scrollTop-X},J=(K)=>{if(!this.#q.active)return;let q=this.#q.didDrag;if(this.#q.active=!1,this.#q.didDrag=!1,this.style.cursor="",this.style.userSelect="",K.pointerId!==void 0)try{this.releasePointerCapture(K.pointerId)}catch{}if(q)K.preventDefault(),K.stopPropagation()},Z=(K)=>{if(this.#q?.suppressClick)K.stopPropagation(),K.preventDefault(),this.#q.suppressClick=!1},j=(K)=>{if(this.#q?.didDrag)this.#q.suppressClick=!0,setTimeout(()=>{if(this.#q)this.#q.suppressClick=!1},0)};this.#q={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)}#F(){if(!this.#q?.bound)return;this.removeEventListener("pointerdown",this.#q.onPointerDown),window.removeEventListener("pointermove",this.#q.onPointerMove),window.removeEventListener("pointerup",this.#q.onPointerUp),this.removeEventListener("pointerup",this.#q.onPointerUpCapture,!0),this.removeEventListener("click",this.#q.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#q=null}#H(){if(this.#W==="scrollbar")this.#D();else this.#P()}#D(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#P(){if(this.#_)return;this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),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.#_.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#S(-1)}),this.#X.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#S(1)}),this.prepend(this.#_),this.append(this.#X)}#S(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#V(Q){if(!Q)return;requestAnimationFrame(()=>{let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let Z={behavior:"smooth"};if($){let j=Q.offsetTop-this.clientHeight/2+Q.offsetHeight/2;Z.top=j}if(J){let j=Q.offsetLeft-this.clientWidth/2+Q.offsetWidth/2;Z.left=j}this.scrollTo(Z)})}#k(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{let Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#Y();else if(!this.#Q&&Q.length)this.#Y()}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",Z1);class j1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","control","hit-area","hit-area-mode"];#Q=!1;#$=!1;#J=null;#K=!1;#Z=null;#j=null;get#_(){return this.getAttribute("control")||null}get#X(){return this.#_==="add"||this.#_==="remove"}get#q(){return this.classList.contains("fig-input-gradient-ghost")}get#W(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#N(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){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"}#Y(Q){let $=this.#U;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}#G(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 $=Q.getBoundingClientRect(),J=this.offsetWidth/2,Z=this.offsetHeight/2,j=parseFloat(this.style.left)||0,K=parseFloat(this.style.top)||0,q=$.width>0?(j+J)/$.width*100:0,_=$.height>0?(K+Z)/$.height*100:0;return`${Math.round(q)}% ${Math.round(_)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#O(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(q)=>{if(!q)return 0;let _=q.includes("px"),X=q.includes("%"),Y=parseFloat(q.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]),K=Z(J[1]??J[0]);return{xToken:j,yToken:K}}#B(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#O(Q),j=$.getBoundingClientRect(),K=this.offsetWidth/2,q=this.offsetHeight/2,_=(Y,W,N)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(-N,Math.min(W-N,Y.px-N));let D=(typeof Y==="number"?Y:0)/100*W;return Math.max(-N,Math.min(W-N,D-N))},X=this.#N;if(X.x)this.style.left=`${Math.round(_(J,j.width,K))}px`;if(X.y)this.style.top=`${Math.round(_(Z,j.height,q))}px`}#A(){this.#K=!0,this.setAttribute("value",this.value),this.#K=!1}get#R(){return this.getAttribute("hit-area-mode")||"handle"}#z(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,K=[];for(let q of $){if(q==="circle"){j=!0;continue}let _=parseFloat(q);if(Number.isFinite(_))K.push(_)}if(K.length>=2)J=K[0],Z=K[1];else if(K.length===1)J=K[0],Z=K[0];else return null;return{vPad:J,hPad:Z,circle:j}}#F(){let Q=this.#z();if(!Q){if(this.#j)this.#j.remove(),this.#j=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#j){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#H(J)),this.prepend($),this.#j=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#j.style.borderRadius="50%";else this.#j.style.borderRadius="inherit"}#H(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#j)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#T(Q)}connectedCallback(){this.#V(),this.#F(),this.addEventListener("click",this.#D),document.addEventListener("pointerdown",this.#P),document.addEventListener("keydown",this.#S);let Q=this.getAttribute("value");if(Q)this.#B(Q);if(this.#X)this.#I()}disconnectedCallback(){if(this.#k(),this.#w(),this.#j)this.#j.remove(),this.#j=null;this.removeEventListener("click",this.#D),document.removeEventListener("pointerdown",this.#P),document.removeEventListener("keydown",this.#S)}select(){if(this.hasAttribute("disabled"))return;if(this.setAttribute("selected",""),this.getAttribute("type")==="color"&&!this.#Q)this.#I()}deselect(){this.removeAttribute("selected"),this.#w()}#D=(Q)=>{if(this.#X)return;if(this.#$){this.#$=!1;return}this.select()};#P=(Q)=>{if(this.#X)return;if(this.contains(Q.target))return;if(this.#Z&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#S=(Q)=>{if(Q.key!=="Enter")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(this.#Z)return;Q.preventDefault(),this.#I()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&J)this.#Z.setAttribute("value",J)}if(Q==="drag")this.#V();if(Q==="hit-area")this.#F();if(Q==="value"&&!this.#K&&!this.#Q)this.#B(J);if(Q==="control")if(this.#X)this.#w(),this.#I();else this.#w()}#V(){if(this.#W&&!this.#J)this.#J=(Q)=>this.#T(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#W&&this.#J)this.#k()}#k(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Q=!1}#T(Q){if(!this.#W||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#Q=!0;let J=this.#N,Z=this.offsetWidth,j=this.offsetHeight,K=null,q=this.getBoundingClientRect(),_=q.left+q.width/2,X=q.top+q.height/2,Y=Q.clientX-_,W=Q.clientY-X,N=Q.clientX,G=Q.clientY,D=3,R=(M,B,A=!1)=>{let F=$.getBoundingClientRect();K=F;let T=parseFloat(this.style.left)||0,S=parseFloat(this.style.top)||0,f=M-Y-F.left-Z/2,I=B-W-F.top-j/2,c=Math.max(-Z/2,Math.min(F.width-Z/2,f)),o=Math.max(-j/2,Math.min(F.height-j/2,I)),h=F.width>0?((J.x?c:T)+Z/2)/F.width:0.5,g=F.height>0?((J.y?o:S)+j/2)/F.height:0.5;if(this.#Y(A)){if(J.x)h=this.#L(h);if(J.y)g=this.#L(g);if(J.x&&J.y){let v=this.#G(h,g);h=v.x,g=v.y}}if(J.x){let v=h*F.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(F.width-Z/2,v)))}px`}if(J.y){let v=g*F.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(F.height-j/2,v)))}px`}},L=(M)=>{if(!this.#Q)return;if(!this.#$){let B=M.clientX-N,A=M.clientY-G;if(B*B+A*A<D*D)return;if(this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#$=!0,R(M.clientX,M.clientY,M.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#v(K),shiftKey:M.shiftKey}}))},O=(M)=>{if(this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",O),this.#$){R(M.clientX,M.clientY,M.shiftKey),this.#A(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#v(K)}));let B=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",B,{capture:!0,once:!0})}else this.#A();this.#$=!1};window.addEventListener("pointermove",L),window.addEventListener("pointerup",O)}showColorTip(){if(this.#Z){this.#Z.style.display="";return}this.#I()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#I(){if(this.#Z)return;let Q=document.createElement("fig-color-tip");if(this.#X)Q.setAttribute("control",this.#_);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true"),Q.setAttribute("selected","");Q.addEventListener("input",this.#y),Q.addEventListener("change",this.#C),Q.addEventListener("add",this.#x),Q.addEventListener("remove",this.#x),this.appendChild(Q),this.#Z=Q}#w(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#y),this.#Z.removeEventListener("change",this.#C),this.#Z.removeEventListener("add",this.#x),this.#Z.removeEventListener("remove",this.#x),this.#Z.remove(),this.#Z=null}#E(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=i(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#y=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#E(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#C=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#E(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#x=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#v(Q){let $=this.offsetWidth/2,J=this.offsetHeight/2,Z=parseFloat(this.style.left)||0,j=parseFloat(this.style.top)||0,K=Q.width>0?(Z+$)/Q.width:0,q=Q.height>0?(j+J)/Q.height:0;return{x:Z,y:j,px:K,py:q}}}customElements.define("fig-handle",j1);class K1 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",K1);class q1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",q1);class _1 extends HTMLElement{#Q=null;#$=null;#J=null;#K;#Z;#j;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#K=this.#O.bind(this),this.#Z=this.#B.bind(this),this.#j=this.#A.bind(this),this.#_=this.#R.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.#q(),this.#W(),this.#N(),this.#U(),this.#L(),this.#M(),this.open)this.#F()}disconnectedCallback(){if(this.#Y(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Q)this.#Q.removeEventListener("close",this.#_),this.#Q.remove(),this.#Q=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#H();else this.#F();return}if(Q==="disabled"){if(this.#$)if(J!==null&&J!=="false")this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q)}#q(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#W(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#Q.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#Q.setAttribute("closedby",J);if(this.#$)this.#Q.anchor=this.#$;this.#Q.addEventListener("close",this.#_),this.appendChild(this.#Q)}#N(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#Q.appendChild($)}#U(){if(this.#$)this.#$.addEventListener("click",this.#K),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false");if(this.#Q)this.#Q.addEventListener("click",this.#Z),this.#Q.addEventListener("keydown",this.#j)}#Y(){if(this.#$)this.#$.removeEventListener("click",this.#K);if(this.#Q)this.#Q.removeEventListener("click",this.#Z),this.#Q.removeEventListener("keydown",this.#j)}#L(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#Q)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#Q.appendChild(J);else if(!this.#$&&J.parentElement===this){if(this.#q(),this.#$)this.#$.addEventListener("click",this.#K),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#Q.anchor=this.#$,this.#M()}}}),this.#J.observe(this,{childList:!0})}#G(){if(!this.#Q)return[];return Array.from(this.#Q.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#M(){if(!this.#$)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.stopPropagation(),this.open)this.open=!1;else this.open=!0}#B(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#z($)}#A(Q){let $=this.#G();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#X=Math.min(this.#X+1,$.length-1),$[this.#X]?.focus();break}case"ArrowUp":{Q.preventDefault(),this.#X=Math.max(this.#X-1,0),$[this.#X]?.focus();break}case"Home":{Q.preventDefault(),this.#X=0,$[0]?.focus();break}case"End":{Q.preventDefault(),this.#X=$.length-1,$[this.#X]?.focus();break}case"Enter":case" ":{Q.preventDefault();let J=$[this.#X];if(J)this.#z(J);break}}}#R(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#X=-1}#z(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.#Q)return;if(this.#Q.open=!0,this.#$)this.#$.setAttribute("aria-expanded","true");this.#X=0,requestAnimationFrame(()=>{let Q=this.#G();if(Q.length)Q[0].focus()})}#H(){if(!this.#Q)return;this.#Q.open=!1}}customElements.define("fig-menu",_1);