@rogieking/figui3 4.10.2 → 4.12.0

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
@@ -32,7 +32,7 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
32
32
  <button type="${this.type}">
33
33
  <slot></slot>
34
34
  </button>
35
- `,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",B0);class O0 extends HTMLElement{#$="Menu";#Q=null;#J;#K;#j=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#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.#j=!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.#j=!0,this.#Z=Z}#Y(){if(!this.#Z)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#K)}#U(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#N(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#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.#Y(),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.#N();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#Y(),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.#N();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#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.#Y()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#M(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#K)}}customElements.define("fig-dropdown",O0);class E extends HTMLElement{static#$=0;static#Q=500;#J;#K;#j;#Z;#_;#X;#q;#Y;#W;#U=null;#N;#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.#H.bind(this),this.#K=this.hidePopupOutsideClick.bind(this),this.#j=this.showDelayedPopup.bind(this),this.#Z=this.#M.bind(this),this.#_=this.#B.bind(this),this.#X=this.#A.bind(this),this.#q=this.#O.bind(this),this.#Y=this.#R.bind(this),this.#W=()=>{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.#W)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#U)this.#U.removeEventListener("close",this.#W),this.#U=null;if(this.action==="click")document.body.removeEventListener("click",this.#K);if(clearTimeout(this.#N),this.action==="hover")this.removeEventListener("pointerenter",this.#j),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#q),this.removeEventListener("touchcancel",this.#Y);else if(this.action==="click")this.removeEventListener("click",this.#j),this.removeEventListener("touchstart",this.#j)}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.#j),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#q,{passive:!0}),this.addEventListener("touchcancel",this.#Y,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#j),document.body.addEventListener("click",this.#K),this.addEventListener("touchstart",this.#j,{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()-E.#$<E.#Q?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,E.#$=Date.now()}hidePopup(){if(this.#G)return;if(clearTimeout(this.timeout),clearTimeout(this.#N),this.popup)this.destroy();this.isOpen=!1,E.#$=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.#N),this.showDelayedPopup()}#A(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#N),this.#N=setTimeout(()=>{this.#L=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#N),this.#N=setTimeout(()=>{this.#L=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#L)this.#L=!1,clearTimeout(this.#N),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")}}#H(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#F=new WeakMap;static show(Q,$,J={}){E.hide(Q);let Z=J.delay??500,K=Date.now()-E.#$<E.#Q?0:Z,q={timeout:null,popup:null};E.#F.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 N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,q.popup=X,E.#$=Date.now()},K)}static hide(Q){let $=E.#F.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();E.#F.delete(Q)}}customElements.define("fig-tooltip",E);class A0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#J=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#K(),this.#j()})}disconnectedCallback(){this.#Z()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#K()}#K(){let Q=this.getAttribute("position")||"right",$=this.#$||"";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=$}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;E.show(this,this.#$)},this.#J=()=>{E.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#Z(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);E.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(A1()+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,N=this.getBoundingClientRect(),W=N.width>0&&N.height>0?N:$,G=W.left,D=W.top,R=10,L;if(_==="top"||_==="bottom"){L=X-G;let B=R,M=Math.max(B,W.width-R);L=Math.min(M,Math.max(B,L))}else{L=Y-D;let B=R,M=Math.max(B,W.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)),N=Math.max(0,q-(j-J.bottom));return _+X+Y+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,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,N="top",W=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 H=this.overflowScore(B,Q,q);if(H<W)W=H,Y=O,N=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<W)W=O,Y=B,N=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,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}j0("fig-popup",z0,{extends:"dialog"});class D0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",D0);class H0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#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.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#j(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#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)}#j(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.#j(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z)}}customElements.define("fig-tabs",H0);class F0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",F0);class P0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#K=null;#j=0;#Z=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#G(),requestAnimationFrame(()=>{this.#B({enforceFallback:!0}),this.#M(),this.#N({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#K?.disconnect(),this.#K=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#Z=!1,this.#_=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#N()}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()||""}#Y(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#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"}#N({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let $=this.#Z;this.#Z=!1,this.#L({forceInstant:$})})}#L({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#U(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#Y();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.#N()}),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.#$=null,this.#N({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#W(Z))return}let j=this.#Y();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.#N({forceInstant:!0});return}if(Q==="value"){this.#B({enforceFallback:!1});return}if(Q==="animated"){if(!this.#U())this.#_=!1;this.#N({forceInstant:!0});return}if(Q==="sizing")this.#N({forceInstant:!0})}}customElements.define("fig-segmented-control",P0);class k0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#J=null;#K=[];#j=null;#Z=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#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.#W();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#N("disabled");return}if(Q==="full"){this.#N("full");return}if(Q==="sizing")this.#N("sizing"),this.#W()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#K=JSON.parse(Q);return}catch{}let $=Q.includes(`
35
+ `,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",B0);class O0 extends HTMLElement{#$="Menu";#Q=null;#J;#K;#j=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#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.#j=!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.#j=!0,this.#Z=Z}#Y(){if(!this.#Z)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#K)}#U(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#N(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#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.#Y(),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.#N();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#Y(),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.#N();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#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.#Y()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#M(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#K)}}customElements.define("fig-dropdown",O0);class E extends HTMLElement{static#$=0;static#Q=500;#J;#K;#j;#Z;#_;#X;#q;#Y;#W;#U=null;#N;#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.#H.bind(this),this.#K=this.hidePopupOutsideClick.bind(this),this.#j=this.showDelayedPopup.bind(this),this.#Z=this.#M.bind(this),this.#_=this.#B.bind(this),this.#X=this.#A.bind(this),this.#q=this.#O.bind(this),this.#Y=this.#R.bind(this),this.#W=()=>{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.#W)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#U)this.#U.removeEventListener("close",this.#W),this.#U=null;if(this.action==="click")document.body.removeEventListener("click",this.#K);if(clearTimeout(this.#N),this.action==="hover")this.removeEventListener("pointerenter",this.#j),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#q),this.removeEventListener("touchcancel",this.#Y);else if(this.action==="click")this.removeEventListener("click",this.#j),this.removeEventListener("touchstart",this.#j)}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.#j),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#q,{passive:!0}),this.addEventListener("touchcancel",this.#Y,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#j),document.body.addEventListener("click",this.#K),this.addEventListener("touchstart",this.#j,{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()-E.#$<E.#Q?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,E.#$=Date.now()}hidePopup(){if(this.#G)return;if(clearTimeout(this.timeout),clearTimeout(this.#N),this.popup)this.destroy();this.isOpen=!1,E.#$=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.#N),this.showDelayedPopup()}#A(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#N),this.#N=setTimeout(()=>{this.#L=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#L)clearTimeout(this.#N),this.#N=setTimeout(()=>{this.#L=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#L)this.#L=!1,clearTimeout(this.#N),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")}}#H(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#P=new WeakMap;static show(Q,$,J={}){E.hide(Q);let Z=J.delay??500,K=Date.now()-E.#$<E.#Q?0:Z,q={timeout:null,popup:null};E.#P.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 N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,q.popup=X,E.#$=Date.now()},K)}static hide(Q){let $=E.#P.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();E.#P.delete(Q)}}customElements.define("fig-tooltip",E);class A0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#J=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#K(),this.#j()})}disconnectedCallback(){this.#Z()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#K()}#K(){let Q=this.getAttribute("position")||"right",$=this.#$||"";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=$}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;E.show(this,this.#$)},this.#J=()=>{E.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#Z(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);E.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(A1()+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,N=this.getBoundingClientRect(),W=N.width>0&&N.height>0?N:$,G=W.left,D=W.top,R=10,L;if(_==="top"||_==="bottom"){L=X-G;let B=R,M=Math.max(B,W.width-R);L=Math.min(M,Math.max(B,L))}else{L=Y-D;let B=R,M=Math.max(B,W.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)),N=Math.max(0,q-(j-J.bottom));return _+X+Y+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,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,N="top",W=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 H=this.overflowScore(B,Q,q);if(H<W)W=H,Y=O,N=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<W)W=O,Y=B,N=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,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}j0("fig-popup",z0,{extends:"dialog"});class D0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",D0);class H0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#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.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#j(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#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)}#j(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.#j(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z)}}customElements.define("fig-tabs",H0);class F0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",F0);class P0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#K=null;#j=0;#Z=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#G(),requestAnimationFrame(()=>{this.#B({enforceFallback:!0}),this.#M(),this.#N({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#K?.disconnect(),this.#K=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#Z=!1,this.#_=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#N()}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()||""}#Y(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#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"}#N({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let $=this.#Z;this.#Z=!1,this.#L({forceInstant:$})})}#L({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#U(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#Y();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.#N()}),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.#$=null,this.#N({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#W(Z))return}let j=this.#Y();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.#N({forceInstant:!0});return}if(Q==="value"){this.#B({enforceFallback:!1});return}if(Q==="animated"){if(!this.#U())this.#_=!1;this.#N({forceInstant:!0});return}if(Q==="sizing")this.#N({forceInstant:!0})}}customElements.define("fig-segmented-control",P0);class k0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#J=null;#K=[];#j=null;#Z=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#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.#W();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#N("disabled");return}if(Q==="full"){this.#N("full");return}if(Q==="sizing")this.#N("sizing"),this.#W()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#K=JSON.parse(Q);return}catch{}let $=Q.includes(`
36
36
  `)?`
