@rogieking/figui3 6.6.6 → 6.7.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
@@ -34,9 +34,9 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
34
34
  <${$} class="fig-button-control"${J}>
35
35
  <slot></slot>
36
36
  </${$}>
37
- `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#Z),this.button.addEventListener("blur",this.#q),this.addEventListener("keydown",this.#j)}this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#G()}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)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#_())return;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}}#K(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#Y(){let Q=this.#K();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#N(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let $=this.#Y();if(!$||$.disabled||$.multiple)return;if(typeof $.showPicker!=="function")return;Q.preventDefault();try{$.showPicker()}catch{}}#W(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,$)})}#G(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#L(),this.#W()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"type":{let Z=(j)=>j==="select"||j==="upload";if(Z($||"button")!==Z(J||"button")){this.button=null,this.connectedCallback();break}this.#G();break}case"disabled":this.#G();break;case"selected":this.#$=J!==null&&J!=="false",this.#W();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",R0);class H0 extends HTMLElement{#$="Menu";#Q=null;#j;#J;#Z;#q=!1;#_=null;get label(){return this.#$}set label(Q){this.#$=Q}#X;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#U.bind(this),this.#J=this.#B.bind(this),this.#Z=this.#M.bind(this),this.#X=this.slotChange.bind(this)}#K(){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}}#Y(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#K()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#_=Z}#N(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#Z)}#L(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#G(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.#O(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#X),this.optionsSlot.addEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#Y(),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.#z(this.value),this.#N(),this.type==="dropdown")this.select.selectedIndex=-1}#U(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#N(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#B(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#M(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}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","label","disabled"]}#O(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#z(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#N()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#z(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$);if(Q==="disabled")this.#O()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z)}}customElements.define("fig-dropdown",H0);class R extends HTMLElement{static#$=0;static#Q=null;static#j=500;static#J=null;#Z;#q;#_;#X;#K;#Y;#N;#W;#L;#G;#U=null;#B=null;#M=null;#O;#z=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#Z=this.#x.bind(this),this.#q=this.hidePopupOutsideClick.bind(this),this.#_=this.showDelayedPopup.bind(this),this.#X=this.#S.bind(this),this.#K=this.#C.bind(this),this.#Y=this.#f.bind(this),this.#N=this.#T.bind(this),this.#W=this.#E.bind(this),this.#G=this.#P.bind(this),this.#L=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.#R(),this.setupEventListeners(),this.#U=this.closest("dialog"),this.#U)this.#U.addEventListener("close",this.#L)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#H(),this.#F(),document.removeEventListener("mousedown",this.#Z,!0),document.removeEventListener("keydown",this.#G,!0),this.#U)this.#U.removeEventListener("close",this.#L),this.#U=null;if(this.action==="click")document.body.removeEventListener("click",this.#q);if(clearTimeout(this.#O),R.#J===this)R.#J=null}#D(){return this.firstElementChild}#F(){this.#M?.disconnect(),this.#M=null}#R(){if(this.#H(),this.action==="manual")return;let Q=this.#D();if(!Q){if(!this.#M&&typeof MutationObserver<"u")this.#M=new MutationObserver(()=>{if(this.#D())this.#F(),this.#R()}),this.#M.observe(this,{childList:!0});return}if(this.#B=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#_),Q.addEventListener("pointerleave",this.#X);Q.addEventListener("touchstart",this.#K,{passive:!0}),Q.addEventListener("touchmove",this.#Y,{passive:!0}),Q.addEventListener("touchend",this.#N,{passive:!0}),Q.addEventListener("touchcancel",this.#W,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#_),Q.addEventListener("touchstart",this.#_,{passive:!0})}#H(){let Q=this.#B;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#_),Q.removeEventListener("pointerleave",this.#X),Q.removeEventListener("touchstart",this.#K),Q.removeEventListener("touchmove",this.#Y),Q.removeEventListener("touchend",this.#N),Q.removeEventListener("touchcancel",this.#W);else if(this.action==="click")Q.removeEventListener("click",this.#_),Q.removeEventListener("touchstart",this.#_);this.#B=null}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","closerequest"),Q)this.popup.setAttribute("popover","manual");let J=y();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)(a()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(a()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.hidePopup?.(),this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#q)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#q);document.addEventListener("mousedown",this.#Z,!0),document.addEventListener("keydown",this.#G,!0)}get#A(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#A)return;clearTimeout(this.timeout);let $=R.#Q===this&&Date.now()-R.#$<R.#j?0:this.delay;this.timeout=setTimeout(()=>{this.render(),this.showPopup()},$)}showPopup(){if(this.#U&&!this.#U.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&R.#J&&R.#J!==this)R.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")R.#J=this;R.#$=Date.now(),R.#Q=this}hidePopup(){if(this.#A)return;if(clearTimeout(this.timeout),clearTimeout(this.#O),this.popup)this.destroy();if(this.isOpen=!1,R.#J===this)R.#J=null}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#S(Q){if(!this.#z)this.hidePopup()}#C(Q){if(this.action==="hover")this.#z=!0,clearTimeout(this.#O),this.showDelayedPopup()}#f(Q){if(this.action==="hover"&&this.#z)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#z=!1,this.hidePopup()},150)}#T(Q){if(this.action==="hover"&&this.#z)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#z=!1,this.hidePopup()},300)}#E(Q){if(this.action==="hover"&&this.#z)this.#z=!1,clearTimeout(this.#O),this.hidePopup()}#P(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#k(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.#k(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")}}#x(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#V=new WeakMap;static show(Q,$,J={}){R.hide(Q);let Z=J.delay??500,q=Date.now()-R.#$<R.#j?0:Z,_={timeout:null,popup:null};R.#V.set(Q,_),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=$,Y.append(K),X)(a()??document.body).append(Y);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(Y);else(a()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,R.#$=Date.now()},q)}static hide(Q){let $=R.#V.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();R.#V.delete(Q)}}customElements.define("fig-tooltip",R);class F0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#j=null;connectedCallback(){this.#$=this.textContent,v(this,()=>{this.#J(),this.#Z()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let _=$.lastIndexOf(J);Z=_>0?_:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;R.show(this,this.#$)},this.#j=()=>{R.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#j)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#j)this.removeEventListener("pointerleave",this.#j);R.hide(this)}}customElements.define("fig-truncate",F0);class P0 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),this._boundRestoreFocus=this._restoreFocus.bind(this),this._previousFocus=null}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(),v(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._syncA11y()}),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(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");Z+=X.height+K}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("aria-label","Close dialog"),Z.setAttribute("close-dialog",""),Z.appendChild(h("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let $=Q.getAttribute("id")||y();Q.setAttribute("id",$),this.setAttribute("aria-labelledby",$)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,_=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}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";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}j0("fig-dialog",P0,{extends:"dialog"});class T0 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)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");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=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}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}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,$,J){if(this._figInit(),$===J)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}j0("fig-toast",T0,{extends:"dialog"});class E0 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;_previousFocus=null;_boundDocumentKeydown;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&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),this._boundDocumentKeydown=this.handleDocumentKeydown.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._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&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);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"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),document.removeEventListener("keydown",this._boundDocumentKeydown,!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(P1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),$=this.resolveAnchor();if($?.classList)$.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch(J){}if(this.matches?.(":open"))try{this.close()}catch(J){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),$=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!$?.isConnected)return;let J=document.activeElement;if(J&&J!==document.body&&!this.contains(J))return;requestAnimationFrame(()=>$.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let Z=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(Z&&Z!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",_=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:_}}if($.length===1){let X=$[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if(J==="top")_=Q.top-$.height-j.yPx;else if(J==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")X=Q.left-$.width-j.xPx;else if(Z==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-$.width)/2;else if(Z==="left")X=Q.left+j.xPx;else if(Z==="right")X=Q.right-$.width-j.xPx;else X=Q.left+(Q.width-$.width)/2;return{top:_,left:X}}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"}lengthToPx(Q,$=0){let J=getComputedStyle(this),Z=String(Q||"").trim(),j=parseFloat(Z);if(!Number.isFinite(j))return $;if(Z.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(Z.endsWith("em"))return j*parseFloat(J.fontSize);return j}radiusForSide(Q){let $=getComputedStyle(this),J=(Z)=>this.lengthToPx(Z,0);if(Q==="top")return Math.max(J($.borderTopLeftRadius),J($.borderTopRightRadius));if(Q==="bottom")return Math.max(J($.borderBottomLeftRadius),J($.borderBottomRightRadius));if(Q==="left")return Math.max(J($.borderTopLeftRadius),J($.borderBottomLeftRadius));if(Q==="right")return Math.max(J($.borderTopRightRadius),J($.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let $=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+$/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let $=window.visualViewport,J=$?.width??window.innerWidth,Z=$?.height??window.innerHeight,j=$?.offsetLeft??0,q=$?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+J-Q.right,maxBottom:q+Z-Q.bottom}}clampToViewport(Q,$,J){let Z=this.getViewportBounds(J),j=Z.maxRight-$.width,q=Z.maxBottom-$.height;return{left:Math.min(j,Math.max(Z.minLeft,Q.left)),top:Math.min(q,Math.max(Z.minTop,Q.top))}}resolveCoordsAtViewport(Q,$,J,Z,j){let{left:q,top:_}=this.clampToViewport(J,$,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(Z),Y=this.getViewportBounds(j),K=Y.maxRight-$.width,N=Y.minLeft,B=Y.maxBottom-$.height,L=Y.minTop;if(X==="top"||X==="bottom"){let A=this.getBeakEdgeInset(X),G=Q.left+Q.width/2,U=G-q;if(U<A)q=G-A;else if(U>$.width-A)q=G-($.width-A);q=Math.min(K,Math.max(N,q))}else if(X==="left"||X==="right"){let A=this.getBeakEdgeInset(X),G=Q.top+Q.height/2,U=G-_;if(U<A)_=G-A;else if(U>$.height-A)_=G-($.height-A);_=Math.min(B,Math.max(L,_))}return{left:q,top:_}}canPointAtAnchor(Q,$,J,Z,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-J;return Y>=_-0.5&&Y<=$.width-_+0.5}let X=Q.top+Q.height/2-Z;return X>=_-0.5&&X<=$.height-_+0.5}updatePopoverBeak(Q,$,J,Z,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:$,N=K.left,B=K.top,L=this.getBeakEdgeInset(q),A;if(q==="top"||q==="bottom"){A=_-N;let G=L,U=Math.max(G,K.width-L);A=Math.min(U,Math.max(G,A))}else{A=X-B;let G=L,U=Math.max(G,K.height-L);A=Math.min(U,Math.max(G,A))}this.style.setProperty("--fig-popup-beak-offset",`${A}px`)}overflowScore(Q,$,J){let Z=this.getViewportBounds(J),j=Q.left+$.width,q=Q.top+$.height,_=Math.max(0,Z.minLeft-Q.left),X=Math.max(0,Z.minTop-Q.top),Y=Math.max(0,j-Z.maxRight),K=Math.max(0,q-Z.maxBottom);return _+X+Y+K}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J,Z=null,j="top"){if(Z)return this.resolveCoordsAtViewport(Z,$,Q,j,J);return this.clampToViewport(Q,$,J)}primaryAxisOverflowPenalty(Q,$,J,Z){let j=this.getViewportBounds(J),q=0;if(Z==="top")q=Math.max(0,j.minTop-Q.top);else if(Z==="bottom")q=Math.max(0,Q.top+$.height-j.maxBottom);else if(Z==="left")q=Math.max(0,j.minLeft-Q.left);else if(Z==="right")q=Math.max(0,Q.left+$.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,$,J,Z,j){let q=this.resolveCoordsAtViewport(Q,$,J,Z,j),_=this.overflowScore(q,$,j);if(_+=this.primaryAxisOverflowPenalty(J,$,j,Z),Q&&!this.canPointAtAnchor(Q,$,q.left,q.top,Z))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,$,J,Z,j){let q=this.resolveCoordsAtViewport(Q,$,J,Z,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,$,q.left,q.top,Z)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let L=this.getViewportBounds(_),A={left:L.minLeft+(L.maxRight-L.minLeft-Q.width)/2,top:L.minTop+(L.maxBottom-L.minTop-Q.height)/2},G=this.clampToViewport(A,Q,_);this.style.left=`${G.left}px`,this.style.top=`${G.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates(J,Z,j),K=null,N="top",B=Number.POSITIVE_INFINITY;for(let{v:L,h:A,s:G}of Y){let U=this.computeCoords(X,Q,L,A,$,G),F=this.getPlacementSide(L,A,G),{score:D,resolved:M}=this.placementScore(X,Q,U,F,_);if(G){let O=this.getViewportBounds(_);if((G==="left"||G==="right"?U.left>=O.minLeft&&U.left+Q.width<=O.maxRight:U.top>=O.minTop&&U.top+Q.height<=O.maxBottom)&&D<1e4){this.applyPopupPosition(X,Q,U,F,_);return}}else if(D===0){this.applyPopupPosition(X,Q,U,F,_);return}if(D<B)B=D,K=M,N=F}this.applyPopupPosition(X,Q,K||{left:0,top:0},N,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!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()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}j0("fig-popup",E0,{extends:"dialog"});class k0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),v(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),$=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",$),this.setAttribute("aria-controls",$),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),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","disabled"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this.setAttribute("tabindex",this.#$?"0":"-1"),this?.content)this.content.style.display=this.#$?"block":"none"}if(Q==="disabled")if(J!==null&&J!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#$?"0":"-1")}}customElements.define("fig-tab",k0);class C0 extends HTMLElement{#$;#Q;#j=this.#B.bind(this);#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.#U(),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),this.#Y.addEventListener("scroll",this.#j),this.#D(),this.#O(),this.#M(),v(this,()=>{let Q=this.getAttribute("value");if(Q)this.#A(Q);if(this.hasAttribute("disabled"))this.#N(!0);this.#L(),this.#B(),this.#G(void 0,"auto")})}get#Y(){return this.#q||this}get scrollLeft(){return this.#Y.scrollLeft}set scrollLeft(Q){this.#Y.scrollLeft=Q}get scrollWidth(){return this.#Y.scrollWidth}scrollTo(...Q){this.#Y.scrollTo(...Q)}scrollBy(...Q){this.#Y.scrollBy(...Q)}#N(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")}),this.#L()}#W(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-tab")),$=Q.find((J)=>J.hasAttribute("selected"))||this.#W()[0];Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false";J.setAttribute("tabindex",!Z&&J===$?"0":"-1")})}#G(Q=this.selectedTab,$="smooth"){let J=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#W()[0];if(!J)return;requestAnimationFrame(()=>{if(!this.isConnected||!J.isConnected)return;let Z=this.#Y;if(!(Z.scrollWidth>Z.clientWidth))return;let q=Z.getBoundingClientRect(),_=J.getBoundingClientRect(),X=_.left-q.left+Z.scrollLeft+_.width/2;Z.scrollTo({left:X-Z.clientWidth/2,behavior:$}),this.#B()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q),this.#Y.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#z()}#U(){if(this.#K)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]"),$=Q?Array.from(this.childNodes).filter((J)=>{if(J===Q)return!1;if(J.nodeType!==Node.ELEMENT_NODE)return!0;return!J.hasAttribute("data-fig-tabs-nav")}):null;if(Q&&Q===this.#q&&!$?.length)return;this.#K=!0;try{let J=this.#q;if(J&&J!==Q)J.removeEventListener("scroll",this.#j);let Z=Q||document.createElement("div");Z.className="fig-tabs-scroll",Z.dataset.figTabsScroll="";let j=$??Array.from(this.childNodes).filter((q)=>{if(q===Z)return!1;if(q.nodeType!==Node.ELEMENT_NODE)return!0;return!q.hasAttribute("data-fig-tabs-nav")});for(let q of j)Z.appendChild(q);if(!Q)this.prepend(Z);if(this.#q=Z,this.#q.removeEventListener("scroll",this.#j),this.#q.addEventListener("scroll",this.#j),this.#Z)this.#Z.observe(this.#q)}finally{this.#K=!1}}#B(){z0(this,this.#Y,"x")}#M(){if(this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>this.#B()),this.#Z.observe(this),this.#q)this.#Z.observe(this.#q)}#O(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#K)return;this.#U(),this.#D(),this.#L(),requestAnimationFrame(()=>{this.#B(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!0})}#z(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#D(){if(this.#_&&this.#X&&this.contains(this.#_)&&this.contains(this.#X))return;this.#_?.remove(),this.#X?.remove();let Q=A0({owner:"tabs",onStart:()=>Z0(this.#Y,"x",-1),onEnd:()=>Z0(this.#Y,"x",1)});this.#_=Q.start,this.#X=Q.end,this.prepend(this.#_),this.append(this.#X)}#F(Q){let $=this.#W();if(!$.length)return;let J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J>=0?J:0;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]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=this.#H($[Z]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");$[Z].focus(),this.#L(),this.#G($[Z]),this.#R()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#R(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let $=Q.getAttribute("value");if($!==null)return $;return Q.textContent?.trim()||""}#A(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(this.#H(J)===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected");this.#L(),this.#G(this.selectedTab)}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#A(J);break;case"disabled":this.#N(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.selectedTab,Z=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===$)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H($);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#L(),this.#G($),J!==$||Z!==this.value)this.#R()}}customElements.define("fig-tabs",C0);class S0 extends HTMLElement{#$;#Q;#j;constructor(){super();this.#j=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),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","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),$)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J,this.#J();break;case"disabled":this.#J();break}}}customElements.define("fig-segment",S0);class f0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#j=this.#U.bind(this);#J=null;#Z=null;#q=0;#_=!1;#X=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#D(),v(this,()=>{this.#R({enforceFallback:!0}),this.#F(),this.#O({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#X=!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.#L(),this.#O()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#K(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#Y(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#N(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-segment")),$=Q.find((J)=>J.hasAttribute("selected"));Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false",j=J===$;J.setAttribute("aria-checked",j?"true":"false"),J.setAttribute("tabindex",!Z&&j?"0":"-1")})}#G(Q){if(!Q)return;let $=this.selectedSegment,J=this.value;this.selectedSegment=Q;let Z=this.#Y(Q);if(Z)this.setAttribute("value",Z);else this.removeAttribute("value");let j=this.value;if($!==Q||J!==j)this.#K(j)}#U(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#W();if(!$.length)return;let J=$.findIndex((q)=>q.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=Z>0?Z-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=Z<$.length-1?Z+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#G(q);return}default:return}let j=$[Z];this.#G(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#B(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#Y(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#M(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#O({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#_;this.#_=!1,this.#z({forceInstant:$})})}#z({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#M(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#N();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#X=!1;return}if(!Z){if(this.#X)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#X)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#X||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#X=!0}#D(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#O()}),this.#F()}#F(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#R({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#O({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.#B(Z))return}let j=this.#N();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#H(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#F(),this.#R({enforceFallback:!0}),this.#L()}),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;this.#G($)}#A(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#L()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#A(J!==null&&J!=="false"),this.#O({forceInstant:!0});return}if(Q==="value"){this.#R({enforceFallback:!1});return}if(Q==="animated"){if(!this.#M())this.#X=!1;this.#O({forceInstant:!0});return}if(Q==="sizing")this.#O({forceInstant:!0})}}customElements.define("fig-segmented-control",f0);class I0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#j=null;#J=[];#Z=null;#q=!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)}#X(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let J=Q.querySelectorAll("fig-segment");if(J.length!==this.#J.length)return!1;return Array.from(J).every((Z,j)=>Z.getAttribute("value")===this.#J[j])}let $=this.querySelector(":scope > fig-dropdown");if($){let J=$.querySelectorAll("option");return J.length===this.#J.length&&Array.from(J).every((Z,j)=>Z.textContent?.trim()===this.#J[j])}return!1}#K(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#Z=Q,this.#$="segments";else this.#Z=this.querySelector(":scope > fig-dropdown"),this.#$="dropdown";this.#G()}connectedCallback(){if(this.#Y(),this.#X()){this.#K(),this.#B(),v(this,()=>v(this,()=>this.#z()));return}this.#N(),this.#B(),v(this,()=>v(this,()=>this.#z()))}disconnectedCallback(){this.#j?.disconnect(),this.#j=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#Y(),this.#L();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#U("disabled");return}if(Q==="full"){this.#U("full");return}if(Q==="sizing")this.#U("sizing"),this.#L()}#Y(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let $=Q.includes(`
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#Z),this.button.addEventListener("blur",this.#q),this.addEventListener("keydown",this.#j)}this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#G()}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)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#_())return;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}}#K(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#Y(){let Q=this.#K();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#N(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let $=this.#Y();if(!$||$.disabled||$.multiple)return;if(typeof $.showPicker!=="function")return;Q.preventDefault();try{$.showPicker()}catch{}}#W(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,$)})}#G(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#L(),this.#W()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"type":{let Z=(j)=>j==="select"||j==="upload";if(Z($||"button")!==Z(J||"button")){this.button=null,this.connectedCallback();break}this.#G();break}case"disabled":this.#G();break;case"selected":this.#$=J!==null&&J!=="false",this.#W();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",R0);class H0 extends HTMLElement{#$="Menu";#Q=null;#j;#J;#Z;#q=!1;#_=null;get label(){return this.#$}set label(Q){this.#$=Q}#X;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#U.bind(this),this.#J=this.#B.bind(this),this.#Z=this.#M.bind(this),this.#X=this.slotChange.bind(this)}#K(){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}}#Y(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#K()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#_=Z}#N(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#Z)}#L(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#G(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.#O(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#X),this.optionsSlot.addEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#Y(),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.#z(this.value),this.#N(),this.type==="dropdown")this.select.selectedIndex=-1}#U(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#N(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#B(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#M(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}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","label","disabled"]}#O(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#z(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#N()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#z(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$);if(Q==="disabled")this.#O()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z)}}customElements.define("fig-dropdown",H0);class R extends HTMLElement{static#$=0;static#Q=0;static#j=1000;static#J=null;#Z;#q;#_;#X;#K;#Y;#N;#W;#L;#G;#U=null;#B=null;#M=null;#O;#z=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#Z=this.#y.bind(this),this.#q=this.hidePopupOutsideClick.bind(this),this.#_=this.showDelayedPopup.bind(this),this.#X=this.#C.bind(this),this.#K=this.#f.bind(this),this.#Y=this.#T.bind(this),this.#N=this.#E.bind(this),this.#W=this.#P.bind(this),this.#G=this.#k.bind(this),this.#L=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.#R(),this.setupEventListeners(),this.#U=this.closest("dialog"),this.#U)this.#U.addEventListener("close",this.#L)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#H(),this.#F(),document.removeEventListener("mousedown",this.#Z,!0),document.removeEventListener("keydown",this.#G,!0),this.#U)this.#U.removeEventListener("close",this.#L),this.#U=null;if(this.action==="click")document.body.removeEventListener("click",this.#q);if(clearTimeout(this.#O),R.#J===this)R.#J=null}#D(){return this.firstElementChild}#F(){this.#M?.disconnect(),this.#M=null}#R(){if(this.#H(),this.action==="manual")return;let Q=this.#D();if(!Q){if(!this.#M&&typeof MutationObserver<"u")this.#M=new MutationObserver(()=>{if(this.#D())this.#F(),this.#R()}),this.#M.observe(this,{childList:!0});return}if(this.#B=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#_),Q.addEventListener("pointerleave",this.#X);Q.addEventListener("touchstart",this.#K,{passive:!0}),Q.addEventListener("touchmove",this.#Y,{passive:!0}),Q.addEventListener("touchend",this.#N,{passive:!0}),Q.addEventListener("touchcancel",this.#W,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#_),Q.addEventListener("touchstart",this.#_,{passive:!0})}#H(){let Q=this.#B;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#_),Q.removeEventListener("pointerleave",this.#X),Q.removeEventListener("touchstart",this.#K),Q.removeEventListener("touchmove",this.#Y),Q.removeEventListener("touchend",this.#N),Q.removeEventListener("touchcancel",this.#W);else if(this.action==="click")Q.removeEventListener("click",this.#_),Q.removeEventListener("touchstart",this.#_);this.#B=null}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","closerequest"),Q)this.popup.setAttribute("popover","manual");let J=y();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)(a()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(a()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.hidePopup?.(),this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#q)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#q);document.addEventListener("mousedown",this.#Z,!0),document.addEventListener("keydown",this.#G,!0)}get#A(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#S(){let Q=Date.now(),$=R.#j;if(this.action==="hover"&&R.#J)return!0;if(R.#$&&Q-R.#$<$)return!0;if(R.#Q&&Q-R.#Q<$)return!0;return!1}showDelayedPopup(){if(this.#A)return;if(clearTimeout(this.timeout),this.#S()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#U&&!this.#U.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&R.#J&&R.#J!==this)R.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")R.#J=this;R.#$=Date.now()}hidePopup(){if(this.#A)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,R.#J===this)R.#J=null;if(Q)R.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#C(Q){if(!this.#z)this.hidePopup()}#f(Q){if(this.action==="hover")this.#z=!0,clearTimeout(this.#O),this.showDelayedPopup()}#T(Q){if(this.action==="hover"&&this.#z)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#z=!1,this.hidePopup()},150)}#E(Q){if(this.action==="hover"&&this.#z)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#z=!1,this.hidePopup()},300)}#P(Q){if(this.action==="hover"&&this.#z)this.#z=!1,clearTimeout(this.#O),this.hidePopup()}#k(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#V(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.#V(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")}}#y(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#I=new WeakMap;static show(Q,$,J={}){R.hide(Q);let Z=J.delay??500,q=Date.now()-R.#$<R.#j?0:Z,_={timeout:null,popup:null};R.#I.set(Q,_),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=$,Y.append(K),X)(a()??document.body).append(Y);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(Y);else(a()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,R.#$=Date.now()},q)}static hide(Q){let $=R.#I.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();R.#I.delete(Q)}}customElements.define("fig-tooltip",R);class F0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#j=null;connectedCallback(){this.#$=this.textContent,v(this,()=>{this.#J(),this.#Z()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let _=$.lastIndexOf(J);Z=_>0?_:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;R.show(this,this.#$)},this.#j=()=>{R.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#j)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#j)this.removeEventListener("pointerleave",this.#j);R.hide(this)}}customElements.define("fig-truncate",F0);class P0 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),this._boundRestoreFocus=this._restoreFocus.bind(this),this._previousFocus=null}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(),v(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._syncA11y()}),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(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");Z+=X.height+K}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("aria-label","Close dialog"),Z.setAttribute("close-dialog",""),Z.appendChild(h("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let $=Q.getAttribute("id")||y();Q.setAttribute("id",$),this.setAttribute("aria-labelledby",$)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,_=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}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";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}j0("fig-dialog",P0,{extends:"dialog"});class T0 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)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");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=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}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}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,$,J){if(this._figInit(),$===J)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}j0("fig-toast",T0,{extends:"dialog"});class E0 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;_previousFocus=null;_boundDocumentKeydown;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&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),this._boundDocumentKeydown=this.handleDocumentKeydown.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._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&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);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"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),document.removeEventListener("keydown",this._boundDocumentKeydown,!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(P1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),$=this.resolveAnchor();if($?.classList)$.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch(J){}if(this.matches?.(":open"))try{this.close()}catch(J){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),$=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!$?.isConnected)return;let J=document.activeElement;if(J&&J!==document.body&&!this.contains(J))return;requestAnimationFrame(()=>$.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let Z=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(Z&&Z!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",_=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:_}}if($.length===1){let X=$[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if(J==="top")_=Q.top-$.height-j.yPx;else if(J==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")X=Q.left-$.width-j.xPx;else if(Z==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-$.width)/2;else if(Z==="left")X=Q.left+j.xPx;else if(Z==="right")X=Q.right-$.width-j.xPx;else X=Q.left+(Q.width-$.width)/2;return{top:_,left:X}}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"}lengthToPx(Q,$=0){let J=getComputedStyle(this),Z=String(Q||"").trim(),j=parseFloat(Z);if(!Number.isFinite(j))return $;if(Z.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(Z.endsWith("em"))return j*parseFloat(J.fontSize);return j}radiusForSide(Q){let $=getComputedStyle(this),J=(Z)=>this.lengthToPx(Z,0);if(Q==="top")return Math.max(J($.borderTopLeftRadius),J($.borderTopRightRadius));if(Q==="bottom")return Math.max(J($.borderBottomLeftRadius),J($.borderBottomRightRadius));if(Q==="left")return Math.max(J($.borderTopLeftRadius),J($.borderBottomLeftRadius));if(Q==="right")return Math.max(J($.borderTopRightRadius),J($.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let $=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+$/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let $=window.visualViewport,J=$?.width??window.innerWidth,Z=$?.height??window.innerHeight,j=$?.offsetLeft??0,q=$?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+J-Q.right,maxBottom:q+Z-Q.bottom}}clampToViewport(Q,$,J){let Z=this.getViewportBounds(J),j=Z.maxRight-$.width,q=Z.maxBottom-$.height;return{left:Math.min(j,Math.max(Z.minLeft,Q.left)),top:Math.min(q,Math.max(Z.minTop,Q.top))}}resolveCoordsAtViewport(Q,$,J,Z,j){let{left:q,top:_}=this.clampToViewport(J,$,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(Z),Y=this.getViewportBounds(j),K=Y.maxRight-$.width,N=Y.minLeft,B=Y.maxBottom-$.height,L=Y.minTop;if(X==="top"||X==="bottom"){let A=this.getBeakEdgeInset(X),G=Q.left+Q.width/2,U=G-q;if(U<A)q=G-A;else if(U>$.width-A)q=G-($.width-A);q=Math.min(K,Math.max(N,q))}else if(X==="left"||X==="right"){let A=this.getBeakEdgeInset(X),G=Q.top+Q.height/2,U=G-_;if(U<A)_=G-A;else if(U>$.height-A)_=G-($.height-A);_=Math.min(B,Math.max(L,_))}return{left:q,top:_}}canPointAtAnchor(Q,$,J,Z,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-J;return Y>=_-0.5&&Y<=$.width-_+0.5}let X=Q.top+Q.height/2-Z;return X>=_-0.5&&X<=$.height-_+0.5}updatePopoverBeak(Q,$,J,Z,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:$,N=K.left,B=K.top,L=this.getBeakEdgeInset(q),A;if(q==="top"||q==="bottom"){A=_-N;let G=L,U=Math.max(G,K.width-L);A=Math.min(U,Math.max(G,A))}else{A=X-B;let G=L,U=Math.max(G,K.height-L);A=Math.min(U,Math.max(G,A))}this.style.setProperty("--fig-popup-beak-offset",`${A}px`)}overflowScore(Q,$,J){let Z=this.getViewportBounds(J),j=Q.left+$.width,q=Q.top+$.height,_=Math.max(0,Z.minLeft-Q.left),X=Math.max(0,Z.minTop-Q.top),Y=Math.max(0,j-Z.maxRight),K=Math.max(0,q-Z.maxBottom);return _+X+Y+K}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J,Z=null,j="top"){if(Z)return this.resolveCoordsAtViewport(Z,$,Q,j,J);return this.clampToViewport(Q,$,J)}primaryAxisOverflowPenalty(Q,$,J,Z){let j=this.getViewportBounds(J),q=0;if(Z==="top")q=Math.max(0,j.minTop-Q.top);else if(Z==="bottom")q=Math.max(0,Q.top+$.height-j.maxBottom);else if(Z==="left")q=Math.max(0,j.minLeft-Q.left);else if(Z==="right")q=Math.max(0,Q.left+$.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,$,J,Z,j){let q=this.resolveCoordsAtViewport(Q,$,J,Z,j),_=this.overflowScore(q,$,j);if(_+=this.primaryAxisOverflowPenalty(J,$,j,Z),Q&&!this.canPointAtAnchor(Q,$,q.left,q.top,Z))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,$,J,Z,j){let q=this.resolveCoordsAtViewport(Q,$,J,Z,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,$,q.left,q.top,Z)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let L=this.getViewportBounds(_),A={left:L.minLeft+(L.maxRight-L.minLeft-Q.width)/2,top:L.minTop+(L.maxBottom-L.minTop-Q.height)/2},G=this.clampToViewport(A,Q,_);this.style.left=`${G.left}px`,this.style.top=`${G.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates(J,Z,j),K=null,N="top",B=Number.POSITIVE_INFINITY;for(let{v:L,h:A,s:G}of Y){let U=this.computeCoords(X,Q,L,A,$,G),F=this.getPlacementSide(L,A,G),{score:D,resolved:M}=this.placementScore(X,Q,U,F,_);if(G){let O=this.getViewportBounds(_);if((G==="left"||G==="right"?U.left>=O.minLeft&&U.left+Q.width<=O.maxRight:U.top>=O.minTop&&U.top+Q.height<=O.maxBottom)&&D<1e4){this.applyPopupPosition(X,Q,U,F,_);return}}else if(D===0){this.applyPopupPosition(X,Q,U,F,_);return}if(D<B)B=D,K=M,N=F}this.applyPopupPosition(X,Q,K||{left:0,top:0},N,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!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()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}j0("fig-popup",E0,{extends:"dialog"});class k0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),v(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),$=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",$),this.setAttribute("aria-controls",$),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),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","disabled"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this.setAttribute("tabindex",this.#$?"0":"-1"),this?.content)this.content.style.display=this.#$?"block":"none"}if(Q==="disabled")if(J!==null&&J!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#$?"0":"-1")}}customElements.define("fig-tab",k0);class C0 extends HTMLElement{#$;#Q;#j=this.#B.bind(this);#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.#U(),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),this.#Y.addEventListener("scroll",this.#j),this.#D(),this.#O(),this.#M(),v(this,()=>{let Q=this.getAttribute("value");if(Q)this.#A(Q);if(this.hasAttribute("disabled"))this.#N(!0);this.#L(),this.#B(),this.#G(void 0,"auto")})}get#Y(){return this.#q||this}get scrollLeft(){return this.#Y.scrollLeft}set scrollLeft(Q){this.#Y.scrollLeft=Q}get scrollWidth(){return this.#Y.scrollWidth}scrollTo(...Q){this.#Y.scrollTo(...Q)}scrollBy(...Q){this.#Y.scrollBy(...Q)}#N(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")}),this.#L()}#W(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-tab")),$=Q.find((J)=>J.hasAttribute("selected"))||this.#W()[0];Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false";J.setAttribute("tabindex",!Z&&J===$?"0":"-1")})}#G(Q=this.selectedTab,$="smooth"){let J=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#W()[0];if(!J)return;requestAnimationFrame(()=>{if(!this.isConnected||!J.isConnected)return;let Z=this.#Y;if(!(Z.scrollWidth>Z.clientWidth))return;let q=Z.getBoundingClientRect(),_=J.getBoundingClientRect(),X=_.left-q.left+Z.scrollLeft+_.width/2;Z.scrollTo({left:X-Z.clientWidth/2,behavior:$}),this.#B()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q),this.#Y.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#z()}#U(){if(this.#K)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]"),$=Q?Array.from(this.childNodes).filter((J)=>{if(J===Q)return!1;if(J.nodeType!==Node.ELEMENT_NODE)return!0;return!J.hasAttribute("data-fig-tabs-nav")}):null;if(Q&&Q===this.#q&&!$?.length)return;this.#K=!0;try{let J=this.#q;if(J&&J!==Q)J.removeEventListener("scroll",this.#j);let Z=Q||document.createElement("div");Z.className="fig-tabs-scroll",Z.dataset.figTabsScroll="";let j=$??Array.from(this.childNodes).filter((q)=>{if(q===Z)return!1;if(q.nodeType!==Node.ELEMENT_NODE)return!0;return!q.hasAttribute("data-fig-tabs-nav")});for(let q of j)Z.appendChild(q);if(!Q)this.prepend(Z);if(this.#q=Z,this.#q.removeEventListener("scroll",this.#j),this.#q.addEventListener("scroll",this.#j),this.#Z)this.#Z.observe(this.#q)}finally{this.#K=!1}}#B(){z0(this,this.#Y,"x")}#M(){if(this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>this.#B()),this.#Z.observe(this),this.#q)this.#Z.observe(this.#q)}#O(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#K)return;this.#U(),this.#D(),this.#L(),requestAnimationFrame(()=>{this.#B(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!0})}#z(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#D(){if(this.#_&&this.#X&&this.contains(this.#_)&&this.contains(this.#X))return;this.#_?.remove(),this.#X?.remove();let Q=A0({owner:"tabs",onStart:()=>Z0(this.#Y,"x",-1),onEnd:()=>Z0(this.#Y,"x",1)});this.#_=Q.start,this.#X=Q.end,this.prepend(this.#_),this.append(this.#X)}#F(Q){let $=this.#W();if(!$.length)return;let J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J>=0?J:0;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]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=this.#H($[Z]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");$[Z].focus(),this.#L(),this.#G($[Z]),this.#R()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#R(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let $=Q.getAttribute("value");if($!==null)return $;return Q.textContent?.trim()||""}#A(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(this.#H(J)===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected");this.#L(),this.#G(this.selectedTab)}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#A(J);break;case"disabled":this.#N(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.selectedTab,Z=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===$)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H($);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#L(),this.#G($),J!==$||Z!==this.value)this.#R()}}customElements.define("fig-tabs",C0);class S0 extends HTMLElement{#$;#Q;#j;constructor(){super();this.#j=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),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","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),$)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J,this.#J();break;case"disabled":this.#J();break}}}customElements.define("fig-segment",S0);class f0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#j=this.#U.bind(this);#J=null;#Z=null;#q=0;#_=!1;#X=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#D(),v(this,()=>{this.#R({enforceFallback:!0}),this.#F(),this.#O({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#X=!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.#L(),this.#O()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#K(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#Y(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#N(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-segment")),$=Q.find((J)=>J.hasAttribute("selected"));Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false",j=J===$;J.setAttribute("aria-checked",j?"true":"false"),J.setAttribute("tabindex",!Z&&j?"0":"-1")})}#G(Q){if(!Q)return;let $=this.selectedSegment,J=this.value;this.selectedSegment=Q;let Z=this.#Y(Q);if(Z)this.setAttribute("value",Z);else this.removeAttribute("value");let j=this.value;if($!==Q||J!==j)this.#K(j)}#U(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#W();if(!$.length)return;let J=$.findIndex((q)=>q.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=Z>0?Z-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=Z<$.length-1?Z+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#G(q);return}default:return}let j=$[Z];this.#G(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#B(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#Y(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#M(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#O({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#_;this.#_=!1,this.#z({forceInstant:$})})}#z({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#M(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#N();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#X=!1;return}if(!Z){if(this.#X)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#X)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#X||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#X=!0}#D(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#O()}),this.#F()}#F(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#R({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#O({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.#B(Z))return}let j=this.#N();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#H(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#F(),this.#R({enforceFallback:!0}),this.#L()}),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;this.#G($)}#A(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#L()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#A(J!==null&&J!=="false"),this.#O({forceInstant:!0});return}if(Q==="value"){this.#R({enforceFallback:!1});return}if(Q==="animated"){if(!this.#M())this.#X=!1;this.#O({forceInstant:!0});return}if(Q==="sizing")this.#O({forceInstant:!0})}}customElements.define("fig-segmented-control",f0);class I0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#j=null;#J=[];#Z=null;#q=!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)}#X(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let J=Q.querySelectorAll("fig-segment");if(J.length!==this.#J.length)return!1;return Array.from(J).every((Z,j)=>Z.getAttribute("value")===this.#J[j])}let $=this.querySelector(":scope > fig-dropdown");if($){let J=$.querySelectorAll("option");return J.length===this.#J.length&&Array.from(J).every((Z,j)=>Z.textContent?.trim()===this.#J[j])}return!1}#K(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#Z=Q,this.#$="segments";else this.#Z=this.querySelector(":scope > fig-dropdown"),this.#$="dropdown";this.#G()}connectedCallback(){if(this.#Y(),this.#X()){this.#K(),this.#B(),v(this,()=>v(this,()=>this.#z()));return}this.#N(),this.#B(),v(this,()=>v(this,()=>this.#z()))}disconnectedCallback(){this.#j?.disconnect(),this.#j=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#Y(),this.#L();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#U("disabled");return}if(Q==="full"){this.#U("full");return}if(Q==="sizing")this.#U("sizing"),this.#L()}#Y(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let $=Q.includes(`
38
38
  `)?`
39
- `:",";this.#J=Q.split($).map((J)=>J.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="segments"}#W(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="dropdown"}#L(){if(this.#$==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#z())});else this.#W()}#G(){if(!this.#Z||this.#q)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#U(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#B(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#z()}),this.#j.observe(this)}#M(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return J>Y+0.5}#O(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#M($))return!0;return!1}#z(){if(this.#J.length<=1)return;if(this.#$==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#O())this.#Q=this.clientWidth,this.#W()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#O())this.#W()})})}}customElements.define("fig-options",I0);class x0 extends HTMLElement{#$=!1;#Q=!1;#j=!1;#J="";#Z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#_;#X;#K;#Y;#N;#W;#L;#G=null;#U=null;#B=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#V()},this.#X=(Q)=>{Q.stopPropagation(),this.#y()},this.#N=(Q)=>{this.#w(Q)},this.#K=(Q)=>{Q.stopPropagation(),this.#R()},this.#Y=(Q)=>{Q.stopPropagation(),this.#b()},this.#W=()=>{this.#$=!0},this.#L=()=>{this.#$=!1}}#M(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];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=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#T(Q)}#O(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#z(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",this.#Q?"":String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#D(){if(this.#k(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.addEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.addEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L),this.input.addEventListener("pointerup",this.#L),this.default)this.style.setProperty("--default",this.#H(this.default));if(this.figInputNumber)this.#x(),this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.addEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y),this.figInputNumber.addEventListener("change",this.#Y)}#F(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);let Q="",$=`<div class="fig-slider-input-container" role="group">
39
+ `:",";this.#J=Q.split($).map((J)=>J.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="segments"}#W(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="dropdown"}#L(){if(this.#$==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#z())});else this.#W()}#G(){if(!this.#Z||this.#q)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#U(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#B(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#z()}),this.#j.observe(this)}#M(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return J>Y+0.5}#O(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#M($))return!0;return!1}#z(){if(this.#J.length<=1)return;if(this.#$==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#O())this.#Q=this.clientWidth,this.#W()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#O())this.#W()})})}}customElements.define("fig-options",I0);class x0 extends HTMLElement{#$=!1;#Q=!1;#j=!1;#J="";#Z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#_;#X;#K;#Y;#N;#W;#L;#G=null;#U=null;#B=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#y()},this.#X=(Q)=>{Q.stopPropagation(),this.#I()},this.#N=(Q)=>{this.#w(Q)},this.#K=(Q)=>{Q.stopPropagation(),this.#R()},this.#Y=(Q)=>{Q.stopPropagation(),this.#b()},this.#W=()=>{this.#$=!0},this.#L=()=>{this.#$=!1}}#M(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];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=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#T(Q)}#O(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#z(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",this.#Q?"":String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#D(){if(this.#k(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.addEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.addEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L),this.input.addEventListener("pointerup",this.#L),this.default)this.style.setProperty("--default",this.#H(this.default));if(this.figInputNumber)this.#V(),this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.addEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y),this.figInputNumber.addEventListener("change",this.#Y)}#F(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);let Q="",$=`<div class="fig-slider-input-container" role="group">
40
40
  <input
41
41
  type="range"
42
42
  ${this.text?'tabindex="-1"':""}
@@ -60,17 +60,17 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
60
60
  value="${this.#Q?"":this.value}"
61
61
  ${this.units?`units="${this.units}"`:""}
62
62
  ${this.precision!==null?`precision="${this.precision}"`:""}>
63
- </fig-input-number>`;else Q=$;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.#D(),this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=(this.max-this.min)/this.step+1;for(let Z=0;Z<J;Z++){let j=document.createElement("option");j.setAttribute("value",this.min+Z*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let J=this.datalist.querySelector(`option[value='${this.default}']`);if(J)J.setAttribute("default","true")}this.#P()}connectedCallback(){if(this.#O()){this.#z(),this.#D(),this.#P();return}this.#F()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#T(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#T($)):$;if(this.#J=Z,this.getAttribute("value")!==Z)this.#j=!0,this.setAttribute("value",Z),this.#j=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#E()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y)}#R(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#T(Q);this.value=$,this.input.value=String($),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#H(Q){let{min:$,max:J}=this.#S(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#A(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#S(){let Q=this.#A(this.min),$=this.#A(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#C(Q){let{min:$,max:J}=this.#S();return Math.min(J,Math.max($,Q))}#f(){if(this.type==="delta"){let $=this.#A(this.default);if($!==null)return this.#C($);return this.#C(0)}if(this.type==="range"){let{min:$,max:J}=this.#S();return this.#C($+(J-$)/2)}let{min:Q}=this.#S();return Q}#T(Q){let $=this.#A(Q);if($===null)return this.#f();return this.#C($)}#E(){let Q=this.#H(this.value),$=this.#H(this.default),J=Q===$?1:0;if(this.#G!==Q)this.style.setProperty("--slider-complete",Q),this.#G=Q;if(this.#U!==$)this.style.setProperty("--default",$),this.#U=$;if(this.#B!==J)this.style.setProperty("--unchanged",J),this.#B=J}#P(){let Q=this.input.value;if(this.value=Q,this.#E(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#k(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#x();return}this.input.removeAttribute("aria-hidden"),this.#Z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#x(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,$)})}#V(){this.#Q=!1,this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(){this.#$=!1,this.#Q=!1,this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let $=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,J=this.#A(this.input.value)??this.#f(),Z=this.#A(this.step)??1,j=this.#T(J+Z*10*$);this.value=j,this.input.value=String(j),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#T(Q);this.value=$,this.input.value=String($),this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#T(J),this.input.value=String(this.value),this.#P(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#E();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#F();break;case"text":this.text=J!=="false",this.#F();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#k();break;default:this[Q]=this.input[Q]=J,this.#P();break}}}customElements.define("fig-slider",x0);class V0 extends HTMLElement{#$=!1;#Q=!1;#j;#J;#Z;#q;#_;#X;#K;#Y=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#D.bind(this),this.#J=this.#R.bind(this),this.#Z=this.#R.bind(this),this.#q=this.#F.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#z(Q)},this.#X=()=>{this.#U()},this.#K=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#N(),this.input.readOnly=this.readonly,this.#W(),this.#L(),this.#G(),this.#U(),this.#B(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#O(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#O(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#O(this.step));this.addEventListener("pointerdown",this.#q)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}focus(){this.input.focus()}#N(){let Q=this.multiline,$=this.querySelector("input,textarea");if($){if(Q?$.tagName==="TEXTAREA":$.tagName==="INPUT")return $}let J=`<input
63
+ </fig-input-number>`;else Q=$;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.#D(),this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=(this.max-this.min)/this.step+1;for(let Z=0;Z<J;Z++){let j=document.createElement("option");j.setAttribute("value",this.min+Z*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let J=this.datalist.querySelector(`option[value='${this.default}']`);if(J)J.setAttribute("default","true")}this.#P()}connectedCallback(){if(this.#O()){this.#z(),this.#D(),this.#P();return}this.#F()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#T(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#T($)):$;if(this.#J=Z,this.getAttribute("value")!==Z)this.#j=!0,this.setAttribute("value",Z),this.#j=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#E()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y)}#R(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#T(Q);this.value=$,this.input.value=String($),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#H(Q){let{min:$,max:J}=this.#S(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#A(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#S(){let Q=this.#A(this.min),$=this.#A(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#C(Q){let{min:$,max:J}=this.#S();return Math.min(J,Math.max($,Q))}#f(){if(this.type==="delta"){let $=this.#A(this.default);if($!==null)return this.#C($);return this.#C(0)}if(this.type==="range"){let{min:$,max:J}=this.#S();return this.#C($+(J-$)/2)}let{min:Q}=this.#S();return Q}#T(Q){let $=this.#A(Q);if($===null)return this.#f();return this.#C($)}#E(){let Q=this.#H(this.value),$=this.#H(this.default),J=Q===$?1:0;if(this.#G!==Q)this.style.setProperty("--slider-complete",Q),this.#G=Q;if(this.#U!==$)this.style.setProperty("--default",$),this.#U=$;if(this.#B!==J)this.style.setProperty("--unchanged",J),this.#B=J}#P(){let Q=this.input.value;if(this.value=Q,this.#E(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#k(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#V();return}this.input.removeAttribute("aria-hidden"),this.#Z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#V(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,$)})}#y(){this.#Q=!1,this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#I(){this.#$=!1,this.#Q=!1,this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let $=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,J=this.#A(this.input.value)??this.#f(),Z=this.#A(this.step)??1,j=this.#T(J+Z*10*$);this.value=j,this.input.value=String(j),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#T(Q);this.value=$,this.input.value=String($),this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#T(J),this.input.value=String(this.value),this.#P(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#E();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#F();break;case"text":this.text=J!=="false",this.#F();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#k();break;default:this[Q]=this.input[Q]=J,this.#P();break}}}customElements.define("fig-slider",x0);class V0 extends HTMLElement{#$=!1;#Q=!1;#j;#J;#Z;#q;#_;#X;#K;#Y=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#D.bind(this),this.#J=this.#R.bind(this),this.#Z=this.#R.bind(this),this.#q=this.#F.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#z(Q)},this.#X=()=>{this.#U()},this.#K=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#N(),this.input.readOnly=this.readonly,this.#W(),this.#L(),this.#G(),this.#U(),this.#B(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#O(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#O(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#O(this.step));this.addEventListener("pointerdown",this.#q)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}focus(){this.input.focus()}#N(){let Q=this.multiline,$=this.querySelector("input,textarea");if($){if(Q?$.tagName==="TEXTAREA":$.tagName==="INPUT")return $}let J=`<input
64
64
  type="${this.type}"
65
65
  ${this.name?`name="${this.name}"`:""}
66
66
  placeholder="${this.placeholder}"
67
67
  value="${this.type==="number"?this.#O(this.value):this.value}" />`;if(Q)J=`<textarea
68
- placeholder="${this.placeholder}">${this.value}</textarea>`;let Z=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=J,j)j.removeEventListener("click",this.#K),j.addEventListener("click",this.#K),this.prepend(j);if(Z)Z.removeEventListener("click",this.#K),Z.addEventListener("click",this.#K),this.append(Z);return this.querySelector("input,textarea")}#W(){if(!this.input)return;this.#Y.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#L(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q){let Z=Q.querySelector("fig-icon");if(Z&&Z.getAttribute("name")!=="search")Z.setAttribute("name","search");return}let J=h("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.#K),this.prepend(J)}#G(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=h("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#U(),this.focus()})}#U(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#B(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#M(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=h("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#M(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#M(J),this.focus()})}#M(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#O(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#A($),$}#z(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#H($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#R();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#H(J,!1);let Z=J*(this.transform||1);J=this.#A(J),Z=this.#A(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}))}#F(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#j),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#Z)}#R(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}#H(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#O(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#O(this.max):this.max,J);J=this.#A(J)}return J}#A(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","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}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.#O(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#H(Z,!1),this.value=Z,this.input.value=this.#O(Z);else this.value=Z,this.input.value=Z;this.#U();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#L(),this.#G(),this.#U(),this.#B();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#W();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",V0);class n extends HTMLElement{#$;#Q;#j;#J;#Z;#q;#_;#X;#K;#Y;#N;#W;#L;#G;#U;#B=!1;#M=null;#O=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#z="px";#D(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#F(Q){let $=(Q||"").trim();if(!$)return"";return(this.#L??[]).includes($.toLowerCase())?"":$}#R(){this.#N=this.#F(this.#W)}#H(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||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#S(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null;this.#A()}#A(){if(!this.#M)return;let Q=this.#M.querySelector(".fig-stepper-up"),$=this.#M.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#E(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&Z<=this.min,X=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||X,$.disabled=q||_}#S(Q){let $=this.step||1,J=this.#E(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#I(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#h.bind(this),this.#Q=this.#v.bind(this),this.#j=this.#v.bind(this),this.#J=this.#g.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#b(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#w(Q)},this.#_=(Q)=>{this.#x(Q)},this.#X=(Q)=>{this.#V(Q)},this.#K=(Q)=>{this.#y(Q)},this.#Y=this.focus.bind(this)}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.#L=this.#D($===null?n.#z:$),this.#R(),this.#G=this.getAttribute("unit-position")||"suffix",this.#U=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";if(this.input=this.#C(),this.#f(),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.#H(J),this.hasAttribute("disabled")){let Z=this.getAttribute("disabled");this.disabled=this.input.disabled=Z!=="false"}this.#A(),this.#T(),this.addEventListener("pointerdown",this.#J),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#C(){let Q=this.querySelector("input");if(Q)return Q;let $=`<input
68
+ placeholder="${this.placeholder}">${this.value}</textarea>`;let Z=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=J,j)j.removeEventListener("click",this.#K),j.addEventListener("click",this.#K),this.prepend(j);if(Z)Z.removeEventListener("click",this.#K),Z.addEventListener("click",this.#K),this.append(Z);return this.querySelector("input,textarea")}#W(){if(!this.input)return;this.#Y.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#L(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q){let Z=Q.querySelector("fig-icon");if(Z&&Z.getAttribute("name")!=="search")Z.setAttribute("name","search");return}let J=h("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.#K),this.prepend(J)}#G(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=h("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#U(),this.focus()})}#U(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#B(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#M(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=h("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#M(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#M(J),this.focus()})}#M(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#O(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#A($),$}#z(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#H($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#R();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#H(J,!1);let Z=J*(this.transform||1);J=this.#A(J),Z=this.#A(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}))}#F(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#j),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#Z)}#R(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}#H(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#O(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#O(this.max):this.max,J);J=this.#A(J)}return J}#A(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","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}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.#O(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#H(Z,!1),this.value=Z,this.input.value=this.#O(Z);else this.value=Z,this.input.value=Z;this.#U();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#L(),this.#G(),this.#U(),this.#B();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#W();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",V0);class n extends HTMLElement{#$;#Q;#j;#J;#Z;#q;#_;#X;#K;#Y;#N;#W;#L;#G;#U;#B=!1;#M=null;#O=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#z="px";#D(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#F(Q){let $=(Q||"").trim();if(!$)return"";return(this.#L??[]).includes($.toLowerCase())?"":$}#R(){this.#N=this.#F(this.#W)}#H(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||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#S(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null;this.#A()}#A(){if(!this.#M)return;let Q=this.#M.querySelector(".fig-stepper-up"),$=this.#M.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#E(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&Z<=this.min,X=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||X,$.disabled=q||_}#S(Q){let $=this.step||1,J=this.#E(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#x(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#h.bind(this),this.#Q=this.#v.bind(this),this.#j=this.#v.bind(this),this.#J=this.#g.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#b(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#w(Q)},this.#_=(Q)=>{this.#V(Q)},this.#X=(Q)=>{this.#y(Q)},this.#K=(Q)=>{this.#I(Q)},this.#Y=this.focus.bind(this)}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.#L=this.#D($===null?n.#z:$),this.#R(),this.#G=this.getAttribute("unit-position")||"suffix",this.#U=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";if(this.input=this.#C(),this.#f(),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.#H(J),this.hasAttribute("disabled")){let Z=this.getAttribute("disabled");this.disabled=this.input.disabled=Z!=="false"}this.#A(),this.#T(),this.addEventListener("pointerdown",this.#J),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#C(){let Q=this.querySelector("input");if(Q)return Q;let $=`<input
69
69
  type="text"
70
70
  inputmode="decimal"
71
71
  ${this.name?`name="${this.name}"`:""}
72
72
  placeholder="${this.placeholder}"
73
- value="${this.#P(this.value)}" />`,J=this.querySelector("[slot=append]"),Z=this.querySelector("[slot=prepend]");if(this.innerHTML=$,Z)Z.removeEventListener("click",this.#Y),Z.addEventListener("click",this.#Y),this.prepend(Z);if(J)J.removeEventListener("click",this.#Y),J.addEventListener("click",this.#Y),this.append(J);return this.querySelector("input")}#f(){if(!this.input)return;this.#O.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#T(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#P(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#E(Q){if(!Q)return"";if(!this.#N){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#N,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#m($),!this.#N)return $.toString();if(this.#G==="prefix")return this.#N+$;else return $+this.#N}#k(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#m($),$.toString()}#x(Q){this.#B=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#N)if(this.#G==="prefix")Q.target.setSelectionRange(this.#N.length,$.length);else{let J=$.indexOf(this.#N);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#V(Q){this.#B=!1;let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(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.#E(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#I(q,!1),this.value=q,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){let $=this.#E(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#b(Q){Q.stopPropagation();let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q){if(this.disabled)return;if(Q.buttons===0){this.#v();return}let $=(this.step||1)*Q.movementX,J=this.#E(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#I(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#B=!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)}#v(Q){this.#B=!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.#m(J),J}#m(Q){let $=this.#U??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","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#A();break;case"units":this.#W=J||"",this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"units-disallow":this.#L=this.#D(J===null?n.#z:J),this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"unit-position":this.#G=J||"suffix",this.input.value=this.#P(this.value),this.#T();break;case"transform":this.transform=Number(J)||1,this.input.value=this.#P(this.value),this.#T();break;case"value":if(this.#B)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#I(Z,!1);this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#A(),this.#T();break}this[Q]=Number(J),this.#A(),this.#T();break;case"steppers":{let j=J!==null&&J!=="false";this.#H(j);break}case"precision":this.#U=J!==null?Number(J):2,this.input.value=this.#P(this.value),this.#T();break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#f();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",n);class y0 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),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",y0);class w0 extends HTMLElement{#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=null;constructor(){super();this.#J=this.focus.bind(this),this.#Z=this.#X.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(this.isConnected)this.#_()})}#_(){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){if(!this.#Q||!this.#Q.isConnected)this.#Q=h("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#j=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else if(this.input&&this.label)this.label.removeEventListener("click",this.#J),this.label.addEventListener("click",this.#J);if(this.input&&this.label&&!this.#$)this.#Y();if(this.label)this.label.removeEventListener("pointerenter",this.#Z),this.label.addEventListener("pointerenter",this.#Z),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.label)R.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#Z)this.label.removeEventListener("pointerenter",this.#Z);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#X(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;R.show(this.label,this.label.textContent.trim())}#K(){if(this.label)R.hide(this.label)}#Y(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let $=this.input.querySelectorAll("input, select, textarea");if($.length===1){let J=$[0],Z=J.getAttribute("id")||y();if(J.setAttribute("id",Z),this.label.setAttribute("for",Z),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J,this.#Y();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",w0);class b0 extends HTMLElement{rgba;hex;#$=100;#Q;#j;#J;#Z;#q=!1;#_=!1;#X=null;#K=this.#T.bind(this);#Y=this.#E.bind(this);#N=this.#P.bind(this);#W=this.#h.bind(this);#L=this.#x.bind(this);#G=this.#y.bind(this);#U=this.#V.bind(this);#B=this.#g.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#M(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#O(){let Q=this.#M();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#z()){this.#D();return}this.#H()}disconnectedCallback(){this.#F()}#z(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-chit")}#D(){if(this.#k(this.getAttribute("value")),this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("value",String(this.#$));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#R()}#F(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.removeEventListener("click",this.#Y,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#N),this.#Q.removeEventListener("input",this.#W);this.#J?.removeEventListener("input",this.#L),this.#J?.removeEventListener("change",this.#G),this.#Z?.removeEventListener("input",this.#U),this.#Z?.removeEventListener("change",this.#G),this.#j?.removeEventListener("input",this.#B),this.#j?.removeEventListener("change",this.#G)}#R(){if(this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.addEventListener("click",this.#Y,{capture:!0}),Q?.addEventListener("keydown",this.#N),this.#Q.addEventListener("input",this.#W)}if(this.#J)this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#G);if(this.#Z)this.#Z.addEventListener("input",this.#U),this.#Z.addEventListener("change",this.#G);if(this.#j)this.#j.addEventListener("input",this.#B),this.#j.addEventListener("change",this.#G)}#H(){this.#k(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#m?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
73
+ value="${this.#P(this.value)}" />`,J=this.querySelector("[slot=append]"),Z=this.querySelector("[slot=prepend]");if(this.innerHTML=$,Z)Z.removeEventListener("click",this.#Y),Z.addEventListener("click",this.#Y),this.prepend(Z);if(J)J.removeEventListener("click",this.#Y),J.addEventListener("click",this.#Y),this.append(J);return this.querySelector("input")}#f(){if(!this.input)return;this.#O.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#T(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#P(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#E(Q){if(!Q)return"";if(!this.#N){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#N,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#m($),!this.#N)return $.toString();if(this.#G==="prefix")return this.#N+$;else return $+this.#N}#k(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#m($),$.toString()}#V(Q){this.#B=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#N)if(this.#G==="prefix")Q.target.setSelectionRange(this.#N.length,$.length);else{let J=$.indexOf(this.#N);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#y(Q){this.#B=!1;let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#x(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(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.#E(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#x(q,!1),this.value=q,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){let $=this.#E(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#b(Q){Q.stopPropagation();let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#x(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q){if(this.disabled)return;if(Q.buttons===0){this.#v();return}let $=(this.step||1)*Q.movementX,J=this.#E(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#x(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#B=!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)}#v(Q){this.#B=!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)}#x(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.#m(J),J}#m(Q){let $=this.#U??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","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#A();break;case"units":this.#W=J||"",this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"units-disallow":this.#L=this.#D(J===null?n.#z:J),this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"unit-position":this.#G=J||"suffix",this.input.value=this.#P(this.value),this.#T();break;case"transform":this.transform=Number(J)||1,this.input.value=this.#P(this.value),this.#T();break;case"value":if(this.#B)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#x(Z,!1);this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#A(),this.#T();break}this[Q]=Number(J),this.#A(),this.#T();break;case"steppers":{let j=J!==null&&J!=="false";this.#H(j);break}case"precision":this.#U=J!==null?Number(J):2,this.input.value=this.#P(this.value),this.#T();break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#f();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",n);class y0 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),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",y0);class w0 extends HTMLElement{#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=null;constructor(){super();this.#J=this.focus.bind(this),this.#Z=this.#X.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(this.isConnected)this.#_()})}#_(){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){if(!this.#Q||!this.#Q.isConnected)this.#Q=h("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#j=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else if(this.input&&this.label)this.label.removeEventListener("click",this.#J),this.label.addEventListener("click",this.#J);if(this.input&&this.label&&!this.#$)this.#Y();if(this.label)this.label.removeEventListener("pointerenter",this.#Z),this.label.addEventListener("pointerenter",this.#Z),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.label)R.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#Z)this.label.removeEventListener("pointerenter",this.#Z);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#X(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;R.show(this.label,this.label.textContent.trim())}#K(){if(this.label)R.hide(this.label)}#Y(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let $=this.input.querySelectorAll("input, select, textarea");if($.length===1){let J=$[0],Z=J.getAttribute("id")||y();if(J.setAttribute("id",Z),this.label.setAttribute("for",Z),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J,this.#Y();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",w0);class b0 extends HTMLElement{rgba;hex;#$=100;#Q;#j;#J;#Z;#q=!1;#_=!1;#X=null;#K=this.#T.bind(this);#Y=this.#E.bind(this);#N=this.#P.bind(this);#W=this.#h.bind(this);#L=this.#V.bind(this);#G=this.#I.bind(this);#U=this.#y.bind(this);#B=this.#g.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#M(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#O(){let Q=this.#M();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#z()){this.#D();return}this.#H()}disconnectedCallback(){this.#F()}#z(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-chit")}#D(){if(this.#k(this.getAttribute("value")),this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("value",String(this.#$));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#R()}#F(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.removeEventListener("click",this.#Y,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#N),this.#Q.removeEventListener("input",this.#W);this.#J?.removeEventListener("input",this.#L),this.#J?.removeEventListener("change",this.#G),this.#Z?.removeEventListener("input",this.#U),this.#Z?.removeEventListener("change",this.#G),this.#j?.removeEventListener("input",this.#B),this.#j?.removeEventListener("change",this.#G)}#R(){if(this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.addEventListener("click",this.#Y,{capture:!0}),Q?.addEventListener("keydown",this.#N),this.#Q.addEventListener("input",this.#W)}if(this.#J)this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#G);if(this.#Z)this.#Z.addEventListener("input",this.#U),this.#Z.addEventListener("change",this.#G);if(this.#j)this.#j.addEventListener("input",this.#B),this.#j.addEventListener("change",this.#G)}#H(){this.#k(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#m?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
74
74
  type="text"
75
75
  placeholder="000000"
76
76
  value="${this.hexOpaque.slice(1).toUpperCase()}"${J}>
@@ -85,7 +85,7 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
85
85
  </fig-tooltip>`;let _="";_=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`,Z=`<div class="input-combo">
86
86
  ${_}
87
87
  ${q}
88
- </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;if(this.innerHTML=Z,this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#b(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#R()}#A(){if(!this.#j)return;for(let[Q,$]of Object.entries(this.#M()))this.#j.setAttribute(Q,$);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled");this.#j.anchorElement=this,this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#S(){if(!p())return null;if(this.#j?.isConnected)return this.#A(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#g.bind(this)),Q.addEventListener("change",this.#y.bind(this)),this.appendChild(Q),this.#j=Q,this.#A(),Q}#C(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#S();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#f(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#T(Q){if(!p())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#X=null},500),this.#f(Q)}#E(Q){if(!this.#q)return;if(this.#q=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#f(Q),this.#_)this.#_=!1,this.#C()}#P(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!p())return;if(!this.#C())return;this.#f(Q)}#k(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#x(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#k("#"+$),this.#Z)this.#Z.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#v()}#V(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#k(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#v()}#y(Q){Q.stopPropagation(),this.#I()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#w(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Z=this.getAttribute("aria-labelledby"),j=this.#w();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if($)this.#J.setAttribute("aria-invalid",$);else this.#J.removeAttribute("aria-invalid");if(J)this.#J.setAttribute("aria-required",J);else this.#J.removeAttribute("aria-required")}if(this.#Z){if(this.#Z.setAttribute("aria-label",`${j} opacity`),Q)this.#Z.setAttribute("aria-describedby",Q);else this.#Z.removeAttribute("aria-describedby");if($)this.#Z.setAttribute("aria-invalid",$);else this.#Z.removeAttribute("aria-invalid");if(J)this.#Z.setAttribute("aria-required",J);else this.#Z.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(Z)q.setAttribute("aria-labelledby",Z),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#h(Q){if(Q.stopPropagation(),this.#k(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#v()}#g(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#k(J),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#v()}}#v(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#I(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#k(J),this.#J)this.#J.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#Z)this.#Z.setAttribute("value",this.#$);break;case"mode":this.#A();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#p();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#p(){let Q=this.#m;for(let $ of[this.#Q,this.#J,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#b(),this.#j)this.#A()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)$=J=Z=Y;else{let K=(L,A,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return L+(A-L)*6*G;if(G<0.5)return A;if(G<0.6666666666666666)return L+(A-L)*(0.6666666666666666-G)*6;return L},N=Y<0.5?Y*(1+X):Y+X-Y*X,B=2*Y-N;$=K(B,N,_+0.3333333333333333),J=K(B,N,_),Z=K(B,N,_-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",b0);var T1=["srgb","srgb-linear","display-p3","oklab","oklch"],E1=["shorter","longer","increasing","decreasing"];function i(Q){let $={...Q??{}},J=String($.interpolationSpace??"srgb").toLowerCase();if(!T1.includes(J))J="srgb";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=E1.includes(Z)?Z:"shorter",$}function v0(Q){let $=i(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function h0(Q){let $=i(Q);if($.interpolationSpace==="srgb")return"";if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function c(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function g(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function u(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function t(Q,$,J){let Z=g(Q),j=g($),q=g(J),_=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function B0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,_=Z*Z*Z,X=j*j*j,Y=q*q*q;return{r:u(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:u(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:u(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function O0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function k1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function C1(Q,$,J,Z){let j=(Q%360+360)%360,_=($%360+360)%360-j;switch(Z){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*J)%360+360)%360}function S1(Q,$,J,Z){let j=[...Q].sort((D,M)=>D.position-M.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,N=K>0?(q-X.position)/K:0,B=c(X.color),L=c(Y.color),A,G,U,F=J||"oklab";if(F==="srgb-linear"){let D=g(B.r),M=g(B.g),O=g(B.b),P=g(L.r),k=g(L.g),S=g(L.b);A=u(D+(P-D)*N),G=u(M+(k-M)*N),U=u(O+(S-O)*N)}else if(F==="oklch"){let D=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=O0(D.l,D.a,D.b),P=O0(M.l,M.a,M.b),k=O.l+(P.l-O.l)*N,S=O.c+(P.c-O.c)*N,I=C1(O.h,P.h,N,Z||"shorter"),C=k1(k,S,I),w=B0(C.l,C.a,C.b);A=w.r,G=w.g,U=w.b}else{let D=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=D.l+(M.l-D.l)*N,P=D.a+(M.a-D.a)*N,k=D.b+(M.b-D.b)*N,S=B0(O,P,k);A=S.r,G=S.g,U=S.b}return`#${A.toString(16).padStart(2,"0")}${G.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class g0 extends HTMLElement{#$="solid";#Q;#j;#J;#Z={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#Y(),this.#B()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#J=null}#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#q=i({...this.#q,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#N(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#W(){switch(this.#$){case"solid":return this.#Z.color;case"gradient":{let $=[...this.#q.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:_}=c(J.color);return`rgba(${j}, ${q}, ${_}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${h0(this.#q)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#L(){switch(this.#$){case"solid":return this.#Z.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#G(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let $ of[this.#Q,this.#j,this.#J]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#U(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#G();let Q=this.getAttribute("aria-label")||"Fill",$=this.getAttribute("aria-describedby"),J=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),$)q.setAttribute("aria-describedby",$);else q.removeAttribute("aria-describedby");if(J)q.setAttribute("aria-invalid",J);else q.removeAttribute("aria-invalid");if(Z)q.setAttribute("aria-required",Z);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#B(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(_)=>J?`<fig-tooltip text="Opacity">
88
+ </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;if(this.innerHTML=Z,this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#b(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#R()}#A(){if(!this.#j)return;for(let[Q,$]of Object.entries(this.#M()))this.#j.setAttribute(Q,$);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled");this.#j.anchorElement=this,this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#S(){if(!p())return null;if(this.#j?.isConnected)return this.#A(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#g.bind(this)),Q.addEventListener("change",this.#I.bind(this)),this.appendChild(Q),this.#j=Q,this.#A(),Q}#C(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#S();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#f(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#T(Q){if(!p())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#X=null},500),this.#f(Q)}#E(Q){if(!this.#q)return;if(this.#q=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#f(Q),this.#_)this.#_=!1,this.#C()}#P(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!p())return;if(!this.#C())return;this.#f(Q)}#k(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#V(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#k("#"+$),this.#Z)this.#Z.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#v()}#y(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#k(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#v()}#I(Q){Q.stopPropagation(),this.#x()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#w(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Z=this.getAttribute("aria-labelledby"),j=this.#w();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if($)this.#J.setAttribute("aria-invalid",$);else this.#J.removeAttribute("aria-invalid");if(J)this.#J.setAttribute("aria-required",J);else this.#J.removeAttribute("aria-required")}if(this.#Z){if(this.#Z.setAttribute("aria-label",`${j} opacity`),Q)this.#Z.setAttribute("aria-describedby",Q);else this.#Z.removeAttribute("aria-describedby");if($)this.#Z.setAttribute("aria-invalid",$);else this.#Z.removeAttribute("aria-invalid");if(J)this.#Z.setAttribute("aria-required",J);else this.#Z.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(Z)q.setAttribute("aria-labelledby",Z),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#h(Q){if(Q.stopPropagation(),this.#k(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#v()}#g(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#k(J),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#v()}}#v(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#x(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#k(J),this.#J)this.#J.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#Z)this.#Z.setAttribute("value",this.#$);break;case"mode":this.#A();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#p();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#p(){let Q=this.#m;for(let $ of[this.#Q,this.#J,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#b(),this.#j)this.#A()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)$=J=Z=Y;else{let K=(L,A,G)=>{if(G<0)G+=1;if(G>1)G-=1;if(G<0.16666666666666666)return L+(A-L)*6*G;if(G<0.5)return A;if(G<0.6666666666666666)return L+(A-L)*(0.6666666666666666-G)*6;return L},N=Y<0.5?Y*(1+X):Y+X-Y*X,B=2*Y-N;$=K(B,N,_+0.3333333333333333),J=K(B,N,_),Z=K(B,N,_-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",b0);var T1=["srgb","srgb-linear","display-p3","oklab","oklch"],E1=["shorter","longer","increasing","decreasing"];function i(Q){let $={...Q??{}},J=String($.interpolationSpace??"srgb").toLowerCase();if(!T1.includes(J))J="srgb";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=E1.includes(Z)?Z:"shorter",$}function v0(Q){let $=i(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function h0(Q){let $=i(Q);if($.interpolationSpace==="srgb")return"";if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function c(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function g(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function u(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function t(Q,$,J){let Z=g(Q),j=g($),q=g(J),_=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function B0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,_=Z*Z*Z,X=j*j*j,Y=q*q*q;return{r:u(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:u(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:u(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function O0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function k1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function C1(Q,$,J,Z){let j=(Q%360+360)%360,_=($%360+360)%360-j;switch(Z){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*J)%360+360)%360}function S1(Q,$,J,Z){let j=[...Q].sort((D,M)=>D.position-M.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,N=K>0?(q-X.position)/K:0,B=c(X.color),L=c(Y.color),A,G,U,F=J||"oklab";if(F==="srgb-linear"){let D=g(B.r),M=g(B.g),O=g(B.b),P=g(L.r),k=g(L.g),S=g(L.b);A=u(D+(P-D)*N),G=u(M+(k-M)*N),U=u(O+(S-O)*N)}else if(F==="oklch"){let D=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=O0(D.l,D.a,D.b),P=O0(M.l,M.a,M.b),k=O.l+(P.l-O.l)*N,S=O.c+(P.c-O.c)*N,I=C1(O.h,P.h,N,Z||"shorter"),C=k1(k,S,I),w=B0(C.l,C.a,C.b);A=w.r,G=w.g,U=w.b}else{let D=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=D.l+(M.l-D.l)*N,P=D.a+(M.a-D.a)*N,k=D.b+(M.b-D.b)*N,S=B0(O,P,k);A=S.r,G=S.g,U=S.b}return`#${A.toString(16).padStart(2,"0")}${G.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class g0 extends HTMLElement{#$="solid";#Q;#j;#J;#Z={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#Y(),this.#B()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#J=null}#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#q=i({...this.#q,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#N(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#W(){switch(this.#$){case"solid":return this.#Z.color;case"gradient":{let $=[...this.#q.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:_}=c(J.color);return`rgba(${j}, ${q}, ${_}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${h0(this.#q)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#L(){switch(this.#$){case"solid":return this.#Z.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#G(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let $ of[this.#Q,this.#j,this.#J]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#U(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#G();let Q=this.getAttribute("aria-label")||"Fill",$=this.getAttribute("aria-describedby"),J=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),$)q.setAttribute("aria-describedby",$);else q.removeAttribute("aria-describedby");if(J)q.setAttribute("aria-invalid",J);else q.removeAttribute("aria-invalid");if(Z)q.setAttribute("aria-required",Z);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#B(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(_)=>J?`<fig-tooltip text="Opacity">
89
89
  <fig-input-number
90
90
  class="fig-input-fill-opacity"
91
91
  placeholder="##"
@@ -183,12 +183,12 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
183
183
  units="%"
184
184
  ${Q?"disabled":""}>
185
185
  </fig-input-number>
186
- </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",_),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#U(),X&&this.#Q)X.addEventListener("click",()=>{let Y=this.#Q.querySelector("fig-chit");if(Y)Y.click()});if(this.#J)this.#J.addEventListener("input",(Y)=>{Y.stopPropagation();let K="#"+Y.target.value.replace("#","");this.#Z.color=K,this.#D(),this.#R()}),this.#J.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()});if(this.#j)this.#j.addEventListener("input",(Y)=>{Y.stopPropagation();let K=parseFloat(Y.target.value),B=(isNaN(K)?100:K)/100;switch(this.#$){case"solid":this.#Z.alpha=B;break;case"gradient":break;case"image":this.#_.opacity=B;break;case"video":this.#X.opacity=B;break;case"webcam":this.#K.opacity=B;break}this.#D(),this.#F(B),this.#R()}),this.#j.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()})}#D(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#F(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:v0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#B();else this.#D(),this.#O();break;case"disabled":this.#G();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#U();break}}}customElements.define("fig-input-fill",g0);class m0 extends HTMLElement{#$=[];#Q=[];#j=[];#J=null;#Z=this.#K.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#Z),this.addEventListener("keydown",this.#Z),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{if(this.#J=null,!this.isConnected)return;this.#Y(),this.#N()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#Z),this.#Q=[],this.#j=[]}#K(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#O();break;case"disabled":this.#z();break;case"min":case"max":case"fixed":this.#N();break;case"open":break}}#Y(){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))}#N(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let $=document.createElement("div");$.className="palette-colors-inline",$.setAttribute("role","button"),$.setAttribute("aria-expanded",String(this.open)),$.setAttribute("aria-label","Edit palette colors");let J=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,$.setAttribute("aria-expanded","true")};$.addEventListener("click",J),$.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),J()});let Z=document.createElement("div");if(Z.className="palette-colors",this.#$.forEach((q,_)=>{Z.appendChild(this.#W(q,_,Q,{inline:!0}))}),$.appendChild(Z),this.appendChild($),!this.#q)this.#U(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#$.forEach((q,_)=>{if(j.appendChild(this.#W(q,_,Q)),!this.#q)j.appendChild(this.#L(_,Q))}),this.appendChild(j)}#W(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let _=Z?this.#j:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#$[$]={color:K.hexOpaque||this.#$[$].color,alpha:K.rgba?K.rgba.a:this.#$[$].alpha};let N=_[$];if(N){let B=this.#$[$],L=B.alpha<1?B.color+Math.round(B.alpha*255).toString(16).padStart(2,"0"):B.color;N.setAttribute("value",L)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#F()}),q.addEventListener("change",(Y)=>{X(Y),this.#R()}),Z)this.#Q.push(q);else this.#j.push(q);return q}#L(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.#_)J.setAttribute("disabled","");J.appendChild(h("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#_)return;this.#$.splice(Q,1),this.#Q=[],this.#j=[],this.#N(),this.#R()}#U(Q,$=this){let J=this.#$.length>=this.#X,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(h("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#X)return;this.open=!0,this.#B({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#B(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#W(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#W(Q,J,$),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#L(J,$));if(this.#$.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#D($),this.#R()}#M(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)}#O(){if(this.#Q.length!==this.#$.length){this.#N();return}this.#$.forEach((Q,$)=>{this.#M($)})}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#X)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#D(Q)}#D(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",m0);class r extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#j=!1;#J=null;#Z=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#K(){return this.#X==="true"}get#Y(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#N(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#W(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#K?"-1":"0")}#L(Q){return{...i(Q),type:"linear",angle:90}}connectedCallback(){if(this.#B(),this.#R(),this.removeEventListener("keydown",this.#U),this.addEventListener("keydown",this.#U),this.#K)document.addEventListener("keydown",this.#G)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#G),this.removeEventListener("keydown",this.#U),this.#Z)this.#Z.disconnect(),this.#Z=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#T),this.removeEventListener("pointermove",this.#P),this.removeEventListener("pointerleave",this.#E),this.removeEventListener("click",this.#V),this.removeEventListener("dblclick",this.#x)}#G=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),Y=this.#_.stops[_];Y.position=Math.max(0,Math.min(100,Y.position+X)),q.setAttribute("value",`${Y.position}% 50%`);let K=q.closest("fig-tooltip");if(K)K.text=`${Math.round(Y.position)}%`,K.setAttribute("show","true"),K.showPopup(),q.hideColorTip(),clearTimeout(this.#J),this.#J=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#I(),this.#p(),this.#d();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#_.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.#_.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#b(),this.#I(),this.#p(),this.#d()};#U=(Q)=>{if(this.#X!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let $=this.querySelector("fig-fill-picker");if(!$||typeof $.open!=="function")return;Q.preventDefault(),$.open()};#B(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#_=this.#L({...this.#_,...$.gradient});return}if($?.gradient)this.#_=this.#L({...this.#_,...$.gradient})}catch($){}}#M(){let Q=this.#L(this.#_),J=[...Q.stops].sort((q,_)=>q.position-_.position).map((q)=>{let _=(q.opacity??100)/100;if(_>=1)return`${q.color} ${q.position}%`;let{r:X,g:Y,b:K}=c(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),Z=h0(Q),j=Z?` ${Z}`:"";return`linear-gradient(${Q.angle}deg${j}, ${J})`}#O(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=c(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#z(){let Q=this.hasAttribute("disabled"),$=this.#Y==="tip"?' tip="color"':"";return this.#_.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#O(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#D=null;#F=!1;#R(){let Q=this.hasAttribute("disabled"),$=this.#X;if($==="picker"&&p()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
186
+ </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",_),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#U(),X&&this.#Q)X.addEventListener("click",()=>{let Y=this.#Q.querySelector("fig-chit");if(Y)Y.click()});if(this.#J)this.#J.addEventListener("input",(Y)=>{Y.stopPropagation();let K="#"+Y.target.value.replace("#","");this.#Z.color=K,this.#D(),this.#R()}),this.#J.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()});if(this.#j)this.#j.addEventListener("input",(Y)=>{Y.stopPropagation();let K=parseFloat(Y.target.value),B=(isNaN(K)?100:K)/100;switch(this.#$){case"solid":this.#Z.alpha=B;break;case"gradient":break;case"image":this.#_.opacity=B;break;case"video":this.#X.opacity=B;break;case"webcam":this.#K.opacity=B;break}this.#D(),this.#F(B),this.#R()}),this.#j.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()})}#D(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#F(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:v0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#B();else this.#D(),this.#O();break;case"disabled":this.#G();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#U();break}}}customElements.define("fig-input-fill",g0);class m0 extends HTMLElement{#$=[];#Q=[];#j=[];#J=null;#Z=this.#K.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#Z),this.addEventListener("keydown",this.#Z),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{if(this.#J=null,!this.isConnected)return;this.#Y(),this.#N()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#Z),this.#Q=[],this.#j=[]}#K(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#O();break;case"disabled":this.#z();break;case"min":case"max":case"fixed":this.#N();break;case"open":break}}#Y(){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))}#N(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let $=document.createElement("div");$.className="palette-colors-inline",$.setAttribute("role","button"),$.setAttribute("aria-expanded",String(this.open)),$.setAttribute("aria-label","Edit palette colors");let J=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,$.setAttribute("aria-expanded","true")};$.addEventListener("click",J),$.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),J()});let Z=document.createElement("div");if(Z.className="palette-colors",this.#$.forEach((q,_)=>{Z.appendChild(this.#W(q,_,Q,{inline:!0}))}),$.appendChild(Z),this.appendChild($),!this.#q)this.#U(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#$.forEach((q,_)=>{if(j.appendChild(this.#W(q,_,Q)),!this.#q)j.appendChild(this.#L(_,Q))}),this.appendChild(j)}#W(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let _=Z?this.#j:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#$[$]={color:K.hexOpaque||this.#$[$].color,alpha:K.rgba?K.rgba.a:this.#$[$].alpha};let N=_[$];if(N){let B=this.#$[$],L=B.alpha<1?B.color+Math.round(B.alpha*255).toString(16).padStart(2,"0"):B.color;N.setAttribute("value",L)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#F()}),q.addEventListener("change",(Y)=>{X(Y),this.#R()}),Z)this.#Q.push(q);else this.#j.push(q);return q}#L(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.#_)J.setAttribute("disabled","");J.appendChild(h("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#_)return;this.#$.splice(Q,1),this.#Q=[],this.#j=[],this.#N(),this.#R()}#U(Q,$=this){let J=this.#$.length>=this.#X,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(h("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#X)return;this.open=!0,this.#B({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#B(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#W(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#W(Q,J,$),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#L(J,$));if(this.#$.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#D($),this.#R()}#M(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)}#O(){if(this.#Q.length!==this.#$.length){this.#N();return}this.#$.forEach((Q,$)=>{this.#M($)})}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#X)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#D(Q)}#D(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",m0);class r extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#j=!1;#J=null;#Z=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#K(){return this.#X==="true"}get#Y(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#N(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#W(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#K?"-1":"0")}#L(Q){return{...i(Q),type:"linear",angle:90}}connectedCallback(){if(this.#B(),this.#R(),this.removeEventListener("keydown",this.#U),this.addEventListener("keydown",this.#U),this.#K)document.addEventListener("keydown",this.#G)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#G),this.removeEventListener("keydown",this.#U),this.#Z)this.#Z.disconnect(),this.#Z=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#T),this.removeEventListener("pointermove",this.#P),this.removeEventListener("pointerleave",this.#E),this.removeEventListener("click",this.#y),this.removeEventListener("dblclick",this.#V)}#G=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),Y=this.#_.stops[_];Y.position=Math.max(0,Math.min(100,Y.position+X)),q.setAttribute("value",`${Y.position}% 50%`);let K=q.closest("fig-tooltip");if(K)K.text=`${Math.round(Y.position)}%`,K.setAttribute("show","true"),K.showPopup(),q.hideColorTip(),clearTimeout(this.#J),this.#J=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#x(),this.#p(),this.#d();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#_.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.#_.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#b(),this.#x(),this.#p(),this.#d()};#U=(Q)=>{if(this.#X!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let $=this.querySelector("fig-fill-picker");if(!$||typeof $.open!=="function")return;Q.preventDefault(),$.open()};#B(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#_=this.#L({...this.#_,...$.gradient});return}if($?.gradient)this.#_=this.#L({...this.#_,...$.gradient})}catch($){}}#M(){let Q=this.#L(this.#_),J=[...Q.stops].sort((q,_)=>q.position-_.position).map((q)=>{let _=(q.opacity??100)/100;if(_>=1)return`${q.color} ${q.position}%`;let{r:X,g:Y,b:K}=c(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),Z=h0(Q),j=Z?` ${Z}`:"";return`linear-gradient(${Q.angle}deg${j}, ${J})`}#O(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=c(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#z(){let Q=this.hasAttribute("disabled"),$=this.#Y==="tip"?' tip="color"':"";return this.#_.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#O(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#D=null;#F=!1;#R(){let Q=this.hasAttribute("disabled"),$=this.#X;if($==="picker"&&p()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
187
187
  <fig-fill-picker mode="gradient"${Z} value='${j}'${Q?" disabled":""}>
188
188
  <fig-chit background="${this.#M()}"${Q?" disabled":""}></fig-chit>
189
189
  </fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#H(),this.#W();return}if(this.innerHTML=`
190
190
  <fig-chit background="${this.#M()}"${Q?" disabled":""}></fig-chit>
191
- ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#z()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#S(),this.#m();this.#W()}#H(){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.#_=this.#L({...this.#_,...Z.gradient}),this.#I()};Q.addEventListener("input",(J)=>{$(J),this.#p()}),Q.addEventListener("change",(J)=>{$(J),this.#d()})}#A(Q){return S1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#Y==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#D=Q,this.addEventListener("pointerenter",this.#T),this.addEventListener("pointermove",this.#P),this.addEventListener("pointerleave",this.#E),this.addEventListener("click",this.#V),this.addEventListener("dblclick",this.#x)}#C(){if(!this.#D)return;this.#D.style.opacity="1"}#f(){if(!this.#D)return;this.#D.style.opacity="0"}#T=()=>{if(this.#j)return;this.#C()};#E=()=>{this.#f()};#P=(Q)=>{if(this.#j){this.#f();return}if(!this.#D||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#f();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#D.style.left=`${J*100}%`;let Z=this.#A(J);this.#D.setAttribute("color",Z),this.#C()};#k(){let Q=this.#_.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#_.stops[$].position=Math.round($/(Q-1)*100);this.#b(),this.#I(),this.#p(),this.#d()}#x=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#k(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#V=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#F){this.#F=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#k(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.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.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===Z&&_.color===j);this.#b(),this.#I(),this.#p(),this.#d(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#y(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#y()}#w(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#y())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops;if(Q.length!==$.length){let J=this.#D;if(this.#Q.innerHTML=this.#z(),J)this.#Q.appendChild(J);this.#h(),this.#g(),this.#w();return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#O(j)),this.#Y==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#h()}#h(){if(!this.#Q)return;let Q=this.#Y==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#D)if(Q)this.#D.setAttribute("tip","add");else this.#D.removeAttribute("tip")}#g(){if(!this.#Z||!this.#Q)return;this.#Z.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#v(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<$.length;X++){if(J.has(X))continue;if($[X].position===j&&$[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<$.length;Y++){if(J.has(Y))continue;let K=Math.abs($[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)J.add(_),Z.dataset.stopIndex=_})}#I(){if(!this.#$)return;this.#$.setAttribute("background",this.#M())}#m(){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.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===Z&&Y.color===j);this.#F=!0,this.#b(),this.#I(),this.#p(),this.#f();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.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 Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#O(this.#_.stops[Y])),this.#I(),this.#p()}return}if(!this.#j)$.style.zIndex="5";this.#j=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===J)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[J].position=q,q!==j)$.style.left=`${q/100*_}px`;let X=$.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),$.hideColorTip()}this.#I(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#O(this.#_.stops[Y])),this.#I(),this.#d()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===Z)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[Z].position=q,$.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#v(),this.#I(),this.#d(),requestAnimationFrame(()=>{this.#j=!1})}),this.#Z=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[Z].color)this.#_.stops[Z].color=j,this.#I(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:v0(this.#L(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#K){let $=this.#N();if($){$.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#B(),this.#I(),this.#b();break;case"disabled":this.#s();break;case"edit":if(this.#R(),this.#K)document.addEventListener("keydown",this.#G);else document.removeEventListener("keydown",this.#G);break;case"mode":this.#h();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#W(),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 e 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",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","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);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();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(){}#J(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Z(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#J("checked"),$=this.#J("indeterminate")&&!Q,J=this.#J("disabled");if(this.input.checked=Q,this.input.indeterminate=$,this.input.disabled=J,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),$)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Z()}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.#J("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",J||this.name);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.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Z(),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",e);class p0 extends e{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",p0);class u0 extends e{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",u0);class c0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#X=this.#B.bind(this);#K=this.#M.bind(this);#Y=this.#O.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#W(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#j=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#A()}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#N())this.#W(),this.#G();else this.#L(),this.#G();if(this.hasAttribute("disabled"))this.#S(!0)}disconnectedCallback(){this.#U()}#L(){let Q=this.#F(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#H(),_=this.#$?"":`<fig-dropdown type="dropdown" label="${q}"${j}>${Q.map((X)=>`<option>${X.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
191
+ ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#z()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#S(),this.#m();this.#W()}#H(){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.#_=this.#L({...this.#_,...Z.gradient}),this.#x()};Q.addEventListener("input",(J)=>{$(J),this.#p()}),Q.addEventListener("change",(J)=>{$(J),this.#d()})}#A(Q){return S1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#Y==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#D=Q,this.addEventListener("pointerenter",this.#T),this.addEventListener("pointermove",this.#P),this.addEventListener("pointerleave",this.#E),this.addEventListener("click",this.#y),this.addEventListener("dblclick",this.#V)}#C(){if(!this.#D)return;this.#D.style.opacity="1"}#f(){if(!this.#D)return;this.#D.style.opacity="0"}#T=()=>{if(this.#j)return;this.#C()};#E=()=>{this.#f()};#P=(Q)=>{if(this.#j){this.#f();return}if(!this.#D||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#f();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#D.style.left=`${J*100}%`;let Z=this.#A(J);this.#D.setAttribute("color",Z),this.#C()};#k(){let Q=this.#_.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#_.stops[$].position=Math.round($/(Q-1)*100);this.#b(),this.#x(),this.#p(),this.#d()}#V=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#k(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#y=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#F){this.#F=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#k(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.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.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===Z&&_.color===j);this.#b(),this.#x(),this.#p(),this.#d(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#I(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#I()}#w(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#I())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops;if(Q.length!==$.length){let J=this.#D;if(this.#Q.innerHTML=this.#z(),J)this.#Q.appendChild(J);this.#h(),this.#g(),this.#w();return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#O(j)),this.#Y==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#h()}#h(){if(!this.#Q)return;let Q=this.#Y==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#D)if(Q)this.#D.setAttribute("tip","add");else this.#D.removeAttribute("tip")}#g(){if(!this.#Z||!this.#Q)return;this.#Z.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#v(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<$.length;X++){if(J.has(X))continue;if($[X].position===j&&$[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<$.length;Y++){if(J.has(Y))continue;let K=Math.abs($[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)J.add(_),Z.dataset.stopIndex=_})}#x(){if(!this.#$)return;this.#$.setAttribute("background",this.#M())}#m(){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.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===Z&&Y.color===j);this.#F=!0,this.#b(),this.#x(),this.#p(),this.#f();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.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 Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#O(this.#_.stops[Y])),this.#x(),this.#p()}return}if(!this.#j)$.style.zIndex="5";this.#j=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===J)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[J].position=q,q!==j)$.style.left=`${q/100*_}px`;let X=$.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),$.hideColorTip()}this.#x(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#O(this.#_.stops[Y])),this.#x(),this.#d()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===Z)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[Z].position=q,$.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#v(),this.#x(),this.#d(),requestAnimationFrame(()=>{this.#j=!1})}),this.#Z=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[Z].color)this.#_.stops[Z].color=j,this.#x(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:v0(this.#L(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#K){let $=this.#N();if($){$.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#B(),this.#x(),this.#b();break;case"disabled":this.#s();break;case"edit":if(this.#R(),this.#K)document.addEventListener("keydown",this.#G);else document.removeEventListener("keydown",this.#G);break;case"mode":this.#h();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#W(),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 e 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",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","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);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();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(){}#J(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Z(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#J("checked"),$=this.#J("indeterminate")&&!Q,J=this.#J("disabled");if(this.input.checked=Q,this.input.indeterminate=$,this.input.disabled=J,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),$)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Z()}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.#J("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",J||this.name);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.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Z(),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",e);class p0 extends e{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",p0);class u0 extends e{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",u0);class c0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#X=this.#B.bind(this);#K=this.#M.bind(this);#Y=this.#O.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#W(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#j=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#A()}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#N())this.#W(),this.#G();else this.#L(),this.#G();if(this.hasAttribute("disabled"))this.#S(!0)}disconnectedCallback(){this.#U()}#L(){let Q=this.#F(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#H(),_=this.#$?"":`<fig-dropdown type="dropdown" label="${q}"${j}>${Q.map((X)=>`<option>${X.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
192
192
  <fig-input-text placeholder="${$}" value="${J}"></fig-input-text>
193
193
  <fig-button type="select" variant="input" icon>
194
194
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -196,7 +196,7 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
196
196
  </svg>
197
197
  ${_}
198
198
  </fig-button>
199
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$&&this.#Z&&this.#J){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(!this.#Z.hasAttribute("label"))this.#Z.setAttribute("label",q);if(Z)this.#Z.setAttribute("experimental",Z);this.#J.append(this.#Z)}this.#j=this.querySelector("fig-dropdown"),this.#A()}#G(){this.#U(),this.#j?.addEventListener("input",this.#X),this.#Q?.addEventListener("input",this.#K),this.#Q?.addEventListener("change",this.#Y)}#U(){this.#j?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("input",this.#K),this.#Q?.removeEventListener("change",this.#Y)}#B(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#Q)this.#Q.setAttribute("value",$);this.#z(),this.#D()}#M(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#z()}#O(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#D()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#F(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#R(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#H(){return`${this.#R()} options`}#A(){if(this.#Q)this.#_.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#H())}#S(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#j&&!this.#$){let Z=this.#F();this.#j.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");this.#A();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#S(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;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break}}}customElements.define("fig-combo-input",c0);class _0 extends HTMLElement{#$="color";#Q=null;#j=!1;constructor(){super();this.#Q=this.#Y.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#X(),this.#J(),this.#K()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=q0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#Z(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#q(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q);this.#K()}else this.innerHTML="<div></div>",this.input=null,this.#K()}else if(this.#$==="color"&&this.input){let q=this.#q(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let $=this.getAttribute("aria-labelledby"),J=this.getAttribute("aria-label")||"Color swatch",Z=this.getAttribute("aria-describedby");if($)this.input.setAttribute("aria-labelledby",$),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",J),this.input.removeAttribute("aria-labelledby");if(Z)this.input.setAttribute("aria-describedby",Z);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#Y(Q){this.#j=!0,this.setAttribute("background",Q.target.value),this.#j=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#j){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")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",_0);class d0 extends _0{}customElements.define("fig-swatch",d0);class Q0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=this.#y.bind(this);#K=this.#b.bind(this);#Y=this.#h.bind(this);#N=this.#g.bind(this);#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#O=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#F(),this.#H(),this.#C(),this.#A(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#x()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#X),this.#D(),this.#k(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#q=null}#D(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#K),this.#Q.removeEventListener("pause",this.#Y),this.#Q.removeEventListener("ended",this.#N)}#F(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let $=document.createElement("fig-preview");$.setAttribute("data-generated",""),this.prepend($),this.#j=$}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#H(){let Q=this.#R();if(Q){if(this.#F(),this.#Q&&this.#Q!==Q){if(this.#D(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#A();return}this.#F();let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#D(),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.#j.append(J),this.#Q=J,this.#Q.addEventListener("play",this.#K),this.#Q.addEventListener("pause",this.#Y),this.#Q.addEventListener("ended",this.#N);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.#j.append(J),this.#Q=J}}#A(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)})}#S(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#C(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#A();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.#S("autoplay",!1),this.#Q.loop=this.#S("loop",!1),this.#Q.muted=this.#S("muted",!1),this.#Q.playsInline=!0,this.#A(),this.#f()}get mediaEl(){return this.#Q}#f(){if(this.mediaKind!=="video"){this.#k();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#k(),this.#W=Q;this.#E();return}if(this.#S("controls",!1))this.#T();else this.#k()}#T(){if(this.#W&&this.#W.isConnected){this.#E();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#W=Q,this.#E()}#E(){if(!this.#W||!this.#Q)return;if(this.#L===this.#Q&&this.#G===this.#W)return;this.#P();let Q=this.#W,$=this.#Q;this.#L=$,this.#G=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 X=$.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>$.pause?.(),_=(X)=>{let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;J=Y;try{$.currentTime=Y}catch{}};this.#U=Z,this.#B=j,this.#M=q,this.#O=_,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),Z()}#P(){let Q=this.#L,$=this.#G;if(Q&&this.#U)Q.removeEventListener("play",this.#U),Q.removeEventListener("pause",this.#U),Q.removeEventListener("ended",this.#U),Q.removeEventListener("timeupdate",this.#U),Q.removeEventListener("loadedmetadata",this.#U),Q.removeEventListener("durationchange",this.#U),Q.removeEventListener("seeked",this.#U);if($){if(this.#B)$.removeEventListener("play",this.#B);if(this.#M)$.removeEventListener("pause",this.#M);if(this.#O)$.removeEventListener("seek",this.#O)}this.#L=null,this.#G=null,this.#U=null,this.#B=null,this.#M=null,this.#O=null}#k(){if(this.#P(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#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.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#X),this.#F(),this.#j.append(Q),this.#J=Q}#V(){if(this.#J)this.#J.removeEventListener("change",this.#X),this.#J.remove(),this.#J=null}#y(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;if(this.#_=null,this.#q=null,J)this.src="";if(this.#C(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#_=$,this.#Z=URL.createObjectURL($),this.#q=this.#Z,this.#C(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#w(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}}))}#b(){this.#w("play")}#h(){this.#w("pause")}#g(){this.#w("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#Z);if(this.#$=Z,this.#Z&&!j)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#q=null,this.#_=null;if(this.#C(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#H(),this.#C(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#A();if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#x();else if(!Z)this.#V()}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.#C()}}customElements.define("fig-media",Q0);class s0 extends Q0{get mediaKind(){return"image"}}customElements.define("fig-image",s0);class r0 extends Q0{get mediaKind(){return"video"}}customElements.define("fig-video",r0);class i0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#Y(),this.#N()}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.#q)return;if(Q==="playing")this.#Y();if(Q==="duration"||Q==="time")this.#N()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");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=h("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full",""),Z.setAttribute("aria-label","Seek"),Z.setAttribute("aria-valuetext",this.#K(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#Z=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#Z=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#j=Z,this.#J=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(Q,$=0){let J=this.#X(Q);if(!Number.isFinite($)||$<=0)return J;return`${J} of ${this.#X($)}`}#Y(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#N(){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.#Z)this.#j.setAttribute("value",String($));if(this.#j.setAttribute("aria-valuetext",this.#K($,Q)),this.#J)this.#J.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",i0);class o0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#G(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#W),this.addEventListener("drop",this.#L)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#j?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#W),this.removeEventListener("drop",this.#L)}attributeChangedCallback(Q,$,J){if($===J)return;this.#G()}clear(){if(this.#q=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#G(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#q=this.#$.files,this.removeAttribute("url"),this.#G(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#W=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#L=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.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.#q=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#G(),this.#X()};#G(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((B)=>B.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#Z.appendChild(X),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",J)this.#j.setAttribute("disabled","");this.#j.replaceChildren(h("minus")),this.#j.addEventListener("click",this.#Y),N.appendChild(this.#j),this.appendChild(N)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),this.#J)this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",o0);class b extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#J="bezier";#Z=2;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=null;#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#O=null;#z=0.8;#D=200;#F=200;#R=null;#H=null;#A=null;#S=5;#C=2;#f=10;#T=10;#E=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#P(Q);this.#M=this.#k(),this.#w(),this.#d()}disconnectedCallback(){if(this.#q=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",J),this.#_)this.#s(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#w();return}if(Q==="value"&&J){let Z=this.#J;if(this.#P(J),this.#M=this.#k(),Z!==this.#J&&this.#y())this.#w();else{if(this.#_)this.#u();this.#a(),this.#c()}}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#J==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#j;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let $=this.#x(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;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)}#P(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#J="spring",this.#j.stiffness=parseFloat($[1]),this.#j.damping=parseFloat($[2]),this.#j.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#k(){if(this.#J==="bezier"){for(let $ of b.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 b.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"}#x(){let{stiffness:Q,damping:$,mass:J}=this.#j,Z=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-$*X;if(X+=K/J*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#V(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let M=0;M<=5;M+=0.004){let O=-J*(Y-1)-Z*K;if(K+=O/j*0.004,Y+=K*0.004,X.push({t:M,value:Y}),M>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let N=X[X.length-1].t||1,B=1;for(let M of X)if(M.value>B)B=M.value;let L=0;for(let M of X)if(M.value<L)L=M.value;let A=Math.max(B-L,1),G=6,U=$-G*2,F=Math.max(1,Math.floor(X.length/30)),D="";for(let M=0;M<X.length;M+=F){let O=G+X[M].t/N*U,P=G+(1-(X[M].value-L)/A)*U;D+=(M===0?"M":"L")+O.toFixed(1)+","+P.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${D}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let _=(j-12)/2,X=48,Y=[],K=(O,P,k,S,I)=>{let C=1-I;return C*C*C*O+3*C*C*I*P+3*C*I*I*k+I*I*I*S};for(let O=0;O<=48;O++){let P=O/48;Y.push({x:K(0,Q,J,1,P),y:K(0,$,Z,1,P)})}let N=1/0,B=-1/0,L=1/0,A=-1/0;for(let O of Y){if(O.x<N)N=O.x;if(O.x>B)B=O.x;if(O.y<L)L=O.y;if(O.y>A)A=O.y}let G=Math.max(B-N,0.000001),U=Math.max(A-L,0.000001),F=(O)=>_+(O-N)/G*12,D=(O)=>_+(1-(O-L)/U)*12,M="";for(let O=0;O<Y.length;O++){let P=F(Y[O].x),k=D(Y[O].y);M+=`${O===0?"M":"L"}${P.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${M}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#y(){return this.getAttribute("edit")!=="false"}#w(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#I(),this.innerHTML=this.#g(),this.#m(),this.#_)this.#p(),this.#s(),this.#u();this.#c(),this.#L0()}static#b(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#h(){let Q="",$=void 0;for(let J of b.PRESETS){if(!this.#y()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#j;Z=b.#V(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=b.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#g(){let $=this.#h();if(!this.#y())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#b(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
199
+ </div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$&&this.#Z&&this.#J){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(!this.#Z.hasAttribute("label"))this.#Z.setAttribute("label",q);if(Z)this.#Z.setAttribute("experimental",Z);this.#J.append(this.#Z)}this.#j=this.querySelector("fig-dropdown"),this.#A()}#G(){this.#U(),this.#j?.addEventListener("input",this.#X),this.#Q?.addEventListener("input",this.#K),this.#Q?.addEventListener("change",this.#Y)}#U(){this.#j?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("input",this.#K),this.#Q?.removeEventListener("change",this.#Y)}#B(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#Q)this.#Q.setAttribute("value",$);this.#z(),this.#D()}#M(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#z()}#O(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#D()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#F(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#R(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#H(){return`${this.#R()} options`}#A(){if(this.#Q)this.#_.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#H())}#S(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#j&&!this.#$){let Z=this.#F();this.#j.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");this.#A();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#S(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;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break}}}customElements.define("fig-combo-input",c0);class _0 extends HTMLElement{#$="color";#Q=null;#j=!1;constructor(){super();this.#Q=this.#Y.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#X(),this.#J(),this.#K()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=q0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#Z(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#q(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q);this.#K()}else this.innerHTML="<div></div>",this.input=null,this.#K()}else if(this.#$==="color"&&this.input){let q=this.#q(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let $=this.getAttribute("aria-labelledby"),J=this.getAttribute("aria-label")||"Color swatch",Z=this.getAttribute("aria-describedby");if($)this.input.setAttribute("aria-labelledby",$),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",J),this.input.removeAttribute("aria-labelledby");if(Z)this.input.setAttribute("aria-describedby",Z);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#Y(Q){this.#j=!0,this.setAttribute("background",Q.target.value),this.#j=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#j){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")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",_0);class d0 extends _0{}customElements.define("fig-swatch",d0);class Q0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=this.#I.bind(this);#K=this.#b.bind(this);#Y=this.#h.bind(this);#N=this.#g.bind(this);#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#O=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#F(),this.#H(),this.#C(),this.#A(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#V()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#X),this.#D(),this.#k(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#q=null}#D(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#K),this.#Q.removeEventListener("pause",this.#Y),this.#Q.removeEventListener("ended",this.#N)}#F(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let $=document.createElement("fig-preview");$.setAttribute("data-generated",""),this.prepend($),this.#j=$}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#H(){let Q=this.#R();if(Q){if(this.#F(),this.#Q&&this.#Q!==Q){if(this.#D(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#A();return}this.#F();let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#D(),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.#j.append(J),this.#Q=J,this.#Q.addEventListener("play",this.#K),this.#Q.addEventListener("pause",this.#Y),this.#Q.addEventListener("ended",this.#N);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.#j.append(J),this.#Q=J}}#A(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)})}#S(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#C(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#A();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.#S("autoplay",!1),this.#Q.loop=this.#S("loop",!1),this.#Q.muted=this.#S("muted",!1),this.#Q.playsInline=!0,this.#A(),this.#f()}get mediaEl(){return this.#Q}#f(){if(this.mediaKind!=="video"){this.#k();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#k(),this.#W=Q;this.#E();return}if(this.#S("controls",!1))this.#T();else this.#k()}#T(){if(this.#W&&this.#W.isConnected){this.#E();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#W=Q,this.#E()}#E(){if(!this.#W||!this.#Q)return;if(this.#L===this.#Q&&this.#G===this.#W)return;this.#P();let Q=this.#W,$=this.#Q;this.#L=$,this.#G=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 X=$.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>$.pause?.(),_=(X)=>{let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;J=Y;try{$.currentTime=Y}catch{}};this.#U=Z,this.#B=j,this.#M=q,this.#O=_,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),Z()}#P(){let Q=this.#L,$=this.#G;if(Q&&this.#U)Q.removeEventListener("play",this.#U),Q.removeEventListener("pause",this.#U),Q.removeEventListener("ended",this.#U),Q.removeEventListener("timeupdate",this.#U),Q.removeEventListener("loadedmetadata",this.#U),Q.removeEventListener("durationchange",this.#U),Q.removeEventListener("seeked",this.#U);if($){if(this.#B)$.removeEventListener("play",this.#B);if(this.#M)$.removeEventListener("pause",this.#M);if(this.#O)$.removeEventListener("seek",this.#O)}this.#L=null,this.#G=null,this.#U=null,this.#B=null,this.#M=null,this.#O=null}#k(){if(this.#P(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#V(){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.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#X),this.#F(),this.#j.append(Q),this.#J=Q}#y(){if(this.#J)this.#J.removeEventListener("change",this.#X),this.#J.remove(),this.#J=null}#I(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;if(this.#_=null,this.#q=null,J)this.src="";if(this.#C(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#_=$,this.#Z=URL.createObjectURL($),this.#q=this.#Z,this.#C(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#w(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}}))}#b(){this.#w("play")}#h(){this.#w("pause")}#g(){this.#w("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#Z);if(this.#$=Z,this.#Z&&!j)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#q=null,this.#_=null;if(this.#C(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#H(),this.#C(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#A();if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#V();else if(!Z)this.#y()}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.#C()}}customElements.define("fig-media",Q0);class s0 extends Q0{get mediaKind(){return"image"}}customElements.define("fig-image",s0);class r0 extends Q0{get mediaKind(){return"video"}}customElements.define("fig-video",r0);class i0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#Y(),this.#N()}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.#q)return;if(Q==="playing")this.#Y();if(Q==="duration"||Q==="time")this.#N()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");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=h("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full",""),Z.setAttribute("aria-label","Seek"),Z.setAttribute("aria-valuetext",this.#K(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#Z=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#Z=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#j=Z,this.#J=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(Q,$=0){let J=this.#X(Q);if(!Number.isFinite($)||$<=0)return J;return`${J} of ${this.#X($)}`}#Y(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#N(){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.#Z)this.#j.setAttribute("value",String($));if(this.#j.setAttribute("aria-valuetext",this.#K($,Q)),this.#J)this.#J.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",i0);class o0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#G(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#W),this.addEventListener("drop",this.#L)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#j?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#W),this.removeEventListener("drop",this.#L)}attributeChangedCallback(Q,$,J){if($===J)return;this.#G()}clear(){if(this.#q=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#G(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#q=this.#$.files,this.removeAttribute("url"),this.#G(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#W=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#L=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.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.#q=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#G(),this.#X()};#G(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((B)=>B.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#Z.appendChild(X),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",J)this.#j.setAttribute("disabled","");this.#j.replaceChildren(h("minus")),this.#j.addEventListener("click",this.#Y),N.appendChild(this.#j),this.appendChild(N)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),this.#J)this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",o0);class b extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#J="bezier";#Z=2;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=null;#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#O=null;#z=0.8;#D=200;#F=200;#R=null;#H=null;#A=null;#S=5;#C=2;#f=10;#T=10;#E=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#P(Q);this.#M=this.#k(),this.#w(),this.#d()}disconnectedCallback(){if(this.#q=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",J),this.#_)this.#s(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#w();return}if(Q==="value"&&J){let Z=this.#J;if(this.#P(J),this.#M=this.#k(),Z!==this.#J&&this.#I())this.#w();else{if(this.#_)this.#u();this.#a(),this.#c()}}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#J==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#j;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let $=this.#V(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;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)}#P(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#J="spring",this.#j.stiffness=parseFloat($[1]),this.#j.damping=parseFloat($[2]),this.#j.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#k(){if(this.#J==="bezier"){for(let $ of b.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 b.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#j.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#j.damping-$.spring.damping)<0.001&&Math.abs(this.#j.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#V(){let{stiffness:Q,damping:$,mass:J}=this.#j,Z=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-$*X;if(X+=K/J*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#y(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let M=0;M<=5;M+=0.004){let O=-J*(Y-1)-Z*K;if(K+=O/j*0.004,Y+=K*0.004,X.push({t:M,value:Y}),M>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let N=X[X.length-1].t||1,B=1;for(let M of X)if(M.value>B)B=M.value;let L=0;for(let M of X)if(M.value<L)L=M.value;let A=Math.max(B-L,1),G=6,U=$-G*2,F=Math.max(1,Math.floor(X.length/30)),D="";for(let M=0;M<X.length;M+=F){let O=G+X[M].t/N*U,P=G+(1-(X[M].value-L)/A)*U;D+=(M===0?"M":"L")+O.toFixed(1)+","+P.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${D}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let _=(j-12)/2,X=48,Y=[],K=(O,P,k,S,I)=>{let C=1-I;return C*C*C*O+3*C*C*I*P+3*C*I*I*k+I*I*I*S};for(let O=0;O<=48;O++){let P=O/48;Y.push({x:K(0,Q,J,1,P),y:K(0,$,Z,1,P)})}let N=1/0,B=-1/0,L=1/0,A=-1/0;for(let O of Y){if(O.x<N)N=O.x;if(O.x>B)B=O.x;if(O.y<L)L=O.y;if(O.y>A)A=O.y}let G=Math.max(B-N,0.000001),U=Math.max(A-L,0.000001),F=(O)=>_+(O-N)/G*12,D=(O)=>_+(1-(O-L)/U)*12,M="";for(let O=0;O<Y.length;O++){let P=F(Y[O].x),k=D(Y[O].y);M+=`${O===0?"M":"L"}${P.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${M}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#I(){return this.getAttribute("edit")!=="false"}#w(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#x(),this.innerHTML=this.#g(),this.#m(),this.#_)this.#p(),this.#s(),this.#u();this.#c(),this.#L0()}static#b(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#h(){let Q="",$=void 0;for(let J of b.PRESETS){if(!this.#I()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#j;Z=b.#y(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=b.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#g(){let $=this.#h();if(!this.#I())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#b(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
200
200
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
201
201
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
202
202
  <line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
@@ -213,7 +213,7 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
213
213
  <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#C}"/>
214
214
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" drag aria-label="First easing control point"></fig-handle></foreignObject>
215
215
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" drag aria-label="Second easing control point"></fig-handle></foreignObject>
216
- </svg></div>${J}`}#v(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#I(){this.#C=this.#v("--easing-bezier-endpoint-radius",this.#C),this.#E=this.#v("--easing-duration-bar-radius",this.#E)}#m(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#W=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#L=this.querySelector('[data-endpoint="start"]'),this.#G=this.querySelector('[data-endpoint="end"]'),this.#U=this.querySelector(".fig-easing-curve-dropdown"),this.#B=this.querySelector(".fig-easing-curve-value-input"),this.#O=this.querySelector(".fig-easing-curve-target"),this.#R=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#N?.querySelector("fig-handle"),$=this.#W?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#S*2,Z=Q.offsetHeight||this.#S*2;this.#S=Math.max(J,Z)/2,this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#f,Z=$.offsetHeight||this.#T;if(this.#J==="spring")this.#f=J,this.#T=Z;this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}}#d(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#s())this.#u()}),this.#A.observe(this)}#s(){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.#D||J!==this.#F;return this.#D=$,this.#F=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#t(Q,$){return{x:Q*this.#D,y:(1-$)*this.#F}}#Q0(Q,$){return{x:Q/this.#D,y:1-$/this.#F}}#o={minVal:0,maxVal:1.2,totalTime:1};#r(Q,$){let Z=this.#F-40,{minVal:j,maxVal:q}=this.#o,_=q-j||1;return{x:Q*this.#D,y:20+(1-($-j)/_)*Z}}#u(){if(this.#s(),this.#J==="spring")this.#Z0();else this.#$0()}#e(){this.#K?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#Y?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#$0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#D),this.#R.setAttribute("height",this.#F);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#F),this.#H.setAttribute("x2",this.#D),this.#H.setAttribute("y2","0");let Q=this.#t(0,0),$=this.#t(this.#$.x,this.#$.y),J=this.#t(this.#Q.x,this.#Q.y),Z=this.#t(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#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.#S;if(this.#N.setAttribute("x",$.x-j),this.#N.setAttribute("y",$.y-j),this.#W.setAttribute("x",J.x-j),this.#W.setAttribute("y",J.y-j),this.#L)this.#L.setAttribute("cx",Q.x),this.#L.setAttribute("cy",Q.y);if(this.#G)this.#G.setAttribute("cx",Z.x),this.#G.setAttribute("cy",Z.y);this.#J0()}#J0(){if(!this.#_||!this.#N||!this.#W)return;let Q=this.#$.y>=this.#Q.y?[this.#N,this.#W]:[this.#W,this.#N];for(let $ of Q)this.#_.append($)}#Z0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#D),this.#R.setAttribute("height",this.#F);let Q=this.#x();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let U of Q){if(U.value<J)J=U.value;if(U.value>Z)Z=U.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let U=0;U<Q.length;U++){let F=Q[U].t/$*_,D=this.#r(F,Q[U].value);X+=(U===0?"M":"L")+D.x.toFixed(1)+","+D.y.toFixed(1)}let Y=this.#r(_,1),K=this.#r(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#X.setAttribute("d",X),this.#O){let U=this.#r(0,1),F=this.#r(1,1);this.#O.setAttribute("x1",U.x),this.#O.setAttribute("y1",U.y),this.#O.setAttribute("x2",F.x),this.#O.setAttribute("y2",F.y)}let N=this.#j0(Q),B=N.t/$*_,L=this.#r(B,N.value),A=this.#S;this.#N.setAttribute("x",L.x-A),this.#N.setAttribute("y",L.y-A);let G=this.#r(_,1);this.#W.setAttribute("x",G.x-this.#f/2),this.#W.setAttribute("y",G.y-this.#T/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.#U)return;this.#U.value=this.#M,this.#N0()}#c(){if(!this.#B)return;this.#B.setAttribute("value",this.value)}#n(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#l(Q,$){let J=this.#n(Q);if(!J){if($==="change")this.#c();return}let Z=this.#J;if(this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#k(),Z!==this.#J)this.#w();else if(this.#u(),this.#a(),$==="change")this.#c();this.#i($)}#q0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#N0(){if(!this.#U)return;if(!this.#y())return;let Q=b.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=b.#V(this.#j);this.#q0(this.#U,"Custom bezier",Q),this.#q0(this.#U,"Custom spring",$),this.#q0(this.#U.select,"Custom bezier",Q),this.#q0(this.#U.select,"Custom spring",$)}#K0(Q){this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i(Q)}#U0(Q,$){let J=Q.shiftKey?0.1:0.01,Z=$===1?this.#$:this.#Q;switch(Q.key){case"ArrowLeft":Z.x-=J;break;case"ArrowRight":Z.x+=J;break;case"ArrowUp":Z.y+=J;break;case"ArrowDown":Z.y-=J;break;case"Home":Z.x=0,Z.y=0;break;case"End":Z.x=1,Z.y=1;break;default:return!1}return Z.x=Math.max(0,Math.min(1,Math.round(Z.x*100)/100)),Z.y=Math.round(Z.y*100)/100,this.#K0("input"),this.#i("change"),!0}#G0(Q,$){let J=Q.shiftKey?10:1;if($==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-J));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+J));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let Z=J*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+Z*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-Z*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#K0("input"),this.#i("change"),!0}#_0(Q,$){let J=Q?.querySelector("fig-handle");if(!J)return;J.addEventListener("pointerdown",(Z)=>{if(Z.preventDefault(),Z.stopImmediatePropagation(),this.#J==="bezier")this.#X0(Z,Number($));else this.#Y0(Z,$)},{capture:!0}),J.addEventListener("keydown",(Z)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Z.key))return;if(!(this.#J==="bezier"?this.#U0(Z,Number($)):this.#G0(Z,$)))return;Z.preventDefault(),Z.stopImmediatePropagation()},{capture:!0})}#i(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#L0(){if(this.#_&&this.#J==="bezier"){this.#_0(this.#N,"1"),this.#_0(this.#W,"2"),this.#N.addEventListener("pointerdown",($)=>this.#X0($,1)),this.#W.addEventListener("pointerdown",($)=>this.#X0($,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.#X0($,this.#M0($))})}else if(this.#_){this.#_0(this.#N,"bounce"),this.#_0(this.#W,"duration"),this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"bounce")}),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"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.#Y0($,"duration")})}if(this.#U)this.#U.addEventListener("change",(Q)=>{let $=Q.detail,J=b.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#J!=="bezier")this.#J="bezier",this.#w();else if(this.#_)this.#u(),this.#c()}else if(J.type==="spring"){if(J.spring)this.#j={...J.spring};if(this.#M=$,this.#J!=="spring")this.#J="spring",this.#w();else if(this.#_)this.#u(),this.#c()}this.#i("input"),this.#i("change")});if(this.#B)this.#B.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"input")}),this.#B.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"change")})}#W0(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}}#M0(Q){return this.#W0(Q).x<=this.#D/2?1:2}#X0(Q,$){Q.preventDefault(),this.#q=$,this.#e();let J=(j)=>{if(!this.#q)return;let q=this.#W0(j),_=this.#Q0(q.x,q.y);if(_.x=Math.round(_.x*100)/100,_.y=Math.round(_.y*100)/100,_.x=Math.max(0,Math.min(1,_.x)),this.#q===1)this.#$.x=_.x,this.#$.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i("input")},Z=()=>{this.#q=null,this.#e(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#i("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#Y0(Q,$){Q.preventDefault(),this.#q=$;let J=this.#j.damping,Z=this.#j.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if($==="bounce"){let N=K.clientY-q;this.#j.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i("input")},Y=()=>{this.#q=null,document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#i("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",b);class l0 extends HTMLElement{#$=0;#Q=0;#j=0;#J=1;#Z=!1;#q=!1;#_=null;#X=null;#K=null;#Y=null;#N=(Q)=>this.#k(Q);#W=null;#L=[];#G={};#U={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#O(this.getAttribute("transform-origin")),this.#F(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#R(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#B();else this.#H();this.#D(this.getAttribute("selected")),this.#z()}disconnectedCallback(){this.#Z=!1,this.#M()}#B(){this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#A(),this.#C(),this.#E()}#M(){if(this.#W?.abort(),this.#W=null,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#Y),this.#K=null,this.#Y=null}#O(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())}#z(){if(!this.#X)return;this.#X.style.cursor=this.#P?"":"default"}#D(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))}#F(Q){if(!Q||!Q.trim()){this.#L=[];return}let $=["rotateX","rotateY","rotateZ"];this.#L=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="perspective"){V(this,"--perspective",J);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#O(J);return}if(Q==="selected"){this.#D(J);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){if(this.#F(J),this.#_)this.#H();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#R(J),this.#C(),this.#S()}if(Q==="precision")this.#J=parseInt(J||"1")}get value(){let Q=this.#J;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#j.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#R(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])}#H(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j},J=this.#L.map((Z)=>`<fig-input-number
216
+ </svg></div>${J}`}#v(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#x(){this.#C=this.#v("--easing-bezier-endpoint-radius",this.#C),this.#E=this.#v("--easing-duration-bar-radius",this.#E)}#m(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#W=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#L=this.querySelector('[data-endpoint="start"]'),this.#G=this.querySelector('[data-endpoint="end"]'),this.#U=this.querySelector(".fig-easing-curve-dropdown"),this.#B=this.querySelector(".fig-easing-curve-value-input"),this.#O=this.querySelector(".fig-easing-curve-target"),this.#R=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#N?.querySelector("fig-handle"),$=this.#W?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#S*2,Z=Q.offsetHeight||this.#S*2;this.#S=Math.max(J,Z)/2,this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#f,Z=$.offsetHeight||this.#T;if(this.#J==="spring")this.#f=J,this.#T=Z;this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}}#d(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#s())this.#u()}),this.#A.observe(this)}#s(){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.#D||J!==this.#F;return this.#D=$,this.#F=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#t(Q,$){return{x:Q*this.#D,y:(1-$)*this.#F}}#Q0(Q,$){return{x:Q/this.#D,y:1-$/this.#F}}#o={minVal:0,maxVal:1.2,totalTime:1};#r(Q,$){let Z=this.#F-40,{minVal:j,maxVal:q}=this.#o,_=q-j||1;return{x:Q*this.#D,y:20+(1-($-j)/_)*Z}}#u(){if(this.#s(),this.#J==="spring")this.#Z0();else this.#$0()}#e(){this.#K?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#Y?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#$0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#D),this.#R.setAttribute("height",this.#F);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#F),this.#H.setAttribute("x2",this.#D),this.#H.setAttribute("y2","0");let Q=this.#t(0,0),$=this.#t(this.#$.x,this.#$.y),J=this.#t(this.#Q.x,this.#Q.y),Z=this.#t(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#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.#S;if(this.#N.setAttribute("x",$.x-j),this.#N.setAttribute("y",$.y-j),this.#W.setAttribute("x",J.x-j),this.#W.setAttribute("y",J.y-j),this.#L)this.#L.setAttribute("cx",Q.x),this.#L.setAttribute("cy",Q.y);if(this.#G)this.#G.setAttribute("cx",Z.x),this.#G.setAttribute("cy",Z.y);this.#J0()}#J0(){if(!this.#_||!this.#N||!this.#W)return;let Q=this.#$.y>=this.#Q.y?[this.#N,this.#W]:[this.#W,this.#N];for(let $ of Q)this.#_.append($)}#Z0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#D),this.#R.setAttribute("height",this.#F);let Q=this.#V();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let U of Q){if(U.value<J)J=U.value;if(U.value>Z)Z=U.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let U=0;U<Q.length;U++){let F=Q[U].t/$*_,D=this.#r(F,Q[U].value);X+=(U===0?"M":"L")+D.x.toFixed(1)+","+D.y.toFixed(1)}let Y=this.#r(_,1),K=this.#r(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#X.setAttribute("d",X),this.#O){let U=this.#r(0,1),F=this.#r(1,1);this.#O.setAttribute("x1",U.x),this.#O.setAttribute("y1",U.y),this.#O.setAttribute("x2",F.x),this.#O.setAttribute("y2",F.y)}let N=this.#j0(Q),B=N.t/$*_,L=this.#r(B,N.value),A=this.#S;this.#N.setAttribute("x",L.x-A),this.#N.setAttribute("y",L.y-A);let G=this.#r(_,1);this.#W.setAttribute("x",G.x-this.#f/2),this.#W.setAttribute("y",G.y-this.#T/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.#U)return;this.#U.value=this.#M,this.#N0()}#c(){if(!this.#B)return;this.#B.setAttribute("value",this.value)}#n(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#l(Q,$){let J=this.#n(Q);if(!J){if($==="change")this.#c();return}let Z=this.#J;if(this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#k(),Z!==this.#J)this.#w();else if(this.#u(),this.#a(),$==="change")this.#c();this.#i($)}#q0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#N0(){if(!this.#U)return;if(!this.#I())return;let Q=b.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=b.#y(this.#j);this.#q0(this.#U,"Custom bezier",Q),this.#q0(this.#U,"Custom spring",$),this.#q0(this.#U.select,"Custom bezier",Q),this.#q0(this.#U.select,"Custom spring",$)}#K0(Q){this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i(Q)}#U0(Q,$){let J=Q.shiftKey?0.1:0.01,Z=$===1?this.#$:this.#Q;switch(Q.key){case"ArrowLeft":Z.x-=J;break;case"ArrowRight":Z.x+=J;break;case"ArrowUp":Z.y+=J;break;case"ArrowDown":Z.y-=J;break;case"Home":Z.x=0,Z.y=0;break;case"End":Z.x=1,Z.y=1;break;default:return!1}return Z.x=Math.max(0,Math.min(1,Math.round(Z.x*100)/100)),Z.y=Math.round(Z.y*100)/100,this.#K0("input"),this.#i("change"),!0}#G0(Q,$){let J=Q.shiftKey?10:1;if($==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-J));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+J));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let Z=J*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+Z*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-Z*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#K0("input"),this.#i("change"),!0}#_0(Q,$){let J=Q?.querySelector("fig-handle");if(!J)return;J.addEventListener("pointerdown",(Z)=>{if(Z.preventDefault(),Z.stopImmediatePropagation(),this.#J==="bezier")this.#X0(Z,Number($));else this.#Y0(Z,$)},{capture:!0}),J.addEventListener("keydown",(Z)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Z.key))return;if(!(this.#J==="bezier"?this.#U0(Z,Number($)):this.#G0(Z,$)))return;Z.preventDefault(),Z.stopImmediatePropagation()},{capture:!0})}#i(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#L0(){if(this.#_&&this.#J==="bezier"){this.#_0(this.#N,"1"),this.#_0(this.#W,"2"),this.#N.addEventListener("pointerdown",($)=>this.#X0($,1)),this.#W.addEventListener("pointerdown",($)=>this.#X0($,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.#X0($,this.#M0($))})}else if(this.#_){this.#_0(this.#N,"bounce"),this.#_0(this.#W,"duration"),this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"bounce")}),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"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.#Y0($,"duration")})}if(this.#U)this.#U.addEventListener("change",(Q)=>{let $=Q.detail,J=b.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#J!=="bezier")this.#J="bezier",this.#w();else if(this.#_)this.#u(),this.#c()}else if(J.type==="spring"){if(J.spring)this.#j={...J.spring};if(this.#M=$,this.#J!=="spring")this.#J="spring",this.#w();else if(this.#_)this.#u(),this.#c()}this.#i("input"),this.#i("change")});if(this.#B)this.#B.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"input")}),this.#B.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"change")})}#W0(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}}#M0(Q){return this.#W0(Q).x<=this.#D/2?1:2}#X0(Q,$){Q.preventDefault(),this.#q=$,this.#e();let J=(j)=>{if(!this.#q)return;let q=this.#W0(j),_=this.#Q0(q.x,q.y);if(_.x=Math.round(_.x*100)/100,_.y=Math.round(_.y*100)/100,_.x=Math.max(0,Math.min(1,_.x)),this.#q===1)this.#$.x=_.x,this.#$.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i("input")},Z=()=>{this.#q=null,this.#e(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#i("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#Y0(Q,$){Q.preventDefault(),this.#q=$;let J=this.#j.damping,Z=this.#j.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if($==="bounce"){let N=K.clientY-q;this.#j.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#u(),this.#M=this.#k(),this.#a(),this.#c(),this.#i("input")},Y=()=>{this.#q=null,document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#i("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",b);class l0 extends HTMLElement{#$=0;#Q=0;#j=0;#J=1;#Z=!1;#q=!1;#_=null;#X=null;#K=null;#Y=null;#N=(Q)=>this.#k(Q);#W=null;#L=[];#G={};#U={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#O(this.getAttribute("transform-origin")),this.#F(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#R(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#B();else this.#H();this.#D(this.getAttribute("selected")),this.#z()}disconnectedCallback(){this.#Z=!1,this.#M()}#B(){this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#A(),this.#C(),this.#E()}#M(){if(this.#W?.abort(),this.#W=null,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#Y),this.#K=null,this.#Y=null}#O(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())}#z(){if(!this.#X)return;this.#X.style.cursor=this.#P?"":"default"}#D(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))}#F(Q){if(!Q||!Q.trim()){this.#L=[];return}let $=["rotateX","rotateY","rotateZ"];this.#L=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="perspective"){V(this,"--perspective",J);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#O(J);return}if(Q==="selected"){this.#D(J);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){if(this.#F(J),this.#_)this.#H();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#R(J),this.#C(),this.#S()}if(Q==="precision")this.#J=parseInt(J||"1")}get value(){let Q=this.#J;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#j.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#R(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])}#H(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j},J=this.#L.map((Z)=>`<fig-input-number
217
217
  name="${Z}"
218
218
  step="1"
219
219
  precision="1"
@@ -231,7 +231,7 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
231
231
  <div class="fig-3d-rotate-face bottom"></div>
232
232
  </div>
233
233
  </div>
234
- </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#A(),this.#C(),this.#E()}#A(){this.#G={};for(let Q of this.#L){let $=this.querySelector(`fig-input-number[name="${Q}"]`);if(!$)continue;if(this.#G[Q]=$,!this.#U[Q])this.#U[Q]=(Z)=>{Z.stopPropagation();let j=parseFloat(Z.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#$=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#j=j;this.#C(),this.#f(Z.type)};let J=this.#U[Q];$.removeEventListener("input",J),$.removeEventListener("change",J),$.addEventListener("input",J),$.addEventListener("change",J)}}#S(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j};for(let $ of this.#L){let J=this.#G[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#J))}}#C(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#j}deg)`}#f(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j}}))}#T(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#E(){if(this.#M(),!this.#X)return;this.#W=new AbortController,this.#X.addEventListener("pointerdown",this.#N,{signal:this.#W.signal}),this.#K=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#Y)}get#P(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#k(Q){if(!this.#P)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(X)=>{if(!this.#Z)return;if(X.buttons===0){_();return}let Y=X.clientX-$,K=X.clientY-J;this.#Q=this.#T(j+Y*0.5),this.#$=this.#T(Z-K*0.5),this.#C(),this.#S(),this.setAttribute("value",this.value),this.#f("input")},_=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",_),this.#X.removeEventListener("pointercancel",_),this.#X.removeEventListener("lostpointercapture",_),this.#f("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",_),this.#X.addEventListener("pointercancel",_),this.#X.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",l0);class X0 extends HTMLElement{#$=50;#Q=50;#j=0;#J=null;#Z=[];#q=null;#_=null;#X=null;#K=!1;#Y=!1;#N=null;#W=null;#L=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"]}#G(){this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#f(),this.#H(),this.#m()}connectedCallback(){if(this.#j=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#F(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#G();else this.#R();this.#M(),this.#A()}disconnectedCallback(){this.#K=!1,this.#h(),this.#I()}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"){V(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#R(),this.#M(),this.#A();return}if(Q==="precision"){this.#j=parseInt(J||"0"),this.#H(),this.#A();return}if(Q==="value"){if(this.#Y||this.#K)return;this.#F(J),this.#C(),this.#f(),this.#H()}}get#U(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#B(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#U)}#O(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#D(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#F(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#D($)}#R(){let Q=Array.from({length:9},(j,q)=>{let _=q%3,X=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${X}">
234
+ </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#A(),this.#C(),this.#E()}#A(){this.#G={};for(let Q of this.#L){let $=this.querySelector(`fig-input-number[name="${Q}"]`);if(!$)continue;if(this.#G[Q]=$,!this.#U[Q])this.#U[Q]=(Z)=>{Z.stopPropagation();let j=parseFloat(Z.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#$=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#j=j;this.#C(),this.#f(Z.type)};let J=this.#U[Q];$.removeEventListener("input",J),$.removeEventListener("change",J),$.addEventListener("input",J),$.addEventListener("change",J)}}#S(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j};for(let $ of this.#L){let J=this.#G[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#J))}}#C(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#j}deg)`}#f(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j}}))}#T(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#E(){if(this.#M(),!this.#X)return;this.#W=new AbortController,this.#X.addEventListener("pointerdown",this.#N,{signal:this.#W.signal}),this.#K=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#Y)}get#P(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#k(Q){if(!this.#P)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(X)=>{if(!this.#Z)return;if(X.buttons===0){_();return}let Y=X.clientX-$,K=X.clientY-J;this.#Q=this.#T(j+Y*0.5),this.#$=this.#T(Z-K*0.5),this.#C(),this.#S(),this.setAttribute("value",this.value),this.#f("input")},_=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",_),this.#X.removeEventListener("pointercancel",_),this.#X.removeEventListener("lostpointercapture",_),this.#f("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",_),this.#X.addEventListener("pointercancel",_),this.#X.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",l0);class X0 extends HTMLElement{#$=50;#Q=50;#j=0;#J=null;#Z=[];#q=null;#_=null;#X=null;#K=!1;#Y=!1;#N=null;#W=null;#L=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"]}#G(){this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#f(),this.#H(),this.#m()}connectedCallback(){if(this.#j=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#F(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#G();else this.#R();this.#M(),this.#A()}disconnectedCallback(){this.#K=!1,this.#h(),this.#x()}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"){V(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#R(),this.#M(),this.#A();return}if(Q==="precision"){this.#j=parseInt(J||"0"),this.#H(),this.#A();return}if(Q==="value"){if(this.#Y||this.#K)return;this.#F(J),this.#C(),this.#f(),this.#H()}}get#U(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#B(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#U)}#O(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#D(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#F(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#D($)}#R(){let Q=Array.from({length:9},(j,q)=>{let _=q%3,X=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${X}">
235
235
  <span class="origin-grid-dot"></span>
236
236
  </span>`}).join(""),$=this.#$.toFixed(this.#j),J=this.#Q.toFixed(this.#j),Z=this.#B?`<div class="origin-values">
237
237
  <fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
@@ -242,7 +242,7 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
242
242
  <fig-handle></fig-handle>
243
243
  </div>
244
244
  </div>
245
- ${Z}`,this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#f(),this.#H(),this.#m()}#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",$)}#A(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#S(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#C(){if(!this.#q)return;let Q=($)=>16.6667+this.#O($)/100*66.6667;this.#q.style.left=`${Q(this.#$)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#f(){if(!this.#q)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",$),this.#q.classList.toggle("overflow-left",J),this.#q.classList.toggle("overflow-right",Z),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#T(Q,$){if(!this.#J)return null;let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#E(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#P(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#k(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.#C(),this.#f(),this.#H(),this.#A(),this.#S(J)}#x(Q,$){if(!this.#J)return{x:this.#$,y:this.#Q};let J=this.#J.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),_=Math.max(1,J.height-j*2),X=(Q-(J.left+Z))/q,Y=($-(J.top+j))/_;return{x:X*100,y:Y*100}}#V(Q,$){if(!this.#J)return{x:50,y:50};let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#y(Q){let J=Q,Z=1/0;for(let j of X0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#w(Q,$){if(!$)return Q;return{x:this.#y(Q.x),y:this.#y(Q.y)}}#b(Q){if(!this.#U)return!1;let $=Q.shiftKey?10:1,J=this.#$,Z=this.#Q;switch(Q.key){case"ArrowLeft":J-=$;break;case"ArrowRight":J+=$;break;case"ArrowUp":Z-=$;break;case"ArrowDown":Z+=$;break;case"Home":J=0,Z=0;break;case"End":J=100,Z=100;break;default:return!1}return this.#k(this.#O(J),this.#O(Z),"input"),this.#S("change"),!0}#h(){if(!this.#J||!this.#W||!this.#L)return;this.#J.removeEventListener("pointermove",this.#W),this.#J.removeEventListener("pointerup",this.#L),this.#J.removeEventListener("pointercancel",this.#L),this.#J.removeEventListener("lostpointercapture",this.#L),this.#W=null,this.#L=null}#g(Q){if(!this.#J||!this.#U)return;Q.preventDefault(),this.#K=!0,this.#N=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#W=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;let _=q.clientX-$,X=q.clientY-J,Y=Math.hypot(_,X);if(!j&&Y<Z)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#E();let K=this.#w(this.#x(q.clientX,q.clientY),q.shiftKey);this.#k(K.x,K.y,"input")},this.#L=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;if(this.#K=!1,this.#N=null,this.#J.classList.remove("is-dragging"),this.#E(),this.#h(),!j){let _=this.#V($,J);this.#k(_.x,_.y,"input")}this.#S("change")},this.#J.addEventListener("pointermove",this.#W),this.#J.addEventListener("pointerup",this.#L),this.#J.addEventListener("pointercancel",this.#L),this.#J.addEventListener("lostpointercapture",this.#L)}#v=null;#I(){this.#v?.abort(),this.#v=null}#m(){if(this.#I(),!this.#J||!this.#q)return;this.#v=new AbortController;let{signal:Q}=this.#v;this.#J.addEventListener("pointerdown",(J)=>{let Z=this.#T(J.clientX,J.clientY);if(this.#P(Z),this.#U){this.#g(J);return}let j=this.#V(J.clientX,J.clientY);this.#k(j.x,j.y,"input"),this.#S("change")},{signal:Q}),this.#J.addEventListener("pointermove",(J)=>{if(this.#K)return;let Z=this.#T(J.clientX,J.clientY);this.#P(Z)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#E()},{signal:Q}),this.#q.addEventListener("keydown",(J)=>{if(!this.#b(J))return;J.preventDefault(),J.stopPropagation()},{signal:Q});let $=(J,Z)=>{if(!J)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(Z==="x")this.#k(_,this.#Q,"input");else this.#k(this.#$,_,"input")};J.addEventListener("input",j,{signal:Q}),J.addEventListener("change",j,{signal:Q}),J.addEventListener("focusout",()=>{this.#S("change")},{signal:Q})};$(this.#_,"x"),$(this.#X,"y")}}customElements.define("fig-origin-grid",X0);class a0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;#Y={x:0.5,y:0.5};#N=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#A(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#j=(Q)=>this.#S(Q),this.#J=()=>this.#C(),this.#Z=(Q)=>this.#D(Q),this.#q=(Q)=>this.#F(Q),this.#_=()=>this.#R(),this.#X=()=>this.#R()}#W(){this.#O(),this.#E(),this.#P(),this.#k(),this.#N=!0}connectedCallback(){v(this,()=>{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",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#W();return}this.#U(),this.#O(),this.#E(),this.#P(),this.#k(),this.#N=!0})}#L(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#G(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#U(){this.innerHTML=this.#M()}#B(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/[\s,]+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#B();return`
245
+ ${Z}`,this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#f(),this.#H(),this.#m()}#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",$)}#A(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#S(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#C(){if(!this.#q)return;let Q=($)=>16.6667+this.#O($)/100*66.6667;this.#q.style.left=`${Q(this.#$)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#f(){if(!this.#q)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",$),this.#q.classList.toggle("overflow-left",J),this.#q.classList.toggle("overflow-right",Z),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#T(Q,$){if(!this.#J)return null;let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#E(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#P(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#k(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.#C(),this.#f(),this.#H(),this.#A(),this.#S(J)}#V(Q,$){if(!this.#J)return{x:this.#$,y:this.#Q};let J=this.#J.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),_=Math.max(1,J.height-j*2),X=(Q-(J.left+Z))/q,Y=($-(J.top+j))/_;return{x:X*100,y:Y*100}}#y(Q,$){if(!this.#J)return{x:50,y:50};let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#I(Q){let J=Q,Z=1/0;for(let j of X0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#w(Q,$){if(!$)return Q;return{x:this.#I(Q.x),y:this.#I(Q.y)}}#b(Q){if(!this.#U)return!1;let $=Q.shiftKey?10:1,J=this.#$,Z=this.#Q;switch(Q.key){case"ArrowLeft":J-=$;break;case"ArrowRight":J+=$;break;case"ArrowUp":Z-=$;break;case"ArrowDown":Z+=$;break;case"Home":J=0,Z=0;break;case"End":J=100,Z=100;break;default:return!1}return this.#k(this.#O(J),this.#O(Z),"input"),this.#S("change"),!0}#h(){if(!this.#J||!this.#W||!this.#L)return;this.#J.removeEventListener("pointermove",this.#W),this.#J.removeEventListener("pointerup",this.#L),this.#J.removeEventListener("pointercancel",this.#L),this.#J.removeEventListener("lostpointercapture",this.#L),this.#W=null,this.#L=null}#g(Q){if(!this.#J||!this.#U)return;Q.preventDefault(),this.#K=!0,this.#N=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#W=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;let _=q.clientX-$,X=q.clientY-J,Y=Math.hypot(_,X);if(!j&&Y<Z)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#E();let K=this.#w(this.#V(q.clientX,q.clientY),q.shiftKey);this.#k(K.x,K.y,"input")},this.#L=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;if(this.#K=!1,this.#N=null,this.#J.classList.remove("is-dragging"),this.#E(),this.#h(),!j){let _=this.#y($,J);this.#k(_.x,_.y,"input")}this.#S("change")},this.#J.addEventListener("pointermove",this.#W),this.#J.addEventListener("pointerup",this.#L),this.#J.addEventListener("pointercancel",this.#L),this.#J.addEventListener("lostpointercapture",this.#L)}#v=null;#x(){this.#v?.abort(),this.#v=null}#m(){if(this.#x(),!this.#J||!this.#q)return;this.#v=new AbortController;let{signal:Q}=this.#v;this.#J.addEventListener("pointerdown",(J)=>{let Z=this.#T(J.clientX,J.clientY);if(this.#P(Z),this.#U){this.#g(J);return}let j=this.#y(J.clientX,J.clientY);this.#k(j.x,j.y,"input"),this.#S("change")},{signal:Q}),this.#J.addEventListener("pointermove",(J)=>{if(this.#K)return;let Z=this.#T(J.clientX,J.clientY);this.#P(Z)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#E()},{signal:Q}),this.#q.addEventListener("keydown",(J)=>{if(!this.#b(J))return;J.preventDefault(),J.stopPropagation()},{signal:Q});let $=(J,Z)=>{if(!J)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(Z==="x")this.#k(_,this.#Q,"input");else this.#k(this.#$,_,"input")};J.addEventListener("input",j,{signal:Q}),J.addEventListener("change",j,{signal:Q}),J.addEventListener("focusout",()=>{this.#S("change")},{signal:Q})};$(this.#_,"x"),$(this.#X,"y")}}customElements.define("fig-origin-grid",X0);class a0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;#Y={x:0.5,y:0.5};#N=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#A(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#j=(Q)=>this.#S(Q),this.#J=()=>this.#C(),this.#Z=(Q)=>this.#D(Q),this.#q=(Q)=>this.#F(Q),this.#_=()=>this.#R(),this.#X=()=>this.#R()}#W(){this.#O(),this.#E(),this.#P(),this.#k(),this.#N=!0}connectedCallback(){v(this,()=>{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",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#W();return}this.#U(),this.#O(),this.#E(),this.#P(),this.#k(),this.#N=!0})}#L(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#G(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#U(){this.innerHTML=this.#M()}#B(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/[\s,]+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#B();return`
246
246
  <div class="fig-input-joystick-plane-container">
247
247
  ${[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("")}
248
248
  <div class="fig-input-joystick-plane">
@@ -275,6 +275,6 @@ var A1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z1={};var L0=A1(()=>{/*! Vendored from @
275
275
  <span slot="prepend">Y</span>
276
276
  </fig-input-number>
277
277
  </div>`:""}
278
- `}#O(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#x());if(this.#G&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#G&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#X)}#D(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#f()}#F(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#f()}#R(){this.#P(),this.#T()}#H(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#P()}#A(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.#f(),this.#T()}#S(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#H($.px,$.py,{syncHandle:!1}),this.#f()}#C(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#T()}#f(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#L(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#G&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#k()}#k(){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")}#x(){this.position={...this.#Y},this.#E(),this.#P(),this.#f(),this.#T()}focus(){this.cursor?.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=(_)=>{if(!_)return 0.5;let X=_.includes("%"),Y=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(Y))return 0.5;let K=X||Math.abs(Y)>1?Y/100:Y;return Math.max(0,Math.min(1,K))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#N)this.#E(),this.#k()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#U(),this.#O(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#U(),this.#O(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",a0);class Y0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#$()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#$()}#$(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}customElements.define("fig-shimmer",Y0);class t0 extends Y0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",t0);class n0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#$=null;#Q=null;connectedCallback(){this.#Z()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#J),this.#$.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){this.#$?.setAttribute("aria-expanded",String(this.open));return}this.#Z()}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(this.#$?.setAttribute("aria-expanded",String(!!Q)),$!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#Z(){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(!j.id)j.id=y();if(this.#$.dataset.generated)j.textContent=J;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let q=h("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.addEventListener("click",this.#j),this.#$.setAttribute("role","button"),this.#$.setAttribute("tabindex","0"),this.#$.setAttribute("aria-expanded",String(this.open)),this.#$.removeEventListener("keydown",this.#J),this.#$.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#$.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.removeAttribute("role"),this.#$.removeAttribute("tabindex"),this.#$.removeAttribute("aria-expanded"),this.#$.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",n0);class e0 extends HTMLElement{}customElements.define("fig-header",e0);class Q1 extends HTMLElement{}customElements.define("fig-footer",Q1);class $1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}customElements.define("fig-spinner",$1);class J1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",J1);var f1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function I1(Q,$="medium"){let J=Q&&f1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class Z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=I1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",Z1);class j1 extends HTMLElement{}customElements.define("fig-content",j1);class q1 extends HTMLElement{}customElements.define("fig-tab-content",q1);class _1 extends HTMLElement{}customElements.define("fig-button-combo",_1);class X1 extends HTMLElement{}customElements.define("fig-input-combo",X1);class Y1 extends HTMLElement{#$=null;#Q=null;#j=null;#J=this.#O.bind(this);#Z=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#U()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#Z);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#Z);if(this.#j)this.#j.disconnect(),this.#j=null}#X(){if(this.#j)this.#j.disconnect(),this.#j=null;if(!this.#Q)return;this.#j=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#j.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${Y}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#N),this.#B();return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#G($),Z=this.#L($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),_=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=p()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
278
+ `}#O(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#V());if(this.#G&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#G&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#X)}#D(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#f()}#F(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#f()}#R(){this.#P(),this.#T()}#H(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#P()}#A(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.#f(),this.#T()}#S(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#H($.px,$.py,{syncHandle:!1}),this.#f()}#C(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#T()}#f(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#L(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#G&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#k()}#k(){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")}#V(){this.position={...this.#Y},this.#E(),this.#P(),this.#f(),this.#T()}focus(){this.cursor?.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=(_)=>{if(!_)return 0.5;let X=_.includes("%"),Y=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(Y))return 0.5;let K=X||Math.abs(Y)>1?Y/100:Y;return Math.max(0,Math.min(1,K))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#N)this.#E(),this.#k()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#U(),this.#O(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#U(),this.#O(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",a0);class Y0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#$()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#$()}#$(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}customElements.define("fig-shimmer",Y0);class t0 extends Y0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",t0);class n0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#$=null;#Q=null;connectedCallback(){this.#Z()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#J),this.#$.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){this.#$?.setAttribute("aria-expanded",String(this.open));return}this.#Z()}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(this.#$?.setAttribute("aria-expanded",String(!!Q)),$!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#Z(){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(!j.id)j.id=y();if(this.#$.dataset.generated)j.textContent=J;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let q=h("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.addEventListener("click",this.#j),this.#$.setAttribute("role","button"),this.#$.setAttribute("tabindex","0"),this.#$.setAttribute("aria-expanded",String(this.open)),this.#$.removeEventListener("keydown",this.#J),this.#$.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#$.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.removeAttribute("role"),this.#$.removeAttribute("tabindex"),this.#$.removeAttribute("aria-expanded"),this.#$.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",n0);class e0 extends HTMLElement{}customElements.define("fig-header",e0);class Q1 extends HTMLElement{}customElements.define("fig-footer",Q1);class $1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}customElements.define("fig-spinner",$1);class J1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",J1);var f1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function I1(Q,$="medium"){let J=Q&&f1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class Z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=I1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",Z1);class j1 extends HTMLElement{}customElements.define("fig-content",j1);class q1 extends HTMLElement{}customElements.define("fig-tab-content",q1);class _1 extends HTMLElement{}customElements.define("fig-button-combo",_1);class X1 extends HTMLElement{}customElements.define("fig-input-combo",X1);class Y1 extends HTMLElement{#$=null;#Q=null;#j=null;#J=this.#O.bind(this);#Z=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#U()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#Z);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#Z);if(this.#j)this.#j.disconnect(),this.#j=null}#X(){if(this.#j)this.#j.disconnect(),this.#j=null;if(!this.#Q)return;this.#j=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#j.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${Y}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#N),this.#B();return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#G($),Z=this.#L($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),_=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=p()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
279
279
  <fig-chit background="${J}"${_}></fig-chit>
280
- </fig-fill-picker>`:`<fig-chit background="${J}"${_}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#Z),!this.#$)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#Z);this.#X(),this.#B()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#W(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"}#L(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#G(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#G(J.color)}catch{}if($.startsWith("#"))return this.#W($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#W($);try{let{ctx:J}=q0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#W(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#U(){let Q=this.getAttribute("value"),$=this.#G(Q),J=this.#L(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){this.#B();let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#B(),this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#B(){let Q=this.#q,$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",$?"true":"false"),this.setAttribute("aria-pressed",J?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),$)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let Z=this.#$||this.#Q;if(!Z)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)Z.setAttribute("aria-labelledby",q),Z.removeAttribute("aria-label");else Z.setAttribute("aria-label",j),Z.removeAttribute("aria-labelledby");if(_)Z.setAttribute("aria-describedby",_);else Z.removeAttribute("aria-describedby")}#M(Q,$){let J=this.#G(Q?.color),Z=this.#G(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#U();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#O(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#Y();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#U(),this.#B();break}}get value(){return this.#G(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#G(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",Y1);class K1 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",K1);class W1 extends HTMLElement{#$=null;#Q=this.#F.bind(this);#j=this.#R.bind(this);#J=this.#A.bind(this);#Z=null;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#L(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),$=Q===null?NaN:Number(Q);if(Number.isInteger($)&&$>0)this.style.setProperty("--fig-chooser-grid-columns",String($));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from((this.#_||this).querySelectorAll(this.#G))}get#B(){return this.#_||this}get scrollTop(){return this.#B.scrollTop}set scrollTop(Q){this.#B.scrollTop=Q}get scrollLeft(){return this.#B.scrollLeft}set scrollLeft(Q){this.#B.scrollLeft=Q}get scrollWidth(){return this.#B.scrollWidth}get scrollHeight(){return this.#B.scrollHeight}scrollTo(...Q){this.#B.scrollTo(...Q)}scrollBy(...Q){this.#B.scrollBy(...Q)}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#V(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.#U(),this.#T(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#B.addEventListener("scroll",this.#J),this.#E(),this.#C(),this.#y(),this.#S(),v(this,()=>{this.#O(),this.#A(),this.#M()})}#M(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#V(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.#B.removeEventListener("scroll",this.#J),this.#f(),this.#Z?.disconnect(),this.#Z=null,this.#q?.disconnect(),this.#q=null,this.#P()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#z(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#O());if(Q==="columns")this.#U();if(Q==="drag")if(this.#L)this.#C();else this.#f();if(Q==="overflow")this.#E();if(Q==="layout")this.#E(),requestAnimationFrame(()=>this.#A())}#O(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#z($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#z(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#D(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#D(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#H()}#R(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#D(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#H()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#A(){if(this.#W==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";z0(this,this.#B,Q?"x":"y")}#S(){if(this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#A()}),this.#q.observe(this),this.#_)this.#q.observe(this.#_)}#C(){if(this.#Y?.bound)return;if(!this.#L)return;let Q=this.#B,$=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?Q.scrollWidth>Q.clientWidth:Q.scrollHeight>Q.clientHeight))return;this.#Y.active=!0,this.#Y.didDrag=!1,this.#Y.startX=_.clientX,this.#Y.startY=_.clientY,this.#Y.scrollLeft=Q.scrollLeft,this.#Y.scrollTop=Q.scrollTop,Q.style.cursor="grab",Q.style.userSelect="none"},J=(_)=>{if(!this.#Y.active)return;let X=this.getAttribute("layout")==="horizontal",Y=_.clientX-this.#Y.startX,K=_.clientY-this.#Y.startY;if(!this.#Y.didDrag&&Math.abs(X?Y:K)>3)this.#Y.didDrag=!0,Q.style.cursor="grabbing",Q.setPointerCapture(_.pointerId);if(!this.#Y.didDrag)return;if(X)Q.scrollLeft=this.#Y.scrollLeft-Y;else Q.scrollTop=this.#Y.scrollTop-K},Z=(_)=>{if(!this.#Y.active)return;let X=this.#Y.didDrag;if(this.#Y.active=!1,this.#Y.didDrag=!1,Q.style.cursor="",Q.style.userSelect="",_.pointerId!==void 0)try{Q.releasePointerCapture(_.pointerId)}catch{}if(X)_.preventDefault(),_.stopPropagation()},j=(_)=>{if(this.#Y?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#Y.suppressClick=!1},q=(_)=>{if(this.#Y?.didDrag)this.#Y.suppressClick=!0,setTimeout(()=>{if(this.#Y)this.#Y.suppressClick=!1},0)};this.#Y={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:$,onPointerMove:J,onPointerUp:Z,onClick:j,onPointerUpCapture:q,scrollEl:Q},Q.addEventListener("pointerdown",$),window.addEventListener("pointermove",J),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",q,!0),this.addEventListener("click",j,!0)}#f(){if(!this.#Y?.bound)return;this.#Y.scrollEl.removeEventListener("pointerdown",this.#Y.onPointerDown),window.removeEventListener("pointermove",this.#Y.onPointerMove),window.removeEventListener("pointerup",this.#Y.onPointerUp),this.removeEventListener("pointerup",this.#Y.onPointerUpCapture,!0),this.removeEventListener("click",this.#Y.onClick,!0),this.#Y.scrollEl.style.cursor="",this.#Y.scrollEl.style.userSelect="",this.#Y=null}#T(){if(this.#N)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(Q&&Q===this.#_)return;this.#N=!0;try{let $=this.#_;if($&&$!==Q)$.removeEventListener("scroll",this.#J);let J=Q||document.createElement("div");J.className="fig-chooser-scroll",J.dataset.figChooserScroll="";let Z=Array.from(this.childNodes).filter((j)=>{if(j===J)return!1;if(j.nodeType!==Node.ELEMENT_NODE)return!0;return!j.hasAttribute("data-fig-chooser-nav")});for(let j of Z)J.appendChild(j);if(!Q)this.prepend(J);if(this.#_=J,this.#_.removeEventListener("scroll",this.#J),this.#_.addEventListener("scroll",this.#J),this.#q)this.#q.observe(this.#_)}finally{this.#N=!1}}#E(){if(this.#T(),this.#W==="scrollbar")this.#P();else this.#k()}#P(){this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#X&&this.#K&&this.contains(this.#X)&&this.contains(this.#K))return;this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null;let Q=A0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#x(-1),onEnd:()=>this.#x(1)});this.#X=Q.start,this.#K=Q.end,this.prepend(this.#X),this.append(this.#K)}#x(Q){let $=this.getAttribute("layout")==="horizontal",J=this.#B;Z0(J,$?"x":"y",Q)}#V(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.#B,Z=J.scrollHeight>J.clientHeight,j=J.scrollWidth>J.clientWidth;if(!j&&!Z)return;let q=Q.getBoundingClientRect(),_=J.getBoundingClientRect(),X={behavior:$};if(Z){let Y=q.top-_.top+J.scrollTop+q.height/2;X.top=Y-J.clientHeight/2}if(j){let Y=q.left-_.left+J.scrollLeft+q.width/2;X.left=Y-J.clientWidth/2}J.scrollTo(X)})}#y(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{if(this.#N)return;this.#T(),this.#E();let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#O();else if(!this.#$&&Q.length)this.#O();requestAnimationFrame(()=>this.#A())}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",W1);class N1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#$=!1;#Q=!1;#j=null;#J=!1;#Z=null;#q=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#Y(){return!this.hasAttribute("data-no-color-picker")}get#N(){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#L(){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"}#G(Q){let $=this.#L;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#U(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}#B(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#l(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#O(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#z(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#O(Q),j=$.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#W;if(this.#D(X),X.x){let Y=q(J,j.width);this.style.left=Y===null?_(J):`${Math.round(Y)}px`}if(X.y){let Y=q(Z,j.height);this.style.top=Y===null?_(Z):`${Math.round(Y)}px`}}#D(Q=this.#W){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#F(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#R(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let _ of $){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#A(){let Q=this.#H();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#S(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#S(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#V(Q)}connectedCallback(){this.#k(),this.#P(),this.#A(),this.addEventListener("click",this.#C),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#T);let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.#K)this.#s()}disconnectedCallback(){if(this.#x(),this.#t(),this.#v(),this.#p(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#C),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#T)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#C=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#Y&&!this.#K){this.#g();return}this.select()};#f=(Q)=>{if(this.contains(Q.target))return;if((this.#Z||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#T=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#N&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#g();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#Y)return;if(Q.preventDefault(),!this.#K)this.#g()};#E(Q){if(this.hasAttribute("disabled"))return!1;let $=this.#M();if(!$)return!1;let J=$.getBoundingClientRect();if(J.width<=0||J.height<=0)return!1;let Z=this.#W,j=this.#l(J),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!Z.x)return!1;_-=q;break;case"ArrowRight":if(!Z.x)return!1;_+=q;break;case"ArrowUp":if(!Z.y)return!1;X-=q;break;case"ArrowDown":if(!Z.y)return!1;X+=q;break;case"Home":if(Z.x)_=0;if(Z.y)X=0;break;case"End":if(Z.x)_=1;if(Z.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#D(Z),Z.x)this.style.left=`${Math.round(_*J.width)}px`;if(Z.y)this.style.top=`${Math.round(X*J.height)}px`;this.#F();let Y={...this.#l(J),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&this.#K==="color"&&J)this.#Z.setAttribute("value",J);this.#b()}if(Q==="drag")this.#P();if(Q==="hit-area")this.#A();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#k();if(Q==="value"&&!this.#J&&!this.#$)this.#z(J);if(Q==="tip"){if(this.#t(),this.#K)this.#v(),this.#s()}}#P(){if(this.#N&&!this.#j)this.#j=(Q)=>this.#V(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#N&&this.#j)this.#x()}#k(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let J=this.#K||this.getAttribute("type")||"handle";this.setAttribute("aria-label",J==="color"?"Color handle":J==="add"?"Add handle":J==="remove"?"Remove handle":"Handle")}}#x(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#$=!1}#V(Q){if(!this.#N||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#W,Z=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,N=Q.clientY,B=3,L=(U,F,D=!1)=>{let M=$.getBoundingClientRect();Z=M;let O=this.#l(M),P=U-X-M.left,k=F-Y-M.top,S=Math.max(0,Math.min(M.width,P)),I=Math.max(0,Math.min(M.height,k)),C=M.width>0?J.x?S/M.width:O.px:0.5,w=M.height>0?J.y?I/M.height:O.py:0.5;if(this.#G(D)){if(J.x)C=this.#U(C);if(J.y)w=this.#U(w);if(J.x&&J.y){let d=this.#B(C,w);C=d.x,w=d.y}}if(this.#D(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,C*M.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,w*M.height)))}px`},A=(U)=>{if(!this.#$)return;if(!this.#Q){let F=U.clientX-K,D=U.clientY-N;if(F*F+D*D<B*B)return;if(this.#d(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,L(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#l(Z),shiftKey:U.shiftKey}}))},G=(U)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",G),this.#Q){L(U.clientX,U.clientY,U.shiftKey),this.#F(),this.#z(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#l(Z)}));let F=(D)=>{D.stopPropagation(),D.preventDefault()};this.addEventListener("click",F,{capture:!0,once:!0})}else this.#F();this.#Q=!1};window.addEventListener("pointermove",A),window.addEventListener("pointerup",G)}showColorTip(){if(!this.#K)return;if(this.#Z){this.#Z.style.display="";return}this.#s()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#y(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,N]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return $},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=q0(1,1);q.fillStyle="#000000",q.fillStyle=J;let _=q.fillStyle;if(_.startsWith("#"))return Z(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return $}#w(){let{color:Q,opacity:$}=this.#y();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#b(){if(!this.#q)return;this.#q.setAttribute("value",this.#w())}#h(){if(!p())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#u),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#g(){if(this.hasAttribute("disabled"))return;let Q=this.#h();if(!Q){this.#m();return}this.setAttribute("selected",""),this.#b(),Q.open()}#v(){if(!this.#q)return;this.#q.removeEventListener("input",this.#u),this.#q.removeEventListener("change",this.#e),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#I(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#J0),Q.addEventListener("change",this.#Z0),this.appendChild(Q),this.#_=Q,Q}#m(){let Q=this.#I(),{color:$}=this.#y();Q.value=$,this.setAttribute("selected",""),Q.click()}#p(){if(!this.#_)return;this.#_.removeEventListener("input",this.#J0),this.#_.removeEventListener("change",this.#Z0),this.#_.remove(),this.#_=null}#d(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#s(){let Q=this.#K;if(!Q)return;if(this.#Z)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#a),$.addEventListener("change",this.#c),$.addEventListener("add",this.#n),$.addEventListener("remove",this.#n),this.appendChild($),this.#Z=$,this.#Q0()}#t(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#a),this.#Z.removeEventListener("change",this.#c),this.#Z.removeEventListener("add",this.#n),this.#Z.removeEventListener("remove",this.#n),this.#Z.remove(),this.#Z=null}#Q0(){if(!this.#Z||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#Z.toggleAttribute("selected",Q)}#o(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=c(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#r(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#u=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#e=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#$0(Q){let{opacity:$}=this.#y();return $<100?{color:Q,opacity:$}:{color:Q}}#J0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#Z0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#j0=()=>{this.removeAttribute("selected")};#a=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#c=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#n=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#l(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,_=J.top-$.top,X=q+Z,Y=_+j,K=$.width>0?X/$.width:0,N=$.height>0?Y/$.height:0;return{x:q,y:_,px:K,py:N}}}customElements.define("fig-handle",N1);class U1 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");this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled")this.#$()}#$(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-menu-item",U1);class G1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",G1);class L1 extends HTMLElement{#$=null;#Q=null;#j=null;#J;#Z;#q;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#J=this.#z.bind(this),this.#Z=this.#D.bind(this),this.#q=this.#F.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.#K(),this.#Y(),this.#N(),this.#W(),this.#G(),this.#O(),this.open)this.#A()}disconnectedCallback(){if(this.#L(),document.removeEventListener("keydown",this.#q,!0),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.#S();else this.#A();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu"),this.#$.setAttribute("id",this.#$.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#N(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#W(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id"));if(this.#$)this.#$.addEventListener("click",this.#Z),this.#$.addEventListener("keydown",this.#q)}#L(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#Z),this.#$.removeEventListener("keydown",this.#q)}#G(){this.#j=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id")),this.#$.anchor=this.#Q,this.#O()}}}),this.#j.observe(this,{childList:!0})}#U(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#B(){let Q=this.#U();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#U();if(!$.length)return;let J=(Q+$.length)%$.length;this.#X=J,$[J].focus()}#O(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#D(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#F(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#$?.contains(Q.target))return;if(!this.open||!this.#$?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#M(0));return}let $=this.#U();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#B(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#B(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#B();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(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}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#A(){if(!this.#$)return;if(this.#$.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#S(){if(!this.#$)return;document.removeEventListener("keydown",this.#q,!0),this.#$.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",L1);
280
+ </fig-fill-picker>`:`<fig-chit background="${J}"${_}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#Z),!this.#$)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#Z);this.#X(),this.#B()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#W(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"}#L(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#G(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#G(J.color)}catch{}if($.startsWith("#"))return this.#W($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#W($);try{let{ctx:J}=q0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#W(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#U(){let Q=this.getAttribute("value"),$=this.#G(Q),J=this.#L(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){this.#B();let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#B(),this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#B(){let Q=this.#q,$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",$?"true":"false"),this.setAttribute("aria-pressed",J?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),$)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let Z=this.#$||this.#Q;if(!Z)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)Z.setAttribute("aria-labelledby",q),Z.removeAttribute("aria-label");else Z.setAttribute("aria-label",j),Z.removeAttribute("aria-labelledby");if(_)Z.setAttribute("aria-describedby",_);else Z.removeAttribute("aria-describedby")}#M(Q,$){let J=this.#G(Q?.color),Z=this.#G(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#U();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#O(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#Y();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#U(),this.#B();break}}get value(){return this.#G(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#G(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",Y1);class K1 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",K1);class W1 extends HTMLElement{#$=null;#Q=this.#F.bind(this);#j=this.#R.bind(this);#J=this.#A.bind(this);#Z=null;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#L(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),$=Q===null?NaN:Number(Q);if(Number.isInteger($)&&$>0)this.style.setProperty("--fig-chooser-grid-columns",String($));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from((this.#_||this).querySelectorAll(this.#G))}get#B(){return this.#_||this}get scrollTop(){return this.#B.scrollTop}set scrollTop(Q){this.#B.scrollTop=Q}get scrollLeft(){return this.#B.scrollLeft}set scrollLeft(Q){this.#B.scrollLeft=Q}get scrollWidth(){return this.#B.scrollWidth}get scrollHeight(){return this.#B.scrollHeight}scrollTo(...Q){this.#B.scrollTo(...Q)}scrollBy(...Q){this.#B.scrollBy(...Q)}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#y(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.#U(),this.#T(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#B.addEventListener("scroll",this.#J),this.#E(),this.#C(),this.#I(),this.#S(),v(this,()=>{this.#O(),this.#A(),this.#M()})}#M(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#y(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.#B.removeEventListener("scroll",this.#J),this.#f(),this.#Z?.disconnect(),this.#Z=null,this.#q?.disconnect(),this.#q=null,this.#P()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#z(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#O());if(Q==="columns")this.#U();if(Q==="drag")if(this.#L)this.#C();else this.#f();if(Q==="overflow")this.#E();if(Q==="layout")this.#E(),requestAnimationFrame(()=>this.#A())}#O(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#z($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#z(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#D(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#D(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#H()}#R(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#D(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#H()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#A(){if(this.#W==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";z0(this,this.#B,Q?"x":"y")}#S(){if(this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#A()}),this.#q.observe(this),this.#_)this.#q.observe(this.#_)}#C(){if(this.#Y?.bound)return;if(!this.#L)return;let Q=this.#B,$=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?Q.scrollWidth>Q.clientWidth:Q.scrollHeight>Q.clientHeight))return;this.#Y.active=!0,this.#Y.didDrag=!1,this.#Y.startX=_.clientX,this.#Y.startY=_.clientY,this.#Y.scrollLeft=Q.scrollLeft,this.#Y.scrollTop=Q.scrollTop,Q.style.cursor="grab",Q.style.userSelect="none"},J=(_)=>{if(!this.#Y.active)return;let X=this.getAttribute("layout")==="horizontal",Y=_.clientX-this.#Y.startX,K=_.clientY-this.#Y.startY;if(!this.#Y.didDrag&&Math.abs(X?Y:K)>3)this.#Y.didDrag=!0,Q.style.cursor="grabbing",Q.setPointerCapture(_.pointerId);if(!this.#Y.didDrag)return;if(X)Q.scrollLeft=this.#Y.scrollLeft-Y;else Q.scrollTop=this.#Y.scrollTop-K},Z=(_)=>{if(!this.#Y.active)return;let X=this.#Y.didDrag;if(this.#Y.active=!1,this.#Y.didDrag=!1,Q.style.cursor="",Q.style.userSelect="",_.pointerId!==void 0)try{Q.releasePointerCapture(_.pointerId)}catch{}if(X)_.preventDefault(),_.stopPropagation()},j=(_)=>{if(this.#Y?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#Y.suppressClick=!1},q=(_)=>{if(this.#Y?.didDrag)this.#Y.suppressClick=!0,setTimeout(()=>{if(this.#Y)this.#Y.suppressClick=!1},0)};this.#Y={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:$,onPointerMove:J,onPointerUp:Z,onClick:j,onPointerUpCapture:q,scrollEl:Q},Q.addEventListener("pointerdown",$),window.addEventListener("pointermove",J),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",q,!0),this.addEventListener("click",j,!0)}#f(){if(!this.#Y?.bound)return;this.#Y.scrollEl.removeEventListener("pointerdown",this.#Y.onPointerDown),window.removeEventListener("pointermove",this.#Y.onPointerMove),window.removeEventListener("pointerup",this.#Y.onPointerUp),this.removeEventListener("pointerup",this.#Y.onPointerUpCapture,!0),this.removeEventListener("click",this.#Y.onClick,!0),this.#Y.scrollEl.style.cursor="",this.#Y.scrollEl.style.userSelect="",this.#Y=null}#T(){if(this.#N)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(Q&&Q===this.#_)return;this.#N=!0;try{let $=this.#_;if($&&$!==Q)$.removeEventListener("scroll",this.#J);let J=Q||document.createElement("div");J.className="fig-chooser-scroll",J.dataset.figChooserScroll="";let Z=Array.from(this.childNodes).filter((j)=>{if(j===J)return!1;if(j.nodeType!==Node.ELEMENT_NODE)return!0;return!j.hasAttribute("data-fig-chooser-nav")});for(let j of Z)J.appendChild(j);if(!Q)this.prepend(J);if(this.#_=J,this.#_.removeEventListener("scroll",this.#J),this.#_.addEventListener("scroll",this.#J),this.#q)this.#q.observe(this.#_)}finally{this.#N=!1}}#E(){if(this.#T(),this.#W==="scrollbar")this.#P();else this.#k()}#P(){this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#X&&this.#K&&this.contains(this.#X)&&this.contains(this.#K))return;this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null;let Q=A0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#V(-1),onEnd:()=>this.#V(1)});this.#X=Q.start,this.#K=Q.end,this.prepend(this.#X),this.append(this.#K)}#V(Q){let $=this.getAttribute("layout")==="horizontal",J=this.#B;Z0(J,$?"x":"y",Q)}#y(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.#B,Z=J.scrollHeight>J.clientHeight,j=J.scrollWidth>J.clientWidth;if(!j&&!Z)return;let q=Q.getBoundingClientRect(),_=J.getBoundingClientRect(),X={behavior:$};if(Z){let Y=q.top-_.top+J.scrollTop+q.height/2;X.top=Y-J.clientHeight/2}if(j){let Y=q.left-_.left+J.scrollLeft+q.width/2;X.left=Y-J.clientWidth/2}J.scrollTo(X)})}#I(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{if(this.#N)return;this.#T(),this.#E();let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#O();else if(!this.#$&&Q.length)this.#O();requestAnimationFrame(()=>this.#A())}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",W1);class N1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#$=!1;#Q=!1;#j=null;#J=!1;#Z=null;#q=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#Y(){return!this.hasAttribute("data-no-color-picker")}get#N(){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#L(){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"}#G(Q){let $=this.#L;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#U(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}#B(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#l(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#O(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#z(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#O(Q),j=$.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#W;if(this.#D(X),X.x){let Y=q(J,j.width);this.style.left=Y===null?_(J):`${Math.round(Y)}px`}if(X.y){let Y=q(Z,j.height);this.style.top=Y===null?_(Z):`${Math.round(Y)}px`}}#D(Q=this.#W){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#F(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#R(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let _ of $){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#A(){let Q=this.#H();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#S(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#S(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#y(Q)}connectedCallback(){this.#k(),this.#P(),this.#A(),this.addEventListener("click",this.#C),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#T);let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.#K)this.#s()}disconnectedCallback(){if(this.#V(),this.#t(),this.#v(),this.#p(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#C),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#T)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#C=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#Y&&!this.#K){this.#g();return}this.select()};#f=(Q)=>{if(this.contains(Q.target))return;if((this.#Z||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#T=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#N&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#g();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#Y)return;if(Q.preventDefault(),!this.#K)this.#g()};#E(Q){if(this.hasAttribute("disabled"))return!1;let $=this.#M();if(!$)return!1;let J=$.getBoundingClientRect();if(J.width<=0||J.height<=0)return!1;let Z=this.#W,j=this.#l(J),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!Z.x)return!1;_-=q;break;case"ArrowRight":if(!Z.x)return!1;_+=q;break;case"ArrowUp":if(!Z.y)return!1;X-=q;break;case"ArrowDown":if(!Z.y)return!1;X+=q;break;case"Home":if(Z.x)_=0;if(Z.y)X=0;break;case"End":if(Z.x)_=1;if(Z.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#D(Z),Z.x)this.style.left=`${Math.round(_*J.width)}px`;if(Z.y)this.style.top=`${Math.round(X*J.height)}px`;this.#F();let Y={...this.#l(J),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&this.#K==="color"&&J)this.#Z.setAttribute("value",J);this.#b()}if(Q==="drag")this.#P();if(Q==="hit-area")this.#A();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#k();if(Q==="value"&&!this.#J&&!this.#$)this.#z(J);if(Q==="tip"){if(this.#t(),this.#K)this.#v(),this.#s()}}#P(){if(this.#N&&!this.#j)this.#j=(Q)=>this.#y(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#N&&this.#j)this.#V()}#k(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let J=this.#K||this.getAttribute("type")||"handle";this.setAttribute("aria-label",J==="color"?"Color handle":J==="add"?"Add handle":J==="remove"?"Remove handle":"Handle")}}#V(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#$=!1}#y(Q){if(!this.#N||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#W,Z=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,N=Q.clientY,B=3,L=(U,F,D=!1)=>{let M=$.getBoundingClientRect();Z=M;let O=this.#l(M),P=U-X-M.left,k=F-Y-M.top,S=Math.max(0,Math.min(M.width,P)),I=Math.max(0,Math.min(M.height,k)),C=M.width>0?J.x?S/M.width:O.px:0.5,w=M.height>0?J.y?I/M.height:O.py:0.5;if(this.#G(D)){if(J.x)C=this.#U(C);if(J.y)w=this.#U(w);if(J.x&&J.y){let d=this.#B(C,w);C=d.x,w=d.y}}if(this.#D(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,C*M.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,w*M.height)))}px`},A=(U)=>{if(!this.#$)return;if(!this.#Q){let F=U.clientX-K,D=U.clientY-N;if(F*F+D*D<B*B)return;if(this.#d(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,L(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#l(Z),shiftKey:U.shiftKey}}))},G=(U)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",G),this.#Q){L(U.clientX,U.clientY,U.shiftKey),this.#F(),this.#z(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#l(Z)}));let F=(D)=>{D.stopPropagation(),D.preventDefault()};this.addEventListener("click",F,{capture:!0,once:!0})}else this.#F();this.#Q=!1};window.addEventListener("pointermove",A),window.addEventListener("pointerup",G)}showColorTip(){if(!this.#K)return;if(this.#Z){this.#Z.style.display="";return}this.#s()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#I(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,N]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return $},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=q0(1,1);q.fillStyle="#000000",q.fillStyle=J;let _=q.fillStyle;if(_.startsWith("#"))return Z(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return $}#w(){let{color:Q,opacity:$}=this.#I();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#b(){if(!this.#q)return;this.#q.setAttribute("value",this.#w())}#h(){if(!p())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#u),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#g(){if(this.hasAttribute("disabled"))return;let Q=this.#h();if(!Q){this.#m();return}this.setAttribute("selected",""),this.#b(),Q.open()}#v(){if(!this.#q)return;this.#q.removeEventListener("input",this.#u),this.#q.removeEventListener("change",this.#e),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#x(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#J0),Q.addEventListener("change",this.#Z0),this.appendChild(Q),this.#_=Q,Q}#m(){let Q=this.#x(),{color:$}=this.#I();Q.value=$,this.setAttribute("selected",""),Q.click()}#p(){if(!this.#_)return;this.#_.removeEventListener("input",this.#J0),this.#_.removeEventListener("change",this.#Z0),this.#_.remove(),this.#_=null}#d(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#s(){let Q=this.#K;if(!Q)return;if(this.#Z)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#a),$.addEventListener("change",this.#c),$.addEventListener("add",this.#n),$.addEventListener("remove",this.#n),this.appendChild($),this.#Z=$,this.#Q0()}#t(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#a),this.#Z.removeEventListener("change",this.#c),this.#Z.removeEventListener("add",this.#n),this.#Z.removeEventListener("remove",this.#n),this.#Z.remove(),this.#Z=null}#Q0(){if(!this.#Z||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#Z.toggleAttribute("selected",Q)}#o(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=c(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#r(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#u=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#e=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#$0(Q){let{opacity:$}=this.#I();return $<100?{color:Q,opacity:$}:{color:Q}}#J0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#Z0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#j0=()=>{this.removeAttribute("selected")};#a=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#c=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#n=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#l(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,_=J.top-$.top,X=q+Z,Y=_+j,K=$.width>0?X/$.width:0,N=$.height>0?Y/$.height:0;return{x:q,y:_,px:K,py:N}}}customElements.define("fig-handle",N1);class U1 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");this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled")this.#$()}#$(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-menu-item",U1);class G1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",G1);class L1 extends HTMLElement{#$=null;#Q=null;#j=null;#J;#Z;#q;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#J=this.#z.bind(this),this.#Z=this.#D.bind(this),this.#q=this.#F.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.#K(),this.#Y(),this.#N(),this.#W(),this.#G(),this.#O(),this.open)this.#A()}disconnectedCallback(){if(this.#L(),document.removeEventListener("keydown",this.#q,!0),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.#S();else this.#A();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu"),this.#$.setAttribute("id",this.#$.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#N(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#W(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id"));if(this.#$)this.#$.addEventListener("click",this.#Z),this.#$.addEventListener("keydown",this.#q)}#L(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#Z),this.#$.removeEventListener("keydown",this.#q)}#G(){this.#j=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id")),this.#$.anchor=this.#Q,this.#O()}}}),this.#j.observe(this,{childList:!0})}#U(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#B(){let Q=this.#U();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#U();if(!$.length)return;let J=(Q+$.length)%$.length;this.#X=J,$[J].focus()}#O(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#D(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#F(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#$?.contains(Q.target))return;if(!this.open||!this.#$?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#M(0));return}let $=this.#U();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#B(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#B(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#B();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(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}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#A(){if(!this.#$)return;if(this.#$.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#S(){if(!this.#$)return;document.removeEventListener("keydown",this.#q,!0),this.#$.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",L1);