@rogieking/figui3 6.20.2 → 6.21.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/README.md +50 -1
- package/components.css +63 -2
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-editor.js +240 -98
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +16 -16
- package/dist/fig.css +1 -1
- package/dist/fig.js +60 -43
- package/dist/propskit.css +1 -0
- package/dist/propskit.js +591 -0
- package/fig-editor.css +157 -17
- package/fig-editor.js +457 -187
- package/fig-lab.css +51 -42
- package/fig-lab.js +125 -9
- package/fig.js +519 -16
- package/package.json +33 -4
- package/propskit-core.js +556 -0
- package/propskit.d.ts +98 -0
- package/propskit.js +15 -0
package/dist/fig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var k1={};var A0=f1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=$.create(q.prototype),Z.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",U=Element.prototype,W=$.assign,F=$.create,B=$.defineProperties,L=$.getOwnPropertyDescriptor,D=$.setPrototypeOf,H=Z.define,M=Z.get,O=Z.upgrade,C=Z.whenDefined,E=F(null),S=new WeakMap,y={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(N){return typeof N=="string"&&/^HTML(?!Element)/.test(N)}).forEach(function(N){function A(){}var T=self[N];D(A,T),(A.prototype=T.prototype).constructor=A,T={},T[N]={value:A},B(self,T)}),new MutationObserver(M0).observe(Q,y),H0(Document.prototype,"importNode"),H0(Node.prototype,"cloneNode"),B(Z,{define:{value:function(N,A,T){if(N=N.toLowerCase(),T&&J in T){E[N]=W({},T,{Class:A});var k=T[J]+'[is="'+N+'"]',f=Q.querySelectorAll(k);for(var V=0,w=f.length;V<w;V++)o(f[V])}else H.apply(Z,arguments)}},get:{value:function(N){return N in E?E[N].Class:M.call(Z,N)}},upgrade:{value:function(N){var A=q0(N);if(A&&!(N instanceof A.Class))F0(N,A);else O.call(Z,N)}},whenDefined:{value:function(N){return N in E?Promise.resolve():C.call(Z,N)}}});var I=Q.createElement;B(Q,{createElement:{value:function(N,A){var T=I.call(Q,N);if(A&&"is"in A)T.setAttribute("is",A.is),Z.upgrade(T);return T}}});var g=L(U,"attachShadow").value,r=L(U,"innerHTML");B(U,{attachShadow:{value:function(){var N=g.apply(this,arguments);return new MutationObserver(M0).observe(N,y),N}},innerHTML:{get:r.get,set:function(N){if(r.set.call(this,N),/\bis=("|')?[a-z0-9_-]+\1/i.test(N))n(this,o)}}});function M0(N){for(var A=0,T=N.length;A<T;A++){var k=N[A],f=k.addedNodes,V=k.removedNodes;for(var w=0,e=f.length;w<e;w++)o(f[w]);for(var _0=0,S1=V.length;_0<S1;_0++)z0(V[_0])}}function O0(N){for(var A=0,T=N.length;A<T;A++){var k=N[A],f=k.attributeName,V=k.oldValue,w=k.target,e=w.getAttribute(f);if(Y in w&&!(V==e&&e==null))w[Y](f,V,w.getAttribute(f),null)}}function z0(N){if(N.nodeType!==1)return;var A=q0(N);if(A&&N instanceof A.Class&&G in N&&S.get(N)!==G)S.set(N,G),Promise.resolve(N).then(E1);n(N,z0)}function q0(N){var A=N.getAttribute("is");if(A){if(A=A.toLowerCase(),A in E)return E[A]}return null}function C1(N){N[K]()}function E1(N){N[G]()}function F0(N,A){var T=A.Class,k=T.observedAttributes||[];if(D(N,T.prototype),k.length){new MutationObserver(O0).observe(N,{attributes:!0,attributeFilter:k,attributeOldValue:!0});var f=[];for(var V=0,w=k.length;V<w;V++)f.push({attributeName:k[V],oldValue:null,target:N});O0(f)}}function o(N){if(N.nodeType!==1)return;var A=q0(N);if(A){if(!(N instanceof A.Class))F0(N,A);if(K in N&&N.isConnected&&S.get(N)!==K)S.set(N,K),Promise.resolve(N).then(C1)}n(N,o)}function n(N,A){for(var T=N.content,k=(T&&T.nodeType==11?T:N).querySelectorAll("[is]"),f=0,V=k.length;f<V;f++)A(k[f])}function H0(N,A){var T=N[A],k={};k[A]={value:function(){var f=T.apply(this,arguments);switch(f.nodeType){case 1:case 11:n(f,o)}return f}},B(N,k)}})()}})(document,customElements,Object)});function I1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function u(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function m(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function R(Q,Z){return Q.hasAttribute(Z)&&Q.getAttribute(Z)!=="false"}function Z0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){X0(Z);return}let $=Z.textContent.trim();if(!$){X0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",q=$===j?J:$,X=Array.from($)[0].toUpperCase();if(Z.textContent!==X)Z.textContent=X;if(q&&q!==X)Z.dataset.figInputSlotFullText=q,Z.setAttribute("aria-label",q),V1(Z);else X0(Z)})}function V1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",R0),Q.addEventListener("pointerleave",Y0),Q.addEventListener("focus",R0),Q.addEventListener("blur",Y0)}function X0(Q){Y0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function R0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;z.show(Z,$)}function Y0(Q){let Z=Q.currentTarget;if(!Z)return;z.hide(Z)}function C0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:q=""}={}){let _=(X,Y)=>{let K=document.createElement("button");if(K.className=["fig-overflow",`fig-overflow-${X}`,X==="start"?J:j].filter(Boolean).join(" "),K.dataset.figOverflow=X,Q)K.setAttribute(`data-fig-${Q}-nav`,X);return K.setAttribute("tabindex","-1"),K.setAttribute("aria-label",X==="start"?"Scroll back":"Scroll forward"),K.appendChild(u("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),K.addEventListener("click",(G)=>{G.preventDefault(),G.stopPropagation(),Y?.(G)}),K};return{start:_("start",Z),end:_("end",$)}}function E0(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",q=j?Z.scrollWidth:Z.scrollHeight,_=j?Z.clientWidth:Z.clientHeight,X=j?Z.scrollLeft:Z.scrollTop,Y=q-_>J,K=!Y||X<=J,G=!Y||X+_>=q-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!G),Y}function K0(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",q=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:q,behavior:"smooth"})}function s(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function x1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var S0=I1()&&!x1(),y1=(S0?Promise.resolve().then(() => (A0(),k1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function W0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!S0){J();return}y1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function b(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function Q0(Q){if(!document.body)return null;let Z="data-figui-overlay-root",$=document.body.querySelector(`:scope > [${Z}]`);if(!$)$=document.createElement("div"),$.setAttribute(Z,""),document.body.append($);return w1($,Q),$}function w1(Q,Z){if(!Q)return;let $=(Z instanceof Element?Z.closest(".figui-root"):null)||document.querySelector(".figui-root");if(!$)return;let J=$.getAttribute("theme"),j=J==="light"||J==="dark"||J==="system"?J:$.classList.contains("figma-dark")?"dark":$.classList.contains("figma-light")?"light":"system";if(Q.classList.toggle("figma-light",j==="light"),Q.classList.toggle("figma-dark",j==="dark"),j==="system")Q.style.setProperty("color-scheme","light dark");else Q.style.setProperty("color-scheme",j);if(J)Q.setAttribute("theme",j);else Q.removeAttribute("theme")}var v1=1e4;function f0(){return v1++}function v(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}function x(Q){return String(Q??"").replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var c=null,D0=null;function U0(Q=1,Z=1){if(!c)c=document.createElement("canvas"),D0=c.getContext("2d");if(c.width!==Q)c.width=Q;if(c.height!==Z)c.height=Z;return{canvas:c,ctx:D0}}class k0 extends HTMLElement{type;#Z;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#G.bind(this);#$=this.#X.bind(this);#j=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#q=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Q=this.type==="select"||this.type==="upload",Z=Q?"span":"button",$=Q?"":' type="button"';this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
button, button:hover, button:active, .fig-button-control {
|
|
4
4
|
padding: 0 var(--spacer-2);
|
|
@@ -34,9 +34,9 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
34
34
|
<${Z} class="fig-button-control"${$}>
|
|
35
35
|
<slot></slot>
|
|
36
36
|
</${Z}>
|
|
37
|
-
`,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#$),this.button.addEventListener("focus",this.#J),this.button.addEventListener("blur",this.#q)}this.removeEventListener("keydown",this.#j),this.addEventListener("keydown",this.#j),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#U()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#G(){if(this.#_())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#X(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#N(){let Q=this.#X();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#Y(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#N();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#K(){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")}#W(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#U(){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="button",this.button.setAttribute("type","button");this.#W(),this.#K()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#U();break}case"disabled":this.#U();break;case"selected":this.#Z=$!==null&&$!=="false",this.#K();break;default:this.#W();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",C0);class S0 extends HTMLElement{#Z="Menu";#Q=null;#j;#$;#J;#q=!1;#_=null;get label(){return this.#Z}set label(Q){this.#Z=Q}#G;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#L.bind(this),this.#$=this.#A.bind(this),this.#J=this.#M.bind(this),this.#G=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#N(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let $=document.createElement("button");$.setAttribute("type","button"),$.setAttribute("aria-hidden","true");let J=document.createElement("selectedcontent");$.appendChild(J),this.select.appendChild($),this.#q=!0,this.#_=J}#Y(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.replaceChildren(...Array.from(Q.childNodes,(Z)=>Z.cloneNode(!0)))}#K(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#J)}#W(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#U(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#O(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#G),this.optionsSlot.addEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J),this.#K()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Q:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.#N(),this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#F($);if(this.#Y(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#W(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.#Y(),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#A(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#W(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y(),this.dispatchEvent(new CustomEvent("change",{detail:$,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}#F(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??"";this.#Y()}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#F($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="experimental")this.slotChange();if(Q==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#O()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}customElements.define("fig-dropdown",S0);class O extends HTMLElement{static#Z=0;static#Q=0;static#j=1000;static#$=null;static#J=!1;static#q=new Set;#_;#G;#X;#N;#Y;#K;#W;#U;#L;#A;#M=null;#O=null;#F=null;#z;#H=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#b.bind(this),this.#G=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#N=this.#R.bind(this),this.#Y=this.#f.bind(this),this.#K=this.#D.bind(this),this.#W=this.#V.bind(this),this.#U=this.#y.bind(this),this.#A=this.#v.bind(this),this.#L=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(O.#x(),this.setup(),this.#T(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#L)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#C(),this.#P(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#A,!0),this.#M)this.#M.removeEventListener("close",this.#L),this.#M=null;if(this.action==="click")document.body.removeEventListener("click",this.#G);if(clearTimeout(this.#z),O.#$===this)O.#$=null}#B(){return this.firstElementChild}#P(){this.#F?.disconnect(),this.#F=null}#T(){if(this.#C(),this.action==="manual")return;let Q=this.#B();if(!Q){if(!this.#F&&typeof MutationObserver<"u")this.#F=new MutationObserver(()=>{if(this.#B())this.#P(),this.#T()}),this.#F.observe(this,{childList:!0});return}if(this.#O=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#N);Q.addEventListener("touchstart",this.#Y,{passive:!0}),Q.addEventListener("touchmove",this.#K,{passive:!0}),Q.addEventListener("touchend",this.#W,{passive:!0}),Q.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#C(){let Q=this.#O;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#N),Q.removeEventListener("touchstart",this.#Y),Q.removeEventListener("touchmove",this.#K),Q.removeEventListener("touchend",this.#W),Q.removeEventListener("touchcancel",this.#U);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#O=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=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 $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let _=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));_.add($),this.firstElementChild.setAttribute("aria-describedby",[..._].join(" "))}if(Q)(n()??document.body).append(this.popup);else{let _=this.closest("dialog");if(_&&_.open)_.append(this.popup);else(n()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#S(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#S(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#G);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#A,!0)}get#E(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#k(){let Q=Date.now(),Z=O.#j;if(this.action==="hover"&&O.#$)return!0;if(O.#Z&&Q-O.#Z<Z)return!0;if(O.#Q&&Q-O.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#E)return;if(clearTimeout(this.timeout),this.#k()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#M&&!this.#M.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&O.#$&&O.#$!==this)O.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")O.#$=this;O.#Z=Date.now()}hidePopup(){if(this.#E)return;clearTimeout(this.timeout),clearTimeout(this.#z);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,O.#$===this)O.#$=null;if(Q)O.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#R(Q){if(!this.#H)this.hidePopup()}#f(Q){if(this.action==="hover")this.#H=!0,clearTimeout(this.#z),this.showDelayedPopup()}#D(Q){if(this.action==="hover"&&this.#H)clearTimeout(this.#z),this.#z=setTimeout(()=>{this.#H=!1,this.hidePopup()},150)}#V(Q){if(this.action==="hover"&&this.#H)clearTimeout(this.#z),this.#z=setTimeout(()=>{this.#H=!1,this.hidePopup()},300)}#y(Q){if(this.action==="hover"&&this.#H)this.#H=!1,clearTimeout(this.#z),this.hidePopup()}#v(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)}#g(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#C(),Z==="click")document.body?.removeEventListener("click",this.#G);if(this.action=$||"hover",this.isConnected){if(this.#T(),this.action==="click")document.body?.addEventListener("click",this.#G)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#g($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#b(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#x(){if(O.#J)return;O.#J=!0;let Q=()=>{O.dismissHoverTooltips()},Z=()=>{O.#I()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof O))continue;if(Q.action!=="hover")continue;if(Q.#E)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(O.#q))O.hide(Q)}static#w=new WeakMap;static#I(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof O))continue;if(Q.#E)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(O.#q))O.hide(Q)}static show(Q,Z,$={}){O.#x(),O.hide(Q);let J=$.delay??500,_=Date.now()-O.#Z<O.#j?0:J,q={timeout:null,popup:null};O.#w.set(Q,q),O.#q.add(Q),q.timeout=setTimeout(()=>{let G=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","closerequest"),G)X.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,X.append(K),G)(n()??document.body).append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else(n()??document.body).append(X)}X.anchor=Q,X.open=!0,q.popup=X,O.#Z=Date.now()},_)}static hide(Q){let Z=O.#w.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),O.#Q=Date.now();O.#w.delete(Q),O.#q.delete(Q)}}customElements.define("fig-tooltip",O);class k0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#j=null;connectedCallback(){this.#Z=this.textContent,h(this,()=>{this.#$(),this.#J()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#$()}#$(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let q=Z.lastIndexOf($);J=q>0?q:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let _=document.createElement("span");_.className="end",_.textContent=Z.slice(J),this.appendChild(j),this.appendChild(_)}else this.textContent=Z}#J(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;O.show(this,this.#Z)},this.#j=()=>{O.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);O.hide(this)}}customElements.define("fig-truncate",k0);class f0 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._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();h(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),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._teardownIframeDismissListeners(),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 Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(E0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),O.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),O.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,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 Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}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 Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,_=0;for(let q of this.children){let G=q.getBoundingClientRect();if(G.height===0)continue;if(_+=1,q===Q)continue;let X=window.getComputedStyle(q),K=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");J+=G.height+K}if(j&&_>1)J+=j*(_-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}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 Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(m("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),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 Z=Q.getAttribute("id")||g();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_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 Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),_=Q.includes("center")&&!Z&&!$,q=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(_)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(_&&q)this.style.margin="auto";else if(_)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.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){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}K0("fig-dialog",f0,{extends:"dialog"});class I0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=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();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}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";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}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",Z=Q?"alert":"status",$=Q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;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}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}K0("fig-toast",I0,{extends:"dialog"});class V0 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;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&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),this._boundNativeClose=this.handleNativeClose.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 Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&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);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.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.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))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.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),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.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="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(E0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(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 $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")O.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.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($){}if(this.matches?.(":open"))try{this.close()}catch($){}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(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}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 Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;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||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))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 J=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,_)=>j.z-_.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=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),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["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"],J=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.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){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),j="top",_="center",q=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))_=Z[1];return{vertical:j,horizontal:_,shorthand:q}}if(Z.length===1){let G=Z[0];if(G==="top"||G==="bottom")j=G,q=G;else if(G==="left"||G==="right")_=G,q=G;else if(G==="center")j="center",_="center"}return{vertical:j,horizontal:_,shorthand:q}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let _=parseFloat($);return Number.isFinite(_)?_:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let _=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:_[0]},{v:Q,h:Z,s:_[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,_){let q,G;if(_==="left"||_==="right")return G=_==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:G};if(_==="top"||_==="bottom")return q=_==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,G=Q.left,{top:q,left:G};if($==="top")q=Q.top-Z.height-j.yPx;else if($==="bottom")q=Q.bottom+j.yPx;else q=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")G=Q.left-Z.width-j.xPx;else if(J==="right")G=Q.right+j.xPx;else G=Q.left+(Q.width-Z.width)/2;else if(J==="left")G=Q.left+j.xPx;else if(J==="right")G=Q.right-Z.width-j.xPx;else G=Q.left+(Q.width-Z.width)/2;return{top:q,left:G}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,_=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:_+Q.top,maxRight:j+$-Q.right,maxBottom:_+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,_=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(_,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:_,top:q}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:_,top:q};let G=this.oppositeSide(J),X=this.getViewportBounds(j),K=X.maxRight-Z.width,N=X.minLeft,F=X.maxBottom-Z.height,W=X.minTop;if(G==="top"||G==="bottom"){let z=this.getBeakEdgeInset(G),L=Q.left+Q.width/2,U=L-_;if(U<z)_=L-z;else if(U>Z.width-z)_=L-(Z.width-z);_=Math.min(K,Math.max(N,_))}else if(G==="left"||G==="right"){let z=this.getBeakEdgeInset(G),L=Q.top+Q.height/2,U=L-q;if(U<z)q=L-z;else if(U>Z.height-z)q=L-(Z.height-z);q=Math.min(F,Math.max(W,q))}return{left:_,top:q}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let _=this.oppositeSide(j),q=this.getBeakEdgeInset(_);if(_==="top"||_==="bottom"){let X=Q.left+Q.width/2-$;return X>=q-0.5&&X<=Z.width-q+0.5}let G=Q.top+Q.height/2-J;return G>=q-0.5&&G<=Z.height-q+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let q=Q.left+Q.width/2,G=Q.top+Q.height/2,X=this.getBoundingClientRect(),K=X.width>0&&X.height>0?X:Z,N=K.left,F=K.top,W=this.getBeakEdgeInset(_),z;if(_==="top"||_==="bottom"){z=q-N;let L=W,U=Math.max(L,K.width-W);z=Math.min(U,Math.max(L,z))}else{z=G-F;let L=W,U=Math.max(L,K.height-W);z=Math.min(U,Math.max(L,z))}this.style.setProperty("--fig-popup-beak-offset",`${z}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,_=Q.top+Z.height,q=Math.max(0,J.minLeft-Q.left),G=Math.max(0,J.minTop-Q.top),X=Math.max(0,j-J.maxRight),K=Math.max(0,_-J.maxBottom);return q+G+X+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),_=0;if(J==="top")_=Math.max(0,j.minTop-Q.top);else if(J==="bottom")_=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")_=Math.max(0,j.minLeft-Q.left);else if(J==="right")_=Math.max(0,Q.left+Z.width-j.maxRight);return _>0?1000+_:0}placementScore(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j),q=this.overflowScore(_,Z,j);if(q+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,_.left,_.top,J))q+=1e4;return{score:q,resolved:_}}applyPopupPosition(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${_.left}px`,this.style.top=`${_.top}px`,this.updatePopoverBeak(Q,Z,_.left,_.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),_=this.resolveAnchor(),q=this.parseViewportMargins();if(!_){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(q),z={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},L=this.clampToViewport(z,Q,q);this.style.left=`${L.left}px`,this.style.top=`${L.top}px`;return}let G=_.getBoundingClientRect(),X=this.getPlacementCandidates($,J,j),K=null,N="top",F=Number.POSITIVE_INFINITY;for(let{v:W,h:z,s:L}of X){let U=this.computeCoords(G,Q,W,z,Z,L),T=this.getPlacementSide(W,z,L),{score:R,resolved:B}=this.placementScore(G,Q,U,T,q);if(L){let M=this.getViewportBounds(q);if((L==="left"||L==="right"?U.left>=M.minLeft&&U.left+Q.width<=M.maxRight:U.top>=M.minTop&&U.top+Q.height<=M.maxBottom)&&R<1e4){this.applyPopupPosition(G,Q,U,T,q);return}}else if(R===0){this.applyPopupPosition(G,Q,U,T,q);return}if(R<F)F=R,K=B,N=T}this.applyPopupPosition(G,Q,K||{left:0,top:0},N,q)}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"))}}K0("fig-popup",V0,{extends:"dialog"});class x0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!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),h(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Z)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.#Z}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(H(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}customElements.define("fig-tab",x0);class y0 extends HTMLElement{#Z;#Q;#j=this.#L.bind(this);#$=null;#J=null;#q=null;#_=null;#G=!1;#X=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#z.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#j),this.#F(),this.#M(),this.#A(),h(this,()=>{let Q=this.getAttribute("value");if(Q)this.#P(Q);if(H(this,"disabled"))this.#N(!0);this.#K(),this.#L(),this.#W(void 0,"auto")})}#N(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#X.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#X.has($))this.#X.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#Y(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#Y()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#W(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#Y()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),_=$.getBoundingClientRect(),q=_.left-j.left+this.scrollLeft+_.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#j),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#O()}#U(){if(this.#G)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#G=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#G=!1}}#L(){T0(this,this,"x")}#A(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#L()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#G)return;this.#U(),this.#F(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#W()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#O(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#F(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=D0({owner:"tabs",onStart:()=>X0(this,"x",-1),onEnd:()=>X0(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#z(Q){let Z=this.#Y();if(!Z.length)return;let $=Z.findIndex((j)=>H(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((_)=>_.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#B(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#W(Z[J]),this.#H()}}get value(){return this.#B(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#B(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#P(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#B($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#W(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#P($);break;case"disabled":this.#N($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let q of j)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let _=this.#B(Z);if(_)this.setAttribute("value",_);else this.removeAttribute("value");if(this.#K(),this.#W(Z),$!==Z||J!==this.value)this.#H()}}customElements.define("fig-tabs",y0);class w0 extends HTMLElement{#Z;#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.#$(),this.addEventListener("click",this.#j)}disconnectedCallback(){this.removeEventListener("click",this.#j)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;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.#Z}set value(Q){this.#Z=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"]}#$(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#$();break;case"disabled":this.#$();break}}}customElements.define("fig-segment",w0);class g0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#j=this.#A.bind(this);#$=null;#J=null;#q=0;#_=!1;#G=!1;#X=new WeakSet;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.#C(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#H(),h(this,()=>{this.#P({enforceFallback:!0}),this.#B(),this.#F({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#G=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=H($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#F()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#N(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#Y(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#Y(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#N(j)}#A(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#W();if(!Z.length)return;let $=Z.findIndex((_)=>H(_,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let _=Q.target.closest("fig-segment");if(_&&this.contains(_))Q.preventDefault(),this.#L(_);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#M(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#Y(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#O(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#F({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#z({forceInstant:Z})})}#z({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#O(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#K();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#G=!1;return}if(!J){if(this.#G)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(),_=J.getBoundingClientRect();if(j.width<=0||_.width<=0){if(this.#G)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let q=Math.max(0,_.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${_.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#G||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#G=!0}#H(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#F()}),this.#B()}#B(){if(!this.#J)return;this.#J.disconnect(),this.#J.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#J?.observe(Q)})}#P({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#F({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#M(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#W()[0]||null}#T(){this.#$?.disconnect(),this.#$=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#C(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#B(),this.#P({enforceFallback:!0}),this.#U()}),this.#$.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 Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#C(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#X.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#X.has(Z))this.#X.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#C($!==null&&$!=="false"),this.#F({forceInstant:!0});return}if(Q==="value"){this.#P({enforceFallback:!1});return}if(Q==="animated"){if(!this.#O())this.#G=!1;this.#F({forceInstant:!0});return}if(Q==="sizing")this.#F({forceInstant:!0})}}customElements.define("fig-segmented-control",g0);class v0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#j=null;#$=[];#J=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#G(){if(this.#$.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#$[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#$[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#J=Q,this.#Z="segments";else this.#J=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#N(),this.#G()){this.#X(),this.#A(),h(this,()=>h(this,()=>this.#F()));return}this.#Y(),this.#A(),h(this,()=>h(this,()=>this.#F()))}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.#$.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#N(),this.#W();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#W()}#N(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#$=JSON.parse(Q);return}catch{}let Z=Q.includes(`
|
|
37
|
+
`,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#$),this.button.addEventListener("focus",this.#j),this.button.addEventListener("blur",this.#q)}this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#U()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#_())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#Y(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#N(){let Q=this.#Y();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#G(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#N();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#K(){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")}#W(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#U(){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="button",this.button.setAttribute("type","button");this.#W(),this.#K()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#U();break}case"disabled":this.#U();break;case"selected":this.#Z=$!==null&&$!=="false",this.#K();break;default:this.#W();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J)}}customElements.define("fig-button",k0);class I0 extends HTMLElement{#Z="Menu";#Q=null;#J;#$;#j;#q=!1;#_=null;get label(){return this.#Z}set label(Q){this.#Z=Q}#X;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#L.bind(this),this.#$=this.#F.bind(this),this.#j=this.#O.bind(this),this.#X=this.slotChange.bind(this)}#Y(){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}}#N(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#Y()){this.#q=!1;return}let $=document.createElement("button");$.setAttribute("type","button"),$.setAttribute("aria-hidden","true");let J=document.createElement("selectedcontent");$.appendChild(J),this.select.appendChild($),this.#q=!0,this.#_=J}#G(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.replaceChildren(...Array.from(Q.childNodes,(Z)=>Z.cloneNode(!0)))}#K(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#j)}#W(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#U(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#B(),!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.#$),this.select.removeEventListener("keydown",this.#j),this.#K()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Q:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.#N(),this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#z($);if(this.#G(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#W(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.#G(),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#F(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#W(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G(),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#O(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"]}#B(){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.value=Q??"";this.#G()}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#z($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="experimental")this.slotChange();if(Q==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#B()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#j)}}customElements.define("fig-dropdown",I0);class z extends HTMLElement{static#Z=0;static#Q=0;static#J=1000;static#$=null;static#j=!1;static#q=new Set;#_;#X;#Y;#N;#G;#K;#W;#U;#L;#F;#O=null;#B=null;#z=null;#H;#A=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#g.bind(this),this.#X=this.hidePopupOutsideClick.bind(this),this.#Y=this.showDelayedPopup.bind(this),this.#N=this.#T.bind(this),this.#G=this.#k.bind(this),this.#K=this.#D.bind(this),this.#W=this.#I.bind(this),this.#U=this.#y.bind(this),this.#F=this.#b.bind(this),this.#L=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(z.#V(),this.setup(),this.#R(),this.setupEventListeners(),this.#O=this.closest("dialog"),this.#O)this.#O.addEventListener("close",this.#L)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#C(),this.#P(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#F,!0),this.#O)this.#O.removeEventListener("close",this.#L),this.#O=null;if(this.action==="click")document.body.removeEventListener("click",this.#X);if(clearTimeout(this.#H),z.#$===this)z.#$=null}#M(){return this.firstElementChild}#P(){this.#z?.disconnect(),this.#z=null}#R(){if(this.#C(),this.action==="manual")return;let Q=this.#M();if(!Q){if(!this.#z&&typeof MutationObserver<"u")this.#z=new MutationObserver(()=>{if(this.#M())this.#P(),this.#R()}),this.#z.observe(this,{childList:!0});return}if(this.#B=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#Y),Q.addEventListener("pointerleave",this.#N);Q.addEventListener("touchstart",this.#G,{passive:!0}),Q.addEventListener("touchmove",this.#K,{passive:!0}),Q.addEventListener("touchend",this.#W,{passive:!0}),Q.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#Y),Q.addEventListener("touchstart",this.#Y,{passive:!0})}#C(){let Q=this.#B;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#Y),Q.removeEventListener("pointerleave",this.#N),Q.removeEventListener("touchstart",this.#G),Q.removeEventListener("touchmove",this.#K),Q.removeEventListener("touchend",this.#W),Q.removeEventListener("touchcancel",this.#U);else if(this.action==="click")Q.removeEventListener("click",this.#Y),Q.removeEventListener("touchstart",this.#Y);this.#B=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=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 $=b();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let q=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));q.add($),this.firstElementChild.setAttribute("aria-describedby",[...q].join(" "))}if(Q)(Q0(this)??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(Q0(this)??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#S(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#S(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#X);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#F,!0)}get#E(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#f(){let Q=Date.now(),Z=z.#J;if(this.action==="hover"&&z.#$)return!0;if(z.#Z&&Q-z.#Z<Z)return!0;if(z.#Q&&Q-z.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#E)return;if(clearTimeout(this.timeout),this.#f()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#O&&!this.#O.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&z.#$&&z.#$!==this)z.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")z.#$=this;z.#Z=Date.now()}hidePopup(){if(this.#E)return;clearTimeout(this.timeout),clearTimeout(this.#H);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,z.#$===this)z.#$=null;if(Q)z.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#T(Q){if(!this.#A)this.hidePopup()}#k(Q){if(this.action==="hover")this.#A=!0,clearTimeout(this.#H),this.showDelayedPopup()}#D(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#A=!1,this.hidePopup()},150)}#I(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#A=!1,this.hidePopup()},300)}#y(Q){if(this.action==="hover"&&this.#A)this.#A=!1,clearTimeout(this.#H),this.hidePopup()}#b(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 Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#C(),Z==="click")document.body?.removeEventListener("click",this.#X);if(this.action=$||"hover",this.isConnected){if(this.#R(),this.action==="click")document.body?.addEventListener("click",this.#X)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#v($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#g(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#V(){if(z.#j)return;z.#j=!0;let Q=()=>{z.dismissHoverTooltips()},Z=()=>{z.#x()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof z))continue;if(Q.action!=="hover")continue;if(Q.#E)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(z.#q))z.hide(Q)}static#w=new WeakMap;static#x(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof z))continue;if(Q.#E)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(z.#q))z.hide(Q)}static show(Q,Z,$={}){z.#V(),z.hide(Q);let J=$.delay??500,q=Date.now()-z.#Z<z.#J?0:J,_={timeout:null,popup:null};z.#w.set(Q,_),z.#q.add(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=Z,Y.append(K),X)(Q0(Q)??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(Q0(Q)??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,z.#Z=Date.now()},q)}static hide(Q){let Z=z.#w.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),z.#Q=Date.now();z.#w.delete(Q),z.#q.delete(Q)}}customElements.define("fig-tooltip",z);class V0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#J=null;connectedCallback(){this.#Z=this.textContent,m(this,()=>{this.#$(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#$()}#$(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let _=Z.lastIndexOf($);J=_>0?_:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let q=document.createElement("span");q.className="end",q.textContent=Z.slice(J),this.appendChild(j),this.appendChild(q)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;z.show(this,this.#Z)},this.#J=()=>{z.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);z.hide(this)}}customElements.define("fig-truncate",V0);class x0 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._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();m(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),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._teardownIframeDismissListeners(),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 Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(f0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),z.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),z.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,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 Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}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 Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.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");J+=X.height+K}if(j&&q>1)J+=j*(q-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}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 Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(u("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),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 Z=Q.getAttribute("id")||b();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_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 Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!Z&&!$,_=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(J)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"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.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){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}W0("fig-dialog",x0,{extends:"dialog"});class y0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=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();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}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";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}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",Z=Q?"alert":"status",$=Q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;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}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}W0("fig-toast",y0,{extends:"dialog"});class w0 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;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&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),this._boundNativeClose=this.handleNativeClose.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 Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&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);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.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.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))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.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),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.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="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(f0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(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 $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")z.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.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($){}if(this.matches?.(":open"))try{this.close()}catch($){}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(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}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 Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;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||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))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 J=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(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=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),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["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"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.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){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),j="top",q="center",_=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))q=Z[1];return{vertical:j,horizontal:q,shorthand:_}}if(Z.length===1){let X=Z[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,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let q=parseFloat($);return Number.isFinite(q)?q:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let q=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:q[0]},{v:Q,h:Z,s:q[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if($==="top")_=Q.top-Z.height-j.yPx;else if($==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")X=Q.left-Z.width-j.xPx;else if(J==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-Z.width)/2;else if(J==="left")X=Q.left+j.xPx;else if(J==="right")X=Q.right-Z.width-j.xPx;else X=Q.left+(Q.width-Z.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,q=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+$-Q.right,maxBottom:q+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,q=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(q,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:q,top:_}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(J),Y=this.getViewportBounds(j),K=Y.maxRight-Z.width,G=Y.minLeft,U=Y.maxBottom-Z.height,W=Y.minTop;if(X==="top"||X==="bottom"){let F=this.getBeakEdgeInset(X),B=Q.left+Q.width/2,L=B-q;if(L<F)q=B-F;else if(L>Z.width-F)q=B-(Z.width-F);q=Math.min(K,Math.max(G,q))}else if(X==="left"||X==="right"){let F=this.getBeakEdgeInset(X),B=Q.top+Q.height/2,L=B-_;if(L<F)_=B-F;else if(L>Z.height-F)_=B-(Z.height-F);_=Math.min(U,Math.max(W,_))}return{left:q,top:_}}canPointAtAnchor(Q,Z,$,J,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-$;return Y>=_-0.5&&Y<=Z.width-_+0.5}let X=Q.top+Q.height/2-J;return X>=_-0.5&&X<=Z.height-_+0.5}updatePopoverBeak(Q,Z,$,J,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:Z,G=K.left,U=K.top,W=this.getBeakEdgeInset(q),F;if(q==="top"||q==="bottom"){F=_-G;let B=W,L=Math.max(B,K.width-W);F=Math.min(L,Math.max(B,F))}else{F=X-U;let B=W,L=Math.max(B,K.height-W);F=Math.min(L,Math.max(B,F))}this.style.setProperty("--fig-popup-beak-offset",`${F}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,q=Q.top+Z.height,_=Math.max(0,J.minLeft-Q.left),X=Math.max(0,J.minTop-Q.top),Y=Math.max(0,j-J.maxRight),K=Math.max(0,q-J.maxBottom);return _+X+Y+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),q=0;if(J==="top")q=Math.max(0,j.minTop-Q.top);else if(J==="bottom")q=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")q=Math.max(0,j.minLeft-Q.left);else if(J==="right")q=Math.max(0,Q.left+Z.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j),_=this.overflowScore(q,Z,j);if(_+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,q.left,q.top,J))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,Z,q.left,q.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(_),F={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},B=this.clampToViewport(F,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates($,J,j),K=null,G="top",U=Number.POSITIVE_INFINITY;for(let{v:W,h:F,s:B}of Y){let L=this.computeCoords(X,Q,W,F,Z,B),D=this.getPlacementSide(W,F,B),{score:H,resolved:M}=this.placementScore(X,Q,L,D,_);if(B){let O=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=O.minLeft&&L.left+Q.width<=O.maxRight:L.top>=O.minTop&&L.top+Q.height<=O.maxBottom)&&H<1e4){this.applyPopupPosition(X,Q,L,D,_);return}}else if(H===0){this.applyPopupPosition(X,Q,L,D,_);return}if(H<U)U=H,K=M,G=D}this.applyPopupPosition(X,Q,K||{left:0,top:0},G,_)}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"))}}W0("fig-popup",w0,{extends:"dialog"});class v0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!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),m(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||b(),Z=this.content.getAttribute("id")||b();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Z)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.#Z}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(R(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}customElements.define("fig-tab",v0);class b0 extends HTMLElement{#Z;#Q;#J=this.#L.bind(this);#$=null;#j=null;#q=null;#_=null;#X=!1;#Y=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#J),this.#z(),this.#O(),this.#F(),m(this,()=>{let Q=this.getAttribute("value");if(Q)this.#P(Q);if(R(this,"disabled"))this.#N(!0);this.#K(),this.#L(),this.#W(void 0,"auto")})}#N(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#Y.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#Y.has($))this.#Y.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#G(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#G()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#W(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#G()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),q=$.getBoundingClientRect(),_=q.left-j.left+this.scrollLeft+q.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#X)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#X=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#X=!1}}#L(){E0(this,this,"x")}#F(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#L()),this.#j.observe(this)}#O(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#X)return;this.#U(),this.#z(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#W()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#z(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=C0({owner:"tabs",onStart:()=>K0(this,"x",-1),onEnd:()=>K0(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#H(Q){let Z=this.#G();if(!Z.length)return;let $=Z.findIndex((j)=>R(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#M(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#W(Z[J]),this.#A()}}get value(){return this.#M(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#A(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#M(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#P(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#M($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#W(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#P($);break;case"disabled":this.#N($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===Z)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#M(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#W(Z),$!==Z||J!==this.value)this.#A()}}customElements.define("fig-tabs",b0);class g0 extends HTMLElement{#Z;#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.#$(),this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;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.#Z}set value(Q){this.#Z=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"]}#$(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#$();break;case"disabled":this.#$();break}}}customElements.define("fig-segment",g0);class h0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#J=this.#F.bind(this);#$=null;#j=null;#q=0;#_=!1;#X=!1;#Y=new WeakSet;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.#C(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#A(),m(this,()=>{this.#P({enforceFallback:!0}),this.#M(),this.#z({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#X=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=R($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#z()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#N(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#G(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#G(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#N(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#W();if(!Z.length)return;let $=Z.findIndex((q)=>R(q,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#L(q);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#O(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#G(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#z({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#H({forceInstant:Z})})}#H({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#K();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#X=!1;return}if(!J){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=J.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}#A(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#z()}),this.#M()}#M(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#P({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#z({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#O(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#W()[0]||null}#R(){this.#$?.disconnect(),this.#$=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#C(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#M(),this.#P({enforceFallback:!0}),this.#U()}),this.#$.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 Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#C(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#Y.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#Y.has(Z))this.#Y.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#C($!==null&&$!=="false"),this.#z({forceInstant:!0});return}if(Q==="value"){this.#P({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#X=!1;this.#z({forceInstant:!0});return}if(Q==="sizing")this.#z({forceInstant:!0})}}customElements.define("fig-segmented-control",h0);class m0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#J=null;#$=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#X(){if(this.#$.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#$[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#$[j])}return!1}#Y(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#N(),this.#X()){this.#Y(),this.#F(),m(this,()=>m(this,()=>this.#z()));return}this.#G(),this.#F(),m(this,()=>m(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.#$.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#N(),this.#W();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#W()}#N(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#$=JSON.parse(Q);return}catch{}let Z=Q.includes(`
|
|
38
38
|
`)?`
|
|
39
|
-
`:",";this.#$=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#
|
|
39
|
+
`:",";this.#$=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#G(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),R(this,"disabled"))Q.setAttribute("disabled","");if(R(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-dropdown");if(R(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#W(){if(this.#Z==="segments")this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#z())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#z()}),this.#J.observe(this)}#O(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#O(Z))return!0;return!1}#z(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}customElements.define("fig-options",m0);class u0 extends HTMLElement{#Z=!1;#Q=!1;#J=!1;#$="";#j=["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;#Y;#N;#G;#K;#W;#U=null;#L=null;#F=null;#O=null;constructor(){super();this.initialInnerHTML=null,this.#_=(Q)=>{Q.stopPropagation(),this.#b()},this.#X=(Q)=>{Q.stopPropagation(),this.#v()},this.#G=(Q)=>{this.#g(Q)},this.#Y=(Q)=>{Q.stopPropagation(),this.#P()},this.#N=(Q)=>{Q.stopPropagation(),this.#V()},this.#K=()=>{this.#Z=!0},this.#W=()=>{this.#Z=!1}}#B(){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.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#q[this.type]||this.#q.range,$=(J,j)=>{let q=this.getAttribute(J),_=q===null||q.trim()===""?j:Number(q);return Number.isFinite(_)?_:j};if(this.min=$("min",Z.min),this.max=$("max",Z.max),this.step=$("step",Z.step),!(this.step>0))this.step=Z.step>0?Z.step:1;this.color=this.getAttribute("color")||Z?.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)}#z(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#H(){if(this.#B(),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)}}#A(){if(this.#I(),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.#G),this.input.addEventListener("keydown",this.#G),this.input.removeEventListener("pointerdown",this.#K),this.input.addEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#W),this.input.addEventListener("pointerup",this.#W),this.input.removeEventListener("pointercancel",this.#W),this.input.addEventListener("pointercancel",this.#W),this.default)this.style.setProperty("--default",this.#R(this.default));if(this.figInputNumber)this.#y(),this.figInputNumber.removeEventListener("input",this.#Y),this.figInputNumber.addEventListener("input",this.#Y),this.figInputNumber.removeEventListener("change",this.#N),this.figInputNumber.addEventListener("change",this.#N)}#M(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
|
|
40
40
|
<input
|
|
41
41
|
type="range"
|
|
42
42
|
${this.text?'tabindex="-1"':""}
|
|
@@ -52,19 +52,19 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
52
52
|
${this.initialInnerHTML}
|
|
53
53
|
</div>`;if(this.text)Q=`${Z}
|
|
54
54
|
<fig-input-number
|
|
55
|
-
placeholder="${
|
|
55
|
+
placeholder="${x(this.placeholder)}"
|
|
56
56
|
min="${this.min}"
|
|
57
57
|
max="${this.max}"
|
|
58
58
|
transform="${this.transform}"
|
|
59
59
|
step="${this.step}"
|
|
60
60
|
value="${this.#Q?"":this.value}"
|
|
61
|
-
${this.units?`units="${
|
|
61
|
+
${this.units?`units="${x(this.units)}"`:""}
|
|
62
62
|
${this.precision!==null?`precision="${this.precision}"`:""}>
|
|
63
|
-
</fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#H(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||g()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",g());let $=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*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",g());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#D()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#F()){this.#z(),this.#H(),this.#D();return}this.#B()}get value(){if(this.#$!=="")return this.#$;let Q=this.getAttribute("value");if(Q!==null)return String(this.#R(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#R(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#j=!0,this.setAttribute("value",J),this.#j=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":J);if(this.input)this.#f()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#G),this.input.removeEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#W),this.input.removeEventListener("pointercancel",this.#W);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#N)}#P(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#R(Q);this.value=Z,this.input.value=String(Z),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#T(Q){let{min:Z,max:$}=this.#S(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#C(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#S(){let Q=this.#C(this.min),Z=this.#C(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#E(Q){let{min:Z,max:$}=this.#S();return Math.min($,Math.max(Z,Q))}#k(){if(this.type==="delta"){let Z=this.#C(this.default);if(Z!==null)return this.#E(Z);return this.#E(0)}if(this.type==="range"){let{min:Z,max:$}=this.#S();return this.#E(Z+($-Z)/2)}let{min:Q}=this.#S();return Q}#R(Q){let Z=this.#C(Q);if(Z===null)return this.#k();return this.#E(Z)}#f(){let Q=this.#T(this.value),Z=this.#T(this.default),$=Q<Z?-1:1,J=Q===Z?1:0;if(this.#U!==Q)this.style.setProperty("--slider-complete",Q),this.#U=Q;if(this.#L!==Z)this.style.setProperty("--default",Z),this.#L=Z;if(this.#A!==$)this.style.setProperty("--slider-delta-direction",$),this.#A=$;if(this.#M!==J)this.style.setProperty("--unchanged",J),this.#M=J}#D(){let Q=this.input.value;if(this.value=Q,this.#f(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#V(){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.#y();return}this.input.removeAttribute("aria-hidden"),this.#J.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#v(){this.#Q=!1,this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#g(){this.#Z=!1,this.#Q=!1,this.#D(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#C(this.input.value)??this.#k(),J=this.#C(this.step)??1,j=this.#R($+J*10*Z);this.value=j,this.input.value=String(j),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#x(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#R(Q);this.value=Z,this.input.value=String(Z),this.#D(),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,Z,$){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;if(this.#Q=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#R($),this.input.value=String(this.value),this.#D(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=$!==null?$:this.type==="delta"?0:this.min,this.#f();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=$,this.#B();break;case"text":this.text=$!=="false",this.#B();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#V();break;default:this[Q]=this.input[Q]=$,this.#D();break}}}customElements.define("fig-slider",b0);class h0 extends HTMLElement{#Z=!1;#Q=!1;#j;#$;#J;#q;#_;#G;#X;#N;#Y=null;#K=0;#W="";#U="";#L=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#R.bind(this),this.#$=this.#D.bind(this),this.#J=this.#D.bind(this),this.#q=this.#f.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#k(Q)},this.#G=(Q)=>{Q.stopPropagation();let Z=Q.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#X=this.focus.bind(this),this.#N=this.#M.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",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.#A(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#H(),this.#B(),this.#P(),this.#T(),this.#C(),Q0(this),this.#O(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#E(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#E(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#E(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#N),this.addEventListener("click",this.#N),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#G);if(this.removeEventListener("click",this.#N),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#J),this.#Y?.disconnect(),this.#Y=null,this.#K)cancelAnimationFrame(this.#K),this.#K=0}focus(){this.input.focus()}#A(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(Q)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#E(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#M(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#O(){this.#Y?.disconnect(),this.#Y=new MutationObserver(()=>this.#F()),this.#Y.observe(this,{childList:!0,characterData:!0,subtree:!0})}#F(){if(this.#K)return;this.#K=requestAnimationFrame(()=>{if(this.#K=0,!this.isConnected)return;this.#z()})}#z(){if(!this.input||!this.contains(this.input))this.input=this.#A(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#_),this.input.addEventListener("input",this.#G);this.#H(),this.#B(),this.#P(),this.#T(),this.#C(),Q0(this)}#H(){if(!this.input)return;this.#L.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#B(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=m("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#X),this.prepend($)}#P(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){let q=Q.querySelector("fig-icon");if(q&&q.getAttribute("name")!=="close")q.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let _=m("close",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.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.#T(),this.focus()})}#T(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#C(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){this.#S(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let _=m("visible",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),this.#S($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#S($),this.focus()})}#S(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Q?"visible":"hidden")}#E(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#y(Z),Z}#k(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#V(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#R(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#D();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#V($,!1);let J=$*(this.transform||1);$=this.#y($),J=this.#y(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#f(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Z=!0,this.#W=this.style.userSelect,this.#U=document.body.style.cursor,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.#$),window.addEventListener("pointercancel",this.#$),window.addEventListener("blur",this.#J)}#D(Q){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#U,this.style.userSelect=this.#W,window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#$),window.removeEventListener("pointercancel",this.#$),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#E(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#E(this.max):this.max,$);$=this.#y($)}return $}#y(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false";break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#E(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#V(J,!1),this.value=J,this.input.value=this.#E(J);else this.value=J,this.input.value=J;this.#T();break;case"min":case"max":case"step":if($===null||$==="")this[Q]=void 0,this.input.removeAttribute(Q);else this[Q]=this.input[Q]=Number($),this.input.setAttribute(Q,$);break;case"name":if(this[Q]=this.input[Q]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#q),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#q);this.#B(),this.#P(),this.#T(),this.#C();break;case"multiline":{let j=$!==null&&$!=="false";if(j!==this.multiline){this.multiline=j;let _=this.input;_.removeEventListener("change",this.#_),_.removeEventListener("input",this.#G),_.remove(),this.input=this.#A(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#_),this.input.addEventListener("input",this.#G),this.#H()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#H();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-text",h0);class Z0 extends HTMLElement{#Z;#Q;#j;#$;#J;#q;#_;#G;#X;#N;#Y;#K;#W;#U;#L;#A;#M=!1;#O=null;#F=null;#z=0;#H="";#B="";#P=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#T="px";#C(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#S(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#E(){this.#K=this.#S(this.#W)}#k(Q){if(Q&&!this.#O)this.#O=document.createElement("span"),this.#O.className="fig-steppers",this.#O.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#O.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#f(J),this.input.focus()}),this.append(this.#O);else if(!Q&&this.#O)this.#O.remove(),this.#O=null;this.#R()}#R(){if(!this.#O)return;let Q=this.#O.querySelector(".fig-stepper-up"),Z=this.#O.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#w(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),_=Boolean(this.disabled),q=j&&typeof this.min==="number"&&J<=this.min,G=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=_||G,Z.disabled=_||q}#f(Q){let Z=this.step||1,$=this.#w(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#p(J,!1),this.value=J,this.input.value=this.#I(this.value),this.#R(),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Z=this.#t.bind(this),this.#Q=this.#d.bind(this),this.#j=this.#d.bind(this),this.#$=this.#r.bind(this),this.#J=(Q)=>{Q.stopPropagation(),this.#c(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#m(Q)},this.#_=(Q)=>{this.#u(Q)},this.#G=(Q)=>{this.#h(Q)},this.#X=(Q)=>{this.#e(Q)},this.#N=this.focus.bind(this),this.#Y=this.#V.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 Z=this.getAttribute("units-disallow");if(this.#U=this.#C(Z===null?Z0.#T:Z),this.#E(),this.#L=this.getAttribute("unit-position")||"suffix",this.#A=this.#Q0(this.hasAttribute("precision")?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 $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#D(),this.#b(),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.#k($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#R(),this.#x(),Q0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.#y(),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),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.#G),this.input.addEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#J),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X);if(this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j),this.#F?.disconnect(),this.#F=null,this.#z)cancelAnimationFrame(this.#z),this.#z=0}focus(){this.input.focus()}#D(){let Q=this.querySelector("input");if(Q)return Q;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#I(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#V(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#y(){this.#F?.disconnect(),this.#F=new MutationObserver(()=>this.#v()),this.#F.observe(this,{childList:!0,characterData:!0,subtree:!0})}#v(){if(this.#z)return;this.#z=requestAnimationFrame(()=>{if(this.#z=0,!this.isConnected)return;this.#g()})}#g(){if(!this.input||!this.contains(this.input))this.input=this.#D(),this.input.addEventListener("change",this.#J),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#_),this.input.addEventListener("blur",this.#G),this.input.addEventListener("keydown",this.#X);let Q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#O&&!this.contains(this.#O))this.#O=null;this.#k(Q),this.#b(),this.#x(),Q0(this)}#b(){if(!this.input)return;this.#P.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#x(){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.#I(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#w(Q){if(!Q)return"";if(!this.#K){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#K,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#I(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#l(Z),!this.#K)return Z.toString();if(this.#L==="prefix")return this.#K+Z;else return Z+this.#K}#s(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#l(Z),Z.toString()}#u(Q){this.#M=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#K)if(this.#L==="prefix")Q.target.setSelectionRange(this.#K.length,Z.length);else{let $=Z.indexOf(this.#K);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#h(Q){this.#M=!1;let Z=this.#w(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#p($,!1),this.value=$,Q.target.value=this.#I(this.value)}else this.value="",Q.target.value="";this.#R(),this.#x()}#e(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#w(this.input.value),_=(j!==""?Number(j)/(this.transform||1):0)+J;_=this.#p(_,!1),this.value=_,this.input.value=this.#I(this.value),this.#R(),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#m(Q){let Z=this.#w(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#R(),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#c(Q){Q.stopPropagation();let Z=this.#w(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#p($,!1),this.value=$,Q.target.value=this.#I(this.value)}else this.value="",Q.target.value="";this.#R(),this.#x(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#t(Q){if(this.disabled)return;if(Q.buttons===0){this.#d();return}let Z=(this.step||1)*Q.movementX,$=this.#w(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#p(J,!1),this.value=J,this.input.value=this.#I(this.value),this.#R(),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#r(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#M=!0,this.#H=this.style.userSelect,this.#B=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#Q),window.addEventListener("pointercancel",this.#Q),window.addEventListener("blur",this.#j)}#d(Q){let Z=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#B,this.style.userSelect=this.#H,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("pointercancel",this.#Q),window.removeEventListener("blur",this.#j),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#l($),$}#l(Q){let Z=this.#A??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(Z))}#Q0(Q){let Z=Number(Q);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}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,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#R();break;case"units":this.#W=$||"",this.#E(),this.input.value=this.#I(this.value),this.#x();break;case"units-disallow":this.#U=this.#C($===null?Z0.#T:$),this.#E(),this.input.value=this.#I(this.value),this.#x();break;case"unit-position":this.#L=$||"suffix",this.input.value=this.#I(this.value),this.#x();break;case"transform":this.transform=Number($)||1,this.input.value=this.#I(this.value),this.#x();break;case"value":if(this.#M)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#p(J,!1);this.value=J,this.input.value=this.#I(this.value),this.#R(),this.#x();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#R(),this.#x();break}this[Q]=Number($),this.#R(),this.#x();break;case"steppers":{let j=$!==null&&$!=="false";this.#k(j);break}case"precision":this.#A=this.#Q0($!==null?$:2),this.input.value=this.#I(this.value),this.#x();break;case"name":if(this[Q]=this.input[Q]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-number",Z0);class m0 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.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=Q,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(Q==="src")this.src=$,this.setSrc(this.src)}}customElements.define("fig-avatar",m0);class p0 extends HTMLElement{#Z=!1;#Q=null;#j=null;#$=null;#J=null;#q=null;#_=null;constructor(){super();this.#j=this.#N.bind(this),this.#$=this.focus.bind(this),this.#J=this.#Y.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#G()})}#G(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#X()}),this.#_.observe(this,{childList:!0})}#X(){let Q=this.label,Z=this.#Q;Q?.removeEventListener("click",this.#j),Q?.removeEventListener("click",this.#$),Q?.removeEventListener("pointerenter",this.#J),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#j),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.nodeName.toLowerCase().startsWith("fig-")&&!(j instanceof Element&&j.classList.contains("fig-field-chevron")));let $=this.input?.localName??"",J=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&!J),this.#Z&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=m("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else{if(this.#Q)this.#Q.removeEventListener("click",this.#j),this.#Q.remove(),this.#Q=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#W();if(this.label)this.label.removeEventListener("pointerenter",this.#J),this.label.addEventListener("pointerenter",this.#J),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)O.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("pointerenter",this.#J);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#N(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#Y(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;O.show(this.label,this.label.textContent.trim())}#K(){if(this.label)O.hide(this.label)}#W(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||g();this.label.setAttribute("id",Q);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||g();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.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,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#W();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();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",p0);class c0 extends HTMLElement{rgba;hex;#Z=100;#Q;#j;#$;#J;#q=!1;#_=!1;#G=null;#X=this.#k.bind(this);#N=this.#R.bind(this);#Y=this.#f.bind(this);#K=this.#x.bind(this);#W=this.#V.bind(this);#U=this.#v.bind(this);#L=this.#y.bind(this);#A=this.#w.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={},Z=this.getAttribute("experimental");if(Z)Q.experimental=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor")Q[$.slice(7)]=J;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#O(){let Q=this.#M();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#F()){this.#z();return}this.#P()}disconnectedCallback(){this.#H()}#F(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#z(){if(this.#D(this.getAttribute("value")),this.#Q=this.querySelector("fig-swatch"),this.#j=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",String(this.#Z));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#B()}#H(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.removeEventListener("click",this.#N,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#Y),this.#Q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#W),this.#$?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#L),this.#J?.removeEventListener("change",this.#U),this.#j?.removeEventListener("input",this.#A),this.#j?.removeEventListener("change",this.#U)}#B(){if(this.#Q){this.#Q.disabled=H(this,"disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#$||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.#X,{capture:!0}),this.#Q.addEventListener("click",this.#N,{capture:!0}),Q?.addEventListener("keydown",this.#Y),this.#Q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#W),this.#$.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#U);if(this.#j)this.#j.addEventListener("input",this.#A),this.#j.addEventListener("change",this.#U)}#P(){this.#D(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#u?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let _=`<fig-input-text
|
|
63
|
+
</fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#A(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||b()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",b());let $=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*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",b());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#D()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#z()){this.#H(),this.#A(),this.#D();return}this.#M()}get value(){if(this.#$!=="")return this.#$;let Q=this.getAttribute("value");if(Q!==null)return String(this.#T(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#T(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":J);if(this.input)this.#k()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#G),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#W),this.input.removeEventListener("pointercancel",this.#W);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#Y),this.figInputNumber.removeEventListener("change",this.#N)}#P(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#T(Q);this.value=Z,this.input.value=String(Z),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#R(Q){let{min:Z,max:$}=this.#S(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#C(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#S(){let Q=this.#C(this.min),Z=this.#C(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#E(Q){let{min:Z,max:$}=this.#S();return Math.min($,Math.max(Z,Q))}#f(){if(this.type==="delta"){let Z=this.#C(this.default);if(Z!==null)return this.#E(Z);return this.#E(0)}if(this.type==="range"){let{min:Z,max:$}=this.#S();return this.#E(Z+($-Z)/2)}let{min:Q}=this.#S();return Q}#T(Q){let Z=this.#C(Q);if(Z===null)return this.#f();return this.#E(Z)}#k(){let Q=this.#R(this.value),Z=this.#R(this.default),$=Q<Z?-1:1,J=Q===Z?1:0;if(this.#U!==Q)this.style.setProperty("--slider-complete",Q),this.#U=Q;if(this.#L!==Z)this.style.setProperty("--default",Z),this.#L=Z;if(this.#F!==$)this.style.setProperty("--slider-delta-direction",$),this.#F=$;if(this.#O!==J)this.style.setProperty("--unchanged",J),this.#O=J}#D(){let Q=this.input.value;if(this.value=Q,this.#k(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#I(){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.#y();return}this.input.removeAttribute("aria-hidden"),this.#j.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#b(){this.#Q=!1,this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#v(){this.#Z=!1,this.#Q=!1,this.#D(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#C(this.input.value)??this.#f(),J=this.#C(this.step)??1,j=this.#T($+J*10*Z);this.value=j,this.input.value=String(j),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#T(Q);this.value=Z,this.input.value=String(Z),this.#D(),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,Z,$){if(Q==="value"&&this.#J)return;if(this.input)switch(Q){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;if(this.#Q=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#T($),this.input.value=String(this.value),this.#D(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=$!==null?$:this.type==="delta"?0:this.min,this.#k();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=$,this.#M();break;case"text":this.text=$!=="false",this.#M();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#I();break;default:this[Q]=this.input[Q]=$,this.#D();break}}}customElements.define("fig-slider",u0);class p0 extends HTMLElement{#Z=!1;#Q=!1;#J;#$;#j;#q;#_;#X;#Y;#N;#G=null;#K=0;#W="";#U="";#L=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#T.bind(this),this.#$=this.#D.bind(this),this.#j=this.#D.bind(this),this.#q=this.#k.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#f(Q)},this.#X=(Q)=>{Q.stopPropagation();let Z=Q.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#R(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#Y=this.focus.bind(this),this.#N=this.#O.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",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.#F(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#A(),this.#M(),this.#P(),this.#R(),this.#C(),Z0(this),this.#B(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#E(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#E(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#E(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#N),this.addEventListener("click",this.#N),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);if(this.removeEventListener("click",this.#N),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#j),this.#G?.disconnect(),this.#G=null,this.#K)cancelAnimationFrame(this.#K),this.#K=0}focus(){this.input.focus()}#F(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(Q)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#E(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#O(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#B(){this.#G?.disconnect(),this.#G=new MutationObserver(()=>this.#z()),this.#G.observe(this,{childList:!0,characterData:!0,subtree:!0})}#z(){if(this.#K)return;this.#K=requestAnimationFrame(()=>{if(this.#K=0,!this.isConnected)return;this.#H()})}#H(){if(!this.input||!this.contains(this.input))this.input=this.#F(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#_),this.input.addEventListener("input",this.#X);this.#A(),this.#M(),this.#P(),this.#R(),this.#C(),Z0(this)}#A(){if(!this.input)return;this.#L.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#M(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=u("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#Y),this.prepend($)}#P(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.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=u("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),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.#R(),this.focus()})}#R(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#C(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){this.#S(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=u("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),this.#S($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#S($),this.focus()})}#S(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Q?"visible":"hidden")}#E(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#y(Z),Z}#f(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#I(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#R(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#T(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#D();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#I($,!1);let J=$*(this.transform||1);$=this.#y($),J=this.#y(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#k(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Z=!0,this.#W=this.style.userSelect,this.#U=document.body.style.cursor,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.#$),window.addEventListener("pointercancel",this.#$),window.addEventListener("blur",this.#j)}#D(Q){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#U,this.style.userSelect=this.#W,window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("pointercancel",this.#$),window.removeEventListener("blur",this.#j),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#E(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#E(this.max):this.max,$);$=this.#y($)}return $}#y(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false";break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#E(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#I(J,!1),this.value=J,this.input.value=this.#E(J);else this.value=J,this.input.value=J;this.#R();break;case"min":case"max":case"step":if($===null||$==="")this[Q]=void 0,this.input.removeAttribute(Q);else this[Q]=this.input[Q]=Number($),this.input.setAttribute(Q,$);break;case"name":if(this[Q]=this.input[Q]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#q),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#q);this.#M(),this.#P(),this.#R(),this.#C();break;case"multiline":{let j=$!==null&&$!=="false";if(j!==this.multiline){this.multiline=j;let q=this.input;q.removeEventListener("change",this.#_),q.removeEventListener("input",this.#X),q.remove(),this.input=this.#F(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#_),this.input.addEventListener("input",this.#X),this.#A()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-text",p0);class $0 extends HTMLElement{#Z;#Q;#J;#$;#j;#q;#_;#X;#Y;#N;#G;#K;#W;#U;#L;#F;#O=!1;#B=null;#z=null;#H=0;#A="";#M="";#P=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#R="px";#C(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#S(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#E(){this.#K=this.#S(this.#W)}#f(Q){if(Q&&!this.#B)this.#B=document.createElement("span"),this.#B.className="fig-steppers",this.#B.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#B.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#k(J),this.input.focus()}),this.append(this.#B);else if(!Q&&this.#B)this.#B.remove(),this.#B=null;this.#T()}#T(){if(!this.#B)return;let Q=this.#B.querySelector(".fig-stepper-up"),Z=this.#B.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#w(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&J<=this.min,X=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=q||X,Z.disabled=q||_}#k(Q){let Z=this.step||1,$=this.#w(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#u(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#T(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Z=this.#n.bind(this),this.#Q=this.#d.bind(this),this.#J=this.#d.bind(this),this.#$=this.#r.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#c(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#m(Q)},this.#_=(Q)=>{this.#p(Q)},this.#X=(Q)=>{this.#h(Q)},this.#Y=(Q)=>{this.#l(Q)},this.#N=this.focus.bind(this),this.#G=this.#I.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 Z=this.getAttribute("units-disallow");if(this.#U=this.#C(Z===null?$0.#R:Z),this.#E(),this.#L=this.getAttribute("unit-position")||"suffix",this.#F=this.#Q0(this.hasAttribute("precision")?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 $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#D(),this.#g(),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.#f($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#T(),this.#V(),Z0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#G),this.addEventListener("click",this.#G),this.#y(),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),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.#Y),this.input.addEventListener("keydown",this.#Y)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#Y);if(this.removeEventListener("click",this.#G),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J),this.#z?.disconnect(),this.#z=null,this.#H)cancelAnimationFrame(this.#H),this.#H=0}focus(){this.input.focus()}#D(){let Q=this.querySelector("input");if(Q)return Q;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#x(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#I(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#y(){this.#z?.disconnect(),this.#z=new MutationObserver(()=>this.#b()),this.#z.observe(this,{childList:!0,characterData:!0,subtree:!0})}#b(){if(this.#H)return;this.#H=requestAnimationFrame(()=>{if(this.#H=0,!this.isConnected)return;this.#v()})}#v(){if(!this.input||!this.contains(this.input))this.input=this.#D(),this.input.addEventListener("change",this.#j),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#_),this.input.addEventListener("blur",this.#X),this.input.addEventListener("keydown",this.#Y);let Q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#B&&!this.contains(this.#B))this.#B=null;this.#f(Q),this.#g(),this.#V(),Z0(this)}#g(){if(!this.input)return;this.#P.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#V(){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.#x(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#w(Q){if(!Q)return"";if(!this.#K){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#K,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#x(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#a(Z),!this.#K)return Z.toString();if(this.#L==="prefix")return this.#K+Z;else return Z+this.#K}#s(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#a(Z),Z.toString()}#p(Q){this.#O=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#K)if(this.#L==="prefix")Q.target.setSelectionRange(this.#K.length,Z.length);else{let $=Z.indexOf(this.#K);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#h(Q){this.#O=!1;let Z=this.#w(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#u($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#T(),this.#V()}#l(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#w(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+J;q=this.#u(q,!1),this.value=q,this.input.value=this.#x(this.value),this.#T(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#m(Q){let Z=this.#w(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#T(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#c(Q){Q.stopPropagation();let Z=this.#w(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#u($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#T(),this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#n(Q){if(this.disabled)return;if(Q.buttons===0){this.#d();return}let Z=(this.step||1)*Q.movementX,$=this.#w(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#u(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#T(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#r(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#O=!0,this.#A=this.style.userSelect,this.#M=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#Q),window.addEventListener("pointercancel",this.#Q),window.addEventListener("blur",this.#J)}#d(Q){let Z=this.#O;if(this.#O=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#M,this.style.userSelect=this.#A,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("pointercancel",this.#Q),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#u(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#a($),$}#a(Q){let Z=this.#F??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(Z))}#Q0(Q){let Z=Number(Q);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}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,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#T();break;case"units":this.#W=$||"",this.#E(),this.input.value=this.#x(this.value),this.#V();break;case"units-disallow":this.#U=this.#C($===null?$0.#R:$),this.#E(),this.input.value=this.#x(this.value),this.#V();break;case"unit-position":this.#L=$||"suffix",this.input.value=this.#x(this.value),this.#V();break;case"transform":this.transform=Number($)||1,this.input.value=this.#x(this.value),this.#V();break;case"value":if(this.#O)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#u(J,!1);this.value=J,this.input.value=this.#x(this.value),this.#T(),this.#V();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#T(),this.#V();break}this[Q]=Number($),this.#T(),this.#V();break;case"steppers":{let j=$!==null&&$!=="false";this.#f(j);break}case"precision":this.#F=this.#Q0($!==null?$:2),this.input.value=this.#x(this.value),this.#V();break;case"name":if(this[Q]=this.input[Q]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#g();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-number",$0);class c0 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.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=Q,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(Q==="src")this.src=$,this.setSrc(this.src)}}customElements.define("fig-avatar",c0);class d0 extends HTMLElement{#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;constructor(){super();this.#J=this.#N.bind(this),this.#$=this.focus.bind(this),this.#j=this.#G.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#Y(),this.#X()})}#X(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#Y()}),this.#_.observe(this,{childList:!0})}#Y(){let Q=this.label,Z=this.#Q;Q?.removeEventListener("click",this.#J),Q?.removeEventListener("click",this.#$),Q?.removeEventListener("pointerenter",this.#j),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.nodeName.toLowerCase().startsWith("fig-")&&!(j instanceof Element&&j.classList.contains("fig-field-chevron")));let $=this.input?.localName??"",J=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&!J),this.#Z&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=u("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else{if(this.#Q)this.#Q.removeEventListener("click",this.#J),this.#Q.remove(),this.#Q=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#W();if(this.label)this.label.removeEventListener("pointerenter",this.#j),this.label.addEventListener("pointerenter",this.#j),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)z.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#j)this.label.removeEventListener("pointerenter",this.#j);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#N(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#G(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;z.show(this.label,this.label.textContent.trim())}#K(){if(this.label)z.hide(this.label)}#W(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||b();this.label.setAttribute("id",Q);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||b();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.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,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#W();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();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",d0);class s0 extends HTMLElement{rgba;hex;#Z=100;#Q;#J;#$;#j;#q=!1;#_=!1;#X=null;#Y=this.#f.bind(this);#N=this.#T.bind(this);#G=this.#k.bind(this);#K=this.#V.bind(this);#W=this.#I.bind(this);#U=this.#b.bind(this);#L=this.#y.bind(this);#F=this.#w.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))}#O(){let Q={},Z=this.getAttribute("experimental");if(Z)Q.experimental=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor")Q[$.slice(7)]=J;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#B(){let Q=this.#O();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#z()){this.#H();return}this.#P()}disconnectedCallback(){this.#A()}#z(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#H(){if(this.#D(this.getAttribute("value")),this.#Q=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",String(this.#Z));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#g(),this.#M()}#A(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#Y,{capture:!0}),this.#Q.removeEventListener("click",this.#N,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#G),this.#Q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#W),this.#$?.removeEventListener("change",this.#U),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#F),this.#J?.removeEventListener("change",this.#U)}#M(){if(this.#Q){this.#Q.disabled=R(this,"disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#$||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.#Y,{capture:!0}),this.#Q.addEventListener("click",this.#N,{capture:!0}),Q?.addEventListener("keydown",this.#G),this.#Q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#W),this.#$.addEventListener("change",this.#U);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#F),this.#J.addEventListener("change",this.#U)}#P(){this.#D(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#p?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
|
|
64
64
|
type="text"
|
|
65
65
|
placeholder="000000"
|
|
66
66
|
value="${this.hexOpaque.slice(1).toUpperCase()}"${$}>
|
|
67
|
-
</fig-input-text>`;if(Q)
|
|
67
|
+
</fig-input-text>`;if(Q)q+=`<fig-tooltip text="Opacity">
|
|
68
68
|
<fig-input-number
|
|
69
69
|
placeholder="##"
|
|
70
70
|
min="0"
|
|
@@ -72,16 +72,16 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
72
72
|
value="${this.#Z}"
|
|
73
73
|
units="%"${$}>
|
|
74
74
|
</fig-input-number>
|
|
75
|
-
</fig-tooltip>`;let
|
|
76
|
-
${q}
|
|
75
|
+
</fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`,J=`<div class="input-combo">
|
|
77
76
|
${_}
|
|
78
|
-
</div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-swatch"),this.#j=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#b(),this.#$){let _=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=_.slice(1).toUpperCase(),this.#Q)this.#Q.background=_}this.#B()}#T(){if(!this.#j)return;for(let[Q,Z]of Object.entries(this.#M()))this.#j.setAttribute(Q,Z);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(H(this,"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.#Z}))}#C(){if(!u())return null;if(this.#j?.isConnected)return this.#T(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#w.bind(this)),Q.addEventListener("change",this.#v.bind(this)),this.appendChild(Q),this.#j=Q,this.#T(),Q}#S(){if(H(this,"disabled")||H(this,"swatch-disabled"))return!1;let Q=this.#C();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#E(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#k(Q){if(!u())return;if(H(this,"disabled")||H(this,"swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#G)clearTimeout(this.#G);this.#G=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#G=null},500),this.#E(Q)}#R(Q){if(!this.#q)return;if(this.#q=!1,this.#G)clearTimeout(this.#G),this.#G=null;if(this.#E(Q),this.#_)this.#_=!1,this.#S()}#f(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!u())return;if(!this.#S())return;this.#E(Q)}#D(Q){let Z=Q||"#D9D9D9";this.rgba=this.convertToRGBA(Z),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.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#V(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#D("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#I()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#D(this.hexOpaque+J),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.#Z}));this.#I()}#v(Q){Q.stopPropagation(),this.#s()}focus(){if(this.#$){this.#$.focus();return}this.#Q?.focus()}#g(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#u)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#g();if(this.#$){if(this.#$.setAttribute("aria-label",`${j} hex color`),Q)this.#$.setAttribute("aria-describedby",Q);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#J){if(this.#J.setAttribute("aria-label",`${j} opacity`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if(Z)this.#J.setAttribute("aria-invalid",Z);else this.#J.removeAttribute("aria-invalid");if($)this.#J.setAttribute("aria-required",$);else this.#J.removeAttribute("aria-required")}if(!this.#$){let _=this.#Q?.querySelector('input[type="color"]');if(!_)return;if(J)_.setAttribute("aria-labelledby",J),_.removeAttribute("aria-label");else _.setAttribute("aria-label",j),_.removeAttribute("aria-labelledby");if(Q)_.setAttribute("aria-describedby",Q);else _.removeAttribute("aria-describedby")}}#x(Q){if(Q.stopPropagation(),this.#D(Q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#I()}#w(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#D($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J&&Z.alpha!==void 0)this.#J.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#I()}}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#s(){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,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#D($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());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.#Z}));if(this.#J)this.#J.setAttribute("value",this.#Z);break;case"mode":this.#T();break;case"alpha":case"text":if(this.isConnected)this.#P();break;case"disabled":this.#h();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#h(){let Q=this.#u;for(let Z of[this.#Q,this.#$,this.#J]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#b(),this.#j)this.#T()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${_}${q}`.toUpperCase();let X=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${_}${q}${X}`.toUpperCase()}convertToRGBA(Q){let Z,$,J,j=1;if(Q.startsWith("#")){let _=Q.slice(1);if(_.length===8)j=parseInt(_.slice(6),16)/255,_=_.slice(0,6);Z=parseInt(_.slice(0,2),16),$=parseInt(_.slice(2,4),16),J=parseInt(_.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let _=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_)Z=parseInt(_[1]),$=parseInt(_[2]),J=parseInt(_[3]),j=_[4]?parseFloat(_[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let _=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_){let q=parseInt(_[1])/360,G=parseInt(_[2])/100,X=parseInt(_[3])/100;if(j=_[4]?parseFloat(_[4]):1,G===0)Z=$=J=X;else{let K=(W,z,L)=>{if(L<0)L+=1;if(L>1)L-=1;if(L<0.16666666666666666)return W+(z-W)*6*L;if(L<0.5)return z;if(L<0.6666666666666666)return W+(z-W)*(0.6666666666666666-L)*6;return W},N=X<0.5?X*(1+G):X+G-X*G,F=2*X-N;Z=K(F,N,q+0.3333333333333333),$=K(F,N,q),J=K(F,N,q-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}customElements.define("fig-input-color",c0);var V1=["srgb","srgb-linear","display-p3","oklab","oklch"],x1=["shorter","longer","increasing","decreasing"];function l(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!V1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=x1.includes(J)?J:"shorter",Z}function u0(Q){let Z=l(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(Z.interpolationSpace==="oklch")$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function d0(Q){let Z=l(Q);if(Z.interpolationSpace==="srgb")return"";if(Z.interpolationSpace==="oklch")return`in oklch ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function s(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function d(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function e(Q,Z,$){let J=p(Q),j=p(Z),_=p($),q=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*_),G=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*_),X=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*_);return{l:0.2104542553*q+0.793617785*G-0.0040720468*X,a:1.9779984951*q-2.428592205*G+0.4505937099*X,b:0.0259040371*q+0.7827717662*G-0.808675766*X}}function H0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,_=Q-0.0894841775*Z-1.291485548*$,q=J*J*J,G=j*j*j,X=_*_*_;return{r:d(4.0767416621*q-3.3077115913*G+0.2309699292*X),g:d(-1.2684380046*q+2.6097574011*G-0.3413193965*X),b:d(-0.0041960863*q-0.7034186147*G+1.707614701*X)}}function R0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function y1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function w1(Q,Z,$,J){let j=(Q%360+360)%360,q=(Z%360+360)%360-j;switch(J){case"longer":if(q>0&&q<180)q-=360;else if(q<0&&q>-180)q+=360;else if(q===0)q=0;break;case"increasing":if(q<0)q+=360;break;case"decreasing":if(q>0)q-=360;break;default:if(q>180)q-=360;else if(q<-180)q+=360;break}return((j+q*$)%360+360)%360}function g1(Q,Z,$,J){let j=[...Q].sort((R,B)=>R.position-B.position),_=Z*100;if(j.length===0)return"#888888";if(_<=j[0].position)return j[0].color;if(_>=j[j.length-1].position)return j[j.length-1].color;let q=0;while(q<j.length-1&&j[q+1].position<_)q++;let G=j[q],X=j[q+1],K=X.position-G.position,N=K>0?(_-G.position)/K:0,F=s(G.color),W=s(X.color),z,L,U,T=$||"oklab";if(T==="srgb-linear"){let R=p(F.r),B=p(F.g),M=p(F.b),P=p(W.r),S=p(W.g),f=p(W.b);z=d(R+(P-R)*N),L=d(B+(S-B)*N),U=d(M+(f-M)*N)}else if(T==="oklch"){let R=e(F.r,F.g,F.b),B=e(W.r,W.g,W.b),M=R0(R.l,R.a,R.b),P=R0(B.l,B.a,B.b),S=M.l+(P.l-M.l)*N,f=M.c+(P.c-M.c)*N,x=w1(M.h,P.h,N,J||"shorter"),k=y1(S,f,x),v=H0(k.l,k.a,k.b);z=v.r,L=v.g,U=v.b}else{let R=e(F.r,F.g,F.b),B=e(W.r,W.g,W.b),M=R.l+(B.l-R.l)*N,P=R.a+(B.a-R.a)*N,S=R.b+(B.b-R.b)*N,f=H0(M,P,S);z=f.r,L=f.g,U=f.b}return`#${z.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class s0 extends HTMLElement{#Z="solid";#Q;#j;#$;#J={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};#G={url:null,scaleMode:"fill",opacity:1};#X={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.#N(),this.#A()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#$=null}#N(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#J.color=Z.color;if(Z.alpha!==void 0)this.#J.alpha=Z.alpha;if(Z.opacity!==void 0)this.#J.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=l({...this.#q,...Z.gradient});break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#G={...this.#G,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#J.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#J.alpha=parseInt($,16)/255}}}}#Y(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("experimental");if($)Q.experimental=$;let J=this.getAttribute("alpha");if(J)Q.alpha=J;for(let{name:j,value:_}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=_;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,_])=>`${j}="${V(_)}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#J.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:_,g:q,b:G}=s(J.color);return`rgba(${_}, ${q}, ${G}, ${j}) ${J.position}%`}).join(", "),$=d0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#W(){switch(this.#Z){case"solid":return this.#J.alpha;case"image":return this.#_.opacity??1;case"video":return this.#G.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#U(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#j,this.#$]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#L(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#U();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(_,q)=>{if(!_)return;if(_.setAttribute("aria-label",q),Z)_.setAttribute("aria-describedby",Z);else _.removeAttribute("aria-describedby");if($)_.setAttribute("aria-invalid",$);else _.removeAttribute("aria-invalid");if(J)_.setAttribute("aria-required",J);else _.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#$,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#A(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(q)=>$?`<fig-tooltip text="Opacity">
|
|
79
|
-
<fig-input-number
|
|
77
|
+
${q}
|
|
78
|
+
</div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#g(),this.#$){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#M()}#R(){if(!this.#J)return;for(let[Q,Z]of Object.entries(this.#O()))this.#J.setAttribute(Q,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(R(this,"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.#Z}))}#C(){if(!s())return null;if(this.#J?.isConnected)return this.#R(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#w.bind(this)),Q.addEventListener("change",this.#b.bind(this)),this.appendChild(Q),this.#J=Q,this.#R(),Q}#S(){if(R(this,"disabled")||R(this,"swatch-disabled"))return!1;let Q=this.#C();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#E(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#f(Q){if(!s())return;if(R(this,"disabled")||R(this,"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.#E(Q)}#T(Q){if(!this.#q)return;if(this.#q=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#E(Q),this.#_)this.#_=!1,this.#S()}#k(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!s())return;if(!this.#S())return;this.#E(Q)}#D(Q){let Z=Q||"#D9D9D9";this.rgba=this.convertToRGBA(Z),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.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#I(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#D("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#x()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#D(this.hexOpaque+J),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.#Z}));this.#x()}#b(Q){Q.stopPropagation(),this.#s()}focus(){if(this.#$){this.#$.focus();return}this.#Q?.focus()}#v(){return this.getAttribute("aria-label")||"Color"}#g(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#p)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#v();if(this.#$){if(this.#$.setAttribute("aria-label",`${j} hex color`),Q)this.#$.setAttribute("aria-describedby",Q);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#$){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(J)q.setAttribute("aria-labelledby",J),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")}}#V(Q){if(Q.stopPropagation(),this.#D(Q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#w(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#D($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#s(){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,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#D($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());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.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#R();break;case"alpha":case"text":if(this.isConnected)this.#P();break;case"disabled":this.#h();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#g();break}}get#p(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#h(){let Q=this.#p;for(let Z of[this.#Q,this.#$,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#g(),this.#J)this.#R()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),q=Z.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let Z,$,J,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);Z=parseInt(q.slice(0,2),16),$=parseInt(q.slice(2,4),16),J=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)Z=parseInt(q[1]),$=parseInt(q[2]),J=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)Z=$=J=Y;else{let K=(W,F,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return W+(F-W)*6*B;if(B<0.5)return F;if(B<0.6666666666666666)return W+(F-W)*(0.6666666666666666-B)*6;return W},G=Y<0.5?Y*(1+X):Y+X-Y*X,U=2*Y-G;Z=K(U,G,_+0.3333333333333333),$=K(U,G,_),J=K(U,G,_-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}customElements.define("fig-input-color",s0);var b1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],g1=["shorter","longer","increasing","decreasing"],i0=new Set(["oklch","hsl"]);function t(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!b1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=g1.includes(J)?J:"shorter",Z}function r0(Q){let Z=t(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(i0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function o0(Q){let Z=t(Q);if(Z.interpolationSpace==="srgb")return"";if(i0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function d(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function i(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function l(Q,Z,$){let J=p(Q),j=p(Z),q=p($),_=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*J+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 T0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,q=Q-0.0894841775*Z-1.291485548*$,_=J*J*J,X=j*j*j,Y=q*q*q;return{r:i(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:i(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:i(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function G0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function h1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function P0(Q,Z,$,J){let j=(Q%360+360)%360,_=(Z%360+360)%360-j;switch(J){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+_*$)%360+360)%360}function m1(Q,Z,$,J){let j=[...Q].sort((H,M)=>H.position-M.position),q=Z*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,G=K>0?(q-X.position)/K:0,U=d(X.color),W=d(Y.color),F,B,L,D=$||"oklab";if(D==="srgb-linear"){let H=p(U.r),M=p(U.g),O=p(U.b),C=p(W.r),E=p(W.g),S=p(W.b);F=i(H+(C-H)*G),B=i(M+(E-M)*G),L=i(O+(S-O)*G)}else if(D==="oklch"){let H=l(U.r,U.g,U.b),M=l(W.r,W.g,W.b),O=G0(H.l,H.a,H.b),C=G0(M.l,M.a,M.b),E=O.l+(C.l-O.l)*G,S=O.c+(C.c-O.c)*G,y=P0(O.h,C.h,G,J||"shorter"),I=h1(E,S,y),g=T0(I.l,I.a,I.b);F=g.r,B=g.g,L=g.b}else if(D==="hsl"){let H=N0(U.r,U.g,U.b),M=N0(W.r,W.g,W.b),O=P0(H.h,M.h,G,J||"shorter"),C=H.s+(M.s-H.s)*G,E=H.l+(M.l-H.l)*G,S=u1(O,C,E);F=S[0],B=S[1],L=S[2]}else if(D==="srgb")F=Math.round(U.r+(W.r-U.r)*G),B=Math.round(U.g+(W.g-U.g)*G),L=Math.round(U.b+(W.b-U.b)*G);else{let H=l(U.r,U.g,U.b),M=l(W.r,W.g,W.b),O=H.l+(M.l-H.l)*G,C=H.a+(M.a-H.a)*G,E=H.b+(M.b-H.b)*G,S=T0(O,C,E);F=S.r,B=S.g,L=S.b}return`#${F.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function N0(Q,Z,$){let J=Q/255,j=Z/255,q=$/255,_=Math.max(J,j,q),X=Math.min(J,j,q),Y=(_+X)/2;if(_===X)return{h:0,s:0,l:Y*100};let K=_-X,G=Y>0.5?K/(2-_-X):K/(_+X),U;switch(_){case J:U=((j-q)/K+(j<q?6:0))/6;break;case j:U=((q-J)/K+2)/6;break;default:U=((J-j)/K+4)/6;break}return{h:U*360,s:G*100,l:Y*100}}function u1(Q,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,j=J*(1-Math.abs(Q/60%2-1)),q=$-J/2,_,X,Y;if(Q<60)_=J,X=j,Y=0;else if(Q<120)_=j,X=J,Y=0;else if(Q<180)_=0,X=J,Y=j;else if(Q<240)_=0,X=j,Y=J;else if(Q<300)_=j,X=0,Y=J;else _=J,X=0,Y=j;return[Math.round((_+q)*255),Math.round((X+q)*255),Math.round((Y+q)*255)]}class l0 extends HTMLElement{#Z="solid";#Q;#J;#$;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,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};#Y={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.#N(),this.#O()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#$=null}#N(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=t({...this.#q,...Z.gradient}),this.#q.opacity=this.#W(Z.gradient.opacity??Z.opacity??Z.alpha,this.#q.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#q.opacity=this.#W(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#X={...this.#X,...Z.video};break;case"webcam":if(Z.webcam)this.#Y={...this.#Y,...Z.webcam};if(Z.opacity!==void 0)this.#Y.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#G(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("experimental");if($)Q.experimental=$;let J=this.getAttribute("alpha");if(J)Q.alpha=J;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}="${x(q)}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:q,g:_,b:X}=d(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=o0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#W(Q,Z=1){if(Q===void 0||Q===null||Q==="")return Z;let $=Number(Q);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#Y.opacity??1;default:return 1}}#L(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#J,this.#$]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#F(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),Z)q.setAttribute("aria-describedby",Z);else q.removeAttribute("aria-describedby");if($)q.setAttribute("aria-invalid",$);else q.removeAttribute("aria-invalid");if(J)q.setAttribute("aria-required",J);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#$,`${Q} hex color`),j(this.#J,`${Q} opacity`)}#O(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(_)=>$?`<fig-tooltip text="Opacity">
|
|
79
|
+
<fig-input-number
|
|
80
80
|
class="fig-input-fill-opacity"
|
|
81
|
-
placeholder="##"
|
|
81
|
+
placeholder="##"
|
|
82
82
|
min="0"
|
|
83
83
|
max="100"
|
|
84
|
-
value="${
|
|
84
|
+
value="${_}"
|
|
85
85
|
units="%"
|
|
86
86
|
${Q?"disabled":""}>
|
|
87
87
|
</fig-input-number>
|
|
@@ -90,28 +90,29 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
90
90
|
type="text"
|
|
91
91
|
class="fig-input-fill-hex"
|
|
92
92
|
placeholder="000000"
|
|
93
|
-
value="${
|
|
93
|
+
value="${x(this.#j.color.slice(1).toUpperCase())}"
|
|
94
94
|
${Q?"disabled":""}>
|
|
95
95
|
</fig-input-text>
|
|
96
|
-
${J(Math.round(this.#
|
|
97
|
-
<label class="fig-input-fill-label">${
|
|
96
|
+
${J(Math.round(this.#j.alpha*100))}`;break;case"gradient":{let _=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);j=`
|
|
97
|
+
<label class="fig-input-fill-label">${x(_)}</label>
|
|
98
|
+
${J(Math.round((this.#q.opacity??1)*100))}`;break}case"image":j=`
|
|
98
99
|
<label class="fig-input-fill-label">Image</label>
|
|
99
100
|
${J(Math.round((this.#_.opacity??1)*100))}`;break;case"video":j=`
|
|
100
101
|
<label class="fig-input-fill-label">Video</label>
|
|
101
|
-
${J(Math.round((this.#
|
|
102
|
+
${J(Math.round((this.#X.opacity??1)*100))}`;break;case"webcam":j=`
|
|
102
103
|
<label class="fig-input-fill-label">Webcam</label>
|
|
103
|
-
${J(Math.round((this.#
|
|
104
|
+
${J(Math.round((this.#Y.opacity??1)*100))}`;break}let q=this.#G();this.innerHTML=`
|
|
104
105
|
<div class="input-combo">
|
|
105
|
-
<fig-fill-picker ${
|
|
106
|
-
<fig-swatch background="${
|
|
106
|
+
<fig-fill-picker ${q} value='${x(Z)}' ${Q?"disabled":""}>
|
|
107
|
+
<fig-swatch background="${x(this.#K())}" alpha="${this.#U()}"${Q?" disabled":""}></fig-swatch>
|
|
107
108
|
</fig-fill-picker>
|
|
108
109
|
${j}
|
|
109
|
-
</div>`,this.#
|
|
110
|
+
</div>`,this.#B()}#B(){this.#Q=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#F(),Q&&this.#Q)Q.addEventListener("click",()=>{let Z=this.#Q.querySelector("fig-swatch");if(Z)Z.click()});if(this.#Q){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#Q.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#Q.anchorElement=$}this.#Q.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let j=J.type,q=j!==this.#Z;switch(this.#Z=j,j){case"solid":this.#j.color=J.color,this.#j.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#q=t({...this.#q,...J.gradient});break;case"image":if(J.image)this.#_=J.image;break;case"video":if(J.video)this.#X=J.video;break}if(q)this.#H();else this.#z();this.#P()}),this.#Q.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#A(),this.#P()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),j=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#j.alpha=j;break;case"gradient":this.#q.opacity=j;break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#Y.opacity=j;break}this.#A(),this.#M(j),this.#P()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()})}#z(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#j.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#j.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let Z=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=Z}if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#Y.opacity??1)*100));break}}#H(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.getAttribute("alpha")!=="false",$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),j=$.querySelector(".fig-input-fill-hex"),q=$.querySelector(".fig-input-fill-opacity"),_=$.querySelectorAll("fig-tooltip");J?.remove(),j?.remove(),_.forEach((K)=>K.remove());let X="";switch(this.#Z){case"solid":X=`
|
|
110
111
|
<fig-input-text
|
|
111
112
|
type="text"
|
|
112
113
|
class="fig-input-fill-hex"
|
|
113
114
|
placeholder="000000"
|
|
114
|
-
value="${
|
|
115
|
+
value="${x(this.#j.color.slice(1).toUpperCase())}"
|
|
115
116
|
${Q?"disabled":""}>
|
|
116
117
|
</fig-input-text>
|
|
117
118
|
${Z?`<fig-tooltip text="Opacity">
|
|
@@ -120,12 +121,23 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
120
121
|
placeholder="##"
|
|
121
122
|
min="0"
|
|
122
123
|
max="100"
|
|
123
|
-
value="${Math.round(this.#
|
|
124
|
+
value="${Math.round(this.#j.alpha*100)}"
|
|
124
125
|
units="%"
|
|
125
126
|
${Q?"disabled":""}>
|
|
126
127
|
</fig-input-number>
|
|
127
|
-
</fig-tooltip>`:""}`;break;case"gradient":{let K=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);
|
|
128
|
-
<label class="fig-input-fill-label">${
|
|
128
|
+
</fig-tooltip>`:""}`;break;case"gradient":{let K=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);X=`
|
|
129
|
+
<label class="fig-input-fill-label">${x(K)}</label>
|
|
130
|
+
${Z?`<fig-tooltip text="Opacity">
|
|
131
|
+
<fig-input-number
|
|
132
|
+
class="fig-input-fill-opacity"
|
|
133
|
+
placeholder="##"
|
|
134
|
+
min="0"
|
|
135
|
+
max="100"
|
|
136
|
+
value="${Math.round((this.#q.opacity??1)*100)}"
|
|
137
|
+
units="%"
|
|
138
|
+
${Q?"disabled":""}>
|
|
139
|
+
</fig-input-number>
|
|
140
|
+
</fig-tooltip>`:""}`;break}case"image":X=`
|
|
129
141
|
<label class="fig-input-fill-label">Image</label>
|
|
130
142
|
${Z?`<fig-tooltip text="Opacity">
|
|
131
143
|
<fig-input-number
|
|
@@ -137,7 +149,7 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
137
149
|
units="%"
|
|
138
150
|
${Q?"disabled":""}>
|
|
139
151
|
</fig-input-number>
|
|
140
|
-
</fig-tooltip>`:""}`;break;case"video":
|
|
152
|
+
</fig-tooltip>`:""}`;break;case"video":X=`
|
|
141
153
|
<label class="fig-input-fill-label">Video</label>
|
|
142
154
|
${Z?`<fig-tooltip text="Opacity">
|
|
143
155
|
<fig-input-number
|
|
@@ -145,11 +157,11 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
145
157
|
placeholder="##"
|
|
146
158
|
min="0"
|
|
147
159
|
max="100"
|
|
148
|
-
value="${Math.round((this.#
|
|
160
|
+
value="${Math.round((this.#X.opacity??1)*100)}"
|
|
149
161
|
units="%"
|
|
150
162
|
${Q?"disabled":""}>
|
|
151
163
|
</fig-input-number>
|
|
152
|
-
</fig-tooltip>`:""}`;break;case"webcam":
|
|
164
|
+
</fig-tooltip>`:""}`;break;case"webcam":X=`
|
|
153
165
|
<label class="fig-input-fill-label">Webcam</label>
|
|
154
166
|
${Z?`<fig-tooltip text="Opacity">
|
|
155
167
|
<fig-input-number
|
|
@@ -157,24 +169,24 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
157
169
|
placeholder="##"
|
|
158
170
|
min="0"
|
|
159
171
|
max="100"
|
|
160
|
-
value="${Math.round((this.#
|
|
172
|
+
value="${Math.round((this.#Y.opacity??1)*100)}"
|
|
161
173
|
units="%"
|
|
162
174
|
${Q?"disabled":""}>
|
|
163
175
|
</fig-input-number>
|
|
164
|
-
</fig-tooltip>`:""}`;break}$.insertAdjacentHTML("beforeend",G),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#L(),X&&this.#Q)X.addEventListener("click",()=>{let K=this.#Q.querySelector("fig-swatch");if(K)K.click()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let N="#"+K.target.value.replace("#","");this.#J.color=N,this.#z(),this.#B()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#P()});if(this.#j)this.#j.addEventListener("input",(K)=>{K.stopPropagation();let N=parseFloat(K.target.value),W=(isNaN(N)?100:N)/100;switch(this.#Z){case"solid":this.#J.alpha=W;break;case"gradient":break;case"image":this.#_.opacity=W;break;case"video":this.#G.opacity=W;break;case"webcam":this.#X.opacity=W;break}this.#z(),this.#H(W),this.#B()}),this.#j.addEventListener("change",(K)=>{K.stopPropagation(),this.#P()})}#z(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#H(Q){if(this.#Q){let Z=this.#Q.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",Q)}}#B(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#P(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Z){case"solid":return{type:"solid",color:this.#J.color,alpha:this.#J.alpha,opacity:Math.round(this.#J.alpha*100)};case"gradient":return{type:"gradient",gradient:u0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#G}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#Z}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Z;if(this.#N(),this.#Q)if(this.#Z!==J)this.#A();else this.#z(),this.#O();break;case"disabled":this.#U();break;case"mode":case"experimental":if(this.#Q)if($)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q);break;case"alpha":if(this.isConnected)this.#A();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#L();break}}}customElements.define("fig-input-fill",s0);class i0 extends HTMLElement{#Z=[];#Q=[];#j=[];#$=null;#J=this.#X.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 Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!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#G(){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.#J),this.addEventListener("keydown",this.#J),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#N(),this.#Y()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#J),this.#Q=[],this.#j=[]}#X(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,Z,$){if(Z===$)return;switch(Q){case"value":this.#N(),this.#O();break;case"disabled":this.#F();break;case"min":case"max":case"fixed":this.#Y();break;case"open":break}}#N(){let Q=this.getAttribute("value");if(!Q){this.#Z=[];return}let Z=Q.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#Y(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors");let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$),Z.addEventListener("keydown",(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),$()});let J=document.createElement("div");if(J.className="palette-colors",this.#Z.forEach((_,q)=>{J.appendChild(this.#K(_,q,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),!this.#q)this.#L(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Z.forEach((_,q)=>{if(j.appendChild(this.#K(_,q,Q)),!this.#q)j.appendChild(this.#W(q,Q))}),this.appendChild(j)}#K(Q,Z,$,{inline:J=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,_=document.createElement("fig-input-color");if(_.setAttribute("value",j),J)_.setAttribute("text","false"),_.setAttribute("alpha","true"),_.setAttribute("swatch-disabled","");else _.setAttribute("text","true"),_.setAttribute("alpha","true"),_.setAttribute("full","");if($)_.setAttribute("disabled","");let q=J?this.#j:this.#Q,G=(X)=>{X.stopPropagation();let K=X.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let N=q[Z];if(N){let F=this.#Z[Z],W=F.alpha<1?F.color+Math.round(F.alpha*255).toString(16).padStart(2,"0"):F.color;N.setAttribute("value",W)}};if(_.addEventListener("input",(X)=>{G(X),this.#H()}),_.addEventListener("change",(X)=>{G(X),this.#B()}),J)this.#Q.push(_);else this.#j.push(_);return _}#W(Q,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#_)$.setAttribute("disabled","");$.appendChild(m("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#U(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#U(Q){if(this.#q)return;if(Q<0||Q>=this.#Z.length)return;if(this.#Z.length<=this.#_)return;this.#Z.splice(Q,1),this.#Q=[],this.#j=[],this.#Y(),this.#B()}#L(Q,Z=this){let $=this.#Z.length>=this.#G,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",Q||$)J.setAttribute("disabled","");J.appendChild(m("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#G)return;this.open=!0,this.#A({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#A(Q){if(this.#q)return;this.#Z.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#K(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let _=this.#K(Q,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(_),q.appendChild(this.#W($,Z));if(this.#Z.length>=this.#G){let G=this.querySelector(".palette-add-btn");if(G)G.setAttribute("disabled","")}this.#z(Z),this.#B()}#M(Q){let Z=this.#Z[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Q[Q];if(J)J.setAttribute("value",$);let j=this.#j[Q];if(j)j.setAttribute("value",$)}#O(){if(this.#Q.length!==this.#Z.length){this.#Y();return}this.#Z.forEach((Q,Z)=>{this.#M(Z)})}#F(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Z.length>=this.#G)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#z(Q)}#z(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Z.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#H(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",i0);class o extends HTMLElement{static SHIFT_SNAP=5;#Z;#Q;#j=!1;#$=null;#J=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","size"]}get#G(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#G==="true"}get#N(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#Y(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#W(Q){let Z=l(Q);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#A(),this.#T(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.removeEventListener("keydown",this.#L),this.#J)this.#J.disconnect(),this.#J=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#f),this.removeEventListener("pointermove",this.#V),this.removeEventListener("pointerleave",this.#D),this.removeEventListener("click",this.#g),this.removeEventListener("dblclick",this.#v)}#U=(Q)=>{let Z=document.activeElement;if(!(Z instanceof Node)||!this.contains(Z))return;let $=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;Q.preventDefault();let q=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],G=q.indexOf(_),X=Q.shiftKey?(G-1+q.length)%q.length:(G+1)%q.length;_.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;let q=parseInt(_.dataset.stopIndex,10);if(isNaN(q)||!this.#_.stops[q])return;Q.preventDefault();let G=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?o.SHIFT_SNAP:1),X=this.#_.stops[q];X.position=Math.max(0,Math.min(100,X.position+G)),_.setAttribute("value",`${X.position}% 50%`);let K=_.closest("fig-tooltip");if(K)K.text=`${Math.round(X.position)}%`,K.setAttribute("show","true"),K.showPopup(),_.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),_.showColorTip()},600);this.#h(),this.#m(),this.#c();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#w(),this.#h(),this.#m(),this.#c()};#L=(Q)=>{if(this.#G!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(H(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#A(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#W({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#W({...this.#_,...Z.gradient})}catch(Z){}}#M(){let Q=this.#W(this.#_),$=[...Q.stops].sort((_,q)=>_.position-q.position).map((_)=>{let q=(_.opacity??100)/100;if(q>=1)return`${_.color} ${_.position}%`;let{r:G,g:X,b:K}=s(_.color);return`rgba(${G}, ${X}, ${K}, ${q}) ${_.position}%`}).join(", "),J=d0(Q),j=J?` ${J}`:"";if(Q.type==="radial")return`radial-gradient(circle at ${Q.centerX}% ${Q.centerY}%${j}, ${$})`;if(Q.type==="angular")return`conic-gradient(from ${Q.angle}deg${j}, ${$})`;return`linear-gradient(${Q.angle}deg${j}, ${$})`}#O(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=s(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#F(){let Q=this.getAttribute("size");return Q?` size="${Q}"`:""}#z(){if(!this.#Z)return;let Q=this.getAttribute("size");if(Q)this.#Z.setAttribute("size",Q);else this.#Z.removeAttribute("size")}#H(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#N==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#O($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#B=null;#P=!1;#T(){this.#J?.disconnect(),this.#J=null;let Q=H(this,"disabled"),Z=this.#G;if(Z==="picker"&&u()){let $=this.getAttribute("experimental"),J=$?` experimental="${$}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
|
|
176
|
+
</fig-tooltip>`:""}`;break}$.insertAdjacentHTML("beforeend",X),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let Y=this.querySelector(".fig-input-fill-label");if(this.#F(),Y&&this.#Q)Y.addEventListener("click",()=>{let K=this.#Q.querySelector("fig-swatch");if(K)K.click()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#j.color=G,this.#A(),this.#P()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),W=(isNaN(G)?100:G)/100;switch(this.#Z){case"solid":this.#j.alpha=W;break;case"gradient":this.#q.opacity=W;break;case"image":this.#_.opacity=W;break;case"video":this.#X.opacity=W;break;case"webcam":this.#Y.opacity=W;break}this.#A(),this.#M(W),this.#P()}),this.#J.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()})}#A(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#M(Q){if(this.#Q){let Z=this.#Q.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",Q)}}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Z){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:r0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#Y}};default:return{type:this.#Z}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Z;if(this.#N(),this.#Q)if(this.#Z!==J)this.#O();else this.#A(),this.#z();break;case"disabled":this.#L();break;case"mode":case"experimental":if(this.#Q)if($)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q);break;case"alpha":if(this.isConnected)this.#O();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break}}}customElements.define("fig-input-fill",l0);class a0 extends HTMLElement{#Z=[];#Q=[];#J=[];#$=null;#j=this.#Y.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 Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!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.#j),this.addEventListener("keydown",this.#j),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#N(),this.#G()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#j),this.#Q=[],this.#J=[]}#Y(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,Z,$){if(Z===$)return;switch(Q){case"value":this.#N(),this.#B();break;case"disabled":this.#z();break;case"min":case"max":case"fixed":this.#G();break;case"open":break}}#N(){let Q=this.getAttribute("value");if(!Q){this.#Z=[];return}let Z=Q.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#G(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors");let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$),Z.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),$()});let J=document.createElement("div");if(J.className="palette-colors",this.#Z.forEach((q,_)=>{J.appendChild(this.#K(q,_,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),!this.#q)this.#L(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Z.forEach((q,_)=>{if(j.appendChild(this.#K(q,_,Q)),!this.#q)j.appendChild(this.#W(_,Q))}),this.appendChild(j)}#K(Q,Z,$,{inline:J=!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),J)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($)q.setAttribute("disabled","");let _=J?this.#J:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let G=_[Z];if(G){let U=this.#Z[Z],W=U.alpha<1?U.color+Math.round(U.alpha*255).toString(16).padStart(2,"0"):U.color;G.setAttribute("value",W)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#A()}),q.addEventListener("change",(Y)=>{X(Y),this.#M()}),J)this.#Q.push(q);else this.#J.push(q);return q}#W(Q,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#_)$.setAttribute("disabled","");$.appendChild(u("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#U(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#U(Q){if(this.#q)return;if(Q<0||Q>=this.#Z.length)return;if(this.#Z.length<=this.#_)return;this.#Z.splice(Q,1),this.#Q=[],this.#J=[],this.#G(),this.#M()}#L(Q,Z=this){let $=this.#Z.length>=this.#X,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",Q||$)J.setAttribute("disabled","");J.appendChild(u("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#X)return;this.open=!0,this.#F({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#F(Q){if(this.#q)return;this.#Z.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#K(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let q=this.#K(Q,$,Z),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#W($,Z));if(this.#Z.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#H(Z),this.#M()}#O(Q){let Z=this.#Z[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Q[Q];if(J)J.setAttribute("value",$);let j=this.#J[Q];if(j)j.setAttribute("value",$)}#B(){if(this.#Q.length!==this.#Z.length){this.#G();return}this.#Z.forEach((Q,Z)=>{this.#O(Z)})}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Z.length>=this.#X)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#H(Q)}#H(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Z.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#M(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",a0);class a extends HTMLElement{static SHIFT_SNAP=5;#Z;#Q;#J=!1;#$=null;#j=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","size"]}get#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#Y(){return this.#X==="true"}get#N(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#G(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#Y?"-1":"0")}#W(Q){let Z=t(Q);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#F(),this.#R(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#Y)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.removeEventListener("keydown",this.#L),this.#j)this.#j.disconnect(),this.#j=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#k),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#D),this.removeEventListener("click",this.#v),this.removeEventListener("dblclick",this.#b)}#U=(Q)=>{let Z=document.activeElement;if(!(Z instanceof Node)||!this.contains(Z))return;let $=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!$){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")&&!$){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?a.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.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#h(),this.#m(),this.#c();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#w(),this.#h(),this.#m(),this.#c()};#L=(Q)=>{if(this.#X!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(R(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#F(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#W({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#W({...this.#_,...Z.gradient})}catch(Z){}}#O(){let Q=this.#W(this.#_),$=[...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}=d(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),J=o0(Q),j=J?` ${J}`:"";if(this.#X==="true")return`linear-gradient(to right${j}, ${$})`;if(Q.type==="radial")return`radial-gradient(circle at ${Q.centerX}% ${Q.centerY}%${j}, ${$})`;if(Q.type==="angular")return`conic-gradient(from ${Q.angle}deg${j}, ${$})`;return`linear-gradient(${Q.angle}deg${j}, ${$})`}#B(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=d(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#z(){let Q=this.getAttribute("size");return Q?` size="${Q}"`:""}#H(){if(!this.#Z)return;let Q=this.getAttribute("size");if(Q)this.#Z.setAttribute("size",Q);else this.#Z.removeAttribute("size")}#A(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#N==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#B($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#M=null;#P=!1;#R(){this.#j?.disconnect(),this.#j=null;let Q=R(this,"disabled"),Z=this.#X;if(Z==="picker"&&s()){let $=this.getAttribute("experimental"),J=$?` experimental="${$}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
|
|
165
177
|
<fig-fill-picker mode="gradient"${J} value='${j}'${Q?" disabled":""}>
|
|
166
|
-
<fig-swatch background="${this.#
|
|
178
|
+
<fig-swatch background="${this.#O()}"${this.#z()}${Q?" disabled":""}></fig-swatch>
|
|
167
179
|
</fig-fill-picker>`,this.#Z=this.querySelector("fig-swatch"),this.#Q=null,this.#C(),this.#K();return}if(this.innerHTML=`
|
|
168
|
-
<fig-swatch background="${this.#
|
|
169
|
-
${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#H()}</div>`:""}`,this.#Z=this.querySelector("fig-swatch"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#E(),this.#e();this.#K()}#C(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#W({...this.#_,...J.gradient}),this.#h()};Q.addEventListener("input",($)=>{Z($),this.#m()}),Q.addEventListener("change",($)=>{Z($),this.#c()})}#S(Q){return g1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#E(){if(!this.#Q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#N==="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.#B=Q,this.addEventListener("pointerenter",this.#f),this.addEventListener("pointermove",this.#V),this.addEventListener("pointerleave",this.#D),this.addEventListener("click",this.#g),this.addEventListener("dblclick",this.#v)}#k(){if(!this.#B)return;this.#B.style.opacity="1"}#R(){if(!this.#B)return;this.#B.style.opacity="0"}#f=()=>{if(this.#j)return;this.#k()};#D=()=>{this.#R()};#V=(Q)=>{if(this.#j){this.#R();return}if(!this.#B||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#R();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#B.style.left=`${$*100}%`;let J=this.#S($);this.#B.setAttribute("color",J),this.#k()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#w(),this.#h(),this.#m(),this.#c()}#v=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#g=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#P){this.#P=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let q=Q.target.closest("fig-handle"),G=parseInt(q?.dataset.stopIndex,10);if(this.#y(),!isNaN(G))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===G)X.select();else X.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((q,G)=>q.position-G.position);let _=this.#_.stops.findIndex((q)=>q.position===J&&q.color===j);this.#w(),this.#h(),this.#m(),this.#c(),requestAnimationFrame(()=>{let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)G.click()})};#b(){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((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#b()}#x(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#b())}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#B;if(this.#Q.innerHTML=this.#H(),$)this.#Q.appendChild($);this.#I(),this.#s(),this.#x();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#O(j)),this.#N==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let _=J.closest("fig-tooltip");if(_)_.setAttribute("text",`${Math.round(j.position)}%`)}this.#I()}#I(){if(!this.#Q)return;let Q=this.#N==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#B)if(Q)this.#B.setAttribute("tip","add");else this.#B.removeAttribute("tip")}#s(){if(!this.#J||!this.#Q)return;this.#J.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#J.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#u(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),_=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let G=0;G<Z.length;G++){if($.has(G))continue;if(Z[G].position===j&&Z[G].color.toUpperCase()===_){q=G;break}}if(q===-1){let G=1/0;for(let X=0;X<Z.length;X++){if($.has(X))continue;let K=Math.abs(Z[X].position-j);if(K<G)G=K,q=X}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#h(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#M()),this.#z()}#e(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(H(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((X,K)=>X.position-K.position);let _=this.#_.stops.findIndex((X)=>X.position===J&&X.color===j);this.#P=!0,this.#w(),this.#h(),this.#m(),this.#R();let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==G)X.deselect()}),G.select(),G.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 Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#O(this.#_.stops[X])),this.#h(),this.#m()}return}if(!this.#j)Z.style.zIndex="5";this.#j=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),_=j,q=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)_=Math.round(_/o.SHIFT_SNAP)*o.SHIFT_SNAP;else{let X=q>0?5/q*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-_)<=X){_=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=_,_!==j)Z.style.left=`${_/100*q}px`;let G=Z.closest("fig-tooltip");if(G){if(G.text=`${Math.round(_)}%`,!G.hasAttribute("show"))G.setAttribute("show","true"),Z.hideColorTip()}this.#h(),this.#m()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#O(this.#_.stops[X])),this.#h(),this.#c()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let j=Q.detail?.px??0,_=Math.round(j*100),q=this.#Q.getBoundingClientRect().width,G=q>0?5/q*100:0;for(let X=0;X<this.#_.stops.length;X++){if(X===J)continue;if(Math.abs(this.#_.stops[X].position-_)<=G){_=this.#_.stops[X].position;break}}this.#_.stops[J].position=_,Z.style.left=`${_/100*q}px`,this.#_.stops.sort((X,K)=>X.position-K.position),this.#u(),this.#h(),this.#c(),requestAnimationFrame(()=>{this.#j=!1})}),this.#J=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#h(),this.#m()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#J.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#c(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:u0(this.#W(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")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Z=this.#Y();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#A(),this.#h(),this.#w();break;case"disabled":this.#t();break;case"edit":if(this.#T(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#I();break;case"size":this.#z();break}}#t(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}customElements.define("fig-input-gradient",o);class $0 extends HTMLElement{#Z=null;#Q;#j;#$;#J=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this),this.#j=this.handleChange.bind(this),this.#$=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Q),this.input.addEventListener("input",this.#Q),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#X();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#J=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#q(){if(!this.#Z)this.#Z=document.createElement("label"),this.#J=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#G(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#X(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#G()}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("input",this.#Q),this.input.removeEventListener("change",this.#j),this.removeEventListener("click",this.#$)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Z.innerText=$;else if(this.#Z&&this.#J)this.#Z.remove(),this.#Z=null,this.#J=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#X();break;case"indeterminate":this.#X();break;case"disabled":this.#X();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#G(),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}}))}handleChange(Q){Q.stopPropagation(),this.#G(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",$0);class r0 extends $0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}customElements.define("fig-radio",r0);class o0 extends $0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",o0);class l0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#j=null;#$=null;#J=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#G=this.#A.bind(this);#X=this.#M.bind(this);#N=this.#O.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#Y(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#$=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.#T()}connectedCallback(){if(this.#J=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#J!==null,this.#J)this.#J.remove();if(this.#Y())this.#K(),this.#U();else this.#W(),this.#U();this.#C(H(this,"disabled"))}disconnectedCallback(){this.#L()}#W(){let Q=this.#H(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.getAttribute("experimental"),j=J?` experimental="${V(J)}"`:"",_=this.#P(),q=this.#Z?"":`<fig-dropdown type="dropdown" label="${V(_)}"${j}>${Q.map((G)=>`<option>${V(G.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
170
|
-
<fig-input-text placeholder="${
|
|
180
|
+
<fig-swatch background="${this.#O()}"${this.#z()}${Q?" disabled":""}></fig-swatch>
|
|
181
|
+
${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#A()}</div>`:""}`,this.#Z=this.querySelector("fig-swatch"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#E(),this.#l();this.#K()}#C(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#W({...this.#_,...J.gradient}),this.#h()};Q.addEventListener("input",($)=>{Z($),this.#m()}),Q.addEventListener("change",($)=>{Z($),this.#c()})}#S(Q){return m1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#E(){if(!this.#Q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#N==="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.#M=Q,this.addEventListener("pointerenter",this.#k),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#D),this.addEventListener("click",this.#v),this.addEventListener("dblclick",this.#b)}#f(){if(!this.#M)return;this.#M.style.opacity="1"}#T(){if(!this.#M)return;this.#M.style.opacity="0"}#k=()=>{if(this.#J)return;this.#f()};#D=()=>{this.#T()};#I=(Q)=>{if(this.#J){this.#T();return}if(!this.#M||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#T();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#M.style.left=`${$*100}%`;let J=this.#S($);this.#M.setAttribute("color",J),this.#f()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#w(),this.#h(),this.#m(),this.#c()}#b=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#v=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#P){this.#P=!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.#y(),!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 Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===J&&_.color===j);this.#w(),this.#h(),this.#m(),this.#c(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#g(){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((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#g()}#V(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#g())}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#M;if(this.#Q.innerHTML=this.#A(),$)this.#Q.appendChild($);this.#x(),this.#s(),this.#V();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#B(j)),this.#N==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let q=J.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#x()}#x(){if(!this.#Q)return;let Q=this.#N==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#M)if(Q)this.#M.setAttribute("tip","add");else this.#M.removeAttribute("tip")}#s(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),q=(J.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<Z.length;X++){if($.has(X))continue;if(Z[X].position===j&&Z[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<Z.length;Y++){if($.has(Y))continue;let K=Math.abs(Z[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)$.add(_),J.dataset.stopIndex=_})}#h(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#O()),this.#H()}#l(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(R(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===J&&Y.color===j);this.#P=!0,this.#w(),this.#h(),this.#m(),this.#T();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 Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.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;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#h(),this.#m()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/a.SHIFT_SNAP)*a.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=q,q!==j)Z.style.left=`${q/100*_}px`;let X=Z.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),Z.hideColorTip()}this.#h(),this.#m()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.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;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#h(),this.#c()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])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===J)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[J].position=q,Z.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#p(),this.#h(),this.#c(),requestAnimationFrame(()=>{this.#J=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#h(),this.#m()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#c(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:r0(this.#W(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")&&this.getAttribute("disabled")!=="false")return;if(this.#Y){let Z=this.#G();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#F(),this.#h(),this.#w();break;case"disabled":this.#n();break;case"edit":if(this.#R(),this.#Y)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#x();break;case"size":this.#H();break}}#n(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}customElements.define("fig-input-gradient",a);class J0 extends HTMLElement{#Z=null;#Q;#J;#$;#j=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",b()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this),this.#J=this.handleChange.bind(this),this.#$=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Q),this.input.addEventListener("input",this.#Q),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#Y();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#j=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#q(){if(!this.#Z)this.#Z=document.createElement("label"),this.#j=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#X(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#Y(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#X()}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("input",this.#Q),this.input.removeEventListener("change",this.#J),this.removeEventListener("click",this.#$)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Z.innerText=$;else if(this.#Z&&this.#j)this.#Z.remove(),this.#Z=null,this.#j=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#Y();break;case"indeterminate":this.#Y();break;case"disabled":this.#Y();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#X(),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}}))}handleChange(Q){Q.stopPropagation(),this.#X(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",J0);class t0 extends J0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}customElements.define("fig-radio",t0);class n0 extends J0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",n0);class e0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#X=this.#F.bind(this);#Y=this.#O.bind(this);#N=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#G(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#$=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.#R()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#G())this.#K(),this.#U();else this.#W(),this.#U();this.#C(R(this,"disabled"))}disconnectedCallback(){this.#L()}#W(){let Q=this.#A(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.getAttribute("experimental"),j=J?` experimental="${x(J)}"`:"",q=this.#P(),_=this.#Z?"":`<fig-dropdown type="dropdown" label="${x(q)}"${j}>${Q.map((X)=>`<option>${x(X.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
182
|
+
<fig-input-text placeholder="${x(Z)}" value="${x($)}"></fig-input-text>
|
|
171
183
|
<fig-button type="select" variant="input" icon>
|
|
172
184
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
173
185
|
<path d="M5.87868 7.12132L8 9.24264L10.1213 7.12132" stroke="currentColor" stroke-opacity="0.9" stroke-linecap="round"/>
|
|
174
186
|
</svg>
|
|
175
|
-
${
|
|
187
|
+
${_}
|
|
176
188
|
</fig-button>
|
|
177
|
-
</div>`,this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z&&this.#J&&this.#$){if(!this.#J.hasAttribute("type"))this.#J.setAttribute("type","dropdown");if(!this.#J.hasAttribute("label"))this.#J.setAttribute("label",_);if(J)this.#J.setAttribute("experimental",J);this.#$.append(this.#J)}this.#j=this.querySelector("fig-dropdown"),this.#T()}#U(){this.#L(),this.#j?.addEventListener("input",this.#G),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#N)}#L(){this.#j?.removeEventListener("input",this.#G),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#N)}#A(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Q)this.#Q.setAttribute("value",Z);this.#F(),this.#z()}#M(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#F()}#O(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#z()}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#z(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#B(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#P(){return`${this.#B()} options`}#T(){if(this.#Q)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#P())}#C(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#j&&!this.#Z){let J=this.#H();this.#j.replaceChildren(...J.map((j)=>{let _=document.createElement("option");return _.textContent=j,_}))}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",$||"");this.#T();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",$||"");break;case"disabled":this.#C($!==null&&$!=="false");break;case"experimental":if(this.#j){if($)this.#j.setAttribute("experimental",$);else if(!this.#Z)this.#j.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#T();break}}}customElements.define("fig-combo-input",l0);class a0 extends HTMLElement{#Z="color";#Q=null;#j=!1;constructor(){super();this.#Q=this.#N.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#G(),this.#$(),this.#X()}#$(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#J(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=Y0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#G(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#J($);if(J!==this.#Z||!this.input){if(this.#Z=J,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#Q);if(this.#Z==="color"){let _=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${_}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Q);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Z==="color"&&this.input){let _=this.#q($);if(this.input.value!==_)this.input.value=_}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);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")}#N(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,Z,$){if(Z===$)return;if(Q==="background"){if(this.#j){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#G()}else if(Q==="alpha")this.#$();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}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-swatch",a0);class J0 extends HTMLElement{#Z=null;#Q=null;#j=null;#$=null;#J=null;#q=null;#_=null;#G=this.#w.bind(this);#X=this.#s.bind(this);#N=this.#u.bind(this);#Y=this.#h.bind(this);#K=null;#W=null;#U=null;#L=null;#A=null;#M=null;#O=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","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.#Z}set src(Q){if(this.#Z=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#F(){return this.#q||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#F())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((J,j)=>{this.#Q.addEventListener("load",J,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,Z=this.#Q.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Q,0,0),$.toDataURL()}connectedCallback(){this.#Z=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 Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#B(),this.#T(),this.#H(),this.#f(),this.#C(),this.#k(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#b();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#G),this.#$?.addEventListener("change",this.#G)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#G),this.#z(),this.#g(),this.#J)URL.revokeObjectURL(this.#J),this.#J=null;this.#q=null}#z(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#N),this.#Q.removeEventListener("ended",this.#Y)}#H(){if(this.#z(),this.#Q?.tagName!=="VIDEO")return;this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#N),this.#Q.addEventListener("ended",this.#Y)}#B(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#j=Z}#P(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#T(){let Q=this.#P();if(Q){if(this.#B(),this.#Q&&this.#Q!==Q){if(this.#z(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#C();return}this.#B();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==Z){if(this.#z(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#j.append($),this.#Q=$,this.#H();let J=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#j.append($),this.#Q=$}}#C(){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 Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)})}#S(){return this.querySelector(":scope > figcaption:not([data-generated])")}#E(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#k(){let Q=this.#S(),Z=this.#E();if(Q){Z.forEach((_)=>_.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((_)=>_.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((_)=>_.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#j?.isConnected)this.#j.after(J);else if(!J.isConnected)this.append(J)}#R(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#f(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#F();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.#C();return}let Z=this.getAttribute("poster");if(Z)this.#Q.setAttribute("poster",Z);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#R("autoplay",!1),this.#Q.loop=this.#R("loop",!1),this.#Q.muted=this.#R("muted",!1),this.#Q.playsInline=!0,this.#C(),this.#D()}get mediaEl(){return this.#Q}#D(){if(this.mediaKind!=="video"){this.#g();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#g(),this.#K=Q;this.#y();return}if(this.#R("controls",!1))this.#V();else this.#g()}#V(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#y();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#y()}#y(){if(!this.#K||!this.#Q)return;if(this.#W===this.#Q&&this.#U===this.#K)return;this.#v();let Q=this.#K,Z=this.#Q;this.#W=Z,this.#U=Q;let $=null,J=()=>{if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{let G=Z.play?.();if(G&&typeof G.catch==="function")G.catch(()=>{})},_=()=>Z.pause?.(),q=(G)=>{let X=Number(G?.detail?.time);if(!Number.isFinite(X))return;$=X;try{Z.currentTime=X}catch{}};this.#L=J,this.#A=j,this.#M=_,this.#O=q,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",_),Q.addEventListener("seek",q),J()}#v(){let Q=this.#W,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#A)Z.removeEventListener("play",this.#A);if(this.#M)Z.removeEventListener("pause",this.#M);if(this.#O)Z.removeEventListener("seek",this.#O)}this.#W=null,this.#U=null,this.#L=null,this.#A=null,this.#M=null,this.#O=null}#g(){this.#v(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=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()}#b(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Z?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Z)Q.setAttribute("url",this.#Z);Q.addEventListener("change",this.#G),this.#B(),this.#j.append(Q),this.#$=Q}#x(){if(this.#$)this.#$.removeEventListener("change",this.#G),this.#$.remove(),this.#$=null}#w(Q){if(Q.target!==this.#$)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#J)URL.revokeObjectURL(this.#J),this.#J=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#f(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#J)URL.revokeObjectURL(this.#J);if(this.#_=Z,this.#J=URL.createObjectURL(Z),this.#q=this.#J,this.#f(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#J}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#I(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#s(){this.#I("play")}#u(){this.#I("pause")}#h(){this.#I("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#J);if(this.#Z=J,this.#J&&!j)URL.revokeObjectURL(this.#J),this.#J=null,this.#q=null,this.#_=null;if(this.#f(),this.#$){let _=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":_),this.#Z)if(this.#_?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#_.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(Q==="type"){if(this.#T(),this.#f(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#C();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#b();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#f();if(Q==="caption")this.#k()}}customElements.define("fig-media",J0);class t0 extends J0{get mediaKind(){return"image"}}customElements.define("fig-image",t0);class n0 extends J0{get mediaKind(){return"video"}}customElements.define("fig-video",n0);class e0 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Z=null;#Q=null;#j=null;#$=null;#J=null;#q=null;#_=!1;connectedCallback(){this.#W(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#W(),this.#U()}#G(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#N(){let Q=this.getAttribute("href");return Boolean(Q)&&!H(this,"disabled")}#Y(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#W(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#N()?"a":"div";if(!this.#Z||this.#Z.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Z){while(this.#Z.firstChild)J.appendChild(this.#Z.firstChild);this.#Z.replaceWith(J)}else this.appendChild(J);this.#Z=J}if(!this.#Q||!this.#Q.isConnected){if(this.#Q=this.#Z.querySelector(":scope > .fig-card-media"),!this.#Q)this.#Q=document.createElement("div"),this.#Q.className="fig-card-media",this.#Z.prepend(this.#Q)}if(Q&&Q.parentElement!==this.#Q)this.#Q.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Q.appendChild(Q),this.#$=null;if(!this.#_){if(this.#$=this.#Q.querySelector(":scope > fig-image[data-generated]")||null,!this.#$)this.#Q.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#$=document.createElement("fig-image"),this.#$.setAttribute("data-generated",""),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto"),this.#Q.appendChild(this.#$)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#Z.querySelector(":scope > .fig-card-text"),!this.#j)this.#j=document.createElement("div"),this.#j.className="fig-card-text",this.#j.setAttribute("data-generated",""),this.#Z.appendChild(this.#j)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#j.querySelector(":scope > .fig-card-label[data-generated]"),!this.#J){if(this.#J=this.#Z.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated","");this.#j.appendChild(this.#J)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#j.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#J.after(this.#q)}}}#U(){if(!this.#Z)return;let Q=H(this,"disabled"),Z=H(this,"selected"),$=this.#G(),J=this.#X(),j=this.#Y();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#N()){let _=this.getAttribute("href")||"",q=this.getAttribute("target");if(this.#Z.setAttribute("href",_),q)if(this.#Z.setAttribute("target",q),q==="_blank")this.#Z.setAttribute("rel","noopener noreferrer");else this.#Z.removeAttribute("rel");else this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel");if(Z)this.#Z.setAttribute("aria-current","true");else this.#Z.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Z.removeAttribute("href"),this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel"),this.#Z.removeAttribute("aria-current"),this.setAttribute("role","group");let _=[$,J].filter(Boolean).join(", ");if(_)this.setAttribute("aria-label",_);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#$&&!this.#_){let _=this.getAttribute("src"),q=this.getAttribute("alt"),G=this.getAttribute("aspect-ratio")||"1/1",X=this.getAttribute("fit")||"contain",K=q!=null?q:"";if(_)this.#$.setAttribute("src",_);else this.#$.removeAttribute("src");this.#$.setAttribute("alt",K),this.#$.setAttribute("aspect-ratio",G),this.#$.setAttribute("fit",X),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto")}if(this.#J)this.#J.textContent=$,this.#J.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#j)this.#j.hidden=!$&&!J}}customElements.define("fig-card",e0);class Q1 extends HTMLElement{#Z=null;#Q=null;#j=null;#$=null;#J=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#N(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#N();if(Q==="duration"||Q==="time")this.#Y()}#_(){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 Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=m("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(q)=>{q.preventDefault(),q.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#G(this.time);let _=(q)=>{let G=q.currentTarget,X=Number(G?.value);if(!Number.isFinite(X))return;this.#J=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#J=!1})};J.addEventListener("input",_),J.addEventListener("change",_),this.append(Q,J,j),this.#Z=Z,this.#Q=Q,this.#j=J,this.#$=j}#G(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#X(Q,Z=0){let $=this.#G(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#G(Z)}`}#N(){if(!this.#Z)return;let Q=this.playing;this.#Z.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Z.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#Y(){if(!this.#j)return;let Q=this.duration;if(Number(this.#j.getAttribute("max"))!==Q)this.#j.setAttribute("max",String(Q));let Z=this.time;if(!this.#J)this.#j.setAttribute("value",String(Z));if(this.#j.setAttribute("aria-valuetext",this.#X(Z,Q)),this.#$)this.#$.textContent=this.#G(Z)}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",Q1);class Z1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Z=null;#Q=null;#j=null;#$=null;#J=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}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.#U(),this.addEventListener("dragover",this.#Y),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#W)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#X),this.#j?.removeEventListener("click",this.#N),this.removeEventListener("dragover",this.#Y),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#W)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#G({cleared:!0})}#G(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Z.files.length>0)this.#q=this.#Z.files,this.removeAttribute("url"),this.#U(),this.#G()};#N=(Q)=>{Q.stopPropagation(),this.clear()};#Y=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#J)this.#J.dataset.prevText=this.#J.textContent,this.#J.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText};#W=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((_)=>_.trim().toLowerCase());$=$.filter((_)=>{let q="."+_.name.split(".").pop().toLowerCase(),G=_.type.toLowerCase();return j.some((X)=>X===q||X===G||X.endsWith("/*")&&G.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#U(),this.#G()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"input",_=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",_){let q=Q?`Accepts ${Q.split(",").map((F)=>F.trim()).join(", ")}`:"";if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j),this.#J.setAttribute("type","upload"),this.#J.className="fig-input-file-filename",$)this.#J.setAttribute("disabled","");let G=document.createElement("fig-truncate");G.setAttribute("position","middle"),G.setAttribute("tooltip","");let X=this.value,K=X.lastIndexOf(".");if(K>0)G.setAttribute("tail",X.slice(K));if(G.textContent=X,this.#J.appendChild(G),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#J.appendChild(this.#Z),q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q),this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",$)this.#j.setAttribute("disabled","");this.#j.replaceChildren(m("minus")),this.#j.addEventListener("click",this.#N),N.appendChild(this.#j),this.appendChild(N)}else{let q=Q?`Accepts ${Q.split(",").map((G)=>G.trim()).join(", ")}`:"";if(q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q);if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j),this.#J.setAttribute("type","upload"),this.#J.textContent=Z,$)this.#J.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#J.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J)}}}customElements.define("fig-input-file",Z1);class b extends HTMLElement{#Z={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#$="bezier";#J=2;#q=null;#_=null;#G=null;#X=null;#N=null;#Y=null;#K=null;#W=null;#U=null;#L=null;#A=null;#M=null;#O=null;#F=0.8;#z=200;#H=200;#B=null;#P=null;#T=null;#C=5;#S=2;#E=10;#k=10;#R=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.#J=parseInt(this.getAttribute("precision")||"2"),w(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#f(Q);this.#M=this.#D(),this.#g(),this.#e()}disconnectedCallback(){if(this.#q=null,this.#T)this.#T.disconnect(),this.#T=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(w(this,"--aspect-ratio",$),this.#_)this.#m(),this.#p();return}if(Q==="edit"){if(this.isConnected)this.#g();return}if(Q==="value"&&$){let J=this.#$;if(this.#f($),this.#M=this.#D(),J!==this.#$&&this.#v())this.#g();else{if(this.#_)this.#p();this.#n(),this.#i()}}if(Q==="precision")this.#J=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#j;return`spring(${Z}, ${$}, ${J})`}let Q=this.#J;return`${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#V(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let _=0;_<Z.length;_+=J)j.push(Z[_].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#J;return`cubic-bezier(${this.#Z.x.toFixed(Q)}, ${this.#Z.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)}#f(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#$="spring",this.#j.stiffness=parseFloat(Z[1]),this.#j.damping=parseFloat(Z[2]),this.#j.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],!0;return!1}#D(){if(this.#$==="bezier"){for(let Z of b.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#Q.x-Z.value[2])<0.001&&Math.abs(this.#Q.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of b.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#j.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#j.damping-Z.spring.damping)<0.001&&Math.abs(this.#j.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#V(){let{stiffness:Q,damping:Z,mass:$}=this.#j,J=0.004,j=5,_=[],q=0,G=0;for(let X=0;X<=5;X+=0.004){let K=-Q*(q-1)-Z*G;if(G+=K/$*0.004,q+=G*0.004,_.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(G)<0.0005)break}return _}static#y(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,_=0.004,q=5,G=[],X=0,K=0;for(let B=0;B<=5;B+=0.004){let M=-$*(X-1)-J*K;if(K+=M/j*0.004,X+=K*0.004,G.push({t:B,value:X}),B>0.1&&Math.abs(X-1)<0.001&&Math.abs(K)<0.001)break}let N=G[G.length-1].t||1,F=1;for(let B of G)if(B.value>F)F=B.value;let W=0;for(let B of G)if(B.value<W)W=B.value;let z=Math.max(F-W,1),L=6,U=Z-L*2,T=Math.max(1,Math.floor(G.length/30)),R="";for(let B=0;B<G.length;B+=T){let M=L+G[B].t/N*U,P=L+(1-(G[B].value-W)/z)*U;R+=(B===0?"M":"L")+M.toFixed(1)+","+P.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let q=(j-12)/2,G=48,X=[],K=(M,P,S,f,x)=>{let k=1-x;return k*k*k*M+3*k*k*x*P+3*k*x*x*S+x*x*x*f};for(let M=0;M<=48;M++){let P=M/48;X.push({x:K(0,Q,$,1,P),y:K(0,Z,J,1,P)})}let N=1/0,F=-1/0,W=1/0,z=-1/0;for(let M of X){if(M.x<N)N=M.x;if(M.x>F)F=M.x;if(M.y<W)W=M.y;if(M.y>z)z=M.y}let L=Math.max(F-N,0.000001),U=Math.max(z-W,0.000001),T=(M)=>q+(M-N)/L*12,R=(M)=>q+(1-(M-W)/U)*12,B="";for(let M=0;M<X.length;M++){let P=T(X[M].x),S=R(X[M].y);B+=`${M===0?"M":"L"}${P.toFixed(1)},${S.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${B}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#v(){return this.getAttribute("edit")!=="false"}#g(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#s(),this.innerHTML=this.#w(),this.#u(),this.#_)this.#h(),this.#m(),this.#p();this.#i(),this.#L0()}static#b(Q){return String(Q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#x(){let Q="",Z=void 0;for(let $ of b.PRESETS){if(!this.#v()&&!$.value&&!$.spring)continue;if($.group!==Z){if(Z!==void 0)Q+="</optgroup>";if($.group)Q+=`<optgroup label="${$.group}">`;Z=$.group}let J;if($.type==="spring"){let _=$.spring||this.#j;J=b.#y(_)}else{let _=$.value||[this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y];J=b.curveIcon(..._)}let j=$.name===this.#M?" selected":"";Q+=`<option value="${$.name}"${j}>${J} ${$.name}</option>`}if(Z)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#w(){let Z=this.#x();if(!this.#v())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#b(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
189
|
+
</div>`,this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z&&this.#j&&this.#$){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",q);if(J)this.#j.setAttribute("experimental",J);this.#$.append(this.#j)}this.#J=this.querySelector("fig-dropdown"),this.#R()}#U(){this.#L(),this.#J?.addEventListener("input",this.#X),this.#Q?.addEventListener("input",this.#Y),this.#Q?.addEventListener("change",this.#N)}#L(){this.#J?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("input",this.#Y),this.#Q?.removeEventListener("change",this.#N)}#F(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Q)this.#Q.setAttribute("value",Z);this.#z(),this.#H()}#O(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#z()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#H()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#M(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#P(){return`${this.#M()} options`}#R(){if(this.#Q)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)});if(this.#J&&!this.#J.hasAttribute("aria-label"))this.#J.setAttribute("label",this.#P())}#C(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#J&&!this.#Z){let J=this.#A();this.#J.replaceChildren(...J.map((j)=>{let q=document.createElement("option");return q.textContent=j,q}))}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",$||"");this.#R();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",$||"");break;case"disabled":this.#C($!==null&&$!=="false");break;case"experimental":if(this.#J){if($)this.#J.setAttribute("experimental",$);else if(!this.#Z)this.#J.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}customElements.define("fig-combo-input",e0);class Q1 extends HTMLElement{#Z="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#N.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#X(),this.#$(),this.#Y()}#$(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=U0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Z||!this.input){if(this.#Z=J,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#Q);if(this.#Z==="color"){let q=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Q);this.#Y()}else this.innerHTML="<div></div>",this.input=null,this.#Y()}else if(this.#Z==="color"&&this.input){let q=this.#q($);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("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#Y(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);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")}#N(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,Z,$){if(Z===$)return;if(Q==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#X()}else if(Q==="alpha")this.#$();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#Y()}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-swatch",Q1);class j0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#X=this.#s.bind(this);#Y=this.#h.bind(this);#N=this.#l.bind(this);#G=this.#m.bind(this);#K=null;#W=null;#U=null;#L=null;#F=null;#O=null;#B=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","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.#Z}set src(Q){if(this.#Z=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#z(){return this.#q||this.#Z||""}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((J,j)=>{this.#Q.addEventListener("load",J,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,Z=this.#Q.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Q,0,0),$.toDataURL()}connectedCallback(){this.#Z=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 Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#M(),this.#R(),this.#A(),this.#k(),this.#C(),this.#f(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#w();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#X),this.#$?.addEventListener("change",this.#X)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#X),this.#H(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#H(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#Y),this.#Q.removeEventListener("pause",this.#N),this.#Q.removeEventListener("ended",this.#G)}#A(){if(this.#H(),this.#Q?.tagName!=="VIDEO")return;this.#Q.addEventListener("play",this.#Y),this.#Q.addEventListener("pause",this.#N),this.#Q.addEventListener("ended",this.#G)}#M(){if(this.#J?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#J=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#P(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#P();if(Q){if(this.#M(),this.#Q&&this.#Q!==Q){if(this.#H(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#J&&Q.parentElement!==this.#J)this.#J.append(Q);this.#C();return}this.#M();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==Z){if(this.#H(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#Q=$,this.#A();let J=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#J.append($),this.#Q=$}}#C(){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 Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)})}#S(){return this.querySelector(":scope > figcaption:not([data-generated])")}#E(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#f(){let Q=this.#S(),Z=this.#E();if(Q){Z.forEach((q)=>q.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((q)=>q.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((q)=>q.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#J?.isConnected)this.#J.after(J);else if(!J.isConnected)this.append(J)}#T(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#k(){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.#C();return}let Z=this.getAttribute("poster");if(Z)this.#Q.setAttribute("poster",Z);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#T("autoplay",!1),this.#Q.loop=this.#T("loop",!1),this.#Q.muted=this.#T("muted",!1),this.#Q.playsInline=!0,this.#C(),this.#y(),this.#I()}get mediaEl(){return this.#Q}#D(){if(this.mediaKind!=="video")return!1;return Boolean(this.#z())}#I(){let Q=this.#K||this.querySelector(":scope > fig-media-controls");if(!Q)return;if(this.mediaKind!=="video")return;if(this.#D()){if(Q.hasAttribute("data-fig-empty-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-fig-empty-disabled");return}Q.setAttribute("disabled",""),Q.setAttribute("data-fig-empty-disabled",""),Q.playing=!1,Q.time=0,Q.duration=0}#y(){if(this.mediaKind!=="video"){this.#V();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#V(),this.#K=Q;this.#v(),this.#I();return}if(this.#T("controls",!1))this.#b();else this.#V()}#b(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#v(),this.#I();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#v(),this.#I()}#v(){if(!this.#K||!this.#Q)return;if(this.#W===this.#Q&&this.#U===this.#K){this.#I();return}this.#g();let Q=this.#K,Z=this.#Q;this.#W=Z,this.#U=Q;let $=null,J=()=>{if(this.#I(),!this.#D())return;if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{if(!this.#D())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#D())return;let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;$=Y;try{Z.currentTime=Y}catch{}};this.#L=J,this.#F=j,this.#O=q,this.#B=_,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),J()}#g(){let Q=this.#W,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#F)Z.removeEventListener("play",this.#F);if(this.#O)Z.removeEventListener("pause",this.#O);if(this.#B)Z.removeEventListener("seek",this.#B)}this.#W=null,this.#U=null,this.#L=null,this.#F=null,this.#O=null,this.#B=null}#V(){this.#g(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=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()}#w(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Z?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Z)Q.setAttribute("url",this.#Z);Q.addEventListener("change",this.#X),this.#M(),this.#J.append(Q),this.#$=Q}#x(){if(this.#$)this.#$.removeEventListener("change",this.#X),this.#$.remove(),this.#$=null}#s(Q){if(Q.target!==this.#$)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#k(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#k(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#p(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#h(){this.#p("play")}#l(){this.#p("pause")}#m(){this.#p("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Z=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#k(),this.#$){let q=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":q),this.#Z)if(this.#_?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#_.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#k(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#C();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#w();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#k();if(Q==="caption")this.#f()}}customElements.define("fig-media",j0);class Z1 extends j0{get mediaKind(){return"image"}}customElements.define("fig-image",Z1);class $1 extends j0{get mediaKind(){return"video"}}customElements.define("fig-video",$1);class J1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=!1;connectedCallback(){this.#W(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#W(),this.#U()}#X(){return this.getAttribute("label")??this.getAttribute("text")??""}#Y(){return this.getAttribute("sublabel")??""}#N(){let Q=this.getAttribute("href");return Boolean(Q)&&!R(this,"disabled")}#G(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#W(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#N()?"a":"div";if(!this.#Z||this.#Z.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Z){while(this.#Z.firstChild)J.appendChild(this.#Z.firstChild);this.#Z.replaceWith(J)}else this.appendChild(J);this.#Z=J}if(!this.#Q||!this.#Q.isConnected){if(this.#Q=this.#Z.querySelector(":scope > .fig-card-media"),!this.#Q)this.#Q=document.createElement("div"),this.#Q.className="fig-card-media",this.#Z.prepend(this.#Q)}if(Q&&Q.parentElement!==this.#Q)this.#Q.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Q.appendChild(Q),this.#$=null;if(!this.#_){if(this.#$=this.#Q.querySelector(":scope > fig-image[data-generated]")||null,!this.#$)this.#Q.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#$=document.createElement("fig-image"),this.#$.setAttribute("data-generated",""),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto"),this.#Q.appendChild(this.#$)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.querySelector(":scope > .fig-card-text"),!this.#J)this.#J=document.createElement("div"),this.#J.className="fig-card-text",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#J.querySelector(":scope > .fig-card-label[data-generated]"),!this.#j){if(this.#j=this.#Z.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-label",this.#j.setAttribute("data-generated","");this.#J.appendChild(this.#j)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#J.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#j.after(this.#q)}}}#U(){if(!this.#Z)return;let Q=R(this,"disabled"),Z=R(this,"selected"),$=this.#X(),J=this.#Y(),j=this.#G();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#N()){let q=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Z.setAttribute("href",q),_)if(this.#Z.setAttribute("target",_),_==="_blank")this.#Z.setAttribute("rel","noopener noreferrer");else this.#Z.removeAttribute("rel");else this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel");if(Z)this.#Z.setAttribute("aria-current","true");else this.#Z.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Z.removeAttribute("href"),this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel"),this.#Z.removeAttribute("aria-current"),this.setAttribute("role","group");let q=[$,J].filter(Boolean).join(", ");if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#$&&!this.#_){let q=this.getAttribute("src"),_=this.getAttribute("alt"),X=this.getAttribute("aspect-ratio")||"1/1",Y=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(q)this.#$.setAttribute("src",q);else this.#$.removeAttribute("src");this.#$.setAttribute("alt",K),this.#$.setAttribute("aspect-ratio",X),this.#$.setAttribute("fit",Y),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto")}if(this.#j)this.#j.textContent=$,this.#j.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#J)this.#J.hidden=!$&&!J}}customElements.define("fig-card",J1);class j1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#_(),this.#G(),this.#K(),this.#X()}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 Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return R(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#G();if(Q==="duration"||Q==="time")this.#K();if(Q==="disabled")this.#X()}#_(){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 Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=u("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#N(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#Y(this.time);let q=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#j=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",q),J.addEventListener("change",q),this.append(Q,J,j),this.#Z=Z,this.#Q=Q,this.#J=J,this.#$=j,this.#X()}#X(){let Q=this.disabled;if(this.setAttribute("aria-disabled",Q?"true":"false"),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}#Y(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#N(Q,Z=0){let $=this.#Y(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#Y(Z)}`}#G(){if(!this.#Z)return;let Q=this.playing;this.#Z.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Z.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#N(Z,Q)),this.#$)this.#$.textContent=this.#Y(Z)}toggle(){if(this.disabled)return;let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",j1);class q1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}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.#U(),this.addEventListener("dragover",this.#G),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#W)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#Y),this.#J?.removeEventListener("click",this.#N),this.removeEventListener("dragover",this.#G),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#W)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#X({cleared:!0})}#X(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#Y=()=>{if(this.#Z.files.length>0)this.#q=this.#Z.files,this.removeAttribute("url"),this.#U(),this.#X()};#N=(Q)=>{Q.stopPropagation(),this.clear()};#G=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#W=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((q)=>q.trim().toLowerCase());$=$.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")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#U(),this.#X()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",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((U)=>U.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.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.#j.appendChild(X),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#Y),this.#j.appendChild(this.#Z),_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_),this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j);let G=document.createElement("fig-tooltip");if(G.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",$)this.#J.setAttribute("disabled","");this.#J.replaceChildren(u("minus")),this.#J.addEventListener("click",this.#N),G.appendChild(this.#J),this.appendChild(G)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#Y),this.#j.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j)}}}customElements.define("fig-input-file",q1);class h extends HTMLElement{#Z={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#$="bezier";#j=2;#q=null;#_=null;#X=null;#Y=null;#N=null;#G=null;#K=null;#W=null;#U=null;#L=null;#F=null;#O=null;#B=null;#z=0.8;#H=200;#A=200;#M=null;#P=null;#R=null;#C=5;#S=2;#E=10;#f=10;#T=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#k(Q);this.#O=this.#D(),this.#v(),this.#l()}disconnectedCallback(){if(this.#q=null,this.#R)this.#R.disconnect(),this.#R=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(v(this,"--aspect-ratio",$),this.#_)this.#m(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#v();return}if(Q==="value"&&$){let J=this.#$;if(this.#k($),this.#O=this.#D(),J!==this.#$&&this.#b())this.#v();else{if(this.#_)this.#u();this.#e(),this.#i()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#J;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#I(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let q=0;q<Z.length;q+=J)j.push(Z[q].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#O}set value(Q){this.setAttribute("value",Q)}#k(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#$="spring",this.#J.stiffness=parseFloat(Z[1]),this.#J.damping=parseFloat(Z[2]),this.#J.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],!0;return!1}#D(){if(this.#$==="bezier"){for(let Z of h.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#Q.x-Z.value[2])<0.001&&Math.abs(this.#Q.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of h.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#J.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#J.damping-Z.spring.damping)<0.001&&Math.abs(this.#J.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#I(){let{stiffness:Q,damping:Z,mass:$}=this.#J,J=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-Z*X;if(X+=K/$*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,Z=24){let{stiffness:$,damping:J,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let M=0;M<=5;M+=0.004){let O=-$*(Y-1)-J*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 G=X[X.length-1].t||1,U=1;for(let M of X)if(M.value>U)U=M.value;let W=0;for(let M of X)if(M.value<W)W=M.value;let F=Math.max(U-W,1),B=6,L=Z-B*2,D=Math.max(1,Math.floor(X.length/30)),H="";for(let M=0;M<X.length;M+=D){let O=B+X[M].t/G*L,C=B+(1-(X[M].value-W)/F)*L;H+=(M===0?"M":"L")+O.toFixed(1)+","+C.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${H}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let _=(j-12)/2,X=48,Y=[],K=(O,C,E,S,y)=>{let I=1-y;return I*I*I*O+3*I*I*y*C+3*I*y*y*E+y*y*y*S};for(let O=0;O<=48;O++){let C=O/48;Y.push({x:K(0,Q,$,1,C),y:K(0,Z,J,1,C)})}let G=1/0,U=-1/0,W=1/0,F=-1/0;for(let O of Y){if(O.x<G)G=O.x;if(O.x>U)U=O.x;if(O.y<W)W=O.y;if(O.y>F)F=O.y}let B=Math.max(U-G,0.000001),L=Math.max(F-W,0.000001),D=(O)=>_+(O-G)/B*12,H=(O)=>_+(1-(O-W)/L)*12,M="";for(let O=0;O<Y.length;O++){let C=D(Y[O].x),E=H(Y[O].y);M+=`${O===0?"M":"L"}${C.toFixed(1)},${E.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>`}#b(){return this.getAttribute("edit")!=="false"}#v(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#s(),this.innerHTML=this.#w(),this.#p(),this.#_)this.#h(),this.#m(),this.#u();this.#i(),this.#L0()}static#g(Q){return String(Q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#V(){let Q="",Z=void 0;for(let $ of h.PRESETS){if(!this.#b()&&!$.value&&!$.spring)continue;if($.group!==Z){if(Z!==void 0)Q+="</optgroup>";if($.group)Q+=`<optgroup label="${$.group}">`;Z=$.group}let J;if($.type==="spring"){let q=$.spring||this.#J;J=h.#y(q)}else{let q=$.value||[this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y];J=h.curveIcon(...q)}let j=$.name===this.#O?" selected":"";Q+=`<option value="${$.name}"${j}>${J} ${$.name}</option>`}if(Z)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#w(){let Z=this.#V();if(!this.#b())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${h.#g(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
178
190
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
179
191
|
<line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
|
|
180
192
|
<line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
|
|
@@ -191,7 +203,7 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
191
203
|
<circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#S}"/>
|
|
192
204
|
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" aria-label="First easing control point"></fig-handle></foreignObject>
|
|
193
205
|
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" aria-label="Second easing control point"></fig-handle></foreignObject>
|
|
194
|
-
</svg></div>${$}`}#I(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#s(){this.#S=this.#I("--easing-bezier-endpoint-radius",this.#S),this.#R=this.#I("--easing-duration-bar-radius",this.#R)}#u(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#G=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#N=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#W=this.querySelector('[data-endpoint="start"]'),this.#U=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#A=this.querySelector(".fig-easing-curve-value-input"),this.#O=this.querySelector(".fig-easing-curve-target"),this.#B=this.querySelector(".fig-easing-curve-bounds"),this.#P=this.querySelector(".fig-easing-curve-diagonal")}#h(){let Q=this.#Y?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#C*2,J=Q.offsetHeight||this.#C*2;this.#C=Math.max($,J)/2,this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#E,J=Z.offsetHeight||this.#k;if(this.#$==="spring")this.#E=$,this.#k=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#e(){if(this.#T||!window.ResizeObserver)return;this.#T=new ResizeObserver(()=>{if(this.#m())this.#p()}),this.#T.observe(this)}#m(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#z||$!==this.#H;return this.#z=Z,this.#H=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#c(Q,Z){return{x:Q*this.#z,y:(1-Z)*this.#H}}#t(Q,Z){return{x:Q/this.#z,y:1-Z/this.#H}}#r={minVal:0,maxVal:1.2,totalTime:1};#d(Q,Z){let J=this.#H-40,{minVal:j,maxVal:_}=this.#r,q=_-j||1;return{x:Q*this.#z,y:20+(1-(Z-j)/q)*J}}#p(){if(this.#m(),this.#$==="spring")this.#J0();else this.#Q0()}#l(){this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===1),this.#N?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===2)}#Q0(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#z),this.#B.setAttribute("height",this.#H);if(this.#P)this.#P.setAttribute("x1","0"),this.#P.setAttribute("y1",this.#H),this.#P.setAttribute("x2",this.#z),this.#P.setAttribute("y2","0");let Q=this.#c(0,0),Z=this.#c(this.#Z.x,this.#Z.y),$=this.#c(this.#Q.x,this.#Q.y),J=this.#c(1,1);this.#G.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y),this.#N.setAttribute("x1",J.x),this.#N.setAttribute("y1",J.y),this.#N.setAttribute("x2",$.x),this.#N.setAttribute("y2",$.y);let j=this.#C;if(this.#Y.setAttribute("x",Z.x-j),this.#Y.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#W)this.#W.setAttribute("cx",Q.x),this.#W.setAttribute("cy",Q.y);if(this.#U)this.#U.setAttribute("cx",J.x),this.#U.setAttribute("cy",J.y);this.#$0()}#$0(){if(!this.#_||!this.#Y||!this.#K)return;let Q=this.#Z.y>=this.#Q.y?[this.#Y,this.#K]:[this.#K,this.#Y];for(let Z of Q)this.#_.append(Z)}#J0(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#z),this.#B.setAttribute("height",this.#H);let Q=this.#V();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let U of Q){if(U.value<$)$=U.value;if(U.value>J)J=U.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),_=0;this.#r={minVal:1-j-_,maxVal:1+j+_,totalTime:Z};let q=Math.max(0.05,Math.min(0.95,this.#F)),G="";for(let U=0;U<Q.length;U++){let T=Q[U].t/Z*q,R=this.#d(T,Q[U].value);G+=(U===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let X=this.#d(q,1),K=this.#d(1,1);if(G+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#G.setAttribute("d",G),this.#O){let U=this.#d(0,1),T=this.#d(1,1);this.#O.setAttribute("x1",U.x),this.#O.setAttribute("y1",U.y),this.#O.setAttribute("x2",T.x),this.#O.setAttribute("y2",T.y)}let N=this.#j0(Q),F=N.t/Z*q,W=this.#d(F,N.value),z=this.#C;this.#Y.setAttribute("x",W.x-z),this.#Y.setAttribute("y",W.y-z);let L=this.#d(q,1);this.#K.setAttribute("x",L.x-this.#E/2),this.#K.setAttribute("y",L.y-this.#k/2)}#j0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#n(){if(!this.#L)return;this.#L.value=this.#M,this.#N0()}#i(){if(!this.#A)return;this.#A.setAttribute("value",this.value)}#Z0(Q){let Z=Q.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#a(Q,Z){let $=this.#Z0(Q);if(!$){if(Z==="change")this.#i();return}let J=this.#$;if(this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],this.#M=this.#D(),J!==this.#$)this.#g();else if(this.#p(),this.#n(),Z==="change")this.#i();this.#o(Z)}#_0(Q,Z,$){if(!Q)return;for(let J of Q.querySelectorAll("option"))if(J.value===Z)J.innerHTML=`${$} ${Z}`}#N0(){if(!this.#L)return;if(!this.#v())return;let Q=b.curveIcon(this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y),Z=b.#y(this.#j);this.#_0(this.#L,"Custom bezier",Q),this.#_0(this.#L,"Custom spring",Z),this.#_0(this.#L.select,"Custom bezier",Q),this.#_0(this.#L.select,"Custom spring",Z)}#K0(Q){this.#p(),this.#M=this.#D(),this.#n(),this.#i(),this.#o(Q)}#W0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#Q;switch(Q.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#K0("input"),this.#o("change"),!0}#U0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-$));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+$));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#F=Math.max(0.05,this.#F-J/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+J*1.5));break;case"ArrowRight":this.#F=Math.min(0.95,this.#F+J/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-J*1.5));break;case"Home":this.#F=0.05;break;case"End":this.#F=0.95;break;default:return!1}}return this.#K0("input"),this.#o("change"),!0}#q0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#G0(J,Number(Z));else this.#X0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#W0(J,Number(Z)):this.#U0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#o(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#L0(){if(this.#_&&this.#$==="bezier"){this.#q0(this.#Y,"1"),this.#q0(this.#K,"2"),this.#Y.addEventListener("pointerdown",(Z)=>this.#G0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#G0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#G0(Z,this.#B0(Z))})}else if(this.#_){this.#q0(this.#Y,"bounce"),this.#q0(this.#K,"duration"),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0(Z,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let Z=Q.detail,$=b.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#Q.x=$.value[2],this.#Q.y=$.value[3];if(this.#M=Z,this.#$!=="bezier")this.#$="bezier",this.#g();else if(this.#_)this.#p(),this.#i()}else if($.type==="spring"){if($.spring)this.#j={...$.spring};if(this.#M=Z,this.#$!=="spring")this.#$="spring",this.#g();else if(this.#_)this.#p(),this.#i()}this.#o("input"),this.#o("change")});if(this.#A)this.#A.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#a(Z,"input")}),this.#A.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#a(Z,"change")})}#Y0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#B0(Q){return this.#Y0(Q).x<=this.#z/2?1:2}#G0(Q,Z){Q.preventDefault(),this.#q=Z,this.#l();let $=(j)=>{if(!this.#q)return;let _=this.#Y0(j),q=this.#t(_.x,_.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#q===1)this.#Z.x=q.x,this.#Z.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#p(),this.#M=this.#D(),this.#n(),this.#i(),this.#o("input")},J=()=>{this.#q=null,this.#l(),document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",J),this.#o("change")};document.addEventListener("pointermove",$),document.addEventListener("pointerup",J)}#X0(Q,Z){Q.preventDefault(),this.#q=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=this.#j.damping,J=this.#j.stiffness,j=this.#F,_=Q.clientY,q=Q.clientX,G=(K)=>{if(!this.#q)return;if(Z==="bounce"){let N=K.clientY-_;this.#j.damping=Math.max(1,Math.round($+N*0.15))}else{let N=K.clientX-q;this.#F=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(J-N*1.5))}this.#p(),this.#M=this.#D(),this.#n(),this.#i(),this.#o("input")},X=()=>{this.#q=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",X),this.#o("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",b);class $1 extends HTMLElement{#Z=0;#Q=0;#j=0;#$=1;#J=!1;#q=!1;#_=null;#G=null;#X=null;#N=null;#Y=(Q)=>this.#D(Q);#K=null;#W=[];#U={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),w(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),w(this,"--perspective",this.getAttribute("perspective")),w(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#O(this.getAttribute("transform-origin")),this.#H(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#B(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#A();else this.#P();this.#z(this.getAttribute("selected")),this.#F()}disconnectedCallback(){this.#J=!1,this.#M()}#A(){this.#G=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#T(),this.#S(),this.#R()}#M(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#N),this.#X=null,this.#N=null}#O(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#F(){if(!this.#G)return;this.#G.style.cursor=this.#f?"":"default"}#z(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#H(Q){if(!Q||!Q.trim()){this.#W=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){w(this,"--aspect-ratio",$);return}if(Q==="perspective"){w(this,"--perspective",$);return}if(Q==="perspective-origin"){w(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#O($);return}if(Q==="selected"){this.#z($);return}if(Q==="drag"){this.#F();return}if(Q==="fields"){if(this.#H($),this.#_)this.#P();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#J)return;this.#B($),this.#S(),this.#C()}if(Q==="precision")this.#$=parseInt($||"1")}get value(){let Q=this.#$;return`rotateX(${this.#Z.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.#Z}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#B(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#Q=parseFloat($[1]);if(J)this.#j=parseFloat(J[1])}#P(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#j},$=this.#W.map((J)=>`<fig-input-number
|
|
206
|
+
</svg></div>${$}`}#x(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#s(){this.#S=this.#x("--easing-bezier-endpoint-radius",this.#S),this.#T=this.#x("--easing-duration-bar-radius",this.#T)}#p(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#Y=this.querySelector('[data-arm="1"]'),this.#N=this.querySelector('[data-arm="2"]'),this.#G=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#W=this.querySelector('[data-endpoint="start"]'),this.#U=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#F=this.querySelector(".fig-easing-curve-value-input"),this.#B=this.querySelector(".fig-easing-curve-target"),this.#M=this.querySelector(".fig-easing-curve-bounds"),this.#P=this.querySelector(".fig-easing-curve-diagonal")}#h(){let Q=this.#G?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#C*2,J=Q.offsetHeight||this.#C*2;this.#C=Math.max($,J)/2,this.#G.setAttribute("width",$),this.#G.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#E,J=Z.offsetHeight||this.#f;if(this.#$==="spring")this.#E=$,this.#f=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#l(){if(this.#R||!window.ResizeObserver)return;this.#R=new ResizeObserver(()=>{if(this.#m())this.#u()}),this.#R.observe(this)}#m(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#H||$!==this.#A;return this.#H=Z,this.#A=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#c(Q,Z){return{x:Q*this.#H,y:(1-Z)*this.#A}}#n(Q,Z){return{x:Q/this.#H,y:1-Z/this.#A}}#r={minVal:0,maxVal:1.2,totalTime:1};#d(Q,Z){let J=this.#A-40,{minVal:j,maxVal:q}=this.#r,_=q-j||1;return{x:Q*this.#H,y:20+(1-(Z-j)/_)*J}}#u(){if(this.#m(),this.#$==="spring")this.#J0();else this.#Q0()}#a(){this.#Y?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===1),this.#N?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===2)}#Q0(){if(this.#M)this.#M.setAttribute("x","0"),this.#M.setAttribute("y","0"),this.#M.setAttribute("width",this.#H),this.#M.setAttribute("height",this.#A);if(this.#P)this.#P.setAttribute("x1","0"),this.#P.setAttribute("y1",this.#A),this.#P.setAttribute("x2",this.#H),this.#P.setAttribute("y2","0");let Q=this.#c(0,0),Z=this.#c(this.#Z.x,this.#Z.y),$=this.#c(this.#Q.x,this.#Q.y),J=this.#c(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#Y.setAttribute("x1",Q.x),this.#Y.setAttribute("y1",Q.y),this.#Y.setAttribute("x2",Z.x),this.#Y.setAttribute("y2",Z.y),this.#N.setAttribute("x1",J.x),this.#N.setAttribute("y1",J.y),this.#N.setAttribute("x2",$.x),this.#N.setAttribute("y2",$.y);let j=this.#C;if(this.#G.setAttribute("x",Z.x-j),this.#G.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#W)this.#W.setAttribute("cx",Q.x),this.#W.setAttribute("cy",Q.y);if(this.#U)this.#U.setAttribute("cx",J.x),this.#U.setAttribute("cy",J.y);this.#$0()}#$0(){if(!this.#_||!this.#G||!this.#K)return;let Q=this.#Z.y>=this.#Q.y?[this.#G,this.#K]:[this.#K,this.#G];for(let Z of Q)this.#_.append(Z)}#J0(){if(this.#M)this.#M.setAttribute("x","0"),this.#M.setAttribute("y","0"),this.#M.setAttribute("width",this.#H),this.#M.setAttribute("height",this.#A);let Q=this.#I();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let L of Q){if(L.value<$)$=L.value;if(L.value>J)J=L.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),q=0;this.#r={minVal:1-j-q,maxVal:1+j+q,totalTime:Z};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let L=0;L<Q.length;L++){let D=Q[L].t/Z*_,H=this.#d(D,Q[L].value);X+=(L===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}let Y=this.#d(_,1),K=this.#d(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.#B){let L=this.#d(0,1),D=this.#d(1,1);this.#B.setAttribute("x1",L.x),this.#B.setAttribute("y1",L.y),this.#B.setAttribute("x2",D.x),this.#B.setAttribute("y2",D.y)}let G=this.#j0(Q),U=G.t/Z*_,W=this.#d(U,G.value),F=this.#C;this.#G.setAttribute("x",W.x-F),this.#G.setAttribute("y",W.y-F);let B=this.#d(_,1);this.#K.setAttribute("x",B.x-this.#E/2),this.#K.setAttribute("y",B.y-this.#f/2)}#j0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#e(){if(!this.#L)return;this.#L.value=this.#O,this.#N0()}#i(){if(!this.#F)return;this.#F.setAttribute("value",this.value)}#Z0(Q){let Z=Q.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#t(Q,Z){let $=this.#Z0(Q);if(!$){if(Z==="change")this.#i();return}let J=this.#$;if(this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],this.#O=this.#D(),J!==this.#$)this.#v();else if(this.#u(),this.#e(),Z==="change")this.#i();this.#o(Z)}#q0(Q,Z,$){if(!Q)return;for(let J of Q.querySelectorAll("option"))if(J.value===Z)J.innerHTML=`${$} ${Z}`}#N0(){if(!this.#L)return;if(!this.#b())return;let Q=h.curveIcon(this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y),Z=h.#y(this.#J);this.#q0(this.#L,"Custom bezier",Q),this.#q0(this.#L,"Custom spring",Z),this.#q0(this.#L.select,"Custom bezier",Q),this.#q0(this.#L.select,"Custom spring",Z)}#K0(Q){this.#u(),this.#O=this.#D(),this.#e(),this.#i(),this.#o(Q)}#W0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#Q;switch(Q.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#K0("input"),this.#o("change"),!0}#U0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#J.damping=Math.max(1,Math.round(this.#J.damping-$));break;case"ArrowDown":this.#J.damping=Math.max(1,Math.round(this.#J.damping+$));break;case"Home":this.#J.damping=1;break;case"End":this.#J.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*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.#o("change"),!0}#_0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#X0(J,Number(Z));else this.#Y0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#W0(J,Number(Z)):this.#U0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#o(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#O}}))}#L0(){if(this.#_&&this.#$==="bezier"){this.#_0(this.#G,"1"),this.#_0(this.#K,"2"),this.#G.addEventListener("pointerdown",(Z)=>this.#X0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#X0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0(Z,this.#B0(Z))})}else if(this.#_){this.#_0(this.#G,"bounce"),this.#_0(this.#K,"duration"),this.#G.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#Y0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#Y0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0(Z,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let Z=Q.detail,$=h.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#Q.x=$.value[2],this.#Q.y=$.value[3];if(this.#O=Z,this.#$!=="bezier")this.#$="bezier",this.#v();else if(this.#_)this.#u(),this.#i()}else if($.type==="spring"){if($.spring)this.#J={...$.spring};if(this.#O=Z,this.#$!=="spring")this.#$="spring",this.#v();else if(this.#_)this.#u(),this.#i()}this.#o("input"),this.#o("change")});if(this.#F)this.#F.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#t(Z,"input")}),this.#F.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#t(Z,"change")})}#G0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#B0(Q){return this.#G0(Q).x<=this.#H/2?1:2}#X0(Q,Z){Q.preventDefault(),this.#q=Z,this.#a();let $=(j)=>{if(!this.#q)return;let q=this.#G0(j),_=this.#n(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.#Z.x=_.x,this.#Z.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#u(),this.#O=this.#D(),this.#e(),this.#i(),this.#o("input")},J=()=>{this.#q=null,this.#a(),document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",J),this.#o("change")};document.addEventListener("pointermove",$),document.addEventListener("pointerup",J)}#Y0(Q,Z){Q.preventDefault(),this.#q=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=this.#J.damping,J=this.#J.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if(Z==="bounce"){let G=K.clientY-q;this.#J.damping=Math.max(1,Math.round($+G*0.15))}else{let G=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+G/200)),this.#J.stiffness=Math.max(10,Math.round(J-G*1.5))}this.#u(),this.#O=this.#D(),this.#e(),this.#i(),this.#o("input")},Y=()=>{this.#q=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#o("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",h);class _1 extends HTMLElement{#Z=0;#Q=0;#J=0;#$=1;#j=!1;#q=!1;#_=null;#X=null;#Y=null;#N=null;#G=(Q)=>this.#D(Q);#K=null;#W=[];#U={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=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.#B(this.getAttribute("transform-origin")),this.#A(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#M(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#F();else this.#P();this.#H(this.getAttribute("selected")),this.#z()}disconnectedCallback(){this.#j=!1,this.#O()}#F(){this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#S(),this.#T()}#O(){if(this.#K?.abort(),this.#K=null,this.#Y)window.removeEventListener("keydown",this.#Y),window.removeEventListener("keyup",this.#N),this.#Y=null,this.#N=null}#B(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#z(){if(!this.#X)return;this.#X.style.cursor=this.#k?"":"default"}#H(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#A(Q){if(!Q||!Q.trim()){this.#W=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){v(this,"--aspect-ratio",$);return}if(Q==="perspective"){v(this,"--perspective",$);return}if(Q==="perspective-origin"){v(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#B($);return}if(Q==="selected"){this.#H($);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){if(this.#A($),this.#_)this.#P();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#j)return;this.#M($),this.#S(),this.#C()}if(Q==="precision")this.#$=parseInt($||"1")}get value(){let Q=this.#$;return`rotateX(${this.#Z.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.#Z}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#M(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#Q=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#P(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J},$=this.#W.map((J)=>`<fig-input-number
|
|
195
207
|
name="${J}"
|
|
196
208
|
step="1"
|
|
197
209
|
precision="1"
|
|
@@ -209,9 +221,9 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
209
221
|
<div class="fig-3d-rotate-face bottom"></div>
|
|
210
222
|
</div>
|
|
211
223
|
</div>
|
|
212
|
-
</div>${$}`,this.#
|
|
224
|
+
</div>${$}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#S(),this.#T()}#R(){this.#U={};for(let Q of this.#W){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#U[Q]=Z,!this.#L[Q])this.#L[Q]=(J)=>{J.stopPropagation();let j=parseFloat(J.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#Z=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#J=j;this.#S(),this.#E(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#C(){let Q={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J};for(let Z of this.#W){let $=this.#U[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#$))}}#S(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#E(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J}}))}#f(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#T(){if(this.#O(),!this.#X)return;this.#K=new AbortController,this.#X.addEventListener("pointerdown",this.#G,{signal:this.#K.signal}),this.#Y=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#N=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#Y),window.addEventListener("keyup",this.#N)}get#k(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#D(Q){if(!this.#k)return;Q.preventDefault(),this.#j=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:Z,clientY:$}=Q,J=this.#Z,j=this.#Q,q=(X)=>{if(!this.#j)return;if(X.buttons===0){_();return}let Y=X.clientX-Z,K=X.clientY-$;this.#Q=this.#f(j+Y*0.5),this.#Z=this.#f(J-K*0.5),this.#S(),this.#C(),this.setAttribute("value",this.value),this.#E("input")},_=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",_),this.#X.removeEventListener("pointercancel",_),this.#X.removeEventListener("lostpointercapture",_),this.#E("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",_),this.#X.addEventListener("pointercancel",_),this.#X.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",_1);class L0 extends HTMLElement{#Z=50;#Q=50;#J=0;#$=null;#j=[];#q=null;#_=null;#X=null;#Y=!1;#N=!1;#G=null;#K=null;#W=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"]}#U(){this.#$=this.querySelector(".origin-grid"),this.#j=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.#S(),this.#E(),this.#P(),this.#p()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#A(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#M();this.#O(),this.#R()}disconnectedCallback(){this.#Y=!1,this.#V(),this.#s()}get value(){let Q=this.#J;return`${this.#Z.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){v(this,"--aspect-ratio",$);return}if(Q==="drag"){this.#O();return}if(Q==="fields"){this.#M(),this.#O(),this.#R();return}if(Q==="precision"){this.#J=parseInt($||"0"),this.#P(),this.#R();return}if(Q==="value"){if(this.#N||this.#Y)return;this.#A($),this.#S(),this.#E(),this.#P()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#F(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#O(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#L)}#B(Q){return Math.max(0,Math.min(100,Q))}#z(Q,Z){let $=(Q||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#Q;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let j=Number.parseFloat($.replace("%",""));if(Number.isFinite(j))return j;return Z==="x"?this.#Z:this.#Q}#H(Q){let Z=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#z(Z[0],"x");this.#Z=$,this.#Q=$;return}this.#Z=this.#z(Z[0],"x"),this.#Q=this.#z(Z[1],"y")}#A(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Z=50,this.#Q=50;return}this.#H(Z)}#M(){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}">
|
|
213
225
|
<span class="origin-grid-dot"></span>
|
|
214
|
-
</span>`}).join(""),Z=this.#Z.toFixed(this.#
|
|
226
|
+
</span>`}).join(""),Z=this.#Z.toFixed(this.#J),$=this.#Q.toFixed(this.#J),J=this.#F?`<div class="origin-values">
|
|
215
227
|
<fig-input-number name="x" value="${Z}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
|
|
216
228
|
<fig-input-number name="y" value="${$}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
|
|
217
229
|
</div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
|
|
@@ -220,7 +232,7 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
220
232
|
<fig-handle></fig-handle>
|
|
221
233
|
</div>
|
|
222
234
|
</div>
|
|
223
|
-
${J}`,this.#$=this.querySelector(".origin-grid"),this.#
|
|
235
|
+
${J}`,this.#$=this.querySelector(".origin-grid"),this.#j=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.#S(),this.#E(),this.#P(),this.#p()}#P(){let Q=this.#Z.toFixed(this.#J),Z=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",Z)}#R(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#N=!0,this.setAttribute("value",Q),this.#N=!1}#C(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#Q}}))}#S(){if(!this.#q)return;let Q=(Z)=>16.6667+this.#B(Z)/100*66.6667;this.#q.style.left=`${Q(this.#Z)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#E(){if(!this.#q)return;let Q=this.#Z<0||this.#Z>100,Z=this.#Q<0||this.#Q>100,$=this.#Z<0,J=this.#Z>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",Z),this.#q.classList.toggle("overflow-left",$),this.#q.classList.toggle("overflow-right",J),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#f(Q,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1),j=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(J*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#j.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#T(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#k(Q){if(this.#T(),Q)Q.classList.add("is-hovered")}#D(Q,Z,$){let J=Number(Q),j=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(j))return;if(J===this.#Z&&j===this.#Q&&$==="input")return;this.#Z=J,this.#Q=j,this.#S(),this.#E(),this.#P(),this.#R(),this.#C($)}#I(Q,Z){if(!this.#$)return{x:this.#Z,y:this.#Q};let $=this.#$.getBoundingClientRect(),J=$.width/6,j=$.height/6,q=Math.max(1,$.width-J*2),_=Math.max(1,$.height-j*2),X=(Q-($.left+J))/q,Y=(Z-($.top+j))/_;return{x:X*100,y:Y*100}}#y(Q,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1)*3,j=(Z-$.top)/Math.max($.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(J))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#b(Q){let $=Q,J=1/0;for(let j of L0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<J)J=q,$=j}return J<=2.5?$:Q}#v(Q,Z){if(!Z)return Q;return{x:this.#b(Q.x),y:this.#b(Q.y)}}#g(Q){if(!this.#L)return!1;let Z=Q.shiftKey?10:1,$=this.#Z,J=this.#Q;switch(Q.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#D(this.#B($),this.#B(J),"input"),this.#C("change"),!0}#V(){if(!this.#$||!this.#K||!this.#W)return;this.#$.removeEventListener("pointermove",this.#K),this.#$.removeEventListener("pointerup",this.#W),this.#$.removeEventListener("pointercancel",this.#W),this.#$.removeEventListener("lostpointercapture",this.#W),this.#K=null,this.#W=null}#w(Q){if(!this.#$||!this.#L)return;Q.preventDefault(),this.#Y=!0,this.#G=Q.pointerId;let{clientX:Z,clientY:$}=Q,J=3,j=!1;this.#$.setPointerCapture(Q.pointerId),this.#K=(q)=>{if(!this.#Y||q.pointerId!==this.#G)return;let _=q.clientX-Z,X=q.clientY-$,Y=Math.hypot(_,X);if(!j&&Y<J)return;if(!j)j=!0,this.#$.classList.add("is-dragging"),this.#T();let K=this.#v(this.#I(q.clientX,q.clientY),q.shiftKey);this.#D(K.x,K.y,"input")},this.#W=(q)=>{if(!this.#Y||q.pointerId!==this.#G)return;if(this.#Y=!1,this.#G=null,this.#$.classList.remove("is-dragging"),this.#T(),this.#V(),!j){let _=this.#y(Z,$);this.#D(_.x,_.y,"input")}this.#C("change")},this.#$.addEventListener("pointermove",this.#K),this.#$.addEventListener("pointerup",this.#W),this.#$.addEventListener("pointercancel",this.#W),this.#$.addEventListener("lostpointercapture",this.#W)}#x=null;#s(){this.#x?.abort(),this.#x=null}#p(){if(this.#s(),!this.#$||!this.#q)return;this.#x=new AbortController;let{signal:Q}=this.#x;this.#$.addEventListener("pointerdown",($)=>{let J=this.#f($.clientX,$.clientY);if(this.#k(J),this.#L){this.#w($);return}let j=this.#y($.clientX,$.clientY);this.#D(j.x,j.y,"input"),this.#C("change")},{signal:Q}),this.#$.addEventListener("pointermove",($)=>{if(this.#Y)return;let J=this.#f($.clientX,$.clientY);this.#k(J)},{signal:Q}),this.#$.addEventListener("pointerleave",()=>{this.#T()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#g($))return;$.preventDefault(),$.stopPropagation()},{signal:Q});let Z=($,J)=>{if(!$)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(J==="x")this.#D(_,this.#Q,"input");else this.#D(this.#Z,_,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#C("change")},{signal:Q})};Z(this.#_,"x"),Z(this.#X,"y")}}customElements.define("fig-origin-grid",L0);class X1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#X=null;#Y=!1;#N={x:0.5,y:0.5};#G=!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.#Z=(Q)=>this.#R(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#C(Q),this.#$=()=>this.#S(),this.#j=(Q)=>this.#H(Q),this.#q=(Q)=>this.#A(Q),this.#_=()=>this.#M(),this.#X=()=>this.#M()}#K(){this.#B(),this.#T(),this.#D(),this.#I(),this.#G=!0}connectedCallback(){m(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.#K();return}this.#L(),this.#B(),this.#T(),this.#D(),this.#I(),this.#G=!0})}#W(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#U(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#O()}#F(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Z=Q.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:"",leftNoRotate:!1};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J,leftNoRotate:!0}}if(Z.length===4){let[$,J,j,q]=Z;return{left:$,right:J,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#O(){let Q=this.#F();return`
|
|
224
236
|
<div class="fig-input-joystick-plane-container">
|
|
225
237
|
${[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("")}
|
|
226
238
|
<div class="fig-input-joystick-plane">
|
|
@@ -253,6 +265,11 @@ var P1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var E1={};var F0=P1(()=>{/*! Vendored from @
|
|
|
253
265
|
<span slot="prepend">Y</span>
|
|
254
266
|
</fig-input-number>
|
|
255
267
|
</div>`:""}
|
|
256
|
-
`}#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.#Z),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#$);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#J),this.xInput.addEventListener("change",this.#J),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#G)}#F(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#J),this.xInput.removeEventListener("change",this.#J),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#G)}#z(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#R(),this.#D(),this.#E()}#H(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#R(),this.#D(),this.#E()}#B(){this.#D(),this.#k()}#P(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),_=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:_},$)this.#R();this.#f(),this.#D()}#T(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#P($,J,{syncHandle:!1}),this.#E(),this.#k()}#C(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#P(Z.px,Z.py,{syncHandle:!1}),this.#E()}#S(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#D(),this.#k()}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#k(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#R(){let Q=this.#W(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#f()}#f(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#D(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#V()}#V(){let Q=this.#N,Z=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",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#y(){this.position={...this.#N},this.#R(),this.#D(),this.#E(),this.#k()}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 Z=Q==null?"":String(Q).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0.5;let G=q.includes("%"),X=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let K=G||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,K))},j=J($[0]),_=J($[1]??$[0]);this.position={x:j,y:_}}if(this.#Y)this.#R(),this.#V()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){w(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#F(),this.#L(),this.#O(),this.#R();if(Q==="axis-labels"&&$!==Z)this.#F(),this.#L(),this.#O(),this.#R();if(Q==="coordinates")this.coordinates=$||"screen",this.#R()}}customElements.define("fig-joystick",J1);class W0 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.#Z()}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,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Z()}#Z(){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",W0);class j1 extends W0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",j1);class _1 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Z=null;#Q=null;connectedCallback(){this.#J()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#Z)this.#Z.removeEventListener("click",this.#j),this.#Z.removeEventListener("keydown",this.#$),this.#Z.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}this.#J()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#$=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#J(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#Z.remove(),this.#Z=null,this.#Q=null;return}if(J)this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);let j=this.#Z.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Z.prepend(j);if(!j.id)j.id=g();if(this.#Z.dataset.generated)j.textContent=$;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 _=m("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(_)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#Z.removeEventListener("click",this.#j),this.#Z.addEventListener("click",this.#j),this.#Z.setAttribute("role","button"),this.#Z.setAttribute("tabindex","0"),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("keydown",this.#$),this.#Z.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#Z.removeEventListener("click",this.#j),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#Z.removeEventListener("keydown",this.#$),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",_1);class q1 extends HTMLElement{}customElements.define("fig-header",q1);class G1 extends HTMLElement{}customElements.define("fig-footer",G1);class X1 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",X1);class K1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Z()}#Z(){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",K1);var v1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},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",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function b1(Q,Z="medium"){let $=Q&&v1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class Y1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=b1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",Y1);class N1 extends HTMLElement{}customElements.define("fig-content",N1);class W1 extends HTMLElement{}customElements.define("fig-tab-content",W1);class U1 extends HTMLElement{}customElements.define("fig-button-combo",U1);class L1 extends HTMLElement{}customElements.define("fig-input-combo",L1);class B1 extends HTMLElement{#Z=null;#Q=null;#j=null;#$=this.#O.bind(this);#J=this.#F.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.#N(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#Y)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#J);if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#J);if(this.#j)this.#j.disconnect(),this.#j=null}#G(){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#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#N(){let Q=this.#q;if(Q==="add"||Q==="remove"){let G=Q==="add"?"add":"minus",X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${V(X)}"><fig-icon name="${G}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#Y),this.#A();return}this.removeEventListener("click",this.#Y);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#W(Z),j=this.#X?"":'alpha="false"',_=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),q=J<1?` alpha="${J}"`:"";if(this.innerHTML=u()?`<fig-fill-picker mode="solid" ${j} value='${_}'>
|
|
257
|
-
|
|
258
|
-
</fig-fill-picker>`:`<fig-swatch background="${$}"${q}></fig-swatch>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-swatch"),this.#_(),this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#J),!this.#Z)this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#J);this.#G(),this.#A()}#Y=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#W(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=Y0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let _=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${_(j[1])}${_(j[2])}${_(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#W(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#A();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#X)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(H(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#A(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(H(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#A(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let G=this.querySelector("fig-button"),X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(G?.setAttribute("aria-label",X),Z)G?.setAttribute("disabled","");else G?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",_=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(_)J.setAttribute("aria-labelledby",_),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#M(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#O(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"input")}#F(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#N();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#A();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return H(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return H(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",B1);class O1 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",H(this,"selected")?"true":"false"),H(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",H(this,"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",O1);class M1 extends HTMLElement{#Z=null;#Q=this.#F.bind(this);#j=this.#z.bind(this);#$=this.#B.bind(this);#J=null;#q=null;#_=null;#G=null;#X=null;#N=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#W(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#W}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,_=H(J,"selected");if(j&&!_)J.setAttribute("selected","");else if(!j&&_)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#V(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.addEventListener("scroll",this.#$),this.#E(),this.#T(),this.#y(),this.#P(),h(this,()=>{this.#A(),this.#B(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#V(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.removeEventListener("scroll",this.#$),this.#C(),this.#J?.disconnect(),this.#J=null,this.#q?.disconnect(),this.#q=null,this.#k()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#M($);if(Q==="disabled"){let J=$!==null&&$!=="false",j=this.choices;for(let _ of j)if(J)_.setAttribute("aria-disabled","true"),_.setAttribute("tabindex","-1");else _.removeAttribute("aria-disabled"),_.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#A());if(Q==="columns")this.#U(),this.#D();if(Q==="drag")if(this.#K)this.#T();else this.#C();if(Q==="overflow")this.#E(),requestAnimationFrame(()=>this.#B());if(Q==="layout"){if(this.#E(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#D()}}#A(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#M(Z))return;let $=Q.find((J)=>H(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#M(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#O(Q){let Z=this.#W,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#O(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#W)){let _=this.#O(document.activeElement);if(_&&_!==this.#Z)this.selectedChoice=_,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].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}))}#B(){if(this.#Y==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";T0(this,this,Q?"x":"y")}#P(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#B(),this.#D()}),this.#q.observe(this)}#T(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(_)=>{if(_.button!==0)return;if(_.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=_.clientX,this.#X.startY=_.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(_)=>{if(!this.#X.active)return;let q=this.getAttribute("layout")==="horizontal",G=_.clientX-this.#X.startX,X=_.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(q?G:X)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(_.pointerId);if(!this.#X.didDrag)return;if(q)this.scrollLeft=this.#X.scrollLeft-G;else this.scrollTop=this.#X.scrollTop-X},$=(_)=>{if(!this.#X.active)return;let q=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",_.pointerId!==void 0)try{this.releasePointerCapture(_.pointerId)}catch{}if(q)_.preventDefault(),_.stopPropagation()},J=(_)=>{if(this.#X?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#X.suppressClick=!1},j=(_)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#C(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#S(){if(this.#N)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#N=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#N=!1}}#E(){if(this.#Y==="scrollbar")this.#k();else this.#R()}#k(){this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#R(){if(this.#_&&this.#G&&this.contains(this.#_)&&this.contains(this.#G))return;this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null;let Q=D0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#f(-1),onEnd:()=>this.#f(1)});this.#_=Q.start,this.#G=Q.end,this.prepend(this.#_),this.append(this.#G)}#f(Q){let Z=this.getAttribute("layout")==="horizontal";X0(this,Z?"x":"y",Q)}#D(){if(!this.#Z)return;this.#V(this.#Z,"auto")}#V(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),_=this.getBoundingClientRect(),q={behavior:Z},G=!1;if($){let X=j.top-_.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;q.top=Math.max(0,Math.min(X+j.height/2-this.clientHeight/2,K)),G=!0}if(J){let X=j.left-_.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;q.left=Math.max(0,Math.min(X+j.width/2-this.clientWidth/2,K)),G=!0}if(G)this.scrollTo(q);this.#B()})}#y(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#N)return;this.#S(),this.#E();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#A();else if(!this.#Z&&Q.length)this.#A();requestAnimationFrame(()=>this.#B())}),this.#J.observe(this,{childList:!0,subtree:!1})}}customElements.define("fig-chooser",M1);class F1 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"];#Z=!1;#Q=!1;#j=null;#$=!1;#J=null;#q=null;#_=null;#G=null;get#X(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#Y(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#K(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#W(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#U(Q){let Z=this.#W;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#A(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#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:Z,py:$}=this.#a(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#O(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let G=q.includes("px"),X=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(G)return{px:K};if(X||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),_=J($[1]??$[0]);return{xToken:j,yToken:_}}#F(Q){let Z=this.#M();if(!Z)return;let{xToken:$,yToken:J}=this.#O(Q),j=Z.getBoundingClientRect(),_=(X,K)=>{if(X&&typeof X==="object"&&"px"in X)return Math.max(0,Math.min(K,X.px));return null},q=(X)=>{return`${typeof X==="number"?X:0}%`},G=this.#K;if(this.#z(G),G.x){let X=_($,j.width);this.style.left=X===null?q($):`${Math.round(X)}px`}if(G.y){let X=_(J,j.height);this.style.top=X===null?q(J):`${Math.round(X)}px`}}#z(Q=this.#K){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#$=!0,this.setAttribute("value",this.value),this.#$=!1}get#B(){return this.getAttribute("hit-area-mode")||"handle"}#P(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,_=[];for(let q of Z){if(q==="circle"){j=!0;continue}let G=parseFloat(q);if(Number.isFinite(G))_.push(G)}if(_.length>=2)$=_[0],J=_[1];else if(_.length===1)$=_[0],J=_[0];else return null;return{vPad:$,hPad:J,circle:j}}#T(){let Q=this.#P();if(!Q){if(this.#G)this.#G.remove(),this.#G=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#G){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#C($)),this.prepend(Z),this.#G=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#G.style.borderRadius="50%";else this.#G.style.borderRadius="inherit"}#C(Q){if(H(this,"disabled"))return;if(Q.target!==this.#G)return;if(this.#B==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#y(Q)}connectedCallback(){this.#D(),this.#f(),this.#T(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#E),document.addEventListener("keydown",this.#k);let Q=this.getAttribute("value");if(Q)this.#F(Q);if(this.#X)this.#m()}disconnectedCallback(){if(this.#V(),this.#c(),this.#I(),this.#h(),this.#G)this.#G.remove(),this.#G=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#E),document.removeEventListener("keydown",this.#k)}select(){if(H(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#X){this.#w();return}this.select()};#E=(Q)=>{if(this.contains(Q.target))return;if((this.#J||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#k=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#Y&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#R(Q)){if(Q.preventDefault(),!H(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!H(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#X)this.#w();else this.select();return}if(!H(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#X)this.#w()};#R(Q){if(H(this,"disabled"))return!1;let Z=this.#M();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#K,j=this.#a($),_=Q.shiftKey?0.1:0.01,q=j.px,G=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;q-=_;break;case"ArrowRight":if(!J.x)return!1;q+=_;break;case"ArrowUp":if(!J.y)return!1;G-=_;break;case"ArrowDown":if(!J.y)return!1;G+=_;break;case"Home":if(J.x)q=0;if(J.y)G=0;break;case"End":if(J.x)q=1;if(J.y)G=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),G=Math.max(0,Math.min(1,G)),this.#z(J),J.x)this.style.left=`${Math.round(q*$.width)}px`;if(J.y)this.style.top=`${Math.round(G*$.height)}px`;this.#H();let X={...this.#a($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:X})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:X})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#J&&this.#X==="color"&&$)this.#J.setAttribute("value",$);this.#b()}if(Q==="drag")this.#f();if(Q==="hit-area")this.#T();if(Q==="selected")this.#t();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#D();if(Q==="value"&&!this.#$&&!this.#Z)this.#F($);if(Q==="tip"){if(this.#c(),this.#X)this.#I(),this.#m()}}#f(){if(this.#Y&&!this.#j)this.#j=(Q)=>this.#y(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#Y&&this.#j)this.#V()}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=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",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#V(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#Z=!1}#y(Q){if(!this.#Y||H(this,"disabled"))return;Q.preventDefault();let Z=this.#M();if(!Z)return;this.#Z=!0;let $=this.#K,J=null,j=this.getBoundingClientRect(),_=j.left+j.width/2,q=j.top+j.height/2,G=Q.clientX-_,X=Q.clientY-q,K=Q.clientX,N=Q.clientY,F=3,W=(U,T,R=!1)=>{let B=Z.getBoundingClientRect();J=B;let M=this.#a(B),P=U-G-B.left,S=T-X-B.top,f=Math.max(0,Math.min(B.width,P)),x=Math.max(0,Math.min(B.height,S)),k=B.width>0?$.x?f/B.width:M.px:0.5,v=B.height>0?$.y?x/B.height:M.py:0.5;if(this.#U(R)){if($.x)k=this.#L(k);if($.y)v=this.#L(v);if($.x&&$.y){let i=this.#A(k,v);k=i.x,v=i.y}}if(this.#z($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(B.width,k*B.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(B.height,v*B.height)))}px`},z=(U)=>{if(!this.#Z)return;if(!this.#Q){let T=U.clientX-K,R=U.clientY-N;if(T*T+R*R<F*F)return;if(this.#e(),this.classList.add("dragging"),this.style.cursor="grabbing",!H(this,"selected"))this.select()}this.#Q=!0,W(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#a(J),shiftKey:U.shiftKey}}))},L=(U)=>{if(this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",L),this.#Q){W(U.clientX,U.clientY,U.shiftKey),this.#H(),this.#F(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#a(J)}));let T=(R)=>{R.stopPropagation(),R.preventDefault()};this.addEventListener("click",T,{capture:!0,once:!0})}else this.#H();this.#Q=!1};window.addEventListener("pointermove",z),window.addEventListener("pointerup",L)}showColorTip(){if(!this.#X)return;if(this.#J){this.#J.style.display="";return}this.#m()}hideColorTip(){if(!this.#J)return;this.#J.style.display="none"}#v(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(_)=>{let q=_.replace("#","").trim();if(q.length===3||q.length===4){let[G,X,K,N]=q;return{color:`#${G}${G}${X}${X}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(q.length===6||q.length===8)return{color:`#${q.slice(0,6)}`.toUpperCase(),opacity:q.length===8?Math.round(parseInt(q.slice(6,8),16)/255*100):100};return Z},j=(_,q,G)=>{let X=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${X(_)}${X(q)}${X(G)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:_}=Y0(1,1);_.fillStyle="#000000",_.fillStyle=$;let q=_.fillStyle;if(q.startsWith("#"))return J(q);let G=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(G)return{color:j(G[1],G[2],G[3]),opacity:G[4]!==void 0?Math.round(parseFloat(G[4])*100):100}}catch{}return Z}#g(){let{color:Q,opacity:Z}=this.#v();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#b(){if(!this.#q)return;this.#q.setAttribute("value",this.#g())}#x(){if(!u())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.#g()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#p),Q.addEventListener("change",this.#l),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#w(){if(H(this,"disabled"))return;let Q=this.#x();if(!Q){this.#u();return}this.setAttribute("selected",""),this.#b(),Q.open()}#I(){if(!this.#q)return;this.#q.removeEventListener("input",this.#p),this.#q.removeEventListener("change",this.#l),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#s(){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.#$0),Q.addEventListener("change",this.#J0),this.appendChild(Q),this.#_=Q,Q}#u(){let Q=this.#s(),{color:Z}=this.#v();Q.value=Z,this.setAttribute("selected",""),Q.click()}#h(){if(!this.#_)return;this.#_.removeEventListener("input",this.#$0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#e(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#m(){let Q=this.#X;if(!Q)return;if(this.#J)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#n),Z.addEventListener("change",this.#i),Z.addEventListener("add",this.#Z0),Z.addEventListener("remove",this.#Z0),this.appendChild(Z),this.#J=Z,this.#t()}#c(){if(!this.#J)return;this.#J.removeEventListener("input",this.#n),this.#J.removeEventListener("change",this.#i),this.#J.removeEventListener("add",this.#Z0),this.#J.removeEventListener("remove",this.#Z0),this.#J.remove(),this.#J=null}#t(){if(!this.#J||this.#X!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#J.toggleAttribute("selected",Q)}#r(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=s(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#d(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#p=(Q)=>{Q.stopPropagation();let Z=this.#d(Q.detail);if(!Z)return;this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#l=(Q)=>{Q.stopPropagation();let Z=this.#d(Q.detail);if(!Z)return;this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#Q0(Q){let{opacity:Z}=this.#v();return Z<100?{color:Q,opacity:Z}:{color:Q}}#$0=(Q)=>{Q.stopPropagation();let Z=this.#Q0(Q.target.value);this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#J0=(Q)=>{Q.stopPropagation();let Z=this.#Q0(Q.target.value);this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0=()=>{this.removeAttribute("selected")};#n=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#r(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#i=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#r(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#Z0=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#a(Q){let Z=Q||this.#M()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,_=$.left-Z.left,q=$.top-Z.top,G=_+J,X=q+j,K=Z.width>0?G/Z.width:0,N=Z.height>0?X/Z.height:0;return{x:_,y:q,px:K,py:N}}}customElements.define("fig-handle",F1);class z1 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.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){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",z1);class A1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Z()}#Z(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}customElements.define("fig-menu-separator",A1);class H1 extends HTMLElement{#Z=null;#Q=null;#j=null;#$=null;#J;#q;#_;#G;#X;#N=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#J=this.#B.bind(this),this.#q=this.#P.bind(this),this.#_=this.#C.bind(this),this.#G=this.#S.bind(this),this.#X=this.#E.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.#Y(),this.#W(),this.#U(),this.#L(),this.#M(),this.#H(),this.open)this.#R()}disconnectedCallback(){if(this.#A(),document.removeEventListener("keydown",this.#G,!0),this.#$)this.#$.disconnect(),this.#$=null;if(this.#Z){this.#Z.removeEventListener("close",this.#X);let Q=Array.from(this.#Z.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.insertBefore(Z,this.#Z);this.#Z.remove(),this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#f();else this.#R();return}if(Q==="disabled"){if(this.#Q)if($!==null&&$!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#Y(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#K(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#W(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||g());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#Q)this.#Z.anchor=this.#Q;this.#Z.addEventListener("close",this.#X),this.appendChild(this.#Z)}#U(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#L(){if(this.addEventListener("keydown",this.#G),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.addEventListener("contextmenu",this.#q),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#_),this.#Z.addEventListener("keydown",this.#G)}#A(){if(this.removeEventListener("keydown",this.#G),this.#Q)this.#Q.removeEventListener("click",this.#J),this.#Q.removeEventListener("contextmenu",this.#q);if(this.#Z)this.#Z.removeEventListener("click",this.#_),this.#Z.removeEventListener("keydown",this.#G)}#M(){this.#$=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z.appendChild($);else if(!this.#Q&&$.parentElement===this){if(this.#Y(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.addEventListener("contextmenu",this.#q),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#Q,this.#H()}}}),this.#$.observe(this,{childList:!0})}#O(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#F(){let Q=this.#O();if(!Q.length){this.#N=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#N=$>=0?$:-1}#z(Q){let Z=this.#O();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#N=$,Z[$].focus()}#H(){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")}#B(Q){if(this.#K())return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0}}#P(Q){if(!this.#K())return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.#T(Q.clientX,Q.clientY)}#T(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",q,!0)},_=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},q=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",q,{once:!0,capture:!0}),J=window.setTimeout(_,180)}#C(Q){let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#k(Z)}#S(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0,requestAnimationFrame(()=>this.#z(0))}return}let Z=this.#O();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#F(),this.#z(this.#N+1);break}case"ArrowUp":{Q.preventDefault(),this.#F(),this.#z(this.#N-1);break}case"Home":{Q.preventDefault(),this.#z(0);break}case"End":{Q.preventDefault(),this.#z(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#F();let $=Z[this.#N];if(!$)return;Q.preventDefault(),this.#k($);break}}}#E(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#N=-1}#k(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#j={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Z)this.#Z.anchor=this.#j;if(this.open)this.open=!1;requestAnimationFrame(()=>{this.open=!0})}#R(){if(!this.#Z)return;if(this.#Z.open=!0,document.addEventListener("keydown",this.#G,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#N=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#z(0)})}#f(){if(!this.#Z)return;document.removeEventListener("keydown",this.#G,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",H1);
|
|
268
|
+
`}#B(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#X)}#H(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#T(),this.#D(),this.#E()}#A(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#T(),this.#D(),this.#E()}#M(){this.#D(),this.#f()}#P(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),q=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:q},$)this.#T();this.#k(),this.#D()}#R(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#P($,J,{syncHandle:!1}),this.#E(),this.#f()}#C(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#P(Z.px,Z.py,{syncHandle:!1}),this.#E()}#S(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#D(),this.#f()}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){let Q=this.#W(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#k()}#k(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#D(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1;this.#I()}#I(){let Q=this.#N,Z=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",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#y(){this.position={...this.#N},this.#T(),this.#D(),this.#E(),this.#f()}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 Z=Q==null?"":String(Q).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{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=J($[0]),q=J($[1]??$[0]);this.position={x:j,y:q}}if(this.#G)this.#T(),this.#I()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){v(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#Y||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#z(),this.#L(),this.#B(),this.#T();if(Q==="axis-labels"&&$!==Z)this.#z(),this.#L(),this.#B(),this.#T();if(Q==="coordinates")this.coordinates=$||"screen",this.#T()}}customElements.define("fig-joystick",X1);class B0 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.#Z()}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,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Z()}#Z(){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",B0);class Y1 extends B0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",Y1);class K1 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Z=null;#Q=null;connectedCallback(){this.#j()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#Z)this.#Z.removeEventListener("click",this.#J),this.#Z.removeEventListener("keydown",this.#$),this.#Z.querySelector("h3")?.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#$=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#Z.remove(),this.#Z=null,this.#Q=null;return}if(J)this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);let j=this.#Z.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Z.prepend(j);if(!j.id)j.id=b();if(this.#Z.dataset.generated)j.textContent=$;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=u("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.addEventListener("click",this.#J),this.#Z.setAttribute("role","button"),this.#Z.setAttribute("tabindex","0"),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("keydown",this.#$),this.#Z.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#Z.removeEventListener("keydown",this.#$),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",K1);class G1 extends HTMLElement{}customElements.define("fig-header",G1);class N1 extends HTMLElement{}customElements.define("fig-footer",N1);class W1 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",W1);class U1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Z()}#Z(){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",U1);class P extends HTMLElement{static#Z=new Set(["oklch","hsl"]);static#Q=10;static#J=10;static#$=8;static#j=3;static#q=210;static#_={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#X=!1;#Y=null;#N=null;#G={...P.#_};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}set value(Q){if(Q==null||Q===""){this.removeAttribute("value");return}if(typeof Q==="string"){this.setAttribute("value",Q);return}this.setAttribute("value",JSON.stringify(Q))}connectedCallback(){this.#K(),this.#W(),this.#C(),this.#S()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q!=="value")return;if(this.#W(),this.#X)this.#S()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#W(){let Q=this.getAttribute("value");if(!Q){this.#G={...P.#_,stops:P.#_.stops.map((Z)=>({...Z}))};return}try{let Z=JSON.parse(Q),$=Z?.type==="gradient"&&Z.gradient?Z.gradient:Z?.gradient?Z.gradient:Z;if(!$||typeof $!=="object")return;this.#G=this.#U({...P.#_,...$})}catch{}}#U(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase(),J=String(Z.hueInterpolation??"shorter").toLowerCase(),j=Array.isArray(Z.stops)?Z.stops.map((q)=>({color:String(q?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:q?.position??0,opacity:q?.opacity??100})):P.#_.stops.map((q)=>({...q}));if(j.length<2)return{...P.#_,stops:P.#_.stops.map((q)=>({...q}))};return{type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):135,interpolationSpace:$,hueInterpolation:J,stops:j}}#L(){return P.#Z.has(this.#G.interpolationSpace||"srgb")}#F(Q){let{r:Z,g:$,b:J}=d(Q);if(this.#G.interpolationSpace==="hsl")return N0(Z,$,J).h;let j=l(Z,$,J);return(G0(j.l,j.a,j.b).h%360+360)%360}#O(){let Q=this.#M(),Z=this.#F(Q[0]?.color||"#FF0000"),$=this.#F(Q[Q.length-1]?.color||"#4F9EFF"),J=P.#q-Z,q=((P.#q-$-J)%360+360)%360,_=q===0?0:q-360,X=this.#G.hueInterpolation||"shorter",Y;if(X==="increasing")Y=_;else if(X==="decreasing")Y=q;else if(X==="longer")Y=q<180?_:q;else Y=q<=180?q:_;let K=Math.sign(Y),G=Math.asin(P.#j/2/P.#$)*180/Math.PI,U=Math.min(G,Math.max(0,(Math.abs(Y)-0.01)/2));return{startDeg:J+K*U,sweepDeg:Y-K*U*2}}#B(Q){let Z=Q*Math.PI/180;return{x:P.#Q+P.#$*Math.cos(Z),y:P.#J+P.#$*Math.sin(Z)}}#z(Q,Z){let $=Q+Z,J=this.#B(Q),j=this.#B($),q=Math.abs(Z)>180?1:0,_=Z>=0?1:0;return`M ${J.x} ${J.y} A ${P.#$} ${P.#$} 0 ${q} ${_} ${j.x} ${j.y}`}#H(){let Q=this.#B(180),Z=this.#B(0);return`M ${Q.x} ${Q.y} L ${Z.x} ${Z.y}`}#A(Q){let Z=P.#j,$=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${Q}" fill="none" stroke="white" stroke-width="${Z}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent($)}")`}#M(){return[...this.#G.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0))}#P(){let Q=this.#G.interpolationSpace||"srgb";if(Q==="srgb")return"";if(P.#Z.has(Q))return` in ${Q} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${Q}`}#R(){let Q=this.#M(),Z=this.#P();if(this.#L()){let J=(P.#q+90)%360,j=this.#G.interpolationSpace,q=(X)=>j==="oklch"?`oklch(65% 0.25 ${X})`:`hsl(${X} 100% 50%)`,_=[0,300,240,180,120,60,0].map(q).join(", ");return`conic-gradient(from ${J}deg in ${j} decreasing hue, ${_})`}let $=Q.map((J)=>`${J.color} ${J.position??0}%`).join(", ");return`linear-gradient(90deg${Z}, ${$})`}#C(){if(this.#X)return;let Q=P.#j;this.innerHTML=`
|
|
269
|
+
<svg class="fig-interpolation-swatch-svg" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
270
|
+
<circle class="fig-interpolation-swatch-rim" cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="${Q}"/>
|
|
271
|
+
</svg>
|
|
272
|
+
<div class="fig-interpolation-swatch-fill" aria-hidden="true"></div>
|
|
273
|
+
`,this.#Y=this.querySelector(".fig-interpolation-swatch-svg"),this.#N=this.querySelector(".fig-interpolation-swatch-fill"),this.#X=!0}#S(){if(!this.#N)return;let Q=this.#L();if(this.#Y)this.#Y.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#O();return this.#z(J,j)})():this.#H(),$=this.#A(Z);this.#N.style.setProperty("-webkit-mask-image",$),this.#N.style.maskImage=$,this.#N.style.background=this.#R()}}customElements.define("fig-interpolation-swatch",P);var p1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},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",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function c1(Q,Z="medium"){let $=Q&&p1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class L1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=c1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",L1);class B1 extends HTMLElement{}customElements.define("fig-content",B1);class M1 extends HTMLElement{}customElements.define("fig-tab-content",M1);class O1 extends HTMLElement{}customElements.define("fig-button-combo",O1);class z1 extends HTMLElement{}customElements.define("fig-input-combo",z1);class F1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=this.#B.bind(this);#j=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.#N(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#G)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#j);if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#j);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#Y(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#N(){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="${x(Y)}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#G),this.#F();return}this.removeEventListener("click",this.#G);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#W(Z),j=this.#Y?"":'alpha="false"',q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),_=J<1?` alpha="${J}"`:"";if(this.innerHTML=s()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
|
|
274
|
+
<fig-swatch background="${$}"${_}></fig-swatch>
|
|
275
|
+
</fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-swatch"),this.#_(),this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#j),!this.#Z)this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#j);this.#X(),this.#F()}#G=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#W(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=U0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.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"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#W(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#Y)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(R(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#F(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(R(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"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),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#O(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#Y){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(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#O(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#O(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#N();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return R(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return R(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",F1);class H1 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",R(this,"selected")?"true":"false"),R(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",R(this,"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",H1);class A1 extends HTMLElement{#Z=null;#Q=this.#z.bind(this);#J=this.#H.bind(this);#$=this.#M.bind(this);#j=null;#q=null;#_=null;#X=null;#Y=null;#N=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#G(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#W(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#W}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=R(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#I(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#E(),this.#R(),this.#y(),this.#P(),m(this,()=>{this.#F(),this.#M(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#I(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#C(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#f()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#O($);if(Q==="disabled"){let J=$!==null&&$!=="false",j=this.choices;for(let q of j)if(J)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#D();if(Q==="drag")if(this.#K)this.#R();else this.#C();if(Q==="overflow")this.#E(),requestAnimationFrame(()=>this.#M());if(Q==="layout"){if(this.#E(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#D()}}#F(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#O(Z))return;let $=Q.find((J)=>R(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#O(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#B(Q){let Z=this.#W,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#B(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#A()}#H(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#W)){let q=this.#B(document.activeElement);if(q&&q!==this.#Z)this.selectedChoice=q,this.#A()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#A()}#A(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#M(){if(this.#G==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";E0(this,this,Q?"x":"y")}#P(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#M(),this.#D()}),this.#q.observe(this)}#R(){if(this.#Y?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#Y.active=!0,this.#Y.didDrag=!1,this.#Y.startX=q.clientX,this.#Y.startY=q.clientY,this.#Y.scrollLeft=this.scrollLeft,this.#Y.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#Y.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#Y.startX,Y=q.clientY-this.#Y.startY;if(!this.#Y.didDrag&&Math.abs(_?X:Y)>3)this.#Y.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#Y.didDrag)return;if(_)this.scrollLeft=this.#Y.scrollLeft-X;else this.scrollTop=this.#Y.scrollTop-Y},$=(q)=>{if(!this.#Y.active)return;let _=this.#Y.didDrag;if(this.#Y.active=!1,this.#Y.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#Y?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#Y.suppressClick=!1},j=(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:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#C(){if(!this.#Y?.bound)return;this.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.style.cursor="",this.style.userSelect="",this.#Y=null}#S(){if(this.#N)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#N=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#N=!1}}#E(){if(this.#G==="scrollbar")this.#f();else this.#T()}#f(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#T(){if(this.#_&&this.#X&&this.contains(this.#_)&&this.contains(this.#X))return;this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null;let Q=C0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#k(-1),onEnd:()=>this.#k(1)});this.#_=Q.start,this.#X=Q.end,this.prepend(this.#_),this.append(this.#X)}#k(Q){let Z=this.getAttribute("layout")==="horizontal";K0(this,Z?"x":"y",Q)}#D(){if(!this.#Z)return;this.#I(this.#Z,"auto")}#I(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#M()})}#y(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#N)return;this.#S(),this.#E();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#F();else if(!this.#Z&&Q.length)this.#F();requestAnimationFrame(()=>this.#M())}),this.#j.observe(this,{childList:!0,subtree:!1})}}customElements.define("fig-chooser",A1);class R1 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"];#Z=!1;#Q=!1;#J=null;#$=!1;#j=null;#q=null;#_=null;#X=null;get#Y(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#G(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#K(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#W(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#U(Q){let Z=this.#W;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#F(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#O(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#O();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#t(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#B(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{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=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#z(Q){let Z=this.#O();if(!Z)return;let{xToken:$,yToken:J}=this.#B(Q),j=Z.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.#K;if(this.#H(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#H(Q=this.#K){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#A(){this.#$=!0,this.setAttribute("value",this.value),this.#$=!1}get#M(){return this.getAttribute("hit-area-mode")||"handle"}#P(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#R(){let Q=this.#P();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#C($)),this.prepend(Z),this.#X=Z}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"}#C(Q){if(R(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#M==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#y(Q)}connectedCallback(){this.#D(),this.#k(),this.#R(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#E),document.addEventListener("keydown",this.#f);let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.#Y)this.#m()}disconnectedCallback(){if(this.#I(),this.#c(),this.#x(),this.#h(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#E),document.removeEventListener("keydown",this.#f)}select(){if(R(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#Y){this.#w();return}this.select()};#E=(Q)=>{if(this.contains(Q.target))return;if((this.#j||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#f=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#G&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#T(Q)){if(Q.preventDefault(),!R(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!R(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#Y)this.#w();else this.select();return}if(!R(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#Y)this.#w()};#T(Q){if(R(this,"disabled"))return!1;let Z=this.#O();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#K,j=this.#t($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#H(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#A();let Y={...this.#t($),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,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#Y==="color"&&$)this.#j.setAttribute("value",$);this.#g()}if(Q==="drag")this.#k();if(Q==="hit-area")this.#R();if(Q==="selected")this.#n();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#D();if(Q==="value"&&!this.#$&&!this.#Z)this.#z($);if(Q==="tip"){if(this.#c(),this.#Y)this.#x(),this.#m()}}#k(){if(this.#G&&!this.#J)this.#J=(Q)=>this.#y(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#G&&this.#J)this.#I()}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=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",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#Y||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#I(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1}#y(Q){if(!this.#G||R(this,"disabled"))return;Q.preventDefault();let Z=this.#O();if(!Z)return;this.#Z=!0;let $=this.#K,J=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,G=Q.clientY,U=3,W=(L,D,H=!1)=>{let M=Z.getBoundingClientRect();J=M;let O=this.#t(M),C=L-X-M.left,E=D-Y-M.top,S=Math.max(0,Math.min(M.width,C)),y=Math.max(0,Math.min(M.height,E)),I=M.width>0?$.x?S/M.width:O.px:0.5,g=M.height>0?$.y?y/M.height:O.py:0.5;if(this.#U(H)){if($.x)I=this.#L(I);if($.y)g=this.#L(g);if($.x&&$.y){let r=this.#F(I,g);I=r.x,g=r.y}}if(this.#H($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,I*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,g*M.height)))}px`},F=(L)=>{if(!this.#Z)return;if(!this.#Q){let D=L.clientX-K,H=L.clientY-G;if(D*D+H*H<U*U)return;if(this.#l(),this.classList.add("dragging"),this.style.cursor="grabbing",!R(this,"selected"))this.select()}this.#Q=!0,W(L.clientX,L.clientY,L.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#t(J),shiftKey:L.shiftKey}}))},B=(L)=>{if(this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",B),this.#Q){W(L.clientX,L.clientY,L.shiftKey),this.#A(),this.#z(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#t(J)}));let D=(H)=>{H.stopPropagation(),H.preventDefault()};this.addEventListener("click",D,{capture:!0,once:!0})}else this.#A();this.#Q=!1};window.addEventListener("pointermove",F),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#Y)return;if(this.#j){this.#j.style.display="";return}this.#m()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#b(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,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 Z},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($.startsWith("#"))return J($);try{let{ctx:q}=U0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);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 Z}#v(){let{color:Q,opacity:Z}=this.#b();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#g(){if(!this.#q)return;this.#q.setAttribute("value",this.#v())}#V(){if(!s())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.#v()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#u),Q.addEventListener("change",this.#a),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#w(){if(R(this,"disabled"))return;let Q=this.#V();if(!Q){this.#p();return}this.setAttribute("selected",""),this.#g(),Q.open()}#x(){if(!this.#q)return;this.#q.removeEventListener("input",this.#u),this.#q.removeEventListener("change",this.#a),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#s(){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.#$0),Q.addEventListener("change",this.#J0),this.appendChild(Q),this.#_=Q,Q}#p(){let Q=this.#s(),{color:Z}=this.#b();Q.value=Z,this.setAttribute("selected",""),Q.click()}#h(){if(!this.#_)return;this.#_.removeEventListener("input",this.#$0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#l(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#m(){let Q=this.#Y;if(!Q)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#e),Z.addEventListener("change",this.#i),Z.addEventListener("add",this.#Z0),Z.addEventListener("remove",this.#Z0),this.appendChild(Z),this.#j=Z,this.#n()}#c(){if(!this.#j)return;this.#j.removeEventListener("input",this.#e),this.#j.removeEventListener("change",this.#i),this.#j.removeEventListener("add",this.#Z0),this.#j.removeEventListener("remove",this.#Z0),this.#j.remove(),this.#j=null}#n(){if(!this.#j||this.#Y!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",Q)}#r(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=d(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#d(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#u=(Q)=>{Q.stopPropagation();let Z=this.#d(Q.detail);if(!Z)return;this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#a=(Q)=>{Q.stopPropagation();let Z=this.#d(Q.detail);if(!Z)return;this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#Q0(Q){let{opacity:Z}=this.#b();return Z<100?{color:Q,opacity:Z}:{color:Q}}#$0=(Q)=>{Q.stopPropagation();let Z=this.#Q0(Q.target.value);this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#J0=(Q)=>{Q.stopPropagation();let Z=this.#Q0(Q.target.value);this.setAttribute("color",this.#r(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0=()=>{this.removeAttribute("selected")};#e=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#r(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#i=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#r(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#Z0=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#t(Q){let Z=Q||this.#O()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}customElements.define("fig-handle",R1);class D1 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.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){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",D1);class T1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Z()}#Z(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}customElements.define("fig-menu-separator",T1);class P1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j;#q;#_;#X;#Y;#N=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#j=this.#M.bind(this),this.#q=this.#P.bind(this),this.#_=this.#C.bind(this),this.#X=this.#S.bind(this),this.#Y=this.#E.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.#G(),this.#W(),this.#U(),this.#L(),this.#O(),this.#A(),this.open)this.#T()}disconnectedCallback(){if(this.#F(),document.removeEventListener("keydown",this.#X,!0),this.#$)this.#$.disconnect(),this.#$=null;if(this.#Z){this.#Z.removeEventListener("close",this.#Y);let Q=Array.from(this.#Z.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.insertBefore(Z,this.#Z);this.#Z.remove(),this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#k();else this.#T();return}if(Q==="disabled"){if(this.#Q)if($!==null&&$!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#G(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#K(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#W(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||b());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#Q)this.#Z.anchor=this.#Q;this.#Z.addEventListener("close",this.#Y),this.appendChild(this.#Z)}#U(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#L(){if(this.addEventListener("keydown",this.#X),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.addEventListener("contextmenu",this.#q),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#_),this.#Z.addEventListener("keydown",this.#X)}#F(){if(this.removeEventListener("keydown",this.#X),this.#Q)this.#Q.removeEventListener("click",this.#j),this.#Q.removeEventListener("contextmenu",this.#q);if(this.#Z)this.#Z.removeEventListener("click",this.#_),this.#Z.removeEventListener("keydown",this.#X)}#O(){this.#$=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z.appendChild($);else if(!this.#Q&&$.parentElement===this){if(this.#G(),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.addEventListener("contextmenu",this.#q),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#Q,this.#A()}}}),this.#$.observe(this,{childList:!0})}#B(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#z(){let Q=this.#B();if(!Q.length){this.#N=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#N=$>=0?$:-1}#H(Q){let Z=this.#B();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#N=$,Z[$].focus()}#A(){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")}#M(Q){if(this.#K())return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0}}#P(Q){if(!this.#K())return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.#R(Q.clientX,Q.clientY)}#R(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#C(Q){let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#f(Z)}#S(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0,requestAnimationFrame(()=>this.#H(0))}return}let Z=this.#B();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#z(),this.#H(this.#N+1);break}case"ArrowUp":{Q.preventDefault(),this.#z(),this.#H(this.#N-1);break}case"Home":{Q.preventDefault(),this.#H(0);break}case"End":{Q.preventDefault(),this.#H(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#z();let $=Z[this.#N];if(!$)return;Q.preventDefault(),this.#f($);break}}}#E(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#N=-1}#f(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Z)this.#Z.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{this.open=!0})}#T(){if(!this.#Z)return;if(this.#Z.open=!0,document.addEventListener("keydown",this.#X,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#N=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#H(0)})}#k(){if(!this.#Z)return;document.removeEventListener("keydown",this.#X,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",P1);
|