37
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.#Z)return;let Z=this.#_(J);if(Z===null)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#$="segments"}#Y(){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.#Z)return;let Z=this.#_(J);if(!Z)return;this.#Z=!0,this.setAttribute("value",Z),this.#Z=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#Z)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#$="dropdown"}#W(){if(this.#$==="segments")this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#B())});else this.#Y()}#U(){if(!this.#j||this.#Z)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#N(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.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.#$==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Q=this.clientWidth,this.#Y()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#q(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Y()})})}}customElements.define("fig-options",k0);class E0 extends HTMLElement{#$=!1;#Q=!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;#j;#Z;#_;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#K=(Q)=>{Q.stopPropagation(),this.#A()},this.#j=(Q)=>{Q.stopPropagation(),this.#O()},this.#Z=(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=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
@@ -63,12 +63,12 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
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.#j)}this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#Q),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.#N($),$}#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.#W();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.#N(J),Z=this.#N(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}))}#Y(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#K)}#W(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),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.#N(J)}return J}#N(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.#$)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 n extends HTMLElement{#$;#Q;#J;#K;#j;#Z;#_;#X;#q;#Y;#W;#U;#N;#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.#U??[]).includes($.toLowerCase())?"":$}#R(){this.#Y=this.#O(this.#W)}#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.#H(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null}#H(Q){let $=this.step||1,J=this.#F(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#I(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.#$=this.#w.bind(this),this.#Q=this.#f.bind(this),this.#J=this.#f.bind(this),this.#K=this.#E.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#C(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#S(Q)},this.#_=(Q)=>{this.#k(Q)},this.#X=(Q)=>{this.#x(Q)},this.#q=(Q)=>{this.#T(Q)}}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#U=this.#A($===null?n.#B:$),this.#R(),this.#N=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.#j)}this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#Q),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.#N($),$}#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.#W();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.#N(J),Z=this.#N(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}))}#Y(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#K)}#W(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),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.#N(J)}return J}#N(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.#$)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 n extends HTMLElement{#$;#Q;#J;#K;#j;#Z;#_;#X;#q;#Y;#W;#U;#N;#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.#U??[]).includes($.toLowerCase())?"":$}#R(){this.#Y=this.#O(this.#W)}#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.#H(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null}#H(Q){let $=this.step||1,J=this.#P(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#y(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.#$=this.#w.bind(this),this.#Q=this.#f.bind(this),this.#J=this.#f.bind(this),this.#K=this.#T.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#C(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#E(Q)},this.#_=(Q)=>{this.#S(Q)},this.#X=(Q)=>{this.#I(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.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#U=this.#A($===null?n.#B:$),this.#R(),this.#N=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.#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.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q),this.input.addEventListener("keydown",this.#q)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#Z),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.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#F(Q){if(!Q)return"";if(!this.#Y){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.#Y,"").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.#V($),!this.#Y)return $.toString();if(this.#N==="prefix")return this.#Y+$;else return $+this.#Y}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#V($),$.toString()}#k(Q){this.#G=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#Y)if(this.#N==="prefix")Q.target.setSelectionRange(this.#Y.length,$.length);else{let J=$.indexOf(this.#Y);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#x(Q){this.#G=!1;let $=this.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(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}))}#T(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#F(this.input.value),K=(j!==""?Number(j)/(this.transform||1):0)+Z;K=this.#I(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}))}#S(Q){let $=this.#F(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.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(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.#f();return}let $=(this.step||1)*Q.movementX,J=this.#F(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#I(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.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#f(Q){this.#G=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#I(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.#V(J),J}#V(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.#W=J||"",this.#R(),this.input.value=this.#D(this.value);break;case"units-disallow":this.#U=this.#A(J===null?n.#B:J),this.#R(),this.input.value=this.#D(this.value);break;case"unit-position":this.#N=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.#I(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",n);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{#$=!1;#Q=null;#J=null;constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label)this.#Q=document.createElement("span"),this.#Q.className="fig-mask-icon fig-field-chevron",this.insertBefore(this.#Q,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J);else if(this.input&&this.label)this.label.addEventListener("click",this.focus.bind(this));if(this.input&&this.label&&!this.#$){let Q=this.input.getAttribute("id")||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.#j.bind(this))})}disconnectedCallback(){if(this.label)E.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#K(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;E.show(this.label,this.label.textContent.trim())}#j(){if(this.label)E.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;#$=100;#Q;#J;#K;#j;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))}#Z(){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.#Z(),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.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q),this.input.addEventListener("keydown",this.#q)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#Z),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.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#P(Q){if(!Q)return"";if(!this.#Y){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.#Y,"").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.#V($),!this.#Y)return $.toString();if(this.#N==="prefix")return this.#Y+$;else return $+this.#Y}#F(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#V($),$.toString()}#S(Q){this.#G=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#Y)if(this.#N==="prefix")Q.target.setSelectionRange(this.#Y.length,$.length);else{let J=$.indexOf(this.#Y);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#I(Q){this.#G=!1;let $=this.#P(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#y(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.#P(this.input.value),K=(j!==""?Number(j)/(this.transform||1):0)+Z;K=this.#y(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}))}#E(Q){let $=this.#P(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.#P(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#y(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.#f();return}let $=(this.step||1)*Q.movementX,J=this.#P(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#y(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}))}#T(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.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#f(Q){this.#G=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#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.#V(J),J}#V(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.#W=J||"",this.#R(),this.input.value=this.#D(this.value);break;case"units-disallow":this.#U=this.#A(J===null?n.#B:J),this.#R(),this.input.value=this.#D(this.value);break;case"unit-position":this.#N=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.#y(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",n);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{#$=!1;#Q=null;#J=null;constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label)this.#Q=document.createElement("span"),this.#Q.className="fig-mask-icon fig-field-chevron",this.insertBefore(this.#Q,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J);else if(this.input&&this.label)this.label.addEventListener("click",this.focus.bind(this));if(this.input&&this.label&&!this.#$){let Q=this.input.getAttribute("id")||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.#j.bind(this))})}disconnectedCallback(){if(this.label)E.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#K(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;E.show(this.label,this.label.textContent.trim())}#j(){if(this.label)E.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;#$=100;#Q;#J;#K;#j;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))}#Z(){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.#Z(),K=this.#B?" 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}>
@@ -179,12 +179,12 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#Q)_.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#K)this.#K.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#j.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),W=(isNaN(Y)?100:Y)/100;switch(this.#$){case"solid":this.#j.alpha=W;break;case"gradient":break;case"image":this.#_.opacity=W;break;case"video":this.#X.opacity=W;break;case"webcam":this.#q.opacity=W;break}this.#B(),this.#A(W),this.#O()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#B(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#A(Q){if(this.#Q){let $=this.#Q.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.#$){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:d(this.#Z)};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.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#N();else this.#B(),this.#G();break;case"disabled":this.#U();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",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#j(){return!this.hasAttribute("add")||this.getAttribute("add")!=="false"}get#Z(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#_(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#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.#Q=[],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.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#q(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline";let J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,K)=>{J.appendChild(this.#Y(j,K,Q,{inline:!0}))}),$.appendChild(J),this.appendChild($),this.#j)this.#N(Q,this);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,K)=>{Z.appendChild(this.#Y(j,K,Q)),Z.appendChild(this.#W(K,Q))}),this.appendChild(Z)}#Y(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","false"),K.setAttribute("full","");if(J)K.setAttribute("disabled","");let q=Z?this.#J:this.#Q,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};let N=q[$];if(N){let W=this.#$[$],G=W.alpha<1?W.color+Math.round(W.alpha*255).toString(16).padStart(2,"0"):W.color;N.setAttribute("value",G)}};if(K.addEventListener("input",(X)=>{_(X),this.#A()}),K.addEventListener("change",(X)=>{_(X),this.#O()}),Z)this.#Q.push(K);else this.#J.push(K);return K}#W(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#Z)J.setAttribute("disabled","");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.#$.length)return;if(this.#$.length<=this.#Z)return;this.#$.splice(Q,1),this.#Q=[],this.#J=[],this.#q(),this.#O()}#N(Q,$=this){let J=this.#$.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.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.#$.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.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#Y(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let K=this.#Y(Q,J,$),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(K),q.appendChild(this.#W(J,$));if(this.#$.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#O()}#G(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#M(){if(this.#Q.length!==this.#$.length){this.#q();return}this.#$.forEach((Q,$)=>{this.#G($)})}#B(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q)$.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;#j=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit"]}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.#Y(),this.#M(),this.#X)document.addEventListener("keydown",this.#q)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#q),this.#j)this.#j.disconnect(),this.#j=null;clearTimeout(this.#K),this.removeEventListener("pointerenter",this.#H),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#F),this.removeEventListener("click",this.#x),this.removeEventListener("dblclick",this.#k)}#q=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let K=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;Q.preventDefault();let q=[...this.#Q.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.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;let q=parseInt(K.dataset.stopIndex,10);if(isNaN(q)||!this.#Z.stops[q])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#Z.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.#I(),this.#V();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#S(),this.#E(),this.#I(),this.#V()};#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=V({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90;return}if($?.gradient)this.#Z=V({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90}catch($){}}#W(){let $=[...this.#Z.stops].sort((Z,j)=>Z.position-j.position).map((Z)=>{let j=(Z.opacity??100)/100;if(j>=1)return`${Z.color} ${Z.position}%`;let{r:K,g:q,b:_}=i(Z.color);return`rgba(${K}, ${q}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=I0(this.#Z);return`linear-gradient(${this.#Z.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}, ${$})`}#N(){let Q=this.hasAttribute("disabled");return this.#Z.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=`
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.#Q)_.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#K)this.#K.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#j.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),W=(isNaN(Y)?100:Y)/100;switch(this.#$){case"solid":this.#j.alpha=W;break;case"gradient":break;case"image":this.#_.opacity=W;break;case"video":this.#X.opacity=W;break;case"webcam":this.#q.opacity=W;break}this.#B(),this.#A(W),this.#O()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#B(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#A(Q){if(this.#Q){let $=this.#Q.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.#$){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:d(this.#Z)};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.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#N();else this.#B(),this.#G();break;case"disabled":this.#U();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",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#j(){return!this.hasAttribute("add")||this.getAttribute("add")!=="false"}get#Z(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#_(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#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.#Q=[],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.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#q(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline";let J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,K)=>{J.appendChild(this.#Y(j,K,Q,{inline:!0}))}),$.appendChild(J),this.appendChild($),this.#j)this.#N(Q,this);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,K)=>{Z.appendChild(this.#Y(j,K,Q)),Z.appendChild(this.#W(K,Q))}),this.appendChild(Z)}#Y(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","false"),K.setAttribute("full","");if(J)K.setAttribute("disabled","");let q=Z?this.#J:this.#Q,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};let N=q[$];if(N){let W=this.#$[$],G=W.alpha<1?W.color+Math.round(W.alpha*255).toString(16).padStart(2,"0"):W.color;N.setAttribute("value",G)}};if(K.addEventListener("input",(X)=>{_(X),this.#A()}),K.addEventListener("change",(X)=>{_(X),this.#O()}),Z)this.#Q.push(K);else this.#J.push(K);return K}#W(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#Z)J.setAttribute("disabled","");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.#$.length)return;if(this.#$.length<=this.#Z)return;this.#$.splice(Q,1),this.#Q=[],this.#J=[],this.#q(),this.#O()}#N(Q,$=this){let J=this.#$.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.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.#$.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.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#Y(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let K=this.#Y(Q,J,$),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(K),q.appendChild(this.#W(J,$));if(this.#$.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#O()}#G(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#M(){if(this.#Q.length!==this.#$.length){this.#q();return}this.#$.forEach((Q,$)=>{this.#G($)})}#B(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q)$.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;#j=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit"]}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.#Y(),this.#M(),this.#X)document.addEventListener("keydown",this.#q)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#q),this.#j)this.#j.disconnect(),this.#j=null;clearTimeout(this.#K),this.removeEventListener("pointerenter",this.#H),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#P),this.removeEventListener("click",this.#I),this.removeEventListener("dblclick",this.#S)}#q=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let K=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;Q.preventDefault();let q=[...this.#Q.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.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!K)return;let q=parseInt(K.dataset.stopIndex,10);if(isNaN(q)||!this.#Z.stops[q])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#Z.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.#T(),this.#y(),this.#V();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#E(),this.#T(),this.#y(),this.#V()};#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=V({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90;return}if($?.gradient)this.#Z=V({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90}catch($){}}#W(){let $=[...this.#Z.stops].sort((Z,j)=>Z.position-j.position).map((Z)=>{let j=(Z.opacity??100)/100;if(j>=1)return`${Z.color} ${Z.position}%`;let{r:K,g:q,b:_}=i(Z.color);return`rgba(${K}, ${q}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=I0(this.#Z);return`linear-gradient(${this.#Z.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}, ${$})`}#N(){let Q=this.hasAttribute("disabled");return this.#Z.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
184
  <fig-chit background="${this.#W()}"${Q?" disabled":""}></fig-chit>
185
185
  </fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#B();return}if(this.innerHTML=`
186
186
  <fig-chit background="${this.#W()}"${Q?" disabled":""}></fig-chit>
187
- ${$==="true"?`<div class="fig-input-gradient-track">${this.#N()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true")this.#O(),this.#f(),requestAnimationFrame(()=>this.#T())}#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.#Z=V({...this.#Z,...Z.gradient}),this.#E()};Q.addEventListener("input",(J)=>{$(J),this.#I()}),Q.addEventListener("change",(J)=>{$(J),this.#V()})}#A(Q){return F1(this.#Z.stops,Q,this.#Z.interpolationSpace,this.#Z.hueInterpolation)}#O(){if(!this.#Q||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.#Q.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#H),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#F),this.addEventListener("click",this.#x),this.addEventListener("dblclick",this.#k)}#R(){if(!this.#L)return;this.#L.style.opacity="1"}#z(){if(!this.#L)return;this.#L.style.opacity="0"}#H=()=>{if(this.#J)return;this.#R()};#F=()=>{this.#z()};#D=(Q)=>{if(this.#J){this.#z();return}if(!this.#L||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#z();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#A(J);this.#L.setAttribute("color",Z),this.#R()};#P(){let Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#S(),this.#E(),this.#I(),this.#V()}#k=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#x=(Q)=>{if(!this.#Q)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.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===_)X.select();else X.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((q,_)=>q.position-_.position);let K=this.#Z.stops.findIndex((q)=>q.position===Z&&q.color===j);this.#S(),this.#E(),this.#I(),this.#V(),requestAnimationFrame(()=>{let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)_.click()})};#T(){if(!this.#Q)return;let Q=this.#Z.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}#S(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){let J=this.#L;if(this.#Q.innerHTML=this.#N(),J)this.#Q.appendChild(J);this.#C(),requestAnimationFrame(()=>this.#T());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)}%`)}}#C(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),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.#$)return;this.#$.setAttribute("background",this.#W())}#f(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);let K=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#G=!0,this.#S(),this.#E(),this.#I(),this.#z();let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==_)X.deselect()}),_.select(),_.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#Z.stops[X])),this.#E(),this.#I()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),K=j,q=this.#Q.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.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-K)<=X){K=this.#Z.stops[Y].position;break}}}if(this.#Z.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.#I()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#Z.stops[X])),this.#E(),this.#V()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;let j=Q.detail?.px??0,K=Math.round(j*100),q=this.#Q.getBoundingClientRect().width,_=q>0?5/q*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-K)<=_){K=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=K,$.style.left=`${K/100*q-$.offsetWidth/2}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#E(),this.#V(),requestAnimationFrame(()=>{this.#J=!1})}),this.#j=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#E(),this.#I()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:d(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#E(),this.#S();break;case"disabled":this.#b();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#q);else document.removeEventListener("keydown",this.#q);break}}#b(){let Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class Q0 extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",u()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",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 b0 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",b0,{extends:"dialog"});class v0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#$=!1;#Q=null;#J=null;#K=null;#j=null;#Z=!1;#_=this.#N.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.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#j!==null,this.#j)this.#j.remove();if(this.#Y(),this.#W(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#U()}#Y(){let Q=this.#A(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",K=this.#$?"":`<fig-dropdown type="dropdown"${j}>${Q.map((q)=>`<option>${q.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
187
+ ${$==="true"?`<div class="fig-input-gradient-track">${this.#N()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true")this.#O(),this.#f(),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.#Z=V({...this.#Z,...Z.gradient}),this.#T()};Q.addEventListener("input",(J)=>{$(J),this.#y()}),Q.addEventListener("change",(J)=>{$(J),this.#V()})}#A(Q){return F1(this.#Z.stops,Q,this.#Z.interpolationSpace,this.#Z.hueInterpolation)}#O(){if(!this.#Q||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.#Q.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#H),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#P),this.addEventListener("click",this.#I),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"}#H=()=>{if(this.#J)return;this.#R()};#P=()=>{this.#z()};#D=(Q)=>{if(this.#J){this.#z();return}if(!this.#L||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#z();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#A(J);this.#L.setAttribute("color",Z),this.#R()};#F(){let Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#E(),this.#T(),this.#y(),this.#V()}#S=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#F(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#I=(Q)=>{if(!this.#Q)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.#F(),!isNaN(_))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===_)X.select();else X.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((q,_)=>q.position-_.position);let K=this.#Z.stops.findIndex((q)=>q.position===Z&&q.color===j);this.#E(),this.#T(),this.#y(),this.#V(),requestAnimationFrame(()=>{let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)_.click()})};#k(){if(!this.#Q)return;let Q=this.#Z.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}#E(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){let J=this.#L;if(this.#Q.innerHTML=this.#N(),J)this.#Q.appendChild(J);this.#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.#U(j));let K=Z.closest("fig-tooltip");if(K)K.setAttribute("text",`${Math.round(j.position)}%`)}}#C(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),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})}#T(){if(!this.#$)return;this.#$.setAttribute("background",this.#W())}#f(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);let K=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#G=!0,this.#E(),this.#T(),this.#y(),this.#z();let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];if(_)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==_)X.deselect()}),_.select(),_.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#Z.stops[X])),this.#T(),this.#y()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),K=j,q=this.#Q.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.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-K)<=X){K=this.#Z.stops[Y].position;break}}}if(this.#Z.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.#T(),this.#y()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#U(this.#Z.stops[X])),this.#T(),this.#V()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;let j=Q.detail?.px??0,K=Math.round(j*100),q=this.#Q.getBoundingClientRect().width,_=q>0?5/q*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-K)<=_){K=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=K,$.style.left=`${K/100*q-$.offsetWidth/2}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#T(),this.#V(),requestAnimationFrame(()=>{this.#J=!1})}),this.#j=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#T(),this.#y()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#y(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:d(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#T(),this.#E();break;case"disabled":this.#b();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#q);else document.removeEventListener("keydown",this.#q);break}}#b(){let Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class Q0 extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",u()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",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 b0 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",b0,{extends:"dialog"});class v0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#$=!1;#Q=null;#J=null;#K=null;#j=null;#Z=!1;#_=this.#N.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.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#j!==null,this.#j)this.#j.remove();if(this.#Y(),this.#W(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#U()}#Y(){let Q=this.#A(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",K=this.#$?"":`<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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
192
192
  </svg>
193
193
  ${K}
194
194
  </fig-button>
195
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#K=this.querySelector("fig-button"),this.#$&&this.#j&&this.#K){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(Z)this.#j.setAttribute("experimental",Z);this.#K.append(this.#j)}this.#J=this.querySelector("fig-dropdown")}#W(){this.#J?.addEventListener("input",this.#_),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#q)}#U(){this.#J?.removeEventListener("input",this.#_),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#q)}#N(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#Q)this.#Q.setAttribute("value",$);this.#M(),this.#B()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#M()}#G(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!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.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#K)if(Q)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#$){let Z=this.#A();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");break;case"value":if(!this.#Z&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#O(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#$)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",v0);class K0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=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")}#j(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=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.#j(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let K=this.#Z(J);if(this.innerHTML=`<div></div><input type="color" value="${K}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="<div></div>",this.input=null}else if(this.#$==="color"&&this.input){let K=this.#Z(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{#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=this.#S.bind(this);#_=this.#w.bind(this);#X=this.#E.bind(this);#q=this.#f.bind(this);#Y=null;#W=null;#U=null;#N=null;#L=null;#G=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#j}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#$)return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#O(),this.#z(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#x()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Z),this.#B(),this.#k(),this.#K)URL.revokeObjectURL(this.#K),this.#K=null}#B(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#_),this.#Q.removeEventListener("pause",this.#X),this.#Q.removeEventListener("ended",this.#q)}#A(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#O(){let Q=this.#A();if(Q){if(this.#Q&&this.#Q!==Q){if(this.#B(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}this.#Q=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#B(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.prepend(J),this.#Q=J,this.#Q.addEventListener("play",this.#_),this.#Q.addEventListener("pause",this.#X),this.#Q.addEventListener("ended",this.#q);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.prepend(J),this.#Q=J}}#R(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#z(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#$||"";if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#Q.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#R("autoplay",!1),this.#Q.loop=this.#R("loop",!1),this.#Q.muted=this.#R("muted",!1),this.#Q.playsInline=!0,this.#H()}get mediaEl(){return this.#Q}#H(){if(this.mediaKind!=="video"){this.#k();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#Y!==Q)this.#k(),this.#Y=Q;this.#D();return}if(this.#R("controls",!1))this.#F();else this.#k()}#F(){if(this.#Y&&this.#Y.isConnected){this.#D();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),Q.setAttribute("overlay",""),this.append(Q),this.#Y=Q,this.#D()}#D(){if(!this.#Y||!this.#Q)return;if(this.#W===this.#Q&&this.#U===this.#Y)return;this.#P();let Q=this.#Y,$=this.#Q;this.#W=$,this.#U=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let _=$.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})},K=()=>$.pause?.(),q=(_)=>{let X=Number(_?.detail?.time);if(!Number.isFinite(X))return;J=X;try{$.currentTime=X}catch{}};this.#N=Z,this.#L=j,this.#G=K,this.#M=q,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",K),Q.addEventListener("seek",q),Z()}#P(){let Q=this.#W,$=this.#U;if(Q&&this.#N)Q.removeEventListener("play",this.#N),Q.removeEventListener("pause",this.#N),Q.removeEventListener("ended",this.#N),Q.removeEventListener("timeupdate",this.#N),Q.removeEventListener("loadedmetadata",this.#N),Q.removeEventListener("durationchange",this.#N),Q.removeEventListener("seeked",this.#N);if($){if(this.#L)$.removeEventListener("play",this.#L);if(this.#G)$.removeEventListener("pause",this.#G);if(this.#M)$.removeEventListener("seek",this.#M)}this.#W=null,this.#U=null,this.#N=null,this.#L=null,this.#G=null,this.#M=null}#k(){if(this.#P(),!this.#Y)return;if(this.#Y.hasAttribute("data-generated"))this.#Y.remove();this.#Y=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#x(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#Z),this.append(Q),this.#J=Q}#T(){if(this.#J)this.#J.removeEventListener("change",this.#Z),this.#J.remove(),this.#J=null}#S(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0];if(!$){if(this.#K)URL.revokeObjectURL(this.#K),this.#K=null;this.#j=null,this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#K)URL.revokeObjectURL(this.#K);if(this.#j=$,this.#K=URL.createObjectURL($),this.setAttribute("src",this.#K),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#K}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeEventListener("change",this.#Z),this.#J.clear(),this.#J.addEventListener("change",this.#Z),this.#J.setAttribute("label","Replace")}#C(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#C("play")}#E(){this.#C("pause")}#f(){this.#C("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){if(this.#$=J||"",this.#K&&this.#$!==this.#K)URL.revokeObjectURL(this.#K),this.#K=null,this.#j=null;if(this.#z(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}}if(Q==="type"){if(this.#O(),this.#z(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#Q&&this.#Q.tagName==="IMG")this.#Q.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#x();else if(!Z)this.#T()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#z()}}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{#$=null;#Q=null;#J=null;#K=null;#j=!1;#Z=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#q(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#Z)return;if(Q==="playing")this.#q();if(Q==="duration"||Q==="time")this.#Y()}#_(){if(this.#Z)return;this.#Z=!0;let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=document.createElement("span");J.className="fig-mask-icon fig-media-controls-play-icon",J.style.setProperty("--icon","var(--icon-play)"),J.style.setProperty("--size","1.5rem"),$.append(J),Q.append($),$.addEventListener("click",(q)=>{q.preventDefault(),q.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("variant","neue"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","0.1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full","");let j=document.createElement("label");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let K=(q)=>{let _=q.currentTarget,X=Number(_?.value);if(!Number.isFinite(X))return;this.#j=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#j=!1})};Z.addEventListener("input",K),Z.addEventListener("change",K),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#J=Z,this.#K=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#q(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.style.setProperty("--icon",Q?"var(--icon-pause)":"var(--icon-play)")}#Y(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let $=this.time;if(!this.#j)this.#J.setAttribute("value",String($));if(this.#K)this.#K.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",c0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url"];#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=null;get files(){return this.#Z}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.#Z&&this.#Z.length>0){if(this.#Z.length===1)return this.#Z[0].name;return`${this.#Z.length} files`}return this.#_}connectedCallback(){this.#L(),this.addEventListener("dragover",this.#W),this.addEventListener("dragleave",this.#U),this.addEventListener("drop",this.#N)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#q),this.#J?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#W),this.removeEventListener("dragleave",this.#U),this.removeEventListener("drop",this.#N)}attributeChangedCallback(Q,$,J){if($===J)return;this.#L()}clear(){if(this.#Z=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.#L(),this.#X()}#X(){let Q={files:this.#Z};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#q=()=>{if(this.#$.files.length>0)this.#Z=this.#$.files,this.removeAttribute("url"),this.#L(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#W=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#U=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#N=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.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.#Z=Z.files,this.#$)this.#$.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.#Z&&this.#Z.length>0||!!this.getAttribute("url");if(this.innerHTML="",K){let q=Q?`Accepts ${Q.split(",").map((W)=>W.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",J)this.#j.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.#j.appendChild(_),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#q),this.#j.appendChild(this.#$),q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q),this.#K.appendChild(this.#j),this.appendChild(this.#K);else this.appendChild(this.#j);let N=document.createElement("fig-tooltip");if(N.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.#Y),N.appendChild(this.#J),this.appendChild(N)}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.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=$,J)this.#j.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#q),this.#j.appendChild(this.#$),this.#K)this.#K.appendChild(this.#j),this.appendChild(this.#K);else this.appendChild(this.#j)}}}customElements.define("fig-input-file",u0);class w extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#K="bezier";#j=2;#Z=null;#_=null;#X=null;#q=null;#Y=null;#W=null;#U=null;#N=null;#L=null;#G=null;#M=null;#B=null;#A=0.8;#O=200;#R=200;#z=null;#H=null;#F=null;#D=5;#P=2;#k=10;#x=10;#T=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.#j=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#S(Q);this.#M=this.#C(),this.#f(),this.#q0()}disconnectedCallback(){if(this.#Z=null,this.#F)this.#F.disconnect(),this.#F=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.#S(J),this.#M=this.#C(),Z!==this.#K)this.#f();else this.#h(),this.#a()}if(Q==="precision")this.#j=parseInt(J||"2")}get value(){if(this.#K==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#j;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.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.#j;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#S(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.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3]}#C(){if(this.#K==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of w.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#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 N=_[_.length-1].t||1,W=1;for(let O of _)if(O.value>W)W=O.value;let G=0;for(let O of _)if(O.value<G)G=O.value;let D=Math.max(W-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/N*L,H=R+(1-(_[O].value-G)/D)*L;M+=(O===0?"M":"L")+A.toFixed(1)+","+H.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,H,T,S,f)=>{let I=1-f;return I*I*I*A+3*I*I*f*H+3*I*f*f*T+f*f*f*S};for(let A=0;A<=48;A++){let H=A/48;X.push({x:Y(0,Q,J,1,H),y:Y(0,$,Z,1,H)})}let N=1/0,W=-1/0,G=1/0,D=-1/0;for(let A of X){if(A.x<N)N=A.x;if(A.x>W)W=A.x;if(A.y<G)G=A.y;if(A.y>D)D=A.y}let R=Math.max(W-N,0.000001),L=Math.max(D-G,0.000001),B=(A)=>q+(A-N)/R*12,M=(A)=>q+(1-(A-G)/L)*12,O="";for(let A=0;A<X.length;A++){let H=B(X[A].x),T=M(X[A].y);O+=`${A===0?"M":"L"}${H.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>`}#f(){this.classList.toggle("spring-mode",this.#K==="spring"),this.classList.toggle("bezier-mode",this.#K!=="spring"),this.#l(),this.innerHTML=this.#V(),this.#K0(),this.#p(),this.#d(),this.#h(),this.#_0()}#I(){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.#$.x,this.#$.y,this.#Q.x,this.#Q.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>`}#V(){let $=this.#I();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.#Q=this.querySelector("fig-input-text"),this.#K=this.querySelector("fig-button"),this.#$&&this.#j&&this.#K){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(Z)this.#j.setAttribute("experimental",Z);this.#K.append(this.#j)}this.#J=this.querySelector("fig-dropdown")}#W(){this.#J?.addEventListener("input",this.#_),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#q)}#U(){this.#J?.removeEventListener("input",this.#_),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#q)}#N(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#Q)this.#Q.setAttribute("value",$);this.#M(),this.#B()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#M()}#G(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!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.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#K)if(Q)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#$){let Z=this.#A();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");break;case"value":if(!this.#Z&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#O(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#$)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",v0);class K0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=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")}#j(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=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.#j(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let K=this.#Z(J);if(this.innerHTML=`<div></div><input type="color" value="${K}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="<div></div>",this.input=null}else if(this.#$==="color"&&this.input){let K=this.#Z(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{#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=this.#E.bind(this);#_=this.#w.bind(this);#X=this.#T.bind(this);#q=this.#f.bind(this);#Y=null;#W=null;#U=null;#N=null;#L=null;#G=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#j}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#$)return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#O(),this.#z(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#I()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Z),this.#B(),this.#S(),this.#K)URL.revokeObjectURL(this.#K),this.#K=null}#B(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#_),this.#Q.removeEventListener("pause",this.#X),this.#Q.removeEventListener("ended",this.#q)}#A(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#O(){let Q=this.#A();if(Q){if(this.#Q&&this.#Q!==Q){if(this.#B(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}this.#Q=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#B(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.prepend(J),this.#Q=J,this.#Q.addEventListener("play",this.#_),this.#Q.addEventListener("pause",this.#X),this.#Q.addEventListener("ended",this.#q);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.prepend(J),this.#Q=J}}#R(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#z(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#$||"";if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#Q.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#R("autoplay",!1),this.#Q.loop=this.#R("loop",!1),this.#Q.muted=this.#R("muted",!1),this.#Q.playsInline=!0,this.#H()}get mediaEl(){return this.#Q}#H(){if(this.mediaKind!=="video"){this.#S();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#Y!==Q)this.#S(),this.#Y=Q;this.#D();return}if(this.#R("controls",!1))this.#P();else this.#S()}#P(){if(this.#Y&&this.#Y.isConnected){this.#D();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),Q.setAttribute("overlay",""),this.append(Q),this.#Y=Q,this.#D()}#D(){if(!this.#Y||!this.#Q)return;if(this.#W===this.#Q&&this.#U===this.#Y)return;this.#F();let Q=this.#Y,$=this.#Q;this.#W=$,this.#U=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let _=$.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})},K=()=>$.pause?.(),q=(_)=>{let X=Number(_?.detail?.time);if(!Number.isFinite(X))return;J=X;try{$.currentTime=X}catch{}};this.#N=Z,this.#L=j,this.#G=K,this.#M=q,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",K),Q.addEventListener("seek",q),Z()}#F(){let Q=this.#W,$=this.#U;if(Q&&this.#N)Q.removeEventListener("play",this.#N),Q.removeEventListener("pause",this.#N),Q.removeEventListener("ended",this.#N),Q.removeEventListener("timeupdate",this.#N),Q.removeEventListener("loadedmetadata",this.#N),Q.removeEventListener("durationchange",this.#N),Q.removeEventListener("seeked",this.#N);if($){if(this.#L)$.removeEventListener("play",this.#L);if(this.#G)$.removeEventListener("pause",this.#G);if(this.#M)$.removeEventListener("seek",this.#M)}this.#W=null,this.#U=null,this.#N=null,this.#L=null,this.#G=null,this.#M=null}#S(){if(this.#F(),!this.#Y)return;if(this.#Y.hasAttribute("data-generated"))this.#Y.remove();this.#Y=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#I(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#Z),this.append(Q),this.#J=Q}#k(){if(this.#J)this.#J.removeEventListener("change",this.#Z),this.#J.remove(),this.#J=null}#E(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0];if(!$){if(this.#K)URL.revokeObjectURL(this.#K),this.#K=null;this.#j=null,this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#K)URL.revokeObjectURL(this.#K);if(this.#j=$,this.#K=URL.createObjectURL($),this.setAttribute("src",this.#K),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#K}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeEventListener("change",this.#Z),this.#J.clear(),this.#J.addEventListener("change",this.#Z),this.#J.setAttribute("label","Replace")}#C(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#C("play")}#T(){this.#C("pause")}#f(){this.#C("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){if(this.#$=J||"",this.#K&&this.#$!==this.#K)URL.revokeObjectURL(this.#K),this.#K=null,this.#j=null;if(this.#z(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}}if(Q==="type"){if(this.#O(),this.#z(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#Q&&this.#Q.tagName==="IMG")this.#Q.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#I();else if(!Z)this.#k()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#z()}}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{#$=null;#Q=null;#J=null;#K=null;#j=!1;#Z=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#q(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#Z)return;if(Q==="playing")this.#q();if(Q==="duration"||Q==="time")this.#Y()}#_(){if(this.#Z)return;this.#Z=!0;let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=document.createElement("span");J.className="fig-mask-icon fig-media-controls-play-icon",J.style.setProperty("--icon","var(--icon-play)"),J.style.setProperty("--size","1.5rem"),$.append(J),Q.append($),$.addEventListener("click",(q)=>{q.preventDefault(),q.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("variant","neue"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","0.1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full","");let j=document.createElement("label");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let K=(q)=>{let _=q.currentTarget,X=Number(_?.value);if(!Number.isFinite(X))return;this.#j=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#j=!1})};Z.addEventListener("input",K),Z.addEventListener("change",K),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#J=Z,this.#K=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#q(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.style.setProperty("--icon",Q?"var(--icon-pause)":"var(--icon-play)")}#Y(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let $=this.time;if(!this.#j)this.#J.setAttribute("value",String($));if(this.#K)this.#K.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",c0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url"];#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=null;get files(){return this.#Z}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.#Z&&this.#Z.length>0){if(this.#Z.length===1)return this.#Z[0].name;return`${this.#Z.length} files`}return this.#_}connectedCallback(){this.#L(),this.addEventListener("dragover",this.#W),this.addEventListener("dragleave",this.#U),this.addEventListener("drop",this.#N)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#q),this.#J?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#W),this.removeEventListener("dragleave",this.#U),this.removeEventListener("drop",this.#N)}attributeChangedCallback(Q,$,J){if($===J)return;this.#L()}clear(){if(this.#Z=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.#L(),this.#X()}#X(){let Q={files:this.#Z};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#q=()=>{if(this.#$.files.length>0)this.#Z=this.#$.files,this.removeAttribute("url"),this.#L(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#W=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#U=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#N=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.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.#Z=Z.files,this.#$)this.#$.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.#Z&&this.#Z.length>0||!!this.getAttribute("url");if(this.innerHTML="",K){let q=Q?`Accepts ${Q.split(",").map((W)=>W.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",J)this.#j.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.#j.appendChild(_),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#q),this.#j.appendChild(this.#$),q)this.#K=document.createElement("fig-tooltip"),this.#K.setAttribute("text",q),this.#K.appendChild(this.#j),this.appendChild(this.#K);else this.appendChild(this.#j);let N=document.createElement("fig-tooltip");if(N.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.#Y),N.appendChild(this.#J),this.appendChild(N)}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.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=$,J)this.#j.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#q),this.#j.appendChild(this.#$),this.#K)this.#K.appendChild(this.#j),this.appendChild(this.#K);else this.appendChild(this.#j)}}}customElements.define("fig-input-file",u0);class w extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#K="bezier";#j=2;#Z=null;#_=null;#X=null;#q=null;#Y=null;#W=null;#U=null;#N=null;#L=null;#G=null;#M=null;#B=null;#A=0.8;#O=200;#R=200;#z=null;#H=null;#P=null;#D=5;#F=2;#S=10;#I=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.#j=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#E(Q);this.#M=this.#C(),this.#f(),this.#q0()}disconnectedCallback(){if(this.#Z=null,this.#P)this.#P.disconnect(),this.#P=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.#E(J),this.#M=this.#C(),Z!==this.#K)this.#f();else this.#h(),this.#a()}if(Q==="precision")this.#j=parseInt(J||"2")}get value(){if(this.#K==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#j;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.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.#j;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#E(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.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3]}#C(){if(this.#K==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of w.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#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#T(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 N=_[_.length-1].t||1,W=1;for(let O of _)if(O.value>W)W=O.value;let G=0;for(let O of _)if(O.value<G)G=O.value;let D=Math.max(W-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/N*L,H=R+(1-(_[O].value-G)/D)*L;M+=(O===0?"M":"L")+A.toFixed(1)+","+H.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,H,T,S,f)=>{let I=1-f;return I*I*I*A+3*I*I*f*H+3*I*f*f*T+f*f*f*S};for(let A=0;A<=48;A++){let H=A/48;X.push({x:Y(0,Q,J,1,H),y:Y(0,$,Z,1,H)})}let N=1/0,W=-1/0,G=1/0,D=-1/0;for(let A of X){if(A.x<N)N=A.x;if(A.x>W)W=A.x;if(A.y<G)G=A.y;if(A.y>D)D=A.y}let R=Math.max(W-N,0.000001),L=Math.max(D-G,0.000001),B=(A)=>q+(A-N)/R*12,M=(A)=>q+(1-(A-G)/L)*12,O="";for(let A=0;A<X.length;A++){let H=B(X[A].x),T=M(X[A].y);O+=`${A===0?"M":"L"}${H.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>`}#f(){this.classList.toggle("spring-mode",this.#K==="spring"),this.classList.toggle("bezier-mode",this.#K!=="spring"),this.#l(),this.innerHTML=this.#V(),this.#K0(),this.#p(),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.#T(K)}else{let K=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.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>`}#V(){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">
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"/>
@@ -205,11 +205,11 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
205
205
  <line class="fig-easing-curve-arm" data-arm="1"/>
206
206
  <line class="fig-easing-curve-arm" data-arm="2"/>
207
207
  <path class="fig-easing-curve-path"/>
208
- <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#P}"/>
209
- <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#P}"/>
208
+ <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#F}"/>
209
+ <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#F}"/>
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>`}#b(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.#b("--easing-bezier-endpoint-radius",this.#P),this.#T=this.#b("--easing-duration-bar-radius",this.#T)}#K0(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#q=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#U=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#N=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.#H=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#W?.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.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#k,Z=$.offsetHeight||this.#x;if(this.#K==="spring")this.#k=J,this.#x=Z;this.#U.setAttribute("width",J),this.#U.setAttribute("height",Z)}}#q0(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#d())this.#h()}),this.#F.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}#v(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.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#R),this.#H.setAttribute("x2",this.#O),this.#H.setAttribute("y2","0");let Q=this.#v(0,0),$=this.#v(this.#$.x,this.#$.y),J=this.#v(this.#Q.x,this.#Q.y),Z=this.#v(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.#Y.setAttribute("x1",Z.x),this.#Y.setAttribute("y1",Z.y),this.#Y.setAttribute("x2",J.x),this.#Y.setAttribute("y2",J.y);let j=this.#D;if(this.#W.setAttribute("x",$.x-j),this.#W.setAttribute("y",$.y-j),this.#U.setAttribute("x",J.x-j),this.#U.setAttribute("y",J.y-j),this.#N)this.#N.setAttribute("cx",Q.x),this.#N.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 N=this.#J0(Q),W=N.t/$*q,G=this.#c(W,N.value),D=this.#D;this.#W.setAttribute("x",G.x-D),this.#W.setAttribute("y",G.y-D);let R=this.#c(q,1);this.#U.setAttribute("x",R.x-this.#k/2),this.#U.setAttribute("y",R.y-this.#x/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 $}#a(){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.#$.x,this.#$.y,this.#Q.x,this.#Q.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.#W.addEventListener("pointerdown",($)=>this.#n($,1)),this.#U.addEventListener("pointerdown",($)=>this.#n($,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.#n($,this.#X0($))})}else{this.#W.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.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#K!=="bezier")this.#K="bezier",this.#f();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.#f();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}#n(Q,$){Q.preventDefault(),this.#Z=$;let J=(j)=>{if(!this.#Z)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.#Z===1)this.#$.x=q.x,this.#$.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#h(),this.#M=this.#C(),this.#a(),this.#g("input")},Z=()=>{this.#Z=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.#Z=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#A,K=Q.clientY,q=Q.clientX,_=(Y)=>{if(!this.#Z)return;if($==="bounce"){let N=Y.clientY-K;this.#J.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=Y.clientX-q;this.#A=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#h(),this.#M=this.#C(),this.#a(),this.#g("input")},X=()=>{this.#Z=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{#$=0;#Q=0;#J=0;#K=1;#j=!1;#Z=!1;#_=null;#X=null;#q=null;#Y=null;#W=[];#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.#N(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.#j=!1,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#Y)}#N(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.#W=[];return}let $=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="perspective"){x(this,"--perspective",J);return}if(Q==="perspective-origin"){x(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#N(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.#j)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.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#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.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#A(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#W.map((Z)=>`<fig-input-number
212
+ </svg></div>`}#b(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#l(){this.#F=this.#b("--easing-bezier-endpoint-radius",this.#F),this.#k=this.#b("--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.#Y=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#U=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#N=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.#H=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#W?.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.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#S,Z=$.offsetHeight||this.#I;if(this.#K==="spring")this.#S=J,this.#I=Z;this.#U.setAttribute("width",J),this.#U.setAttribute("height",Z)}}#q0(){if(this.#P||!window.ResizeObserver)return;this.#P=new ResizeObserver(()=>{if(this.#d())this.#h()}),this.#P.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}#v(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.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#R),this.#H.setAttribute("x2",this.#O),this.#H.setAttribute("y2","0");let Q=this.#v(0,0),$=this.#v(this.#$.x,this.#$.y),J=this.#v(this.#Q.x,this.#Q.y),Z=this.#v(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.#Y.setAttribute("x1",Z.x),this.#Y.setAttribute("y1",Z.y),this.#Y.setAttribute("x2",J.x),this.#Y.setAttribute("y2",J.y);let j=this.#D;if(this.#W.setAttribute("x",$.x-j),this.#W.setAttribute("y",$.y-j),this.#U.setAttribute("x",J.x-j),this.#U.setAttribute("y",J.y-j),this.#N)this.#N.setAttribute("cx",Q.x),this.#N.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 N=this.#J0(Q),W=N.t/$*q,G=this.#c(W,N.value),D=this.#D;this.#W.setAttribute("x",G.x-D),this.#W.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.#I/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 $}#a(){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.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=w.#T(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.#W.addEventListener("pointerdown",($)=>this.#n($,1)),this.#U.addEventListener("pointerdown",($)=>this.#n($,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.#n($,this.#X0($))})}else{this.#W.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.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#K!=="bezier")this.#K="bezier",this.#f();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.#f();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}#n(Q,$){Q.preventDefault(),this.#Z=$;let J=(j)=>{if(!this.#Z)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.#Z===1)this.#$.x=q.x,this.#$.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#h(),this.#M=this.#C(),this.#a(),this.#g("input")},Z=()=>{this.#Z=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.#Z=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#A,K=Q.clientY,q=Q.clientX,_=(Y)=>{if(!this.#Z)return;if($==="bounce"){let N=Y.clientY-K;this.#J.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=Y.clientX-q;this.#A=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#h(),this.#M=this.#C(),this.#a(),this.#g("input")},X=()=>{this.#Z=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{#$=0;#Q=0;#J=0;#K=1;#j=!1;#Z=!1;#_=null;#X=null;#q=null;#Y=null;#W=[];#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.#N(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.#j=!1,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#Y)}#N(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.#W=[];return}let $=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="perspective"){x(this,"--perspective",J);return}if(Q==="perspective-origin"){x(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#N(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.#j)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.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#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.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#A(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#W.map((Z)=>`<fig-input-number
213
213
  name="${Z}"
214
214
  step="1"
215
215
  precision="1"
@@ -227,7 +227,7 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#U={};for(let Z of this.#W){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.#$=_;else if(Z==="rotateY")this.#Q=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#z(q.type)};j.addEventListener("input",K),j.addEventListener("change",K)}}this.#R(),this.#F()}#O(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J};for(let $ of this.#W){let J=this.#U[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#K))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#z(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J}}))}#H(Q){if(!this.#Z)return Q;return Math.round(Q/15)*15}#F(){this.#X.addEventListener("pointerdown",(Q)=>this.#P(Q)),this.#q=(Q)=>{if(Q.key==="Shift")this.#Z=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#Z=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#Y)}get#D(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#P(Q){if(!this.#D)return;Q.preventDefault(),this.#j=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,K=(_)=>{if(!this.#j)return;if(_.buttons===0){q();return}let X=_.clientX-$,Y=_.clientY-J;this.#Q=this.#H(j+X*0.5),this.#$=this.#H(Z-Y*0.5),this.#R(),this.#O(),this.setAttribute("value",this.value),this.#z("input")},q=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!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{#$=50;#Q=50;#J=0;#K=null;#j=[];#Z=null;#_=null;#X=null;#q=!1;#Y=!1;#W=null;#U=null;#N=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.#F()}disconnectedCallback(){this.#q=!1,this.#V()}get value(){let Q=this.#J;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#z(),this.#M(),this.#F();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#H(),this.#F();return}if(Q==="value"){if(this.#Y||this.#q)return;this.#R(J),this.#P(),this.#k(),this.#H()}}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.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#O(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#A($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#A($[0],"x"),this.#Q=this.#A($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=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.#W){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.#$=_;else if(Z==="rotateY")this.#Q=_;else if(Z==="rotateZ")this.#J=_;this.#R(),this.#z(q.type)};j.addEventListener("input",K),j.addEventListener("change",K)}}this.#R(),this.#P()}#O(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J};for(let $ of this.#W){let J=this.#U[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#K))}}#R(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#z(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J}}))}#H(Q){if(!this.#Z)return Q;return Math.round(Q/15)*15}#P(){this.#X.addEventListener("pointerdown",(Q)=>this.#F(Q)),this.#q=(Q)=>{if(Q.key==="Shift")this.#Z=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#Z=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#Y)}get#D(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#F(Q){if(!this.#D)return;Q.preventDefault(),this.#j=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,K=(_)=>{if(!this.#j)return;if(_.buttons===0){q();return}let X=_.clientX-$,Y=_.clientY-J;this.#Q=this.#H(j+X*0.5),this.#$=this.#H(Z-Y*0.5),this.#R(),this.#O(),this.setAttribute("value",this.value),this.#z("input")},q=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!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{#$=50;#Q=50;#J=0;#K=null;#j=[];#Z=null;#_=null;#X=null;#q=!1;#Y=!1;#W=null;#U=null;#N=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.#P()}disconnectedCallback(){this.#q=!1,this.#V()}get value(){let Q=this.#J;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#z(),this.#M(),this.#P();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#H(),this.#P();return}if(Q==="value"){if(this.#Y||this.#q)return;this.#R(J),this.#F(),this.#S(),this.#H()}}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.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#O(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#A($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#A($[0],"x"),this.#Q=this.#A($[1],"y")}#R(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=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="${_}">
231
231
  <span class="origin-grid-dot"></span>
232
232
  </span>`}).join(""),$=this.#$.toFixed(this.#J),J=this.#Q.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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
238
238
  <fig-handle></fig-handle>
239
239
  </div>
240
240
  </div>
241
- ${Z}`,this.#K=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#Z=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#P(),this.#k(),this.#H(),this.#l()}#H(){let Q=this.#$.toFixed(this.#J),$=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#F(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#D(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#P(){if(!this.#Z)return;let Q=($)=>16.6667+this.#B($)/100*66.6667;this.#Z.style.left=`${Q(this.#$)}%`,this.#Z.style.top=`${Q(this.#Q)}%`}#k(){if(!this.#Z)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,K=this.#Q>100;this.#Z.classList.toggle("beyond-bounds-x",Q),this.#Z.classList.toggle("beyond-bounds-y",$),this.#Z.classList.toggle("overflow-left",J),this.#Z.classList.toggle("overflow-right",Z),this.#Z.classList.toggle("overflow-up",j),this.#Z.classList.toggle("overflow-down",K)}#x(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.#j.find((_)=>Number(_.getAttribute("data-col"))===K&&Number(_.getAttribute("data-row"))===q)}#T(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#S(Q){if(this.#T(),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.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#P(),this.#k(),this.#H(),this.#F(),this.#D(J)}#w(Q,$){if(!this.#K)return{x:this.#$,y:this.#Q};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}}#f(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}#I(Q,$){if(!$)return Q;return{x:this.#f(Q.x),y:this.#f(Q.y)}}#V(){if(!this.#K||!this.#U||!this.#N)return;this.#K.removeEventListener("pointermove",this.#U),this.#K.removeEventListener("pointerup",this.#N),this.#K.removeEventListener("pointercancel",this.#N),this.#K.removeEventListener("lostpointercapture",this.#N),this.#U=null,this.#N=null}#b(Q){if(!this.#K||!this.#L)return;Q.preventDefault(),this.#q=!0,this.#W=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.#W)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.#T();let Y=this.#I(this.#w(K.clientX,K.clientY),K.shiftKey);this.#C(Y.x,Y.y,"input")},this.#N=(K)=>{if(!this.#q||K.pointerId!==this.#W)return;if(this.#q=!1,this.#W=null,this.#K.classList.remove("is-dragging"),this.#T(),this.#V(),!j){let q=this.#E($,J);this.#C(q.x,q.y,"input")}this.#D("change")},this.#K.addEventListener("pointermove",this.#U),this.#K.addEventListener("pointerup",this.#N),this.#K.addEventListener("pointercancel",this.#N),this.#K.addEventListener("lostpointercapture",this.#N)}#l(){if(!this.#K||!this.#Z)return;this.#K.addEventListener("pointerdown",($)=>{let J=this.#x($.clientX,$.clientY);if(this.#S(J),this.#L){this.#b($);return}let Z=this.#E($.clientX,$.clientY);this.#C(Z.x,Z.y,"input"),this.#D("change")}),this.#K.addEventListener("pointermove",($)=>{if(this.#q)return;let J=this.#x($.clientX,$.clientY);this.#S(J)}),this.#K.addEventListener("pointerleave",()=>{this.#T()});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.#Q,"input");else this.#C(this.#$,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 s0 extends HTMLElement{#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=null;#_=null;#X=null;#q=!1;#Y={x:0.5,y:0.5};#W=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#F(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#D(Q),this.#K=()=>this.#P(),this.#j=(Q)=>this.#O(Q),this.#Z=(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.#T(),this.#S(),this.#C(),this.#W=!0})}#U(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#A()}get#N(){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.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#Z=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#F(),this.#S(),this.#H(),this.#l()}#H(){let Q=this.#$.toFixed(this.#J),$=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#P(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#D(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#F(){if(!this.#Z)return;let Q=($)=>16.6667+this.#B($)/100*66.6667;this.#Z.style.left=`${Q(this.#$)}%`,this.#Z.style.top=`${Q(this.#Q)}%`}#S(){if(!this.#Z)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,K=this.#Q>100;this.#Z.classList.toggle("beyond-bounds-x",Q),this.#Z.classList.toggle("beyond-bounds-y",$),this.#Z.classList.toggle("overflow-left",J),this.#Z.classList.toggle("overflow-right",Z),this.#Z.classList.toggle("overflow-up",j),this.#Z.classList.toggle("overflow-down",K)}#I(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.#j.find((_)=>Number(_.getAttribute("data-col"))===K&&Number(_.getAttribute("data-row"))===q)}#k(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#E(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.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#F(),this.#S(),this.#H(),this.#P(),this.#D(J)}#w(Q,$){if(!this.#K)return{x:this.#$,y:this.#Q};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}}#T(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}}#f(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.#f(Q.x),y:this.#f(Q.y)}}#V(){if(!this.#K||!this.#U||!this.#N)return;this.#K.removeEventListener("pointermove",this.#U),this.#K.removeEventListener("pointerup",this.#N),this.#K.removeEventListener("pointercancel",this.#N),this.#K.removeEventListener("lostpointercapture",this.#N),this.#U=null,this.#N=null}#b(Q){if(!this.#K||!this.#L)return;Q.preventDefault(),this.#q=!0,this.#W=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.#W)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.#N=(K)=>{if(!this.#q||K.pointerId!==this.#W)return;if(this.#q=!1,this.#W=null,this.#K.classList.remove("is-dragging"),this.#k(),this.#V(),!j){let q=this.#T($,J);this.#C(q.x,q.y,"input")}this.#D("change")},this.#K.addEventListener("pointermove",this.#U),this.#K.addEventListener("pointerup",this.#N),this.#K.addEventListener("pointercancel",this.#N),this.#K.addEventListener("lostpointercapture",this.#N)}#l(){if(!this.#K||!this.#Z)return;this.#K.addEventListener("pointerdown",($)=>{let J=this.#I($.clientX,$.clientY);if(this.#E(J),this.#L){this.#b($);return}let Z=this.#T($.clientX,$.clientY);this.#C(Z.x,Z.y,"input"),this.#D("change")}),this.#K.addEventListener("pointermove",($)=>{if(this.#q)return;let J=this.#I($.clientX,$.clientY);this.#E(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.#Q,"input");else this.#C(this.#$,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 s0 extends HTMLElement{#$=null;#Q=null;#J=null;#K=null;#j=null;#Z=null;#_=null;#X=null;#q=!1;#Y={x:0.5,y:0.5};#W=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#P(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#D(Q),this.#K=()=>this.#F(),this.#j=(Q)=>this.#O(Q),this.#Z=(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.#E(),this.#C(),this.#W=!0})}#U(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#A()}get#N(){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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#$),this.cursor?.addEventListener("pointerdown",this.#Q),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.#N&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#A(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#K),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#N&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#T(),this.#S(),this.#k()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#T(),this.#S(),this.#k()}#z(){this.#S(),this.#x()}#H(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.#T();this.#S()}#F(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.#H(J,Z,{syncHandle:!1}),this.#k(),this.#x()}#D(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#H($.px,$.py,{syncHandle:!1}),this.#k()}#P(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#S(),this.#x()}#k(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#x(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){let Q=this.#U(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#N&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#S(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#q=!0,this.setAttribute("value",Q),this.#q=!1;this.#C()}#C(){let Q=this.#Y,$=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.#Y},this.#T(),this.#S(),this.#k(),this.#x()}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.#W)this.#T(),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.#T();if(Q==="axis-labels"&&J!==$)this.#A(),this.#L(),this.#B(),this.#T();if(Q==="coordinates")this.coordinates=J||"screen",this.#T()}}customElements.define("fig-joystick",s0);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 d0 extends _0{}customElements.define("fig-skeleton",d0);class r0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#K.bind(this),this.#$.addEventListener("click",this.#Q)}#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",r0);class i0 extends HTMLElement{static observedAttributes=["name","collapsible"];#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>this.#K())}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.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.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(this.#$.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let K=document.createElement("span");K.className="fig-mask-icon fig-group-chevron",j.prepend(K)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",i0);class o0 extends HTMLElement{}customElements.define("fig-header",o0);class l0 extends HTMLElement{}customElements.define("fig-footer",l0);class t0 extends HTMLElement{}customElements.define("fig-spinner",t0);class a0 extends HTMLElement{}customElements.define("fig-icon",a0);class n0 extends HTMLElement{}customElements.define("fig-content",n0);class e0 extends HTMLElement{}customElements.define("fig-tab-content",e0);class Q1 extends HTMLElement{}customElements.define("fig-button-combo",Q1);class $1 extends HTMLElement{}customElements.define("fig-input-combo",$1);class e extends HTMLElement{#$=null;#Q=null;#J=null;#K="solid";anchorElement=null;#j="solid";#Z="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}]};#Y={url:null,scaleMode:"fill",scale:50};#W={url:null,scaleMode:"fill",scale:50};#U={stream:null,snapshot:null};#N={};#L={};#G=null;#M=null;#B=null;#A=null;#O=!1;#R=null;#z=null;#H=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#F(),this.#D(),this.#P()})}disconnectedCallback(){if(this.#R)this.#R(),this.#R=null;if(this.#z)this.#z.disconnect(),this.#z=null;if(this.#H)this.#H.disconnect(),this.#H=null;if(this.#U.stream)this.#U.stream.getTracks().forEach((Q)=>Q.stop()),this.#U.stream=null;if(this.#W.url&&this.#W.url.startsWith("blob:"))URL.revokeObjectURL(this.#W.url);if(this.#Q)this.#Q.removeAttribute("selected");if(this.#J)this.#J.close(),this.#J.remove(),this.#J=null}#F(){let Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#Q=document.createElement("fig-chit"),this.#Q.setAttribute("background","#D9D9D9"),this.appendChild(this.#Q),this.#$=this.#Q;else if(Q.tagName==="FIG-CHIT")this.#Q=Q,this.#$=Q;else this.#$=Q,this.#Q=null;if(this.#$.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#x()}),this.#Q)requestAnimationFrame(()=>{let $=this.#Q.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.#j=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.#Z=J.colorSpace;if(J.gradient)this.#q=V({...this.#q,...J.gradient});if(J.image)this.#Y={...this.#Y,...J.image};if(J.video)this.#W={...this.#W,...J.video};if(J.type&&!$.includes(J.type)){let{type:Z,...j}=J;this.#L[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#j="solid",this.#_=this.#j0(Q)}}#P(){if(!this.#Q)return;let Q,$="cover",J="center";switch(this.#j){case"solid":Q=this.#s(this.#_);break;case"gradient":Q=this.#J0();break;case"image":if(this.#Y.url){Q=`url(${this.#Y.url})`;let j=this.#k(this.#Y.scaleMode,this.#Y.scale);$=j.size,J=j.position}else Q="";break;case"video":if(this.#W.url){Q=`url(${this.#W.url})`;let j=this.#k(this.#W.scaleMode,this.#W.scale);$=j.size,J=j.position}else Q="";break;default:Q=this.#N[this.#j]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#Q.setAttribute("background",Q),this.#Q.style.setProperty("--chit-bg-size",$),this.#Q.style.setProperty("--chit-bg-position",J),this.#j==="solid")this.#Q.setAttribute("alpha",this.#_.a);else this.#Q.removeAttribute("alpha")}#k(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"}}}#x(){if(!this.#J)this.#T();this.#S(this.#j);let Q=this.#J.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#Z;if(this.#Q)this.#Q.setAttribute("selected","true");this.#J.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#E(),this.#f()})})}#T(){this.#N={},this.querySelectorAll('[slot^="mode-"]').forEach((L)=>{let B=L.getAttribute("slot").slice(5);this.#N[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.#$;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.#N[B]),j.length===0)j=[...$]}else j=[...$];let K={...J};for(let[L,{label:B}]of Object.entries(this.#N))K[L]=B;if(!j.includes(this.#j))this.#j=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
+ `}#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.#$),this.cursor?.addEventListener("pointerdown",this.#Q),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.#N&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#A(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#K),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#N&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#k(),this.#E(),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.#E(),this.#S()}#z(){this.#E(),this.#I()}#H(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.#E()}#P(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.#H(J,Z,{syncHandle:!1}),this.#S(),this.#I()}#D(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#H($.px,$.py,{syncHandle:!1}),this.#S()}#F(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#E(),this.#I()}#S(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#I(){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.#N&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#E(){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.#Y,$=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.#Y},this.#k(),this.#E(),this.#S(),this.#I()}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.#W)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",s0);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 d0 extends _0{}customElements.define("fig-skeleton",d0);class r0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#K.bind(this),this.#$.addEventListener("click",this.#Q)}#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",r0);class i0 extends HTMLElement{static observedAttributes=["name","collapsible"];#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>this.#K())}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.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.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(this.#$.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let K=document.createElement("span");K.className="fig-mask-icon fig-group-chevron",j.prepend(K)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",i0);class o0 extends HTMLElement{}customElements.define("fig-header",o0);class l0 extends HTMLElement{}customElements.define("fig-footer",l0);class t0 extends HTMLElement{}customElements.define("fig-spinner",t0);class a0 extends HTMLElement{}customElements.define("fig-icon",a0);class n0 extends HTMLElement{}customElements.define("fig-content",n0);class e0 extends HTMLElement{}customElements.define("fig-tab-content",e0);class Q1 extends HTMLElement{}customElements.define("fig-button-combo",Q1);class $1 extends HTMLElement{}customElements.define("fig-input-combo",$1);class e extends HTMLElement{#$=null;#Q=null;#J=null;#K="solid";anchorElement=null;#j="solid";#Z="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}]};#Y={url:null,scaleMode:"fill",scale:50};#W={url:null,scaleMode:"fill",scale:50};#U={stream:null,snapshot:null};#N={};#L={};#G=null;#M=null;#B=null;#A=null;#O=!1;#R=null;#z=null;#H=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#P(),this.#D(),this.#F()})}disconnectedCallback(){if(this.#R)this.#R(),this.#R=null;if(this.#z)this.#z.disconnect(),this.#z=null;if(this.#H)this.#H.disconnect(),this.#H=null;if(this.#U.stream)this.#U.stream.getTracks().forEach((Q)=>Q.stop()),this.#U.stream=null;if(this.#W.url&&this.#W.url.startsWith("blob:"))URL.revokeObjectURL(this.#W.url);if(this.#Q)this.#Q.removeAttribute("selected");if(this.#J)this.#J.close(),this.#J.remove(),this.#J=null}#P(){let Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#Q=document.createElement("fig-chit"),this.#Q.setAttribute("background","#D9D9D9"),this.appendChild(this.#Q),this.#$=this.#Q;else if(Q.tagName==="FIG-CHIT")this.#Q=Q,this.#$=Q;else this.#$=Q,this.#Q=null;if(this.#$.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#I()}),this.#Q)requestAnimationFrame(()=>{let $=this.#Q.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.#j=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.#Z=J.colorSpace;if(J.gradient)this.#q=V({...this.#q,...J.gradient});if(J.image)this.#Y={...this.#Y,...J.image};if(J.video)this.#W={...this.#W,...J.video};if(J.type&&!$.includes(J.type)){let{type:Z,...j}=J;this.#L[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#j="solid",this.#_=this.#j0(Q)}}#F(){if(!this.#Q)return;let Q,$="cover",J="center";switch(this.#j){case"solid":Q=this.#s(this.#_);break;case"gradient":Q=this.#J0();break;case"image":if(this.#Y.url){Q=`url(${this.#Y.url})`;let j=this.#S(this.#Y.scaleMode,this.#Y.scale);$=j.size,J=j.position}else Q="";break;case"video":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;default:Q=this.#N[this.#j]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#Q.setAttribute("background",Q),this.#Q.style.setProperty("--chit-bg-size",$),this.#Q.style.setProperty("--chit-bg-position",J),this.#j==="solid")this.#Q.setAttribute("alpha",this.#_.a);else this.#Q.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"}}}#I(){if(!this.#J)this.#k();this.#E(this.#j);let Q=this.#J.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#Z;if(this.#Q)this.#Q.setAttribute("selected","true");this.#J.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#T(),this.#f()})})}#k(){this.#N={},this.querySelectorAll('[slot^="mode-"]').forEach((L)=>{let B=L.getAttribute("slot").slice(5);this.#N[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.#$;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.#N[B]),j.length===0)j=[...$]}else j=[...$];let K={...J};for(let[L,{label:B}]of Object.entries(this.#N))K[L]=B;if(!j.includes(this.#j))this.#j=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(`
275
275
  `);X=`<fig-dropdown class="fig-fill-picker-type" ${_} value="${this.#j}">
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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#N)){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 W=this.#J.querySelector(".fig-fill-picker-type");if(W)W.addEventListener("change",(L)=>{this.#S(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.#Z)this.#Z=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.#Q)this.#Q.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.#C(),gradient:()=>this.#q0(),image:()=>this.#a(),video:()=>this.#_0(),webcam:()=>this.#X0()};for(let[L,B]of Object.entries(R))if(!this.#N[L]&&j.includes(L))B();for(let L of Object.keys(this.#N)){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.#y()}),B.addEventListener("change",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#u()})}}#S(Q){if(!this.#J?.querySelector(`.fig-fill-picker-tab[data-tab="${Q}"]`))return;this.#K=Q,this.#j=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.#N[Q]?"0":"";if(Q==="gradient")requestAnimationFrame(()=>{this.#v()});this.#P(),this.#y()}#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:B}]of Object.entries(this.#N)){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 W=this.#J.querySelector(".fig-fill-picker-type");if(W)W.addEventListener("change",(L)=>{this.#E(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.#Z)this.#Z=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.#Q)this.#Q.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.#C(),gradient:()=>this.#q0(),image:()=>this.#a(),video:()=>this.#_0(),webcam:()=>this.#X0()};for(let[L,B]of Object.entries(R))if(!this.#N[L]&&j.includes(L))B();for(let L of Object.keys(this.#N)){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.#x()}),B.addEventListener("change",(M)=>{if(M.target===this)return;if(M.stopPropagation(),M.detail)this.#L[L]=M.detail;this.#u()})}}#E(Q){if(!this.#J?.querySelector(`.fig-fill-picker-tab[data-tab="${Q}"]`))return;this.#K=Q,this.#j=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.#N[Q]?"0":"";if(Q==="gradient")requestAnimationFrame(()=>{this.#v()});this.#F(),this.#x()}#C(){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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#f(),this.#V(),this.#B=Q.querySelector('fig-slider[type="hue"]'),this.#B.addEventListener("input",(q)=>{this.#_.h=parseFloat(q.target.value),this.#E(),this.#f(),this.#p(),this.#y()}),this.#B.addEventListener("change",()=>{this.#u()}),$)this.#A=Q.querySelector('fig-slider[type="opacity"]'),this.#A.addEventListener("input",(q)=>{this.#_.a=parseFloat(q.target.value)/100,this.#p(),this.#y()}),this.#A.addEventListener("change",()=>{this.#u()});Q.querySelector(".fig-fill-picker-input-mode").addEventListener("input",(q)=>{this.#X=q.target.value,this.#b()}),this.#b();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.#f(),this.#p(),this.#y()}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.#V()}this.#E(),this.#f()}this.#m(),this.#y()}#E(){if(!this.#G&&this.#J)this.#G=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#G)return;let Q=this.#Z==="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.#Z==="display-p3",q=$.createLinearGradient(0,0,J,0);if(K){q.addColorStop(0,"color(display-p3 1 1 1)");let[X,Y,N]=P1(j,100,50);q.addColorStop(1,`color(display-p3 ${X} ${Y} ${N})`)}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)}#f(Q=0){if(!this.#M||!this.#G)return;let $=this.#G.getBoundingClientRect();if(($.width===0||$.height===0)&&Q<5){requestAnimationFrame(()=>this.#f(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}))}#I(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.#f();if(this.#p(),j)this.#y();if(K)this.#u()}#V(){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,N={})=>{let W=Q.getBoundingClientRect();if(W.width===0||W.height===0)return;let G=Math.max(0,Math.min(Y.clientX-W.left,W.width)),D=Math.max(0,Math.min(Y.clientY-W.top,W.height));this.#I(G/W.width,D/W.height,N)},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.#u()},_=(Y)=>{this.#O=!0;let N=Y.detail?.px,W=Y.detail?.py;if(!Number.isFinite(N)||!Number.isFinite(W))return;$.setAttribute("value",`${N*100}% ${W*100}%`),this.#I(N,W,{updateHandle:!1,emitInput:!0})},X=(Y)=>{let N=Y.detail?.px,W=Y.detail?.py;if(Number.isFinite(N)&&Number.isFinite(W))$.setAttribute("value",`${N*100}% ${W*100}%`),this.#I(N,W,{updateHandle:!1,emitInput:!1});this.#O=!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.#O=!1}}#b(){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.#T(),this.#f(),this.#V(),this.#B=Q.querySelector('fig-slider[type="hue"]'),this.#B.addEventListener("input",(q)=>{this.#_.h=parseFloat(q.target.value),this.#T(),this.#f(),this.#p(),this.#x()}),this.#B.addEventListener("change",()=>{this.#u()}),$)this.#A=Q.querySelector('fig-slider[type="opacity"]'),this.#A.addEventListener("input",(q)=>{this.#_.a=parseFloat(q.target.value)/100,this.#p(),this.#x()}),this.#A.addEventListener("change",()=>{this.#u()});Q.querySelector(".fig-fill-picker-input-mode").addEventListener("input",(q)=>{this.#X=q.target.value,this.#b()}),this.#b();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.#T(),this.#f(),this.#p(),this.#x()}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.#V()}this.#T(),this.#f()}this.#m(),this.#x()}#T(){if(!this.#G&&this.#J)this.#G=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#G)return;let Q=this.#Z==="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.#Z==="display-p3",q=$.createLinearGradient(0,0,J,0);if(K){q.addColorStop(0,"color(display-p3 1 1 1)");let[X,Y,N]=P1(j,100,50);q.addColorStop(1,`color(display-p3 ${X} ${Y} ${N})`)}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)}#f(Q=0){if(!this.#M||!this.#G)return;let $=this.#G.getBoundingClientRect();if(($.width===0||$.height===0)&&Q<5){requestAnimationFrame(()=>this.#f(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.#f();if(this.#p(),j)this.#x();if(K)this.#u()}#V(){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,N={})=>{let W=Q.getBoundingClientRect();if(W.width===0||W.height===0)return;let G=Math.max(0,Math.min(Y.clientX-W.left,W.width)),D=Math.max(0,Math.min(Y.clientY-W.top,W.height));this.#y(G/W.width,D/W.height,N)},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.#u()},_=(Y)=>{this.#O=!0;let N=Y.detail?.px,W=Y.detail?.py;if(!Number.isFinite(N)||!Number.isFinite(W))return;$.setAttribute("value",`${N*100}% ${W*100}%`),this.#y(N,W,{updateHandle:!1,emitInput:!0})},X=(Y)=>{let N=Y.detail?.px,W=Y.detail?.py;if(Number.isFinite(N)&&Number.isFinite(W))$.setAttribute("value",`${N*100}% ${W*100}%`),this.#y(N,W,{updateHandle:!1,emitInput:!1});this.#O=!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.#O=!1}}#b(){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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#p())}#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.#f(),this.#B)this.#B.setAttribute("value",this.#_.h);this.#y()},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.#N0({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}`)}}}#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.#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.#O)return;let j=this.#K0();if(!j)return;if(this.#_={...j,a:this.#_.a},this.#T(),this.#f(),this.#B)this.#B.setAttribute("value",this.#_.h);this.#x()},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.#N0({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}`)}}}#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.#A)this.#A.setAttribute("color",Q);this.#F()}#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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
386
386
  </fig-header>
387
387
  <div class="fig-fill-picker-gradient-stops-list"></div>
388
388
  </div>
389
- `,this.#v(),this.#d(Q)}#d(Q){let $=Q.querySelector(".fig-fill-picker-gradient-type"),J=(N)=>N.currentTarget?.value??N.target?.value??N.detail,Z=(N)=>{this.#q.type=J(N),this.#v(),this.#y()};$.addEventListener("input",Z),$.addEventListener("change",Z);let j=Q.querySelector(".fig-fill-picker-gradient-space"),K=(N)=>{let W=J(N),G=W,D="shorter";if(W.startsWith("oklch-"))G="oklch",D=W.slice(6);this.#q=V({...this.#q,interpolationSpace:G,hueInterpolation:D}),this.#v(),this.#y()};j?.addEventListener("input",K),j?.addEventListener("change",K),Q.querySelector(".fig-fill-picker-gradient-angle").addEventListener("input",(N)=>{let W=parseFloat(N.target.value)||0;this.#q.angle=(W+90)%360,this.#m(),this.#y()});let _=Q.querySelector(".fig-fill-picker-gradient-cx"),X=Q.querySelector(".fig-fill-picker-gradient-cy");_?.addEventListener("input",(N)=>{this.#q.centerX=parseFloat(N.target.value)||50,this.#m(),this.#y()}),X?.addEventListener("input",(N)=>{this.#q.centerY=parseFloat(N.target.value)||50,this.#m(),this.#y()}),Q.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#q.stops.forEach((N)=>{N.position=100-N.position}),this.#q.stops.sort((N,W)=>N.position-W.position),this.#v(),this.#y()}),Q.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#q.stops.push({position:50,color:"#888888",opacity:100}),this.#q.stops.sort((W,G)=>W.position-G.position),this.#v(),this.#y()});let Y=Q.querySelector(".fig-fill-picker-gradient-bar-input");if(Y){let N=(W)=>{W.stopPropagation();let G=W.detail;if(!G?.gradient)return;this.#q=V({...this.#q,...G.gradient}),this.#P(),this.#t()};Y.addEventListener("input",(W)=>{N(W),this.#y()}),Y.addEventListener("change",(W)=>{N(W),this.#u()})}}#v(){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.#v(),this.#d(Q)}#d(Q){let $=Q.querySelector(".fig-fill-picker-gradient-type"),J=(N)=>N.currentTarget?.value??N.target?.value??N.detail,Z=(N)=>{this.#q.type=J(N),this.#v(),this.#x()};$.addEventListener("input",Z),$.addEventListener("change",Z);let j=Q.querySelector(".fig-fill-picker-gradient-space"),K=(N)=>{let W=J(N),G=W,D="shorter";if(W.startsWith("oklch-"))G="oklch",D=W.slice(6);this.#q=V({...this.#q,interpolationSpace:G,hueInterpolation:D}),this.#v(),this.#x()};j?.addEventListener("input",K),j?.addEventListener("change",K),Q.querySelector(".fig-fill-picker-gradient-angle").addEventListener("input",(N)=>{let W=parseFloat(N.target.value)||0;this.#q.angle=(W+90)%360,this.#m(),this.#x()});let _=Q.querySelector(".fig-fill-picker-gradient-cx"),X=Q.querySelector(".fig-fill-picker-gradient-cy");_?.addEventListener("input",(N)=>{this.#q.centerX=parseFloat(N.target.value)||50,this.#m(),this.#x()}),X?.addEventListener("input",(N)=>{this.#q.centerY=parseFloat(N.target.value)||50,this.#m(),this.#x()}),Q.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#q.stops.forEach((N)=>{N.position=100-N.position}),this.#q.stops.sort((N,W)=>N.position-W.position),this.#v(),this.#x()}),Q.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#q.stops.push({position:50,color:"#888888",opacity:100}),this.#q.stops.sort((W,G)=>W.position-G.position),this.#v(),this.#x()});let Y=Q.querySelector(".fig-fill-picker-gradient-bar-input");if(Y){let N=(W)=>{W.stopPropagation();let G=W.detail;if(!G?.gradient)return;this.#q=V({...this.#q,...G.gradient}),this.#F(),this.#t()};Y.addEventListener("input",(W)=>{N(W),this.#x()}),Y.addEventListener("change",(W)=>{N(W),this.#u()})}}#v(){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.#F()}#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>
@@ -394,7 +394,7 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
394
394
  <span class="fig-mask-icon" style="--icon: var(--icon-minus)"></span>
395
395
  </fig-button>
396
396
  </fig-field>
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.#y()});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.#y()}),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{if(this.#q.stops.length>2)this.#q.stops.splice(J,1),this.#v(),this.#y()})})}#h(Q,$=!0){let J=V({...this.#q,interpolationSpace:Q??this.#q.interpolationSpace}),Z=this.#Z==="display-p3",j=J.stops.map((q)=>{let _=(q.opacity??100)/100;return`${Z?this.#U0(q.color,_):this.#W0(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)}#a(){let Q=this.#J.querySelector('[data-tab="image"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
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.#x()});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.#x()}),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{if(this.#q.stops.length>2)this.#q.stops.splice(J,1),this.#v(),this.#x()})})}#h(Q,$=!0){let J=V({...this.#q,interpolationSpace:Q??this.#q.interpolationSpace}),Z=this.#Z==="display-p3",j=J.stops.map((q)=>{let _=(q.opacity??100)/100;return`${Z?this.#U0(q.color,_):this.#W0(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)}#a(){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
399
  <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#Y.scaleMode}">
400
400
  <option value="fill" selected>Fill</option>
@@ -412,7 +412,7 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#Y.scaleMode=_.target.value,J.style.display=_.target.value==="tile"?"block":"none",this.#i(K),this.#P(),this.#y()}),J.addEventListener("input",(_)=>{this.#Y.scale=parseFloat(_.target.value)||100,this.#i(K),this.#P(),this.#y()}),Z.addEventListener("click",()=>{j.click()}),j.addEventListener("change",(_)=>{let X=_.target.files[0];if(X){let Y=new FileReader;Y.onload=(N)=>{this.#Y.url=N.target.result,this.#i(K),this.#P(),this.#y()},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=(N)=>{this.#Y.url=N.target.result,this.#i(K),this.#P(),this.#y()},Y.readAsDataURL(X)}})}#i(Q){let $=Q.closest(".fig-fill-picker-media-preview");if(!this.#Y.url){Q.style.display="none",$?.classList.remove("has-media");return}switch(Q.style.display="block",$?.classList.add("has-media"),Q.style.backgroundImage=`url(${this.#Y.url})`,Q.style.backgroundPosition="center",this.#Y.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.#Y.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.#W.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.#Y.scaleMode=_.target.value,J.style.display=_.target.value==="tile"?"block":"none",this.#i(K),this.#F(),this.#x()}),J.addEventListener("input",(_)=>{this.#Y.scale=parseFloat(_.target.value)||100,this.#i(K),this.#F(),this.#x()}),Z.addEventListener("click",()=>{j.click()}),j.addEventListener("change",(_)=>{let X=_.target.files[0];if(X){let Y=new FileReader;Y.onload=(N)=>{this.#Y.url=N.target.result,this.#i(K),this.#F(),this.#x()},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=(N)=>{this.#Y.url=N.target.result,this.#i(K),this.#F(),this.#x()},Y.readAsDataURL(X)}})}#i(Q){let $=Q.closest(".fig-fill-picker-media-preview");if(!this.#Y.url){Q.style.display="none",$?.classList.remove("has-media");return}switch(Q.style.display="block",$?.classList.add("has-media"),Q.style.backgroundImage=`url(${this.#Y.url})`,Q.style.backgroundPosition="center",this.#Y.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.#Y.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.#W.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
417
  <fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#W.scaleMode}">
418
418
  <option value="fill" selected>Fill</option>
@@ -428,7 +428,7 @@ var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! 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.#W.scaleMode=q.target.value,this.#g(j),this.#P(),this.#y()}),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.#W.url=URL.createObjectURL(_),j.src=this.#W.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#y()}),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.#W.url=URL.createObjectURL(_),j.src=this.#W.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#P(),this.#y()})}#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.#W.scaleMode=q.target.value,this.#g(j),this.#F(),this.#x()}),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.#W.url=URL.createObjectURL(_),j.src=this.#W.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#F(),this.#x()}),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.#W.url=URL.createObjectURL(_),j.src=this.#W.url,j.style.display="block",j.play(),K.classList.add("has-media"),this.#g(j),this.#F(),this.#x()})}#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 U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @
443
443
  Capture
444
444
  </fig-button>
445
445
  </fig-field>
446
- `,this.#n(Q)}#n(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((N)=>N.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((N)=>N.kind==="videoinput");if(Y.length>1)j.style.display="block",j.innerHTML=Y.map((N,W)=>`<option value="${N.deviceId}">${N.label||`Camera ${W+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.#H=new MutationObserver(()=>{if(Q.style.display!=="none"&&!this.#U.stream)K()}),this.#H.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.#Y.url=this.#U.snapshot,this.#j="image",this.#P(),this.#y(),this.#S("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),N=Z*(1-X*J),W=Z*(1-(1-X)*J);switch(_%6){case 0:j=Z,K=W,q=Y;break;case 1:j=N,K=Z,q=Y;break;case 2:j=Y,K=Z,q=W;break;case 3:j=Y,K=N,q=Z;break;case 4:j=W,K=Y,q=Z;break;case 5:j=Z,K=Y,q=N;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})}#W0(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 _=(N,W,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return N+(W-N)*6*G;if(G<0.5)return W;if(G<0.6666666666666666)return N+(W-N)*(0.6666666666666666-G)*6;return N},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 $=(W)=>{return W=W/255,W<=0.04045?W/12.92:Math.pow((W+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),N=Math.cbrt(_);return{l:0.2104542553*X+0.793617785*Y-0.0040720468*N,a:1.9779984951*X-2.428592205*Y+0.4505937099*N,b:0.0259040371*X+0.7827717662*Y-0.808675766*N}}#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}}#N0(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.#N0({l:Q.l,a:Q.c*Math.cos($),b:Q.c*Math.sin($)})}#y(){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.#j,colorSpace:this.#Z};switch(this.#j){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.#Y}};case"video":return{...Q,video:{...this.#W}};case"webcam":return{...Q,image:{url:this.#U.snapshot,scaleMode:"fill",scale:50}};default:return{...Q,...this.#L[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":if(this.#D(),this.#P(),this.#J){if(!this.#O){if(this.#f(),this.#p(),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 J1 extends HTMLElement{#$=null;#Q=null;#J=null;#K=this.#B.bind(this);#j=this.#A.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#G()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#W)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#K),this.#$.removeEventListener("change",this.#j);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#q(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){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.#$=null,this.#Q=null,this.addEventListener("click",this.#W);return}this.removeEventListener("click",this.#W);let $=(this.getAttribute("value")||"").trim(),J=this.#L($),Z=this.#N($),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=`
446
+ `,this.#n(Q)}#n(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((N)=>N.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((N)=>N.kind==="videoinput");if(Y.length>1)j.style.display="block",j.innerHTML=Y.map((N,W)=>`<option value="${N.deviceId}">${N.label||`Camera ${W+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.#H=new MutationObserver(()=>{if(Q.style.display!=="none"&&!this.#U.stream)K()}),this.#H.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.#Y.url=this.#U.snapshot,this.#j="image",this.#F(),this.#x(),this.#E("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),N=Z*(1-X*J),W=Z*(1-(1-X)*J);switch(_%6){case 0:j=Z,K=W,q=Y;break;case 1:j=N,K=Z,q=Y;break;case 2:j=Y,K=Z,q=W;break;case 3:j=Y,K=N,q=Z;break;case 4:j=W,K=Y,q=Z;break;case 5:j=Z,K=Y,q=N;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})}#W0(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 _=(N,W,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return N+(W-N)*6*G;if(G<0.5)return W;if(G<0.6666666666666666)return N+(W-N)*(0.6666666666666666-G)*6;return N},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 $=(W)=>{return W=W/255,W<=0.04045?W/12.92:Math.pow((W+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),N=Math.cbrt(_);return{l:0.2104542553*X+0.793617785*Y-0.0040720468*N,a:1.9779984951*X-2.428592205*Y+0.4505937099*N,b:0.0259040371*X+0.7827717662*Y-0.808675766*N}}#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}}#N0(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.#N0({l:Q.l,a:Q.c*Math.cos($),b:Q.c*Math.sin($)})}#x(){this.#F(),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.#j,colorSpace:this.#Z};switch(this.#j){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.#Y}};case"video":return{...Q,video:{...this.#W}};case"webcam":return{...Q,image:{url:this.#U.snapshot,scaleMode:"fill",scale:50}};default:return{...Q,...this.#L[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":if(this.#D(),this.#F(),this.#J){if(!this.#O){if(this.#f(),this.#p(),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 J1 extends HTMLElement{#$=null;#Q=null;#J=null;#K=this.#B.bind(this);#j=this.#A.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#G()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#W)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#K),this.#$.removeEventListener("change",this.#j);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#q(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){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.#$=null,this.#Q=null,this.addEventListener("click",this.#W);return}this.removeEventListener("click",this.#W);let $=(this.getAttribute("value")||"").trim(),J=this.#L($),Z=this.#N($),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.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#K),this.#$?.addEventListener("change",this.#j),this.#X()}#W=()=>{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"}#N(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.#N(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#q)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q)if(this.#Q.setAttribute("background",$),this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.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}))}#B(Q){Q.stopPropagation(),this.#M(Q.detail,"input")}#A(Q){Q.stopPropagation(),this.#M(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#Y();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",J1);class Z1 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",Z1);class j1 extends HTMLElement{#$=null;#Q=this.#M.bind(this);#J=this.#B.bind(this);#K=this.#O.bind(this);#j=null;#Z=null;#_=null;#X=null;#q=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop","padding"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#W(){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.#$}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;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#x(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#K),this.#F(),this.#z(),this.#T(),this.#R(),requestAnimationFrame(()=>{this.#N(),this.#O()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#K),this.#H(),this.#j?.disconnect(),this.#j=null,this.#Z?.disconnect(),this.#Z=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.#N());if(Q==="drag")if(this.#W)this.#z();else this.#H();if(Q==="overflow")this.#F()}#N(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#L($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#L(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#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.#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.#$),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.#$)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.#Y==="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.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#O()}),this.#Z.observe(this)}#z(){if(this.#q?.bound)return;if(!this.#W)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)}#H(){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}#F(){if(this.#Y==="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.#k(-1)}),this.#X.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#k(1)}),this.prepend(this.#_),this.append(this.#X)}#k(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#x(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)})}#T(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#N();else if(!this.#$&&Q.length)this.#N()}),this.#j.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",j1);class K1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","control","hit-area","hit-area-mode"];#$=!1;#Q=!1;#J=null;#K=!1;#j=null;#Z=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#Y(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#W(){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"}#N(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%")}#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,N,W)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(-W,Math.min(N-W,Y.px-W));let D=(typeof Y==="number"?Y:0)/100*N;return Math.max(-W,Math.min(N-W,D-W))},X=this.#W;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}}#H(){let Q=this.#z();if(!Q){if(this.#Z)this.#Z.remove(),this.#Z=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#Z){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#F(J)),this.prepend($),this.#Z=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#Z.style.borderRadius="50%";else this.#Z.style.borderRadius="inherit"}#F(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#Z)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#S(Q)}connectedCallback(){this.#x(),this.#H(),this.addEventListener("click",this.#D),document.addEventListener("pointerdown",this.#P),document.addEventListener("keydown",this.#k);let Q=this.getAttribute("value");if(Q)this.#A(Q);if(this.#X)this.#C()}disconnectedCallback(){if(this.#T(),this.#w(),this.#Z)this.#Z.remove(),this.#Z=null;this.removeEventListener("click",this.#D),document.removeEventListener("pointerdown",this.#P),document.removeEventListener("keydown",this.#k)}select(){if(this.hasAttribute("disabled"))return;if(this.setAttribute("selected",""),this.getAttribute("type")==="color"&&!this.#$)this.#C()}deselect(){this.removeAttribute("selected"),this.#w()}#D=(Q)=>{if(this.#X)return;if(this.#Q){this.#Q=!1;return}this.select()};#P=(Q)=>{if(this.#X)return;if(this.contains(Q.target))return;if(this.#j&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#k=(Q)=>{if(Q.key!=="Enter")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(this.#j)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.#j&&J)this.#j.setAttribute("value",J)}if(Q==="drag")this.#x();if(Q==="hit-area")this.#H();if(Q==="value"&&!this.#K&&!this.#$)this.#A(J);if(Q==="control")if(this.#X)this.#w(),this.#C();else this.#w()}#x(){if(this.#Y&&!this.#J)this.#J=(Q)=>this.#S(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#T()}#T(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#S(Q){if(!this.#Y||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#W,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-_,N=Q.clientY-X,W=Q.clientX,G=Q.clientY,D=3,R=(M,O,A=!1)=>{let H=$.getBoundingClientRect();K=H;let T=parseFloat(this.style.left)||0,S=parseFloat(this.style.top)||0,f=M-Y-H.left-Z/2,I=O-N-H.top-j/2,c=Math.max(-Z/2,Math.min(H.width-Z/2,f)),o=Math.max(-j/2,Math.min(H.height-j/2,I)),h=H.width>0?((J.x?c:T)+Z/2)/H.width:0.5,g=H.height>0?((J.y?o:S)+j/2)/H.height:0.5;if(this.#N(A)){if(J.x)h=this.#L(h);if(J.y)g=this.#L(g);if(J.x&&J.y){let b=this.#G(h,g);h=b.x,g=b.y}}if(J.x){let b=h*H.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(H.width-Z/2,b)))}px`}if(J.y){let b=g*H.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(H.height-j/2,b)))}px`}},L=(M)=>{if(!this.#$)return;if(!this.#Q){let O=M.clientX-W,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.#Q=!0,R(M.clientX,M.clientY,M.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#b(K),shiftKey:M.shiftKey}}))},B=(M)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",B),this.#Q){R(M.clientX,M.clientY,M.shiftKey),this.#O(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#b(K)}));let O=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",O,{capture:!0,once:!0})}else this.#O();this.#Q=!1};window.addEventListener("pointermove",L),window.addEventListener("pointerup",B)}showColorTip(){if(this.#j){this.#j.style.display="";return}this.#C()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#C(){if(this.#j)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.#f),Q.addEventListener("change",this.#I),Q.addEventListener("add",this.#V),Q.addEventListener("remove",this.#V),this.appendChild(Q),this.#j=Q}#w(){if(!this.#j)return;this.#j.removeEventListener("input",this.#f),this.#j.removeEventListener("change",this.#I),this.#j.removeEventListener("add",this.#V),this.#j.removeEventListener("remove",this.#V),this.#j.remove(),this.#j=null}#E(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=i(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#f=(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}}))};#I=(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}}))};#V=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#b(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",K1);class q1 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",q1);class _1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",_1);class X1 extends HTMLElement{#$=null;#Q=null;#J=null;#K;#j;#Z;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#K=this.#B.bind(this),this.#j=this.#A.bind(this),this.#Z=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.#Y(),this.#W(),this.#U(),this.#L(),this.#M(),this.open)this.#H()}disconnectedCallback(){if(this.#N(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#F();else this.#H();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#q(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#W(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#U(){if(this.#Q)this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false");if(this.#$)this.#$.addEventListener("click",this.#j),this.#$.addEventListener("keydown",this.#Z)}#N(){if(this.#Q)this.#Q.removeEventListener("click",this.#K);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#Z)}#L(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#q(),this.#Q)this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#$.anchor=this.#Q,this.#M()}}}),this.#J.observe(this,{childList:!0})}#G(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#M(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled","");else this.#Q.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.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.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}#H(){if(!this.#$)return;if(this.#$.open=!0,this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=0,requestAnimationFrame(()=>{let Q=this.#G();if(Q.length)Q[0].focus()})}#F(){if(!this.#$)return;this.#$.open=!1}}customElements.define("fig-menu",X1);
449
+ </fig-fill-picker>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#K),this.#$?.addEventListener("change",this.#j),this.#X()}#W=()=>{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"}#N(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.#N(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#q)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q)if(this.#Q.setAttribute("background",$),this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.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}))}#B(Q){Q.stopPropagation(),this.#M(Q.detail,"input")}#A(Q){Q.stopPropagation(),this.#M(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#Y();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",J1);class Z1 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",Z1);class j1 extends HTMLElement{#$=null;#Q=this.#B.bind(this);#J=this.#A.bind(this);#K=this.#R.bind(this);#j=null;#Z=null;#_=null;#X=null;#q=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#W(){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.#$}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;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#k(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#K),this.#D(),this.#H(),this.#E(),this.#z(),requestAnimationFrame(()=>{this.#L(),this.#R(),this.#N()})}#N(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#k(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#K),this.#P(),this.#j?.disconnect(),this.#j=null,this.#Z?.disconnect(),this.#Z=null,this.#F()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#G(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.#L());if(Q==="drag")if(this.#W)this.#H();else this.#P();if(Q==="overflow")this.#D()}#L(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#G($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#G(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#M(Q){let $=this.#U,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#B(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#M(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#O()}#A(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.#$),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.#M(document.activeElement);if(K&&K!==this.#$)this.selectedChoice=K,this.#O()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#O()}#O(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#R(){if(this.#Y==="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)}}#z(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#H(){if(this.#q?.bound)return;if(!this.#W)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)}#P(){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}#D(){if(this.#Y==="scrollbar")this.#F();else this.#S()}#F(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#S(){if(this.#_)return;let Q=()=>{let $=document.createElement("span");return $.className="fig-mask-icon fig-chooser-nav-chevron",$.style.setProperty("--icon","var(--icon-chevron)"),$.style.setProperty("--size","1rem"),$};this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),this.#_.appendChild(Q()),this.#X=document.createElement("button"),this.#X.className="fig-chooser-nav-end",this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-label","Scroll forward"),this.#X.appendChild(Q()),this.#_.addEventListener("pointerup",($)=>{$.stopPropagation(),this.#I(-1)}),this.#X.addEventListener("pointerup",($)=>{$.stopPropagation(),this.#I(1)}),this.prepend(this.#_),this.append(this.#X)}#I(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#k(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.scrollHeight>this.clientHeight,Z=this.scrollWidth>this.clientWidth;if(!Z&&!J)return;let j=Q.getBoundingClientRect(),K=this.getBoundingClientRect(),q={behavior:$};if(J){let _=j.top-K.top+this.scrollTop+j.height/2;q.top=_-this.clientHeight/2}if(Z){let _=j.left-K.left+this.scrollLeft+j.width/2;q.left=_-this.clientWidth/2}this.scrollTo(q)})}#E(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#L();else if(!this.#$&&Q.length)this.#L()}),this.#j.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",j1);class K1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","control","hit-area","hit-area-mode"];#$=!1;#Q=!1;#J=null;#K=!1;#j=null;#Z=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#Y(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#W(){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"}#N(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%")}#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,N,W)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(-W,Math.min(N-W,Y.px-W));let D=(typeof Y==="number"?Y:0)/100*N;return Math.max(-W,Math.min(N-W,D-W))},X=this.#W;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}}#H(){let Q=this.#z();if(!Q){if(this.#Z)this.#Z.remove(),this.#Z=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#Z){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#P(J)),this.prepend($),this.#Z=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#Z.style.borderRadius="50%";else this.#Z.style.borderRadius="inherit"}#P(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#Z)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#E(Q)}connectedCallback(){if(!this.hasAttribute("type"))this.setAttribute("type","canvas");this.#I(),this.#H(),this.addEventListener("click",this.#D),document.addEventListener("pointerdown",this.#F),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.#Z)this.#Z.remove(),this.#Z=null;this.removeEventListener("click",this.#D),document.removeEventListener("pointerdown",this.#F),document.removeEventListener("keydown",this.#S)}select(){if(this.hasAttribute("disabled"))return;if(this.setAttribute("selected",""),this.getAttribute("type")==="color"&&!this.#$)this.#C()}deselect(){this.removeAttribute("selected"),this.#w()}#D=(Q)=>{if(this.#X)return;if(this.#Q){this.#Q=!1;return}this.select()};#F=(Q)=>{if(this.#X)return;if(this.contains(Q.target))return;if(this.#j&&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.#j)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.#j&&J)this.#j.setAttribute("value",J)}if(Q==="drag")this.#I();if(Q==="hit-area")this.#H();if(Q==="value"&&!this.#K&&!this.#$)this.#A(J);if(Q==="control")if(this.#X)this.#w(),this.#C();else this.#w()}#I(){if(this.#Y&&!this.#J)this.#J=(Q)=>this.#E(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#k()}#k(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#E(Q){if(!this.#Y||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#W,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-_,N=Q.clientY-X,W=Q.clientX,G=Q.clientY,D=3,R=(M,O,A=!1)=>{let H=$.getBoundingClientRect();K=H;let T=parseFloat(this.style.left)||0,S=parseFloat(this.style.top)||0,f=M-Y-H.left-Z/2,I=O-N-H.top-j/2,c=Math.max(-Z/2,Math.min(H.width-Z/2,f)),o=Math.max(-j/2,Math.min(H.height-j/2,I)),h=H.width>0?((J.x?c:T)+Z/2)/H.width:0.5,g=H.height>0?((J.y?o:S)+j/2)/H.height:0.5;if(this.#N(A)){if(J.x)h=this.#L(h);if(J.y)g=this.#L(g);if(J.x&&J.y){let b=this.#G(h,g);h=b.x,g=b.y}}if(J.x){let b=h*H.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(H.width-Z/2,b)))}px`}if(J.y){let b=g*H.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(H.height-j/2,b)))}px`}},L=(M)=>{if(!this.#$)return;if(!this.#Q){let O=M.clientX-W,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.#Q=!0,R(M.clientX,M.clientY,M.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#b(K),shiftKey:M.shiftKey}}))},B=(M)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",B),this.#Q){R(M.clientX,M.clientY,M.shiftKey),this.#O(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#b(K)}));let O=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",O,{capture:!0,once:!0})}else this.#O();this.#Q=!1};window.addEventListener("pointermove",L),window.addEventListener("pointerup",B)}showColorTip(){if(this.#j){this.#j.style.display="";return}this.#C()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#C(){if(this.#j)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.#f),Q.addEventListener("change",this.#y),Q.addEventListener("add",this.#V),Q.addEventListener("remove",this.#V),this.appendChild(Q),this.#j=Q}#w(){if(!this.#j)return;this.#j.removeEventListener("input",this.#f),this.#j.removeEventListener("change",this.#y),this.#j.removeEventListener("add",this.#V),this.#j.removeEventListener("remove",this.#V),this.#j.remove(),this.#j=null}#T(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=i(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#f=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#T(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.#T(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#V=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#b(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",K1);class q1 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",q1);class _1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",_1);class X1 extends HTMLElement{#$=null;#Q=null;#J=null;#K;#j;#Z;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#K=this.#B.bind(this),this.#j=this.#A.bind(this),this.#Z=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.#Y(),this.#W(),this.#U(),this.#L(),this.#M(),this.open)this.#H()}disconnectedCallback(){if(this.#N(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#P();else this.#H();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#q(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#W(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#U(){if(this.#Q)this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false");if(this.#$)this.#$.addEventListener("click",this.#j),this.#$.addEventListener("keydown",this.#Z)}#N(){if(this.#Q)this.#Q.removeEventListener("click",this.#K);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#Z)}#L(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#q(),this.#Q)this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#$.anchor=this.#Q,this.#M()}}}),this.#J.observe(this,{childList:!0})}#G(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#M(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled","");else this.#Q.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.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.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}#H(){if(!this.#$)return;if(this.#$.open=!0,this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=0,requestAnimationFrame(()=>{let Q=this.#G();if(Q.length)Q[0].focus()})}#P(){if(!this.#$)return;this.#$.open=!1}}customElements.define("fig-menu",X1);