@rogieking/figui3 6.4.6 → 6.4.8
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/.cursor/skills/a11y/SKILL.md +96 -0
- package/.cursor/skills/css-render-performance/SKILL.md +46 -0
- package/.cursor/skills/frontend-performance-testing/SKILL.md +46 -0
- package/.cursor/skills/js-runtime-performance/SKILL.md +45 -0
- package/.cursor/skills/web-component-performance/SKILL.md +47 -0
- package/README.md +126 -17
- package/components.css +241 -320
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-editor.js +62 -60
- package/dist/fig-lab.css +1 -1
- package/dist/fig-layer.css +1 -0
- package/dist/fig-layer.js +1 -0
- package/dist/fig.css +1 -1
- package/dist/fig.js +57 -55
- package/fig-editor.css +61 -0
- package/fig-editor.js +369 -61
- package/fig-lab.css +33 -5
- package/fig-layer.css +111 -0
- package/fig-layer.js +155 -0
- package/fig.js +2240 -919
- package/package.json +13 -4
package/dist/fig.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var L1={};var N0=U1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=J.create(q.prototype),$.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",N="disconnectedCallback",L=Element.prototype,B=J.assign,H=J.create,O=J.defineProperties,U=J.getOwnPropertyDescriptor,z=J.setPrototypeOf,A=$.define,G=$.get,M=$.upgrade,D=$.whenDefined,T=H(null),P=new WeakMap,S={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(W){return typeof W=="string"&&/^HTML(?!Element)/.test(W)}).forEach(function(W){function R(){}var F=self[W];z(R,F),(R.prototype=F.prototype).constructor=R,F={},F[W]={value:R},O(self,F)}),new MutationObserver(_0).observe(Q,S),W0(Document.prototype,"importNode"),W0(Node.prototype,"cloneNode"),O($,{define:{value:function(W,R,F){if(W=W.toLowerCase(),F&&Z in F){T[W]=B({},F,{Class:R});var k=F[Z]+'[is="'+W+'"]',E=Q.querySelectorAll(k);for(var I=0,x=E.length;I<x;I++)s(E[I])}else A.apply($,arguments)}},get:{value:function(W){return W in T?T[W].Class:G.call($,W)}},upgrade:{value:function(W){var R=e(W);if(R&&!(W instanceof R.Class))K0(W,R);else M.call($,W)}},whenDefined:{value:function(W){return W in T?Promise.resolve():D.call($,W)}}});var f=Q.createElement;O(Q,{createElement:{value:function(W,R){var F=f.call(Q,W);if(R&&"is"in R)F.setAttribute("is",R.is),$.upgrade(F);return F}}});var w=U(L,"attachShadow").value,u=U(L,"innerHTML");O(L,{attachShadow:{value:function(){var W=w.apply(this,arguments);return new MutationObserver(_0).observe(W,S),W}},innerHTML:{get:u.get,set:function(W){if(u.set.call(this,W),/\bis=("|')?[a-z0-9_-]+\1/i.test(W))o(this,s)}}});function _0(W){for(var R=0,F=W.length;R<F;R++){var k=W[R],E=k.addedNodes,I=k.removedNodes;for(var x=0,i=E.length;x<i;x++)s(E[x]);for(var Q0=0,G1=I.length;Q0<G1;Q0++)Y0(I[Q0])}}function X0(W){for(var R=0,F=W.length;R<F;R++){var k=W[R],E=k.attributeName,I=k.oldValue,x=k.target,i=x.getAttribute(E);if(Y in x&&!(I==i&&i==null))x[Y](E,I,x.getAttribute(E),null)}}function Y0(W){if(W.nodeType!==1)return;var R=e(W);if(R&&W instanceof R.Class&&N in W&&P.get(W)!==N)P.set(W,N),Promise.resolve(W).then(N1);o(W,Y0)}function e(W){var R=W.getAttribute("is");if(R){if(R=R.toLowerCase(),R in T)return T[R]}return null}function W1(W){W[K]()}function N1(W){W[N]()}function K0(W,R){var F=R.Class,k=F.observedAttributes||[];if(z(W,F.prototype),k.length){new MutationObserver(X0).observe(W,{attributes:!0,attributeFilter:k,attributeOldValue:!0});var E=[];for(var I=0,x=k.length;I<x;I++)E.push({attributeName:k[I],oldValue:null,target:W});X0(E)}}function s(W){if(W.nodeType!==1)return;var R=e(W);if(R){if(!(W instanceof R.Class))K0(W,R);if(K in W&&W.isConnected&&P.get(W)!==K)P.set(W,K),Promise.resolve(W).then(W1)}o(W,s)}function o(W,R){for(var F=W.content,k=(F&&F.nodeType==11?F:W).querySelectorAll("[is]"),E=0,I=k.length;E<I;E++)R(k[E])}function W0(W,R){var F=W[R],k={};k[R]={value:function(){var E=F.apply(this,arguments);switch(E.nodeType){case 1:case 11:o(E,s)}return E}},O(W,k)}})()}})(document,customElements,Object)});function M1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function v(Q,$={}){let J=document.createElement("fig-icon");if(Q)J.setAttribute("name",Q);if($.size)J.setAttribute("size",$.size);if($.className)J.className=$.className;return J}function m(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function O1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}var M0=M1()&&!O1(),B1=(M0?Promise.resolve().then(() => (N0(),L1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function $0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!M0){Z();return}B1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function y(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var R1=1e4;function A1(){return R1++}function V(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var g=null,G0=null;function J0(Q=1,$=1){if(!g)g=document.createElement("canvas"),G0=g.getContext("2d");if(g.width!==Q)g.width=Q;if(g.height!==$)g.height=$;return{canvas:g,ctx:G0}}class O0 extends HTMLElement{type;#$;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#j=this.#Y.bind(this);constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button";let Q=this.type==="select"||this.type==="upload",$=Q?"span":"button",J=Q?"":` type="${this.type}"`;this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
|
-
button, button:hover, button:active {
|
|
3
|
+
button, button:hover, button:active, .fig-button-control {
|
|
4
4
|
padding: 0 var(--spacer-2);
|
|
5
5
|
appearance: none;
|
|
6
6
|
display: flex;
|
|
@@ -22,19 +22,21 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
22
22
|
width: 100%;
|
|
23
23
|
min-width: 0;
|
|
24
24
|
}
|
|
25
|
-
:host([size="large"]) button
|
|
25
|
+
:host([size="large"]) button,
|
|
26
|
+
:host([size="large"]) .fig-button-control {
|
|
26
27
|
height: var(--spacer-5);
|
|
27
28
|
}
|
|
28
|
-
:host([size="large"][icon]) button
|
|
29
|
+
:host([size="large"][icon]) button,
|
|
30
|
+
:host([size="large"][icon]) .fig-button-control {
|
|
29
31
|
padding: 0;
|
|
30
32
|
}
|
|
31
33
|
</style>
|
|
32
|
-
|
|
34
|
+
<${$} class="fig-button-control"${J}>
|
|
33
35
|
<slot></slot>
|
|
34
|
-
|
|
35
|
-
`,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",M0);class B0 extends HTMLElement{#$="Menu";#Q=null;#J;#j;#q=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#_;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#N.bind(this),this.#j=this.#L.bind(this),this.#_=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#K(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#Z=Z}#U(){if(!this.#Z)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#j)}#G(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#Y(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#_),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#K(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#A(this.value),this.#U(),this.type==="dropdown")this.select.selectedIndex=-1}#N(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#L(Q){let $=Q.target.selectedOptions?.[0];if(this.#G($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#A(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#U()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#A(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#_),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#j)}}customElements.define("fig-dropdown",B0);class C extends HTMLElement{static#$=0;static#Q=500;#J;#j;#q;#Z;#_;#X;#K;#U;#W;#G=null;#Y;#N=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#B.bind(this),this.#j=this.hidePopupOutsideClick.bind(this),this.#q=this.showDelayedPopup.bind(this),this.#Z=this.#A.bind(this),this.#_=this.#M.bind(this),this.#X=this.#z.bind(this),this.#K=this.#O.bind(this),this.#U=this.#R.bind(this),this.#W=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#G=this.closest("dialog"),this.#G)this.#G.addEventListener("close",this.#W)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#G)this.#G.removeEventListener("close",this.#W),this.#G=null;if(this.action==="click")document.body.removeEventListener("click",this.#j);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#q),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#K),this.removeEventListener("touchcancel",this.#U);else if(this.action==="click")this.removeEventListener("click",this.#q),this.removeEventListener("touchstart",this.#q)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","none"),Q)this.popup.setAttribute("popover","manual");let J=c();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#j)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#K,{passive:!0}),this.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#q),document.body.addEventListener("click",this.#j),this.addEventListener("touchstart",this.#q,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}get#L(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#L)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-C.#$<C.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#G&&!this.#G.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,C.#$=Date.now()}hidePopup(){if(this.#L)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.popup)this.destroy();this.isOpen=!1,C.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#A(Q){if(!this.#N)this.hidePopup()}#M(Q){if(this.action==="hover")this.#N=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#z(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},300)}#R(Q){if(this.action==="hover"&&this.#N)this.#N=!1,clearTimeout(this.#Y),this.hidePopup()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#D(Q){if(!this.popup)return;let $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#D(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#B(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#H=new WeakMap;static show(Q,$,J={}){C.hide(Q);let Z=J.delay??500,q=Date.now()-C.#$<C.#Q?0:Z,K={timeout:null,popup:null};C.#H.set(Q,K),K.timeout=setTimeout(()=>{let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","none"),_)X.setAttribute("popover","manual");let Y=document.createElement("span");if(Y.innerText=$,X.append(Y),_)document.body.append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else document.body.append(X)}X.anchor=Q,X.open=!0,K.popup=X,C.#$=Date.now()},q)}static hide(Q){let $=C.#H.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();C.#H.delete(Q)}}customElements.define("fig-tooltip",C);class O0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#J=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#j(),this.#q()})}disconnectedCallback(){this.#Z()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#j()}#j(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let K=$.lastIndexOf(J);Z=K>0?K:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;C.show(this,this.#$)},this.#J=()=>{C.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#Z(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);C.hide(this)}}customElements.define("fig-truncate",O0);class R0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this)}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),requestAnimationFrame(()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let K of this.children){let _=K.getBoundingClientRect();if(_.height===0)continue;if(q+=1,K===Q)continue;let X=window.getComputedStyle(K),Y=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");Z+=_.height+Y}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-dialog",""),Z.appendChild(b("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,K=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(K)this.style.left="0",this.style.right="0";if(q&&K)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(K)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog"}}}$0("fig-dialog",R0,{extends:"dialog"});class z0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(z1()+1);let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this.resolveAnchor();if(Q?.classList)Q.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((K)=>q.matches?.(K))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",K=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:K}}if($.length===1){let _=$[0];if(_==="top"||_==="bottom")j=_,K=_;else if(_==="left"||_==="right")q=_,K=_;else if(_==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:K}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let K,_;if(q==="left"||q==="right")return _=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,K=Q.top,{top:K,left:_};if(q==="top"||q==="bottom")return K=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,_=Q.left,{top:K,left:_};if(J==="top")K=Q.top-$.height-j.yPx;else if(J==="bottom")K=Q.bottom+j.yPx;else K=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")_=Q.left-$.width-j.xPx;else if(Z==="right")_=Q.right+j.xPx;else _=Q.left+(Q.width-$.width)/2;else if(Z==="left")_=Q.left+j.xPx;else if(Z==="right")_=Q.right-$.width-j.xPx;else _=Q.left+(Q.width-$.width)/2;return{top:K,left:_}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let X=Q.left+Q.width/2,Y=Q.top+Q.height/2,N=this.getBoundingClientRect(),L=N.width>0&&N.height>0?N:$,B=L.left,H=L.top,M=getComputedStyle(this),G=(D,T=0)=>{let E=String(D||"").trim(),S=parseFloat(E);if(!Number.isFinite(S))return T;if(E.endsWith("rem"))return S*parseFloat(getComputedStyle(document.documentElement).fontSize);if(E.endsWith("em"))return S*parseFloat(M.fontSize);return S},z=(D)=>{if(D==="top")return Math.max(G(M.borderTopLeftRadius),G(M.borderTopRightRadius));if(D==="bottom")return Math.max(G(M.borderBottomLeftRadius),G(M.borderBottomRightRadius));if(D==="left")return Math.max(G(M.borderTopLeftRadius),G(M.borderBottomLeftRadius));if(D==="right")return Math.max(G(M.borderTopRightRadius),G(M.borderBottomRightRadius));return 0},R=G(M.getPropertyValue("--fig-popup-beak-width"),16),U=Math.max(10,z(_)+R/2),A;if(_==="top"||_==="bottom"){A=X-B;let D=U,T=Math.max(D,L.width-U);A=Math.min(T,Math.max(D,A))}else{A=Y-H;let D=U,T=Math.max(D,L.height-U);A=Math.min(T,Math.max(D,A))}this.style.setProperty("--fig-popup-beak-offset",`${A}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,K=Q.top+$.height,_=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,q-(Z-J.right)),N=Math.max(0,K-(j-J.bottom));return _+X+Y+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),K=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(K,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),K=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:K.left+(window.innerWidth-K.right-K.left-Q.width)/2,top:K.top+(window.innerHeight-K.bottom-K.top-Q.height)/2},M=this.clamp(H,Q,K);this.style.left=`${M.left}px`,this.style.top=`${M.top}px`;return}let _=q.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j),Y=null,N="top",L=Number.POSITIVE_INFINITY;for(let{v:H,h:M,s:G}of X){let z=this.computeCoords(_,Q,H,M,$,G),R=this.getPlacementSide(H,M,G);if(G){let U=this.clamp(z,Q,K);if(G==="left"||G==="right"?z.left>=K.left&&z.left+Q.width<=window.innerWidth-K.right:z.top>=K.top&&z.top+Q.height<=window.innerHeight-K.bottom){this.style.left=`${U.left}px`,this.style.top=`${U.top}px`,this.updatePopoverBeak(_,Q,U.left,U.top,R);return}let D=this.overflowScore(z,Q,K);if(D<L)L=D,Y=U,N=R}else{if(this.fits(z,Q,K)){this.style.left=`${z.left}px`,this.style.top=`${z.top}px`,this.updatePopoverBeak(_,Q,z.left,z.top,R);return}let U=this.overflowScore(z,Q,K);if(U<L)L=U,Y=z,N=R}}let B=this.clamp(Y||{left:0,top:0},Q,K);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(_,Q,B.left,B.top,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}$0("fig-popup",z0,{extends:"dialog"});class D0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",D0);class H0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#j.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#q(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#j(Q){let $=Array.from(this.querySelectorAll("fig-tab")),J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){$.forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=$[Z].getAttribute("value");if(j)this.setAttribute("value",j);$[Z].focus()}}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#q(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected")}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#q(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z)}}customElements.define("fig-tabs",H0);class F0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",F0);class T0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#j=null;#q=0;#Z=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#z(),this.#L(),requestAnimationFrame(()=>{this.#M({enforceFallback:!0}),this.#A(),this.#Y({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#Z=!1,this.#_=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#Y()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#K(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#U(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#K(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#G(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#Y({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#Z;this.#Z=!1,this.#N({forceInstant:$})})}#N({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#G(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#U();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#_=!1;return}if(!Z){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let K=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${K}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#Y()}),this.#A()}#A(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#M({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#Y({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#W(Z))return}let j=this.#U();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#z(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#M({enforceFallback:!0})}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;let J=this.selectedSegment,Z=this.value;this.selectedSegment=$;let j=this.#K($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");let q=this.value;if(J!==$||Z!==q)this.#X(q)}#O(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")})}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#O(J!==null&&J!=="false"),this.#Y({forceInstant:!0});return}if(Q==="value"){this.#M({enforceFallback:!1});return}if(Q==="animated"){if(!this.#G())this.#_=!1;this.#Y({forceInstant:!0});return}if(Q==="sizing")this.#Y({forceInstant:!0})}}customElements.define("fig-segmented-control",T0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#J=null;#j=[];#q=null;#Z=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#K(),this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#j.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#X(),this.#W();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#Y("disabled");return}if(Q==="full"){this.#Y("full");return}if(Q==="sizing")this.#Y("sizing"),this.#W()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#j=JSON.parse(Q);return}catch{}let $=Q.includes(`
|
|
36
|
+
</${$}>
|
|
37
|
+
`,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.#K(),this.button.addEventListener("click",this.#Z.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")}),this.addEventListener("keydown",this.#j)}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#J(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#Z(){if(this.#J())return;if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}#_(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#q(){let Q=this.#_();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 $=this.#q();if(!$||$.disabled||$.multiple)return;if(typeof $.showPicker!=="function")return;Q.preventDefault();try{$.showPicker()}catch{}}#X(){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")}#U(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,$)})}#K(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#U(),this.#X()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"disabled":case"type":this.#K();break;case"selected":this.#$=J!==null&&J!=="false",this.#X();break;default:this.#U();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",O0);class B0 extends HTMLElement{#$="Menu";#Q=null;#j;#J;#Z;#_=!1;#q=null;get label(){return this.#$}set label(Q){this.#$=Q}#Y;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#M.bind(this),this.#J=this.#R.bind(this),this.#Z=this.#N.bind(this),this.#Y=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}}#U(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#_=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#_=!0,this.#q=Z}#K(){if(!this.#q)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#q.textContent="";return}this.#q.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#Z)}#L(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#G(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.#z(),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#Y),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#U(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#D(this.value),this.#K(),this.type==="dropdown")this.select.selectedIndex=-1}#M(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#K(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#R(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#K(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#N(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#_&&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"]}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#D(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#K()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#D(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$);if(Q==="disabled")this.#z()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#Y),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z)}}customElements.define("fig-dropdown",B0);class C extends HTMLElement{static#$=0;static#Q=500;#j;#J;#Z;#_;#q;#Y;#X;#U;#K;#W;#L=null;#G;#M=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#j=this.#A.bind(this),this.#J=this.hidePopupOutsideClick.bind(this),this.#Z=this.showDelayedPopup.bind(this),this.#_=this.#N.bind(this),this.#q=this.#z.bind(this),this.#Y=this.#D.bind(this),this.#X=this.#O.bind(this),this.#U=this.#H.bind(this),this.#W=this.#B.bind(this),this.#K=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#K)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#j,!0),document.removeEventListener("keydown",this.#W,!0),this.#L)this.#L.removeEventListener("close",this.#K),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#J);if(clearTimeout(this.#G),this.action==="hover")this.removeEventListener("pointerenter",this.#Z),this.removeEventListener("pointerleave",this.#_),this.removeEventListener("touchstart",this.#q),this.removeEventListener("touchmove",this.#Y),this.removeEventListener("touchend",this.#X),this.removeEventListener("touchcancel",this.#U);else if(this.action==="click")this.removeEventListener("click",this.#Z),this.removeEventListener("touchstart",this.#Z)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),Q)this.popup.setAttribute("popover","manual");let J=y();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#J)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#Z),this.addEventListener("pointerleave",this.#_);this.addEventListener("touchstart",this.#q,{passive:!0}),this.addEventListener("touchmove",this.#Y,{passive:!0}),this.addEventListener("touchend",this.#X,{passive:!0}),this.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#Z),document.body.addEventListener("click",this.#J),this.addEventListener("touchstart",this.#Z,{passive:!0});document.addEventListener("mousedown",this.#j,!0),document.addEventListener("keydown",this.#W,!0)}get#R(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#R)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-C.#$<C.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,C.#$=Date.now()}hidePopup(){if(this.#R)return;if(clearTimeout(this.timeout),clearTimeout(this.#G),this.popup)this.destroy();this.isOpen=!1,C.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#N(Q){if(!this.#M)this.hidePopup()}#z(Q){if(this.action==="hover")this.#M=!0,clearTimeout(this.#G),this.showDelayedPopup()}#D(Q){if(this.action==="hover"&&this.#M)clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#M=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#M)clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#M=!1,this.hidePopup()},300)}#H(Q){if(this.action==="hover"&&this.#M)this.#M=!1,clearTimeout(this.#G),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)}#F(Q){if(!this.popup)return;let $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#F(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#A(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#k=new WeakMap;static show(Q,$,J={}){C.hide(Q);let Z=J.delay??500,q=Date.now()-C.#$<C.#Q?0:Z,_={timeout:null,popup:null};C.#k.set(Q,_),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=$,Y.append(K),X)document.body.append(Y);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(Y);else document.body.append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,C.#$=Date.now()},q)}static hide(Q){let $=C.#k.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();C.#k.delete(Q)}}customElements.define("fig-tooltip",C);class R0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#j=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#J(),this.#Z()})}disconnectedCallback(){this.#_()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let _=$.lastIndexOf(J);Z=_>0?_:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;C.show(this,this.#$)},this.#j=()=>{C.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#j)}#_(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#j)this.removeEventListener("pointerleave",this.#j);C.hide(this)}}customElements.define("fig-truncate",R0);class A0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),requestAnimationFrame(()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(Z,$)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");Z+=X.height+K}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("aria-label","Close dialog"),Z.setAttribute("close-dialog",""),Z.appendChild(v("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let $=Q.getAttribute("id")||y();Q.setAttribute("id",$),this.setAttribute("aria-labelledby",$)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,_=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}$0("fig-dialog",A0,{extends:"dialog"});class z0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,$,J){if(this._figInit(),$===J)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}$0("fig-toast",z0,{extends:"dialog"});class D0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(A1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),$=this.resolveAnchor();if($?.classList)$.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch(J){}if(this.matches?.(":open"))try{this.close()}catch(J){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),$=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!$?.isConnected)return;let J=document.activeElement;if(J&&J!==document.body&&!this.contains(J))return;requestAnimationFrame(()=>$.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let Z=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(Z&&Z!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",_=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:_}}if($.length===1){let X=$[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if(J==="top")_=Q.top-$.height-j.yPx;else if(J==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")X=Q.left-$.width-j.xPx;else if(Z==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-$.width)/2;else if(Z==="left")X=Q.left+j.xPx;else if(Z==="right")X=Q.right-$.width-j.xPx;else X=Q.left+(Q.width-$.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let X=this.oppositeSide(j);this.setAttribute("data-beak-side",X);let Y=Q.left+Q.width/2,K=Q.top+Q.height/2,N=this.getBoundingClientRect(),L=N.width>0&&N.height>0?N:$,B=L.left,H=L.top,O=getComputedStyle(this),U=(D,T=0)=>{let P=String(D||"").trim(),S=parseFloat(P);if(!Number.isFinite(S))return T;if(P.endsWith("rem"))return S*parseFloat(getComputedStyle(document.documentElement).fontSize);if(P.endsWith("em"))return S*parseFloat(O.fontSize);return S},z=(D)=>{if(D==="top")return Math.max(U(O.borderTopLeftRadius),U(O.borderTopRightRadius));if(D==="bottom")return Math.max(U(O.borderBottomLeftRadius),U(O.borderBottomRightRadius));if(D==="left")return Math.max(U(O.borderTopLeftRadius),U(O.borderBottomLeftRadius));if(D==="right")return Math.max(U(O.borderTopRightRadius),U(O.borderBottomRightRadius));return 0},A=U(O.getPropertyValue("--fig-popup-beak-width"),16),G=Math.max(10,z(X)+A/2),M;if(X==="top"||X==="bottom"){M=Y-B;let D=G,T=Math.max(D,L.width-G);M=Math.min(T,Math.max(D,M))}else{M=K-H;let D=G,T=Math.max(D,L.height-G);M=Math.min(T,Math.max(D,M))}this.style.setProperty("--fig-popup-beak-offset",`${M}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,_=Q.top+$.height,X=Math.max(0,J.left-Q.left),Y=Math.max(0,J.top-Q.top),K=Math.max(0,q-(Z-J.right)),N=Math.max(0,_-(j-J.bottom));return X+Y+K+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),_=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(_,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:_.left+(window.innerWidth-_.right-_.left-Q.width)/2,top:_.top+(window.innerHeight-_.bottom-_.top-Q.height)/2},O=this.clamp(H,Q,_);this.style.left=`${O.left}px`,this.style.top=`${O.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates(J,Z,j),K=null,N="top",L=Number.POSITIVE_INFINITY;for(let{v:H,h:O,s:U}of Y){let z=this.computeCoords(X,Q,H,O,$,U),A=this.getPlacementSide(H,O,U);if(U){let G=this.clamp(z,Q,_);if(U==="left"||U==="right"?z.left>=_.left&&z.left+Q.width<=window.innerWidth-_.right:z.top>=_.top&&z.top+Q.height<=window.innerHeight-_.bottom){this.style.left=`${G.left}px`,this.style.top=`${G.top}px`,this.updatePopoverBeak(X,Q,G.left,G.top,A);return}let D=this.overflowScore(z,Q,_);if(D<L)L=D,K=G,N=A}else{if(this.fits(z,Q,_)){this.style.left=`${z.left}px`,this.style.top=`${z.top}px`,this.updatePopoverBeak(X,Q,z.left,z.top,A);return}let G=this.overflowScore(z,Q,_);if(G<L)L=G,K=z,N=A}}let B=this.clamp(K||{left:0,top:0},Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(X,Q,B.left,B.top,N)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}$0("fig-popup",D0,{extends:"dialog"});class H0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),$=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",$),this.setAttribute("aria-controls",$),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this.setAttribute("tabindex",this.#$?"0":"-1"),this?.content)this.content.style.display=this.#$?"block":"none"}if(Q==="disabled")if(J!==null&&J!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#$?"0":"-1")}}customElements.define("fig-tab",H0);class F0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#_.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#q(Q);if(this.hasAttribute("disabled"))this.#j(!0)})}#j(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled")}),this.#Z()}#J(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#Z(){let Q=Array.from(this.querySelectorAll("fig-tab")),$=Q.find((J)=>J.hasAttribute("selected"))||this.#J()[0];Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false";J.setAttribute("tabindex",!Z&&J===$?"0":"-1")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#_(Q){let $=this.#J();if(!$.length)return;let J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=$[Z].getAttribute("value");if(j)this.setAttribute("value",j);$[Z].focus(),this.#Z()}}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#q(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected");this.#Z()}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#q(J);break;case"disabled":this.#j(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z);this.#Z()}}customElements.define("fig-tabs",F0);class T0 extends HTMLElement{#$;#Q;#j;constructor(){super();this.#j=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#j)}disconnectedCallback(){this.removeEventListener("click",this.#j)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),$)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J,this.#J();break;case"disabled":this.#J();break}}}customElements.define("fig-segment",T0);class P0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#j=this.#M.bind(this);#J=null;#Z=null;#_=0;#q=!1;#Y=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#F(),this.#O(),requestAnimationFrame(()=>{this.#B({enforceFallback:!0}),this.#H(),this.#z({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#_)cancelAnimationFrame(this.#_),this.#_=0;this.#q=!1,this.#Y=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#L(),this.#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))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#U(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-segment")),$=Q.find((J)=>J.hasAttribute("selected"));Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false",j=J===$;J.setAttribute("aria-checked",j?"true":"false"),J.setAttribute("tabindex",!Z&&j?"0":"-1")})}#G(Q){if(!Q)return;let $=this.selectedSegment,J=this.value;this.selectedSegment=Q;let Z=this.#U(Q);if(Z)this.setAttribute("value",Z);else this.removeAttribute("value");let j=this.value;if($!==Q||J!==j)this.#X(j)}#M(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#W();if(!$.length)return;let J=$.findIndex((q)=>q.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=Z>0?Z-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=Z<$.length-1?Z+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#G(q);return}default:return}let j=$[Z];this.#G(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#R(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#U(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#N(){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.#q=this.#q||Q,this.#_)return;this.#_=requestAnimationFrame(()=>{this.#_=0;let $=this.#q;this.#q=!1,this.#D({forceInstant:$})})}#D({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#N(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#K();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#Y=!1;return}if(!Z){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#Y)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.#Y||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#Y=!0}#O(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#z()}),this.#H()}#H(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#B({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#z({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#R(Z))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#F(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#B({enforceFallback:!0}),this.#L()}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;this.#G($)}#A(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#L()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#A(J!==null&&J!=="false"),this.#z({forceInstant:!0});return}if(Q==="value"){this.#B({enforceFallback:!1});return}if(Q==="animated"){if(!this.#N())this.#Y=!1;this.#z({forceInstant:!0});return}if(Q==="sizing")this.#z({forceInstant:!0})}}customElements.define("fig-segmented-control",P0);class E0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#j=null;#J=[];#Z=null;#_=!1;#q(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#Y(),this.#X(),this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#N())})}disconnectedCallback(){this.#j?.disconnect(),this.#j=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#Y(),this.#K();return}if(Q==="value"){this.#W();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#K()}#Y(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let $=Q.includes(`
|
|
36
38
|
`)?`
|
|
37
|
-
`:",";this.#
|
|
39
|
+
`:",";this.#J=Q.split($).map((J)=>J.trim()).filter(Boolean)}#X(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#_)return;let Z=this.#q(J);if(Z===null)return;this.#_=!0,this.setAttribute("value",Z),this.#_=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#_)return;let Z=this.#q(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="segments"}#U(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#_)return;let Z=this.#q(J);if(!Z)return;this.#_=!0,this.setAttribute("value",Z),this.#_=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#_)return;let Z=this.#q(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="dropdown"}#K(){if(this.#$==="segments")this.#X(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#N())});else this.#U()}#W(){if(!this.#Z||this.#_)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#L(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#G(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#N()}),this.#j.observe(this)}#M(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return J>Y+0.5}#R(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#M($))return!0;return!1}#N(){if(this.#J.length<=1)return;if(this.#$==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#R())this.#Q=this.clientWidth,this.#U()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#X(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#R())this.#U()})})}}customElements.define("fig-options",E0);class S0 extends HTMLElement{#$=!1;#Q=!1;#j=!1;#J="";#Z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#_={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"}};#q;#Y;#X;#U;#K;#W;#L;#G=null;#M=null;#R=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#q=(Q)=>{Q.stopPropagation(),this.#P()},this.#Y=(Q)=>{Q.stopPropagation(),this.#C()},this.#K=(Q)=>{this.#f(Q)},this.#X=(Q)=>{Q.stopPropagation(),this.#z()},this.#U=(Q)=>{Q.stopPropagation(),this.#V()},this.#W=()=>{this.#$=!0},this.#L=()=>{this.#$=!1}}#N(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#_[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#A(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
|
|
38
40
|
<input
|
|
39
41
|
type="range"
|
|
40
42
|
${this.text?'tabindex="-1"':""}
|
|
@@ -58,17 +60,17 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
58
60
|
value="${this.#Q?"":this.value}"
|
|
59
61
|
${this.units?`units="${this.units}"`:""}
|
|
60
62
|
${this.precision!==null?`precision="${this.precision}"`:""}>
|
|
61
|
-
</fig-input-number>`;else J=Z;this.innerHTML=J,
|
|
63
|
+
</fig-input-number>`;else J=Z;if(this.innerHTML=J,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.#T(),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("change",this.#Y),this.input.addEventListener("change",this.#Y),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#W),this.input.addEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L),this.input.addEventListener("pointerup",this.#L),this.default)this.style.setProperty("--default",this.#D(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let j=(this.max-this.min)/this.step+1;for(let q=0;q<j;q++){let _=document.createElement("option");_.setAttribute("value",this.min+q*this.step),this.datalist.append(_)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let j=document.createElement("option");j.setAttribute("value",this.default),this.datalist.append(j),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let j=this.datalist.querySelector(`option[value='${this.default}']`);if(j)j.setAttribute("default","true")}if(this.figInputNumber)this.#S(),this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#U),this.figInputNumber.addEventListener("change",this.#U);this.#E()}connectedCallback(){this.#N()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#A(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#A($)):$;if(this.#J=Z,this.getAttribute("value")!==Z)this.#j=!0,this.setAttribute("value",Z),this.#j=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#k()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#q),this.input.removeEventListener("change",this.#Y),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#U)}#z(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#A(Q);this.value=$,this.input.value=String($),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#D(Q){let{min:$,max:J}=this.#H(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#O(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#H(){let Q=this.#O(this.min),$=this.#O(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#B(Q){let{min:$,max:J}=this.#H();return Math.min(J,Math.max($,Q))}#F(){if(this.type==="delta"){let $=this.#O(this.default);if($!==null)return this.#B($);return this.#B(0)}if(this.type==="range"){let{min:$,max:J}=this.#H();return this.#B($+(J-$)/2)}let{min:Q}=this.#H();return Q}#A(Q){let $=this.#O(Q);if($===null)return this.#F();return this.#B($)}#k(){let Q=this.#D(this.value),$=this.#D(this.default),J=Q===$?1:0;if(this.#G!==Q)this.style.setProperty("--slider-complete",Q),this.#G=Q;if(this.#M!==$)this.style.setProperty("--default",$),this.#M=$;if(this.#R!==J)this.style.setProperty("--unchanged",J),this.#R=J}#E(){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)}#T(){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.#S();return}this.input.removeAttribute("aria-hidden"),this.#Z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#S(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,$)})}#P(){this.#Q=!1,this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#C(){this.#$=!1,this.#Q=!1,this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#f(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let $=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,J=this.#O(this.input.value)??this.#F(),Z=this.#O(this.step)??1,j=this.#A(J+Z*10*$);this.value=j,this.input.value=String(j),this.#E(),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 $=this.#A(Q);this.value=$,this.input.value=String($),this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#A(J),this.input.value=String(this.value),this.#E(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#k();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#N();break;case"text":this.text=J!=="false",this.#N();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#T();break;default:this[Q]=this.input[Q]=J,this.#E();break}}}customElements.define("fig-slider",S0);class k0 extends HTMLElement{#$=!1;#Q=!1;#j;#J;#Z;#_;#q;#Y;#X;#U=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#D.bind(this),this.#J=this.#H.bind(this),this.#Z=this.#H.bind(this),this.#_=this.#O.bind(this),this.#q=(Q)=>{Q.stopPropagation(),this.#z(Q)},this.#Y=()=>{this.#G()},this.#X=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}let Q=`<input
|
|
62
64
|
type="${this.type}"
|
|
63
65
|
${this.name?`name="${this.name}"`:""}
|
|
64
66
|
placeholder="${this.placeholder}"
|
|
65
67
|
value="${this.type==="number"?this.#N(this.value):this.value}" />`;if(this.multiline)Q=`<textarea
|
|
66
|
-
placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if($)$.addEventListener("click",this.focus.bind(this)),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.#K(),this.#U(),this.#W(),this.#G(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#N(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#N(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#N(this.step));this.addEventListener("pointerdown",this.#Z)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}focus(){this.input.focus()}#K(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q)return;let J=b("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.focus.bind(this)),this.prepend(J)}#U(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q)return;let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=b("",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),q.style.setProperty("--icon","var(--icon-16-close)"),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#W(),this.focus()})}#W(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#G(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#Y(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=b("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#Y(J),j.addEventListener("click",(K)=>{if(K.preventDefault(),K.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#Y(J),this.focus()})}#Y(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#N(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#R($),$}#L(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#O($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#W(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#z();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#O(J,!1);let Z=J*(this.transform||1);J=this.#R(J),Z=this.#R(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#M(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#j),window.addEventListener("blur",this.#q)}#z(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#q)}#O(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#N(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#N(this.max):this.max,J);J=this.#R(J)}return J}#R(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#N(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#O(Z,!1),this.value=Z,this.input.value=this.#N(Z);else this.value=Z,this.input.value=Z;this.#W();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#K(),this.#U(),this.#W(),this.#G();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",S0);class t extends HTMLElement{#$;#Q;#J;#j;#q;#Z;#_;#X;#K;#U;#W;#G;#Y;#N;#L=!1;#A=null;static#M="px";#z(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#O(Q){let $=(Q||"").trim();if(!$)return"";return(this.#G??[]).includes($.toLowerCase())?"":$}#R(){this.#U=this.#O(this.#W)}#D(Q){if(Q&&!this.#A)this.#A=document.createElement("span"),this.#A.className="fig-steppers",this.#A.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#A.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#H(Z),this.input.focus()}),this.append(this.#A);else if(!Q&&this.#A)this.#A.remove(),this.#A=null;this.#B()}#B(){if(!this.#A)return;let Q=this.#A.querySelector(".fig-stepper-up"),$=this.#A.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#F(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),K=j&&typeof this.min==="number"&&Z<=this.min,_=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||_,$.disabled=q||K}#H(Q){let $=this.step||1,J=this.#F(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#V.bind(this),this.#Q=this.#k.bind(this),this.#J=this.#k.bind(this),this.#j=this.#w.bind(this),this.#q=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#I(Q)},this.#_=(Q)=>{this.#C(Q)},this.#X=(Q)=>{this.#E(Q)},this.#K=(Q)=>{this.#S(Q)}}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#G=this.#z($===null?t.#M:$),this.#R(),this.#Y=this.getAttribute("unit-position")||"suffix",this.#N=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false",Z=`<input
|
|
68
|
+
placeholder="${this.placeholder}">${this.value}</textarea>`;let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.removeEventListener("click",this.#X),J.addEventListener("click",this.#X),this.prepend(J);if($)$.removeEventListener("click",this.#X),$.addEventListener("click",this.#X),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.#K(),this.#W(),this.#L(),this.#G(),this.#M(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#N(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#N(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#N(this.step));this.addEventListener("pointerdown",this.#_)}this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#Y),this.input.addEventListener("input",this.#Y)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#Y);this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}focus(){this.input.focus()}#K(){if(!this.input)return;this.#U.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#W(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q)return;let J=v("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.focus.bind(this)),this.prepend(J)}#L(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q)return;let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=v("",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),q.style.setProperty("--icon","var(--icon-16-close)"),j.addEventListener("click",(_)=>{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.#G(),this.focus()})}#G(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#M(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#R(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=v("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#R(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#R(J),this.focus()})}#R(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#N(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#F($),$}#z(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#B($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#G(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#H();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#B(J,!1);let Z=J*(this.transform||1);J=this.#F(J),Z=this.#F(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#O(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#j),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#Z)}#H(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}#B(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#N(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#N(this.max):this.max,J);J=this.#F(J)}return J}#F(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#N(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#B(Z,!1),this.value=Z,this.input.value=this.#N(Z);else this.value=Z,this.input.value=Z;this.#G();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#W(),this.#L(),this.#G(),this.#M();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#K();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",k0);class a extends HTMLElement{#$;#Q;#j;#J;#Z;#_;#q;#Y;#X;#U;#K;#W;#L;#G;#M;#R=!1;#N=null;#z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#D="px";#O(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#H(Q){let $=(Q||"").trim();if(!$)return"";return(this.#L??[]).includes($.toLowerCase())?"":$}#B(){this.#K=this.#H(this.#W)}#F(Q){if(Q&&!this.#N)this.#N=document.createElement("span"),this.#N.className="fig-steppers",this.#N.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#N.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#k(Z),this.input.focus()}),this.append(this.#N);else if(!Q&&this.#N)this.#N.remove(),this.#N=null;this.#A()}#A(){if(!this.#N)return;let Q=this.#N.querySelector(".fig-stepper-up"),$=this.#N.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#S(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&Z<=this.min,X=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||X,$.disabled=q||_}#k(Q){let $=this.step||1,J=this.#S(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#h(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#w.bind(this),this.#Q=this.#v.bind(this),this.#j=this.#v.bind(this),this.#J=this.#g.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#x(Q)},this.#_=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#q=(Q)=>{this.#f(Q)},this.#Y=(Q)=>{this.#V(Q)},this.#X=(Q)=>{this.#b(Q)},this.#U=this.focus.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#L=this.#O($===null?a.#D:$),this.#B(),this.#G=this.getAttribute("unit-position")||"suffix",this.#M=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false",Z=`<input
|
|
67
69
|
type="text"
|
|
68
70
|
inputmode="decimal"
|
|
69
71
|
${this.name?`name="${this.name}"`:""}
|
|
70
72
|
placeholder="${this.placeholder}"
|
|
71
|
-
value="${this.#T(this.value)}" />`;requestAnimationFrame(()=>{let j=this.querySelector("[slot=append]"),q=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,q)q.addEventListener("click",this.focus.bind(this)),this.prepend(q);if(j)j.addEventListener("click",this.focus.bind(this)),this.append(j);if(this.input=this.querySelector("input"),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#D(J),this.hasAttribute("disabled")){let K=this.getAttribute("disabled");this.disabled=this.input.disabled=K!=="false"}this.#B(),this.addEventListener("pointerdown",this.#j),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#F(Q){if(!Q)return"";if(!this.#U){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#U,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#T(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#x($),!this.#U)return $.toString();if(this.#Y==="prefix")return this.#U+$;else return $+this.#U}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#C(Q){this.#L=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#U)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#U.length,$.length);else{let J=$.indexOf(this.#U);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#E(Q){this.#L=!1;let $=this.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#S(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#F(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#f(q,!1),this.value=q,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(Q){let $=this.#F(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){Q.stopPropagation();let $=this.#F(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#f(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled)return;if(Q.buttons===0){this.#k();return}let $=(this.step||1)*Q.movementX,J=this.#F(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#f(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#B(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#L=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#k(Q){this.#L=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#f(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#x(J),J}#x(Q){let $=this.#N??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#B();break;case"units":this.#W=J||"",this.#R(),this.input.value=this.#T(this.value);break;case"units-disallow":this.#G=this.#z(J===null?t.#M:J),this.#R(),this.input.value=this.#T(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#T(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#T(this.value);break;case"value":if(this.#L)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#f(Z,!1);this.value=Z,this.input.value=this.#T(this.value),this.#B();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#B();break}this[Q]=Number(J),this.#B();break;case"steppers":{let j=J!==null&&J!=="false";this.#D(j);break}case"precision":this.#N=J!==null?Number(J):2,this.input.value=this.#T(this.value);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",t);class k0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",k0);class C0 extends HTMLElement{#$=!1;#Q=null;#J=null;constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label)this.#Q=b("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label),this.#J=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J);else if(this.input&&this.label)this.label.addEventListener("click",this.focus.bind(this));if(this.input&&this.label&&!this.#$){let Q=this.input.getAttribute("id")||c();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}if(this.label)this.label.addEventListener("pointerenter",this.#j.bind(this)),this.label.addEventListener("pointerleave",this.#q.bind(this))})}disconnectedCallback(){if(this.label)C.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#j(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;C.show(this.label,this.label.textContent.trim())}#q(){if(this.label)C.hide(this.label)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J;break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",C0);class I0 extends HTMLElement{rgba;hex;#$=100;#Q;#J;#j;#q;#Z=!1;#_=!1;#X=null;constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#K(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#U(){let Q=this.#K();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#W)cancelAnimationFrame(this.#W);this.#W=requestAnimationFrame(()=>{this.#W=null,this.#G()})}#W=null;#G(){this.#R(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#E?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
|
|
73
|
+
value="${this.#P(this.value)}" />`,j=this.querySelector("[slot=append]"),q=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,q)q.removeEventListener("click",this.#U),q.addEventListener("click",this.#U),this.prepend(q);if(j)j.removeEventListener("click",this.#U),j.addEventListener("click",this.#U),this.append(j);if(this.input=this.querySelector("input"),this.#E(),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(J),this.hasAttribute("disabled")){let _=this.getAttribute("disabled");this.disabled=this.input.disabled=_!=="false"}this.#A(),this.#T(),this.addEventListener("pointerdown",this.#J),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("focus",this.#q),this.input.addEventListener("focus",this.#q),this.input.removeEventListener("blur",this.#Y),this.input.addEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#_),this.input.removeEventListener("focus",this.#q),this.input.removeEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X);this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#E(){if(!this.input)return;this.#z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#T(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#P(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#S(Q){if(!Q)return"";if(!this.#K){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#K,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#I($),!this.#K)return $.toString();if(this.#G==="prefix")return this.#K+$;else return $+this.#K}#C(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#I($),$.toString()}#f(Q){this.#R=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#K)if(this.#G==="prefix")Q.target.setSelectionRange(this.#K.length,$.length);else{let J=$.indexOf(this.#K);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#V(Q){this.#R=!1;let $=this.#S(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#h(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#S(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#h(q,!1),this.value=q,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(Q){let $=this.#S(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#x(Q){Q.stopPropagation();let $=this.#S(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#h(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled)return;if(Q.buttons===0){this.#v();return}let $=(this.step||1)*Q.movementX,J=this.#S(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#h(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#R=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#j)}#v(Q){this.#R=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}#h(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#I(J),J}#I(Q){let $=this.#M??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#A();break;case"units":this.#W=J||"",this.#B(),this.input.value=this.#P(this.value),this.#T();break;case"units-disallow":this.#L=this.#O(J===null?a.#D:J),this.#B(),this.input.value=this.#P(this.value),this.#T();break;case"unit-position":this.#G=J||"suffix",this.input.value=this.#P(this.value),this.#T();break;case"transform":this.transform=Number(J)||1,this.input.value=this.#P(this.value),this.#T();break;case"value":if(this.#R)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#h(Z,!1);this.value=Z,this.input.value=this.#P(this.value),this.#A(),this.#T();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#A(),this.#T();break}this[Q]=Number(J),this.#A(),this.#T();break;case"steppers":{let j=J!==null&&J!=="false";this.#F(j);break}case"precision":this.#M=J!==null?Number(J):2,this.input.value=this.#P(this.value),this.#T();break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#E();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",a);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.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",C0);class f0 extends HTMLElement{#$=!1;#Q=null;#j=null;#J=null;#Z=null;#_=null;constructor(){super();this.#J=this.focus.bind(this),this.#Z=this.#Y.bind(this),this.#_=this.#X.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(this.isConnected)this.#q()})}#q(){if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=v("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#j=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else if(this.input&&this.label)this.label.removeEventListener("click",this.#J),this.label.addEventListener("click",this.#J);if(this.input&&this.label&&!this.#$)this.#U();if(this.label)this.label.removeEventListener("pointerenter",this.#Z),this.label.addEventListener("pointerenter",this.#Z),this.label.removeEventListener("pointerleave",this.#_),this.label.addEventListener("pointerleave",this.#_)}disconnectedCallback(){if(this.label)C.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#Z)this.label.removeEventListener("pointerenter",this.#Z);if(this.label&&this.#_)this.label.removeEventListener("pointerleave",this.#_);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#Y(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;C.show(this.label,this.label.textContent.trim())}#X(){if(this.label)C.hide(this.label)}#U(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let $=this.input.querySelectorAll("input, select, textarea");if($.length===1){let J=$[0],Z=J.getAttribute("id")||y();if(J.setAttribute("id",Z),this.label.setAttribute("for",Z),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J,this.#U();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",f0);class I0 extends HTMLElement{rgba;hex;#$=100;#Q;#j;#J;#Z;#_=!1;#q=!1;#Y=null;constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#X(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#U(){let Q=this.#X();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){this.#K()}#K(){this.#D(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#P?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
|
|
72
74
|
type="text"
|
|
73
75
|
placeholder="000000"
|
|
74
76
|
value="${this.hexOpaque.slice(1).toUpperCase()}"${J}>
|
|
@@ -80,16 +82,16 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
80
82
|
value="${this.#$}"
|
|
81
83
|
units="%"${J}>
|
|
82
84
|
</fig-input-number>
|
|
83
|
-
</fig-tooltip>`;let
|
|
84
|
-
${
|
|
85
|
+
</fig-tooltip>`;let _="";_=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`,Z=`<div class="input-combo">
|
|
86
|
+
${_}
|
|
85
87
|
${q}
|
|
86
|
-
</div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;this.innerHTML=Z,requestAnimationFrame(()=>{if(this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#j=this.querySelector("fig-input-text:not([type=number])"),this.#q=this.querySelector("fig-input-number"),this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let q=this.#Q.querySelector('input[type="color"]');if(this.#j||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#M.bind(this),{capture:!0}),this.#Q.addEventListener("click",this.#z.bind(this),{capture:!0}),q?.addEventListener("keydown",this.#O.bind(this)),this.#Q.addEventListener("input",this.#F.bind(this))}if(this.#j){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#j.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q;this.#j.addEventListener("input",this.#D.bind(this)),this.#j.addEventListener("change",this.#H.bind(this))}if(this.#q)this.#q.addEventListener("input",this.#B.bind(this)),this.#q.addEventListener("change",this.#H.bind(this))})}#Y(){if(!this.#J)return;for(let[Q,$]of Object.entries(this.#K()))this.#J.setAttribute(Q,$);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#N(){if(!m())return null;if(this.#J?.isConnected)return this.#Y(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#T.bind(this)),Q.addEventListener("change",this.#H.bind(this)),this.appendChild(Q),this.#J=Q,this.#Y(),Q}#L(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#N();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#A(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#M(Q){if(!m())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#Z=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#Z=!1,this.#_=!1,this.#X=null},500),this.#A(Q)}#z(Q){if(!this.#Z)return;if(this.#Z=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#A(Q),this.#_)this.#_=!1,this.#L()}#O(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!m())return;if(!this.#L())return;this.#A(Q)}#R(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#D(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#R("#"+$),this.#q)this.#q.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#P()}#B(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#R(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#P()}#H(Q){Q.stopPropagation(),this.#C()}focus(){if(this.#j){this.#j.focus();return}this.#Q?.focus()}#F(Q){if(Q.stopPropagation(),this.#R(Q.target.value),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#P()}#T(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#R(J),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#q&&$.alpha!==void 0)this.#q.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#P()}}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#R(J),this.#j)this.#j.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#q)this.#q.setAttribute("value",this.#$);break;case"mode":this.#Y();break;case"alpha":case"text":if(this.isConnected)this.#G();break;case"disabled":this.#S();break}}get#E(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#S(){let Q=this.#E;for(let $ of[this.#Q,this.#j,this.#q]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)this.#Y()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),K=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${K}`.toUpperCase();let X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${K}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let K=parseInt(q[1])/360,_=parseInt(q[2])/100,X=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,_===0)$=J=Z=X;else{let Y=(B,H,M)=>{if(M<0)M+=1;if(M>1)M-=1;if(M<0.16666666666666666)return B+(H-B)*6*M;if(M<0.5)return H;if(M<0.6666666666666666)return B+(H-B)*(0.6666666666666666-M)*6;return B},N=X<0.5?X*(1+_):X+_-X*_,L=2*X-N;$=Y(L,N,K+0.3333333333333333),J=Y(L,N,K),Z=Y(L,N,K-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",I0);var D1=["srgb","srgb-linear","display-p3","oklab","oklch"],H1=["shorter","longer","increasing","decreasing"];function h(Q){let $={...Q??{}},J=String($.interpolationSpace??"oklab").toLowerCase();if(!D1.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=H1.includes(Z)?Z:"shorter",$}function f0(Q){let $=h(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function y0(Q){let $=h(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function u(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function v(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function p(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function l(Q,$,J){let Z=v(Q),j=v($),q=v(J),K=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),_=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),X=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*K+0.793617785*_-0.0040720468*X,a:1.9779984951*K-2.428592205*_+0.4505937099*X,b:0.0259040371*K+0.7827717662*_-0.808675766*X}}function G0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,K=Z*Z*Z,_=j*j*j,X=q*q*q;return{r:p(4.0767416621*K-3.3077115913*_+0.2309699292*X),g:p(-1.2684380046*K+2.6097574011*_-0.3413193965*X),b:p(-0.0041960863*K-0.7034186147*_+1.707614701*X)}}function L0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function F1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function T1(Q,$,J,Z){let j=(Q%360+360)%360,K=($%360+360)%360-j;switch(Z){case"longer":if(K>0&&K<180)K-=360;else if(K<0&&K>-180)K+=360;else if(K===0)K=0;break;case"increasing":if(K<0)K+=360;break;case"decreasing":if(K>0)K-=360;break;default:if(K>180)K-=360;else if(K<-180)K+=360;break}return((j+K*J)%360+360)%360}function E1(Q,$,J,Z){let j=[...Q].sort((R,U)=>R.position-U.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let K=0;while(K<j.length-1&&j[K+1].position<q)K++;let _=j[K],X=j[K+1],Y=X.position-_.position,N=Y>0?(q-_.position)/Y:0,L=u(_.color),B=u(X.color),H,M,G,z=J||"oklab";if(z==="srgb-linear"){let R=v(L.r),U=v(L.g),A=v(L.b),D=v(B.r),T=v(B.g),E=v(B.b);H=p(R+(D-R)*N),M=p(U+(T-U)*N),G=p(A+(E-A)*N)}else if(z==="oklch"){let R=l(L.r,L.g,L.b),U=l(B.r,B.g,B.b),A=L0(R.l,R.a,R.b),D=L0(U.l,U.a,U.b),T=A.l+(D.l-A.l)*N,E=A.c+(D.c-A.c)*N,S=T1(A.h,D.h,N,Z||"shorter"),I=F1(T,E,S),V=G0(I.l,I.a,I.b);H=V.r,M=V.g,G=V.b}else{let R=l(L.r,L.g,L.b),U=l(B.r,B.g,B.b),A=R.l+(U.l-R.l)*N,D=R.a+(U.a-R.a)*N,T=R.b+(U.b-R.b)*N,E=G0(A,D,T);H=E.r,M=E.g,G=E.b}return`#${H.toString(16).padStart(2,"0")}${M.toString(16).padStart(2,"0")}${G.toString(16).padStart(2,"0")}`.toUpperCase()}class x0 extends HTMLElement{#$="solid";#Q;#J;#j;#q={color:"#D9D9D9",alpha:1};#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#j=null}#U(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#q.color=$.color;if($.alpha!==void 0)this.#q.alpha=$.alpha;if($.opacity!==void 0)this.#q.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#Z=h({...this.#Z,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#q.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#q.alpha=parseInt(J,16)/255}}}}#W(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#G(){switch(this.#$){case"solid":return this.#q.color;case"gradient":{let $=[...this.#Z.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:K}=u(J.color);return`rgba(${j}, ${q}, ${K}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#Z.angle}deg ${y0(this.#Z)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#Y(){switch(this.#$){case"solid":return this.#q.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#N(){let Q=this.hasAttribute("disabled");for(let $ of[this.#Q,this.#J,this.#j]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#L(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(K)=>J?`<fig-tooltip text="Opacity">
|
|
88
|
+
</div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;if(this.innerHTML=Z,this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#A(),this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#R.bind(this),{capture:!0}),this.#Q.addEventListener("click",this.#N.bind(this),{capture:!0}),q?.addEventListener("keydown",this.#z.bind(this)),this.#Q.addEventListener("input",this.#k.bind(this))}if(this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q;this.#J.addEventListener("input",this.#O.bind(this)),this.#J.addEventListener("change",this.#B.bind(this))}if(this.#Z)this.#Z.addEventListener("input",this.#H.bind(this)),this.#Z.addEventListener("change",this.#B.bind(this))}#W(){if(!this.#j)return;for(let[Q,$]of Object.entries(this.#X()))this.#j.setAttribute(Q,$);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled");this.#j.anchorElement=this,this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#L(){if(!m())return null;if(this.#j?.isConnected)return this.#W(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#E.bind(this)),Q.addEventListener("change",this.#B.bind(this)),this.appendChild(Q),this.#j=Q,this.#W(),Q}#G(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#L();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#M(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#R(Q){if(!m())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#q=!0,this.#_=!0,this.#Y)clearTimeout(this.#Y);this.#Y=setTimeout(()=>{this.#_=!1,this.#q=!1,this.#Y=null},500),this.#M(Q)}#N(Q){if(!this.#_)return;if(this.#_=!1,this.#Y)clearTimeout(this.#Y),this.#Y=null;if(this.#M(Q),this.#q)this.#q=!1,this.#G()}#z(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!m())return;if(!this.#G())return;this.#M(Q)}#D(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#O(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#D("#"+$),this.#Z)this.#Z.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#T()}#H(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#D(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#T()}#B(Q){Q.stopPropagation(),this.#S()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#F(){return this.getAttribute("aria-label")||"Color"}#A(){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"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Z=this.getAttribute("aria-labelledby"),j=this.#F();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if($)this.#J.setAttribute("aria-invalid",$);else this.#J.removeAttribute("aria-invalid");if(J)this.#J.setAttribute("aria-required",J);else this.#J.removeAttribute("aria-required")}if(this.#Z){if(this.#Z.setAttribute("aria-label",`${j} opacity`),Q)this.#Z.setAttribute("aria-describedby",Q);else this.#Z.removeAttribute("aria-describedby");if($)this.#Z.setAttribute("aria-invalid",$);else this.#Z.removeAttribute("aria-invalid");if(J)this.#Z.setAttribute("aria-required",J);else this.#Z.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(Z)q.setAttribute("aria-labelledby",Z),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#k(Q){if(Q.stopPropagation(),this.#D(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#T()}#E(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#D(J),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#T()}}#T(){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,$,J){if($===J)return;switch(Q){case"value":if(this.#D(J),this.#J)this.#J.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#Z)this.#Z.setAttribute("value",this.#$);break;case"mode":this.#W();break;case"alpha":case"text":if(this.isConnected)this.#K();break;case"disabled":this.#C();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break}}get#P(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#C(){let Q=this.#P;for(let $ of[this.#Q,this.#J,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#A(),this.#j)this.#W()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)$=parseInt(q[1]),J=parseInt(q[2]),Z=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)$=J=Z=Y;else{let K=(B,H,O)=>{if(O<0)O+=1;if(O>1)O-=1;if(O<0.16666666666666666)return B+(H-B)*6*O;if(O<0.5)return H;if(O<0.6666666666666666)return B+(H-B)*(0.6666666666666666-O)*6;return B},N=Y<0.5?Y*(1+X):Y+X-Y*X,L=2*Y-N;$=K(L,N,_+0.3333333333333333),J=K(L,N,_),Z=K(L,N,_-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",I0);var z1=["srgb","srgb-linear","display-p3","oklab","oklch"],D1=["shorter","longer","increasing","decreasing"];function r(Q){let $={...Q??{}},J=String($.interpolationSpace??"srgb").toLowerCase();if(!z1.includes(J))J="srgb";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=D1.includes(Z)?Z:"shorter",$}function x0(Q){let $=r(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function V0(Q){let $=r(Q);if($.interpolationSpace==="srgb")return"";if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function p(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function h(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function c(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function l(Q,$,J){let Z=h(Q),j=h($),q=h(J),_=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*Z+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function U0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,_=Z*Z*Z,X=j*j*j,Y=q*q*q;return{r:c(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:c(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:c(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function L0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function H1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function F1(Q,$,J,Z){let j=(Q%360+360)%360,_=($%360+360)%360-j;switch(Z){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*J)%360+360)%360}function T1(Q,$,J,Z){let j=[...Q].sort((A,G)=>A.position-G.position),q=$*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,N=K>0?(q-X.position)/K:0,L=p(X.color),B=p(Y.color),H,O,U,z=J||"oklab";if(z==="srgb-linear"){let A=h(L.r),G=h(L.g),M=h(L.b),D=h(B.r),T=h(B.g),P=h(B.b);H=c(A+(D-A)*N),O=c(G+(T-G)*N),U=c(M+(P-M)*N)}else if(z==="oklch"){let A=l(L.r,L.g,L.b),G=l(B.r,B.g,B.b),M=L0(A.l,A.a,A.b),D=L0(G.l,G.a,G.b),T=M.l+(D.l-M.l)*N,P=M.c+(D.c-M.c)*N,S=F1(M.h,D.h,N,Z||"shorter"),f=H1(T,P,S),w=U0(f.l,f.a,f.b);H=w.r,O=w.g,U=w.b}else{let A=l(L.r,L.g,L.b),G=l(B.r,B.g,B.b),M=A.l+(G.l-A.l)*N,D=A.a+(G.a-A.a)*N,T=A.b+(G.b-A.b)*N,P=U0(M,D,T);H=P.r,O=P.g,U=P.b}return`#${H.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class y0 extends HTMLElement{#$="solid";#Q;#j;#J;#Z={color:"#D9D9D9",alpha:1};#_={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#q={url:null,scaleMode:"fill",scale:50,opacity:1};#Y={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.#U(),this.#R()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#J=null}#U(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#_=r({...this.#_,...$.gradient});break;case"image":if($.image)this.#q={...this.#q,...$.image};break;case"video":if($.video)this.#Y={...this.#Y,...$.video};break;case"webcam":if($.webcam)this.#X={...this.#X,...$.webcam};if($.opacity!==void 0)this.#X.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#K(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#W(){switch(this.#$){case"solid":return this.#Z.color;case"gradient":{let $=[...this.#_.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:_}=p(J.color);return`rgba(${j}, ${q}, ${_}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#_.angle}deg ${V0(this.#_)}, ${$})`}case"image":return this.#q.url?`url(${this.#q.url})`:"#D9D9D9";default:return"#D9D9D9"}}#L(){switch(this.#$){case"solid":return this.#Z.alpha;case"image":return this.#q.opacity??1;case"video":return this.#Y.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#G(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let $ of[this.#Q,this.#j,this.#J]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#M(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#G();let Q=this.getAttribute("aria-label")||"Fill",$=this.getAttribute("aria-describedby"),J=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),$)q.setAttribute("aria-describedby",$);else q.removeAttribute("aria-describedby");if(J)q.setAttribute("aria-invalid",J);else q.removeAttribute("aria-invalid");if(Z)q.setAttribute("aria-required",Z);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#R(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(_)=>J?`<fig-tooltip text="Opacity">
|
|
87
89
|
<fig-input-number
|
|
88
90
|
class="fig-input-fill-opacity"
|
|
89
91
|
placeholder="##"
|
|
90
92
|
min="0"
|
|
91
93
|
max="100"
|
|
92
|
-
value="${
|
|
94
|
+
value="${_}"
|
|
93
95
|
units="%"
|
|
94
96
|
${Q?"disabled":""}>
|
|
95
97
|
</fig-input-number>
|
|
@@ -98,29 +100,29 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
98
100
|
type="text"
|
|
99
101
|
class="fig-input-fill-hex"
|
|
100
102
|
placeholder="000000"
|
|
101
|
-
value="${this.#
|
|
103
|
+
value="${this.#Z.color.slice(1).toUpperCase()}"
|
|
102
104
|
${Q?"disabled":""}>
|
|
103
105
|
</fig-input-text>
|
|
104
|
-
${Z(Math.round(this.#
|
|
105
|
-
<label class="fig-input-fill-label">${this.#
|
|
106
|
+
${Z(Math.round(this.#Z.alpha*100))}`;break;case"gradient":{j=`
|
|
107
|
+
<label class="fig-input-fill-label">${this.#_.type.charAt(0).toUpperCase()+this.#_.type.slice(1)}</label>
|
|
106
108
|
${Z(100)}`;break}case"image":j=`
|
|
107
109
|
<label class="fig-input-fill-label">Image</label>
|
|
108
|
-
${Z(Math.round((this.#
|
|
110
|
+
${Z(Math.round((this.#q.opacity??1)*100))}`;break;case"video":j=`
|
|
109
111
|
<label class="fig-input-fill-label">Video</label>
|
|
110
|
-
${Z(Math.round((this.#
|
|
112
|
+
${Z(Math.round((this.#Y.opacity??1)*100))}`;break;case"webcam":j=`
|
|
111
113
|
<label class="fig-input-fill-label">Webcam</label>
|
|
112
|
-
${Z(Math.round((this.#
|
|
114
|
+
${Z(Math.round((this.#X.opacity??1)*100))}`;break}let q=this.#K();this.innerHTML=`
|
|
113
115
|
<div class="input-combo">
|
|
114
116
|
<fig-fill-picker ${q} value='${$}' ${Q?"disabled":""}>
|
|
115
|
-
<fig-chit background="${this.#
|
|
117
|
+
<fig-chit background="${this.#W()}" alpha="${this.#L()}"${Q?" disabled":""}></fig-chit>
|
|
116
118
|
</fig-fill-picker>
|
|
117
119
|
${j}
|
|
118
|
-
</div>`,this.#
|
|
120
|
+
</div>`,this.#N()}#N(){this.#Q=this.querySelector("fig-fill-picker"),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#M(),Q&&this.#Q)Q.addEventListener("click",()=>{let $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{let J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,q=j!==this.#$;switch(this.#$=j,j){case"solid":this.#Z.color=Z.color,this.#Z.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#_=r({...this.#_,...Z.gradient});break;case"image":if(Z.image)this.#q=Z.image;break;case"video":if(Z.video)this.#Y=Z.video;break}if(q)this.#D();else this.#z();this.#B()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#F()})}if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#Z.color=J,this.#O(),this.#B()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#F()});if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#$){case"solid":this.#Z.alpha=j;break;case"gradient":break;case"image":this.#q.opacity=j;break;case"video":this.#Y.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#O(),this.#H(j),this.#B()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#F()})}#z(){switch(this.#$){case"solid":if(this.#J)this.#J.setAttribute("value",this.#Z.color.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",Math.round(this.#Z.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#_.type.charAt(0).toUpperCase()+this.#_.type.slice(1);Q.textContent=$}break}case"image":if(this.#j)this.#j.setAttribute("value",Math.round((this.#q.opacity??1)*100));break;case"video":if(this.#j)this.#j.setAttribute("value",Math.round((this.#Y.opacity??1)*100));break;case"webcam":if(this.#j)this.#j.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#D(){let Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),q=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),q.forEach((Y)=>Y.remove());let _="";switch(this.#$){case"solid":_=`
|
|
119
121
|
<fig-input-text
|
|
120
122
|
type="text"
|
|
121
123
|
class="fig-input-fill-hex"
|
|
122
124
|
placeholder="000000"
|
|
123
|
-
value="${this.#
|
|
125
|
+
value="${this.#Z.color.slice(1).toUpperCase()}"
|
|
124
126
|
${Q?"disabled":""}>
|
|
125
127
|
</fig-input-text>
|
|
126
128
|
<fig-tooltip text="Opacity">
|
|
@@ -129,12 +131,12 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
129
131
|
placeholder="##"
|
|
130
132
|
min="0"
|
|
131
133
|
max="100"
|
|
132
|
-
value="${Math.round(this.#
|
|
134
|
+
value="${Math.round(this.#Z.alpha*100)}"
|
|
133
135
|
units="%"
|
|
134
136
|
${Q?"disabled":""}>
|
|
135
137
|
</fig-input-number>
|
|
136
|
-
</fig-tooltip>`;break;case"gradient":{
|
|
137
|
-
<label class="fig-input-fill-label">${this.#
|
|
138
|
+
</fig-tooltip>`;break;case"gradient":{_=`
|
|
139
|
+
<label class="fig-input-fill-label">${this.#_.type.charAt(0).toUpperCase()+this.#_.type.slice(1)}</label>
|
|
138
140
|
<fig-tooltip text="Opacity">
|
|
139
141
|
<fig-input-number
|
|
140
142
|
class="fig-input-fill-opacity"
|
|
@@ -145,7 +147,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
145
147
|
units="%"
|
|
146
148
|
${Q?"disabled":""}>
|
|
147
149
|
</fig-input-number>
|
|
148
|
-
</fig-tooltip>`;break}case"image":
|
|
150
|
+
</fig-tooltip>`;break}case"image":_=`
|
|
149
151
|
<label class="fig-input-fill-label">Image</label>
|
|
150
152
|
<fig-tooltip text="Opacity">
|
|
151
153
|
<fig-input-number
|
|
@@ -153,11 +155,11 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
153
155
|
placeholder="##"
|
|
154
156
|
min="0"
|
|
155
157
|
max="100"
|
|
156
|
-
value="${Math.round((this.#
|
|
158
|
+
value="${Math.round((this.#q.opacity??1)*100)}"
|
|
157
159
|
units="%"
|
|
158
160
|
${Q?"disabled":""}>
|
|
159
161
|
</fig-input-number>
|
|
160
|
-
</fig-tooltip>`;break;case"video":
|
|
162
|
+
</fig-tooltip>`;break;case"video":_=`
|
|
161
163
|
<label class="fig-input-fill-label">Video</label>
|
|
162
164
|
<fig-tooltip text="Opacity">
|
|
163
165
|
<fig-input-number
|
|
@@ -165,11 +167,11 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
165
167
|
placeholder="##"
|
|
166
168
|
min="0"
|
|
167
169
|
max="100"
|
|
168
|
-
value="${Math.round((this.#
|
|
170
|
+
value="${Math.round((this.#Y.opacity??1)*100)}"
|
|
169
171
|
units="%"
|
|
170
172
|
${Q?"disabled":""}>
|
|
171
173
|
</fig-input-number>
|
|
172
|
-
</fig-tooltip>`;break;case"webcam":
|
|
174
|
+
</fig-tooltip>`;break;case"webcam":_=`
|
|
173
175
|
<label class="fig-input-fill-label">Webcam</label>
|
|
174
176
|
<fig-tooltip text="Opacity">
|
|
175
177
|
<fig-input-number
|
|
@@ -177,41 +179,41 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
177
179
|
placeholder="##"
|
|
178
180
|
min="0"
|
|
179
181
|
max="100"
|
|
180
|
-
value="${Math.round((this.#
|
|
182
|
+
value="${Math.round((this.#X.opacity??1)*100)}"
|
|
181
183
|
units="%"
|
|
182
184
|
${Q?"disabled":""}>
|
|
183
185
|
</fig-input-number>
|
|
184
|
-
</fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",K),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(_&&this.#Q)_.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#j)this.#j.addEventListener("input",(X)=>{X.stopPropagation();let Y="#"+X.target.value.replace("#","");this.#q.color=Y,this.#O(),this.#D()}),this.#j.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let Y=parseFloat(X.target.value),L=(isNaN(Y)?100:Y)/100;switch(this.#$){case"solid":this.#q.alpha=L;break;case"gradient":break;case"image":this.#_.opacity=L;break;case"video":this.#X.opacity=L;break;case"webcam":this.#K.opacity=L;break}this.#O(),this.#R(L),this.#D()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#B()})})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#R(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#q.color,alpha:this.#q.alpha,opacity:Math.round(this.#q.alpha*100)};case"gradient":return{type:"gradient",gradient:f0(this.#Z)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#U(),this.#Q)if(this.#$!==Z)this.#L();else this.#O(),this.#M();break;case"disabled":this.#N();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",x0);class V0 extends HTMLElement{#$=[];#Q=[];#J=[];#j=null;static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Z(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#_(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#j)cancelAnimationFrame(this.#j);this.#j=requestAnimationFrame(()=>{this.#j=null,this.#X(),this.#K()})}disconnectedCallback(){if(this.#j)cancelAnimationFrame(this.#j),this.#j=null;this.#Q=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#A();break;case"disabled":this.#M();break;case"min":case"max":case"fixed":this.#K();break;case"open":break}}#X(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let $=document.createElement("div");$.className="palette-colors-inline",$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0});let J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,q)=>{J.appendChild(this.#U(j,q,Q,{inline:!0}))}),$.appendChild(J),this.appendChild($),!this.#q)this.#Y(Q,this);let Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,q)=>{if(Z.appendChild(this.#U(j,q,Q)),!this.#q)Z.appendChild(this.#W(q,Q))}),this.appendChild(Z)}#U(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let K=Z?this.#J:this.#Q,_=(X)=>{X.stopPropagation();let Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};let N=K[$];if(N){let L=this.#$[$],B=L.alpha<1?L.color+Math.round(L.alpha*255).toString(16).padStart(2,"0"):L.color;N.setAttribute("value",B)}};if(q.addEventListener("input",(X)=>{_(X),this.#O()}),q.addEventListener("change",(X)=>{_(X),this.#R()}),Z)this.#Q.push(q);else this.#J.push(q);return q}#W(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#Z)J.setAttribute("disabled","");J.appendChild(b("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#Z)return;this.#$.splice(Q,1),this.#Q=[],this.#J=[],this.#K(),this.#R()}#Y(Q,$=this){let J=this.#$.length>=this.#_,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(b("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#_)return;this.open=!0,this.#N({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#N(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#U(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#U(Q,J,$),K=this.querySelector(".palette-colors-expanded");if(K)K.appendChild(q),K.appendChild(this.#W(J,$));if(this.#$.length>=this.#_){let _=this.querySelector(".palette-add-btn");if(_)_.setAttribute("disabled","")}this.#z($),this.#R()}#L(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#J[Q];if(j)j.setAttribute("value",J)}#A(){if(this.#Q.length!==this.#$.length){this.#K();return}this.#$.forEach((Q,$)=>{this.#L($)})}#M(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#_)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#z(Q)}#z(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#Z;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",V0);class r extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#J=!1;#j=null;#q=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#_(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#_==="true"}get#K(){return this.getAttribute("mode")==="tip"?"tip":"handle"}connectedCallback(){if(this.#W(),this.#M(),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.#q)this.#q.disconnect(),this.#q=null;clearTimeout(this.#j),this.removeEventListener("pointerenter",this.#H),this.removeEventListener("pointermove",this.#T),this.removeEventListener("pointerleave",this.#F),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#C)}#U=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let K=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],_=K.indexOf(q),X=Q.shiftKey?(_-1+K.length)%K.length:(_+1)%K.length;q.deselect(),K[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let K=parseInt(q.dataset.stopIndex,10);if(isNaN(K)||!this.#Z.stops[K])return;Q.preventDefault();let _=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.SHIFT_SNAP:1),X=this.#Z.stops[K];X.position=Math.max(0,Math.min(100,X.position+_)),q.setAttribute("value",`${X.position}% 50%`);let Y=q.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),q.hideColorTip(),clearTimeout(this.#j),this.#j=setTimeout(()=>{Y.removeAttribute("show"),q.showColorTip()},600);this.#k(),this.#x(),this.#b();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#I(),this.#k(),this.#x(),this.#b()};#W(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=h({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90;return}if($?.gradient)this.#Z=h({...this.#Z,...$.gradient}),this.#Z.type="linear",this.#Z.angle=90}catch($){}}#G(){let $=[...this.#Z.stops].sort((Z,j)=>Z.position-j.position).map((Z)=>{let j=(Z.opacity??100)/100;if(j>=1)return`${Z.color} ${Z.position}%`;let{r:q,g:K,b:_}=u(Z.color);return`rgba(${q}, ${K}, ${_}, ${j}) ${Z.position}%`}).join(", "),J=y0(this.#Z);return`linear-gradient(${this.#Z.angle}deg ${J}, ${$})`}#Y(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=u(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#N(){let Q=this.hasAttribute("disabled"),$=this.#K==="tip"?' tip="color"':"";return this.#Z.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#Y(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#L=null;#A=!1;#M(){let Q=this.hasAttribute("disabled"),$=this.#_;if($==="picker"&&m()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
|
|
186
|
+
</fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",_),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#M(),X&&this.#Q)X.addEventListener("click",()=>{let Y=this.#Q.querySelector("fig-chit");if(Y)Y.click()});if(this.#J)this.#J.addEventListener("input",(Y)=>{Y.stopPropagation();let K="#"+Y.target.value.replace("#","");this.#Z.color=K,this.#O(),this.#B()}),this.#J.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#F()});if(this.#j)this.#j.addEventListener("input",(Y)=>{Y.stopPropagation();let K=parseFloat(Y.target.value),L=(isNaN(K)?100:K)/100;switch(this.#$){case"solid":this.#Z.alpha=L;break;case"gradient":break;case"image":this.#q.opacity=L;break;case"video":this.#Y.opacity=L;break;case"webcam":this.#X.opacity=L;break}this.#O(),this.#H(L),this.#B()}),this.#j.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#F()})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#H(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#B(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#F(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:x0(this.#_)};case"image":return{type:"image",image:{...this.#q}};case"video":return{type:"video",video:{...this.#Y}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#U(),this.#Q)if(this.#$!==Z)this.#R();else this.#O(),this.#z();break;case"disabled":this.#G();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#M();break}}}customElements.define("fig-input-fill",y0);class w0 extends HTMLElement{#$=[];#Q=[];#j=[];#J=null;#Z=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 $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#_(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#q(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#Y(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#Z),this.addEventListener("keydown",this.#Z),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{this.#J=null,this.#U(),this.#K()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#Z),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,$,J){if($===J)return;switch(Q){case"value":this.#U(),this.#z();break;case"disabled":this.#D();break;case"min":case"max":case"fixed":this.#K();break;case"open":break}}#U(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let $=document.createElement("div");$.className="palette-colors-inline",$.setAttribute("role","button"),$.setAttribute("aria-expanded",String(this.open)),$.setAttribute("aria-label","Edit palette colors");let J=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,$.setAttribute("aria-expanded","true")};$.addEventListener("click",J),$.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),J()});let Z=document.createElement("div");if(Z.className="palette-colors",this.#$.forEach((q,_)=>{Z.appendChild(this.#W(q,_,Q,{inline:!0}))}),$.appendChild(Z),this.appendChild($),!this.#_)this.#M(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#$.forEach((q,_)=>{if(j.appendChild(this.#W(q,_,Q)),!this.#_)j.appendChild(this.#L(_,Q))}),this.appendChild(j)}#W(Q,$,J,{inline:Z=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),Z)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if(J)q.setAttribute("disabled","");let _=Z?this.#j:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#$[$]={color:K.hexOpaque||this.#$[$].color,alpha:K.rgba?K.rgba.a:this.#$[$].alpha};let N=_[$];if(N){let L=this.#$[$],B=L.alpha<1?L.color+Math.round(L.alpha*255).toString(16).padStart(2,"0"):L.color;N.setAttribute("value",B)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#H()}),q.addEventListener("change",(Y)=>{X(Y),this.#B()}),Z)this.#Q.push(q);else this.#j.push(q);return q}#L(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#q)J.setAttribute("disabled","");J.appendChild(v("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#_)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#q)return;this.#$.splice(Q,1),this.#Q=[],this.#j=[],this.#K(),this.#B()}#M(Q,$=this){let J=this.#$.length>=this.#Y,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(v("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#Y)return;this.open=!0,this.#R({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#R(Q){if(this.#_)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#W(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#W(Q,J,$),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#L(J,$));if(this.#$.length>=this.#Y){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#O($),this.#B()}#N(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#j[Q];if(j)j.setAttribute("value",J)}#z(){if(this.#Q.length!==this.#$.length){this.#K();return}this.#$.forEach((Q,$)=>{this.#N($)})}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#Y)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#O(Q)}#O(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#q;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.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",w0);class d extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#j=!1;#J=null;#Z=null;#_=null;#q={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#Y(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#Y==="true"}get#U(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#K(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#W(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#L(Q){return{...r(Q),type:"linear",angle:90}}connectedCallback(){if(this.#R(),this.#B(),this.removeEventListener("keydown",this.#M),this.addEventListener("keydown",this.#M),this.#X)document.addEventListener("keydown",this.#G)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#G),this.removeEventListener("keydown",this.#M),this.#Z)this.#Z.disconnect(),this.#Z=null;if(this.#_!==null)cancelAnimationFrame(this.#_),this.#_=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#S),this.removeEventListener("pointermove",this.#C),this.removeEventListener("pointerleave",this.#P),this.removeEventListener("click",this.#b),this.removeEventListener("dblclick",this.#V)}#G=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#q.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?d.SHIFT_SNAP:1),Y=this.#q.stops[_];Y.position=Math.max(0,Math.min(100,Y.position+X)),q.setAttribute("value",`${Y.position}% 50%`);let K=q.closest("fig-tooltip");if(K)K.text=`${Math.round(Y.position)}%`,K.setAttribute("show","true"),K.showPopup(),q.hideColorTip(),clearTimeout(this.#J),this.#J=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#I(),this.#m(),this.#u();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#q.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#q.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#q.stops.splice(j,1),this.#w(),this.#I(),this.#m(),this.#u()};#M=(Q)=>{if(this.#Y!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let $=this.querySelector("fig-fill-picker");if(!$||typeof $.open!=="function")return;Q.preventDefault(),$.open()};#R(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#q=this.#L({...this.#q,...$.gradient});return}if($?.gradient)this.#q=this.#L({...this.#q,...$.gradient})}catch($){}}#N(){let Q=this.#L(this.#q),J=[...Q.stops].sort((q,_)=>q.position-_.position).map((q)=>{let _=(q.opacity??100)/100;if(_>=1)return`${q.color} ${q.position}%`;let{r:X,g:Y,b:K}=p(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),Z=V0(Q),j=Z?` ${Z}`:"";return`linear-gradient(${Q.angle}deg${j}, ${J})`}#z(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=p(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#D(){let Q=this.hasAttribute("disabled"),$=this.#U==="tip"?' tip="color"':"";return this.#q.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#z(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#H=!1;#B(){let Q=this.hasAttribute("disabled"),$=this.#Y;if($==="picker"&&m()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
|
|
185
187
|
<fig-fill-picker mode="gradient"${Z} value='${j}'${Q?" disabled":""}>
|
|
186
|
-
<fig-chit background="${this.#
|
|
187
|
-
</fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#
|
|
188
|
-
<fig-chit background="${this.#
|
|
189
|
-
${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#N()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#R(),this.#f(),requestAnimationFrame(()=>this.#S())}#z(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#Z=h({...this.#Z,...Z.gradient}),this.#k()};Q.addEventListener("input",(J)=>{$(J),this.#x()}),Q.addEventListener("change",(J)=>{$(J),this.#b()})}#O(Q){return E1(this.#Z.stops,Q,this.#Z.interpolationSpace,this.#Z.hueInterpolation)}#R(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#K==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#L=Q,this.addEventListener("pointerenter",this.#H),this.addEventListener("pointermove",this.#T),this.addEventListener("pointerleave",this.#F),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#C)}#D(){if(!this.#L)return;this.#L.style.opacity="1"}#B(){if(!this.#L)return;this.#L.style.opacity="0"}#H=()=>{if(this.#J)return;this.#D()};#F=()=>{this.#B()};#T=(Q)=>{if(this.#J){this.#B();return}if(!this.#L||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#B();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#L.style.left=`${J*100}%`;let Z=this.#O(J);this.#L.setAttribute("color",Z),this.#D()};#P(){let Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#I(),this.#k(),this.#x(),this.#b()}#C=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#E=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#A){this.#A=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let K=Q.target.closest("fig-handle"),_=parseInt(K?.dataset.stopIndex,10);if(this.#P(),!isNaN(_))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===_)X.select();else X.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((K,_)=>K.position-_.position);let q=this.#Z.stops.findIndex((K)=>K.position===Z&&K.color===j);this.#I(),this.#k(),this.#x(),this.#b(),requestAnimationFrame(()=>{let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)_.click()})};#S(){if(!this.#Q)return;let Q=this.#Z.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#S()}#I(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){let J=this.#L;if(this.#Q.innerHTML=this.#N(),J)this.#Q.appendChild(J);this.#y(),this.#V(),requestAnimationFrame(()=>this.#S());return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#Y(j)),this.#K==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#y()}#y(){if(!this.#Q)return;let Q=this.#K==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#L)if(Q)this.#L.setAttribute("tip","add");else this.#L.removeAttribute("tip")}#V(){if(!this.#q||!this.#Q)return;this.#q.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),K=-1;for(let _=0;_<$.length;_++){if(J.has(_))continue;if($[_].position===j&&$[_].color.toUpperCase()===q){K=_;break}}if(K===-1){let _=1/0;for(let X=0;X<$.length;X++){if(J.has(X))continue;let Y=Math.abs($[X].position-j);if(Y<_)_=Y,K=X}}if(K!==-1)J.add(K),Z.dataset.stopIndex=K})}#k(){if(!this.#$)return;this.#$.setAttribute("background",this.#G())}#f(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);let q=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#A=!0,this.#I(),this.#k(),this.#x(),this.#B();let _=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(_)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==_)X.deselect()}),_.select(),_.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#k(),this.#x()}return}if(!this.#J)$.style.zIndex="5";this.#J=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,K=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let X=K>0?5/K*100:0;for(let Y=0;Y<this.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-q)<=X){q=this.#Z.stops[Y].position;break}}}if(this.#Z.stops[J].position=q,q!==j)$.style.left=`${q/100*K}px`;let _=$.closest("fig-tooltip");if(_){if(_.text=`${Math.round(q)}%`,!_.hasAttribute("show"))_.setAttribute("show","true"),$.hideColorTip()}this.#k(),this.#x()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt($.dataset.stopIndex,10);if(!isNaN(X)&&this.#Z.stops[X]){if(this.#Z.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#Z.stops[X].opacity=Q.detail.opacity;$.setAttribute("color",this.#Y(this.#Z.stops[X])),this.#k(),this.#b()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),K=this.#Q.getBoundingClientRect().width,_=K>0?5/K*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-q)<=_){q=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=q,$.style.left=`${q/100*K}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#w(),this.#k(),this.#b(),requestAnimationFrame(()=>{this.#J=!1})}),this.#q=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#k(),this.#x()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#q.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:f0(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#W(),this.#k(),this.#I();break;case"disabled":this.#d();break;case"edit":if(this.#M(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#y();break}}#d(){let Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class a extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",c()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",a);class w0 extends a{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",w0);class b0 extends a{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",b0);class v0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}getOffset(){return parseInt(this.getAttribute("offset")??this._defaultOffset)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");let Q=this.getAttribute("open")==="true"||this.getAttribute("open")==="";if(this.hasAttribute("open")&&!Q)this.removeAttribute("open");if(!Q)this.close();requestAnimationFrame(()=>{if(this.addCloseListeners(),this.applyPosition(),Q)this.showToast()})}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${this.getOffset()}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>{this.hideToast()},Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let $=(getComputedStyle(document.documentElement).colorScheme||"").includes("dark");this.style.colorScheme=$?"light":"dark"}showToast(){this._resolveAutoTheme(),this.show(),this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){this.clearAutoClose(),this.close(),this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme")if(J==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme")}}$0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental"];#$=!1;#Q=null;#J=null;#j=null;#q=null;#Z=!1;#_=this.#Y.bind(this);#X=this.#N.bind(this);#K=this.#L.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#q=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#q!==null,this.#q)this.#q.remove();if(this.#U(),this.#W(),this.hasAttribute("disabled"))this.#O(!0)}disconnectedCallback(){this.#G()}#U(){let Q=this.#z(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#$?"":`<fig-dropdown type="dropdown"${j}>${Q.map((K)=>`<option>${K.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
188
|
+
<fig-chit background="${this.#N()}"${Q?" disabled":""}></fig-chit>
|
|
189
|
+
</fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#F(),this.#W();return}if(this.innerHTML=`
|
|
190
|
+
<fig-chit background="${this.#N()}"${Q?" disabled":""}></fig-chit>
|
|
191
|
+
${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#D()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#k(),this.#n();this.#W()}#F(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#q=this.#L({...this.#q,...Z.gradient}),this.#I()};Q.addEventListener("input",(J)=>{$(J),this.#m()}),Q.addEventListener("change",(J)=>{$(J),this.#u()})}#A(Q){return T1(this.#q.stops,Q,this.#q.interpolationSpace,this.#q.hueInterpolation)}#k(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#U==="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.#O=Q,this.addEventListener("pointerenter",this.#S),this.addEventListener("pointermove",this.#C),this.addEventListener("pointerleave",this.#P),this.addEventListener("click",this.#b),this.addEventListener("dblclick",this.#V)}#E(){if(!this.#O)return;this.#O.style.opacity="1"}#T(){if(!this.#O)return;this.#O.style.opacity="0"}#S=()=>{if(this.#j)return;this.#E()};#P=()=>{this.#T()};#C=(Q)=>{if(this.#j){this.#T();return}if(!this.#O||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#T();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#O.style.left=`${J*100}%`;let Z=this.#A(J);this.#O.setAttribute("color",Z),this.#E()};#f(){let Q=this.#q.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#q.stops[$].position=Math.round($/(Q-1)*100);this.#w(),this.#I(),this.#m(),this.#u()}#V=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#f(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#b=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#H){this.#H=!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.#f(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#q.stops.push({position:Z,color:j,opacity:100}),this.#q.stops.sort((_,X)=>_.position-X.position);let q=this.#q.stops.findIndex((_)=>_.position===Z&&_.color===j);this.#w(),this.#I(),this.#m(),this.#u(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#y(){if(this.#_=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#q.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#y()}#x(){if(this.#_!==null)return;this.#_=requestAnimationFrame(()=>this.#y())}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#q.stops;if(Q.length!==$.length){let J=this.#O;if(this.#Q.innerHTML=this.#D(),J)this.#Q.appendChild(J);this.#g(),this.#v(),this.#x();return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#z(j)),this.#U==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#g()}#g(){if(!this.#Q)return;let Q=this.#U==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#O)if(Q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#v(){if(!this.#Z||!this.#Q)return;this.#Z.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#h(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#q.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<$.length;X++){if(J.has(X))continue;if($[X].position===j&&$[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<$.length;Y++){if(J.has(Y))continue;let K=Math.abs($[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)J.add(_),Z.dataset.stopIndex=_})}#I(){if(!this.#$)return;this.#$.setAttribute("background",this.#N())}#n(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#A(J);this.#q.stops.push({position:Z,color:j,opacity:100}),this.#q.stops.sort((Y,K)=>Y.position-K.position);let q=this.#q.stops.findIndex((Y)=>Y.position===Z&&Y.color===j);this.#H=!0,this.#w(),this.#I(),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 $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#q.stops[Y]){if(this.#q.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#q.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#z(this.#q.stops[Y])),this.#I(),this.#m()}return}if(!this.#j)$.style.zIndex="5";this.#j=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#q.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/d.SHIFT_SNAP)*d.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#q.stops.length;K++){if(K===J)continue;if(Math.abs(this.#q.stops[K].position-q)<=Y){q=this.#q.stops[K].position;break}}}if(this.#q.stops[J].position=q,q!==j)$.style.left=`${q/100*_}px`;let X=$.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),$.hideColorTip()}this.#I(),this.#m()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.dataset.stopIndex,10);if(!isNaN(Y)&&this.#q.stops[Y]){if(this.#q.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#q.stops[Y].opacity=Q.detail.opacity;$.setAttribute("color",this.#z(this.#q.stops[Y])),this.#I(),this.#u()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#q.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#q.stops.length;Y++){if(Y===Z)continue;if(Math.abs(this.#q.stops[Y].position-q)<=X){q=this.#q.stops[Y].position;break}}this.#q.stops[Z].position=q,$.style.left=`${q/100*_}px`,this.#q.stops.sort((Y,K)=>Y.position-K.position),this.#h(),this.#I(),this.#u(),requestAnimationFrame(()=>{this.#j=!1})}),this.#Z=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#q.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#q.stops[Z].color)this.#q.stops[Z].color=j,this.#I(),this.#m()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:x0(this.#L(this.#q))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#X){let $=this.#K();if($){$.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#R(),this.#I(),this.#w();break;case"disabled":this.#s();break;case"edit":if(this.#B(),this.#X)document.addEventListener("keydown",this.#G);else document.removeEventListener("keydown",this.#G);break;case"mode":this.#g();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#W(),this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",d);class t extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#_();let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}#J(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Z(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#_(){let Q=this.#J("checked"),$=this.#J("indeterminate")&&!Q,J=this.#J("disabled");if(this.input.checked=Q,this.input.indeterminate=$,this.input.disabled=J,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),$)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Z()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#j(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.#J("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#_();break;case"indeterminate":this.#_();break;case"disabled":this.#_();break;case"name":this.input.setAttribute("name",J||this.name);break;case"value":this.input.value=J||"";break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Z(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",t);class b0 extends t{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",b0);class v0 extends t{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",v0);class h0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#$=!1;#Q=null;#j=null;#J=null;#Z=null;#_=!1;#q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Y=this.#G.bind(this);#X=this.#M.bind(this);#U=this.#R.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#K(),this.#W(),this.hasAttribute("disabled"))this.#F(!0)}disconnectedCallback(){this.#L()}#K(){let Q=this.#D(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#H(),_=this.#$?"":`<fig-dropdown type="dropdown" label="${q}"${j}>${Q.map((X)=>`<option>${X.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
190
192
|
<fig-input-text placeholder="${$}" value="${J}"></fig-input-text>
|
|
191
193
|
<fig-button type="select" variant="input" icon>
|
|
192
194
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
193
195
|
<path d="M5.87868 7.12132L8 9.24264L10.1213 7.12132" stroke="currentColor" stroke-opacity="0.9" stroke-linecap="round"/>
|
|
194
196
|
</svg>
|
|
195
|
-
${
|
|
197
|
+
${_}
|
|
196
198
|
</fig-button>
|
|
197
|
-
</div>`,this.#Q=this.querySelector("fig-input-text"),this.#j=this.querySelector("fig-button"),this.#$&&this.#q&&this.#j){if(!this.#q.hasAttribute("type"))this.#q.setAttribute("type","dropdown");if(Z)this.#q.setAttribute("experimental",Z);this.#j.append(this.#q)}this.#J=this.querySelector("fig-dropdown")}#W(){this.#J?.addEventListener("input",this.#_),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#K)}#G(){this.#J?.removeEventListener("input",this.#_),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#K)}#Y(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#Q)this.#Q.setAttribute("value",$);this.#A(),this.#M()}#N(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#A()}#L(Q){Q.stopPropagation();let $=Q.target.value??"";this.#Z=!0,this.setAttribute("value",$),this.#Z=!1,this.#M()}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#M(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#z(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#J&&!this.#$){let Z=this.#z();this.#J.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");break;case"value":if(!this.#Z&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#O(J!==null&&J!=="false");break;case"experimental":if(this.#J){if(J)this.#J.setAttribute("experimental",J);else if(!this.#$)this.#J.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",g0);class Z0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#K.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#j()}#j(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#q(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=J0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#q(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#Z(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="<div></div>",this.input=null}else if(this.#$==="color"&&this.input){let q=this.#Z(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#J){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#j()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",Z0);class h0 extends Z0{}customElements.define("fig-swatch",h0);class n extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;#_=this.#y.bind(this);#X=this.#w.bind(this);#K=this.#k.bind(this);#U=this.#f.bind(this);#W=null;#G=null;#Y=null;#N=null;#L=null;#A=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#Z}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#D(),this.#H(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#S()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#_),this.#O(),this.#E(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#K),this.#Q.removeEventListener("ended",this.#U)}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#D(){let Q=this.#R();if(Q){if(this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}this.#Q=Q;return}let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.prepend(J),this.#Q=J,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#K),this.#Q.addEventListener("ended",this.#U);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.prepend(J),this.#Q=J}}#B(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#H(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#Q.alt=this.getAttribute("alt")||"";return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#B("autoplay",!1),this.#Q.loop=this.#B("loop",!1),this.#Q.muted=this.#B("muted",!1),this.#Q.playsInline=!0,this.#F()}get mediaEl(){return this.#Q}#F(){if(this.mediaKind!=="video"){this.#E();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#E(),this.#W=Q;this.#P();return}if(this.#B("controls",!1))this.#T();else this.#E()}#T(){if(this.#W&&this.#W.isConnected){this.#P();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),Q.setAttribute("overlay",""),this.append(Q),this.#W=Q,this.#P()}#P(){if(!this.#W||!this.#Q)return;if(this.#G===this.#Q&&this.#Y===this.#W)return;this.#C();let Q=this.#W,$=this.#Q;this.#G=$,this.#Y=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let _=$.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})},q=()=>$.pause?.(),K=(_)=>{let X=Number(_?.detail?.time);if(!Number.isFinite(X))return;J=X;try{$.currentTime=X}catch{}};this.#N=Z,this.#L=j,this.#A=q,this.#M=K,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",K),Z()}#C(){let Q=this.#G,$=this.#Y;if(Q&&this.#N)Q.removeEventListener("play",this.#N),Q.removeEventListener("pause",this.#N),Q.removeEventListener("ended",this.#N),Q.removeEventListener("timeupdate",this.#N),Q.removeEventListener("loadedmetadata",this.#N),Q.removeEventListener("durationchange",this.#N),Q.removeEventListener("seeked",this.#N);if($){if(this.#L)$.removeEventListener("play",this.#L);if(this.#A)$.removeEventListener("pause",this.#A);if(this.#M)$.removeEventListener("seek",this.#M)}this.#G=null,this.#Y=null,this.#N=null,this.#L=null,this.#A=null,this.#M=null}#E(){if(this.#C(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#S(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#Z?.name)Q.setAttribute("filename",this.#Z.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#_),this.append(Q),this.#J=Q}#I(){if(this.#J)this.#J.removeEventListener("change",this.#_),this.#J.remove(),this.#J=null}#y(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#Z=null,this.#q=null,J)this.src="";if(this.#H(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#Z=$,this.#j=URL.createObjectURL($),this.#q=this.#j,this.#H(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#V(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#V("play")}#k(){this.#V("pause")}#f(){this.#V("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#j);if(this.#$=Z,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#Z=null;if(this.#H(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#Z?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#Z.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#D(),this.#H(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(Q==="alt"&&this.#Q&&this.#Q.tagName==="IMG")this.#Q.alt=J||"";if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#S();else if(!Z)this.#I()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#H()}}customElements.define("fig-media",n);class m0 extends n{get mediaKind(){return"image"}}customElements.define("fig-image",m0);class c0 extends n{get mediaKind(){return"video"}}customElements.define("fig-video",c0);class p0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#q=!1;#Z=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#K(),this.#U()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#Z)return;if(Q==="playing")this.#K();if(Q==="duration"||Q==="time")this.#U()}#_(){if(this.#Z)return;this.#Z=!0;let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=b("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(K)=>{K.preventDefault(),K.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","0.1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full","");let j=document.createElement("label");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(K)=>{let _=K.currentTarget,X=Number(_?.value);if(!Number.isFinite(X))return;this.#q=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#q=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#J=Z,this.#j=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#U(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let $=this.time;if(!this.#q)this.#J.setAttribute("value",String($));if(this.#j)this.#j.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",p0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#J=null;#j=null;#q=null;#Z=null;get files(){return this.#Z}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#Z&&this.#Z.length>0){if(this.#Z.length===1)return this.#Z[0].name;return`${this.#Z.length} files`}return this.#_}connectedCallback(){this.#N(),this.addEventListener("dragover",this.#W),this.addEventListener("dragleave",this.#G),this.addEventListener("drop",this.#Y)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#J?.removeEventListener("click",this.#U),this.removeEventListener("dragover",this.#W),this.removeEventListener("dragleave",this.#G),this.removeEventListener("drop",this.#Y)}attributeChangedCallback(Q,$,J){if($===J)return;this.#N()}clear(){if(this.#Z=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#N(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#Z,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#Z=this.#$.files,this.removeAttribute("url"),this.#N(),this.#X()};#U=(Q)=>{Q.stopPropagation(),this.clear()};#W=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#q)this.#q.dataset.prevText=this.#q.textContent,this.#q.textContent="Drop file"}};#G=()=>{if(this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText};#Y=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#q&&this.#q.dataset.prevText!==void 0)this.#q.textContent=this.#q.dataset.prevText,delete this.#q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let K="."+q.name.split(".").pop().toLowerCase(),_=q.type.toLowerCase();return j.some((X)=>X===K||X===_||X.endsWith("/*")&&_.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#Z=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#N(),this.#X()};#N(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#Z&&this.#Z.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let K=Q?`Accepts ${Q.split(",").map((L)=>L.trim()).join(", ")}`:"";if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.className="fig-input-file-filename",J)this.#q.setAttribute("disabled","");let _=document.createElement("fig-truncate");_.setAttribute("position","middle"),_.setAttribute("tooltip","");let X=this.value,Y=X.lastIndexOf(".");if(Y>0)_.setAttribute("tail",X.slice(Y));if(_.textContent=X,this.#q.appendChild(_),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K),this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");this.#J.replaceChildren(b("minus")),this.#J.addEventListener("click",this.#U),N.appendChild(this.#J),this.appendChild(N)}else{let K=Q?`Accepts ${Q.split(",").map((_)=>_.trim()).join(", ")}`:"";if(K)this.#j=document.createElement("fig-tooltip"),this.#j.setAttribute("text",K);if(this.#q=document.createElement("fig-button"),this.#q.setAttribute("variant",j),this.#q.setAttribute("type","upload"),this.#q.textContent=$,J)this.#q.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#q.appendChild(this.#$),this.#j)this.#j.appendChild(this.#q),this.appendChild(this.#j);else this.appendChild(this.#q)}}}customElements.define("fig-input-file",u0);class w extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#j="bezier";#q=2;#Z=null;#_=null;#X=null;#K=null;#U=null;#W=null;#G=null;#Y=null;#N=null;#L=null;#A=null;#M=null;#z=null;#O=0.8;#R=200;#D=200;#B=null;#H=null;#F=null;#T=5;#P=2;#C=10;#E=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#q=parseInt(this.getAttribute("precision")||"2"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#M=this.#y(),this.#f(),this.#t()}disconnectedCallback(){if(this.#Z=null,this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(x(this,"--aspect-ratio",J),this.#_)this.#c(),this.#g();return}if(Q==="edit"){if(this.isConnected)this.#f();return}if(Q==="value"&&J){let Z=this.#j;if(this.#I(J),this.#M=this.#y(),Z!==this.#j&&this.#k())this.#f();else{if(this.#_)this.#g();this.#p(),this.#v()}}if(Q==="precision")this.#q=parseInt(J||"2")}get value(){if(this.#j==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}let Q=this.#q;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#j==="spring"){let $=this.#V(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#q;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#I(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#j="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#y(){if(this.#j==="bezier"){for(let $ of w.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of w.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#V(){let{stiffness:Q,damping:$,mass:J}=this.#J,Z=0.004,j=5,q=[],K=0,_=0;for(let X=0;X<=5;X+=0.004){let Y=-Q*(K-1)-$*_;if(_+=Y/J*0.004,K+=_*0.004,q.push({t:X,value:K}),X>0.1&&Math.abs(K-1)<0.0005&&Math.abs(_)<0.0005)break}return q}static#w(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,K=5,_=[],X=0,Y=0;for(let U=0;U<=5;U+=0.004){let A=-J*(X-1)-Z*Y;if(Y+=A/j*0.004,X+=Y*0.004,_.push({t:U,value:X}),U>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}let N=_[_.length-1].t||1,L=1;for(let U of _)if(U.value>L)L=U.value;let B=0;for(let U of _)if(U.value<B)B=U.value;let H=Math.max(L-B,1),M=6,G=$-M*2,z=Math.max(1,Math.floor(_.length/30)),R="";for(let U=0;U<_.length;U+=z){let A=M+_[U].t/N*G,D=M+(1-(_[U].value-B)/H)*G;R+=(U===0?"M":"L")+A.toFixed(1)+","+D.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let K=(j-12)/2,_=48,X=[],Y=(A,D,T,E,S)=>{let I=1-S;return I*I*I*A+3*I*I*S*D+3*I*S*S*T+S*S*S*E};for(let A=0;A<=48;A++){let D=A/48;X.push({x:Y(0,Q,J,1,D),y:Y(0,$,Z,1,D)})}let N=1/0,L=-1/0,B=1/0,H=-1/0;for(let A of X){if(A.x<N)N=A.x;if(A.x>L)L=A.x;if(A.y<B)B=A.y;if(A.y>H)H=A.y}let M=Math.max(L-N,0.000001),G=Math.max(H-B,0.000001),z=(A)=>K+(A-N)/M*12,R=(A)=>K+(1-(A-B)/G)*12,U="";for(let A=0;A<X.length;A++){let D=z(X[A].x),T=R(X[A].y);U+=`${A===0?"M":"L"}${D.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${U}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#k(){return this.getAttribute("edit")!=="false"}#f(){if(this.classList.toggle("spring-mode",this.#j==="spring"),this.classList.toggle("bezier-mode",this.#j!=="spring"),this.#J0(),this.innerHTML=this.#d(),this.#Z0(),this.#_)this.#r(),this.#c(),this.#g();this.#v(),this.#Y0()}static#x(Q){return String(Q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#b(){let Q="",$=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#J;Z=w.#w(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=w.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#d(){let $=this.#b();if(!this.#k())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#x(this.value)}" full></fig-input-text>`;if(this.#j==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
199
|
+
</div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$&&this.#Z&&this.#J){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(!this.#Z.hasAttribute("label"))this.#Z.setAttribute("label",q);if(Z)this.#Z.setAttribute("experimental",Z);this.#J.append(this.#Z)}this.#j=this.querySelector("fig-dropdown"),this.#B()}#W(){this.#j?.addEventListener("input",this.#Y),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#U)}#L(){this.#j?.removeEventListener("input",this.#Y),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#U)}#G(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#_=!0,this.setAttribute("value",$),this.#_=!1,this.#Q)this.#Q.setAttribute("value",$);this.#N(),this.#z()}#M(Q){Q.stopPropagation();let $=Q.target.value??"";this.#_=!0,this.setAttribute("value",$),this.#_=!1,this.#N()}#R(Q){Q.stopPropagation();let $=Q.target.value??"";this.#_=!0,this.setAttribute("value",$),this.#_=!1,this.#z()}#N(){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}}))}#D(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#H(){return`${this.#O()} options`}#B(){if(this.#Q)this.#q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#H())}#F(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#j&&!this.#$){let Z=this.#D();this.#j.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");this.#B();break;case"value":if(!this.#_&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#F(J!==null&&J!=="false");break;case"experimental":if(this.#j){if(J)this.#j.setAttribute("experimental",J);else if(!this.#$)this.#j.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#B();break}}}customElements.define("fig-combo-input",h0);class Z0 extends HTMLElement{#$="color";#Q=null;#j=!1;constructor(){super();this.#Q=this.#U.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#Y(),this.#J(),this.#X()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#_(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=J0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#q(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#Y(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#q(Q):Q,Z=this.#Z(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#_(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#$==="color"&&this.input){let q=this.#_(J);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#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 $=this.getAttribute("aria-labelledby"),J=this.getAttribute("aria-label")||"Color swatch",Z=this.getAttribute("aria-describedby");if($)this.input.setAttribute("aria-labelledby",$),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",J),this.input.removeAttribute("aria-labelledby");if(Z)this.input.setAttribute("aria-describedby",Z);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#U(Q){this.#j=!0,this.setAttribute("background",Q.target.value),this.#j=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#j){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#Y()}else if(Q==="alpha")this.#J();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-chit",Z0);class g0 extends Z0{}customElements.define("fig-swatch",g0);class n extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#_=null;#q=null;#Y=this.#y.bind(this);#X=this.#w.bind(this);#U=this.#g.bind(this);#K=this.#v.bind(this);#W=null;#L=null;#G=null;#M=null;#R=null;#N=null;#z=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#q}#D(){return this.#_||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#D())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#H(),this.#F(),this.#E(),this.#A(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#V()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Y),this.#O(),this.#f(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#_=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#U),this.#Q.removeEventListener("ended",this.#K)}#H(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let $=document.createElement("fig-preview");$.setAttribute("data-generated",""),this.prepend($),this.#j=$}#B(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#F(){let Q=this.#B();if(Q){if(this.#H(),this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#A();return}this.#H();let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.#j.append(J),this.#Q=J,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#U),this.#Q.addEventListener("ended",this.#K);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.#j.append(J),this.#Q=J}}#A(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)})}#k(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#E(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#D();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#A();return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#k("autoplay",!1),this.#Q.loop=this.#k("loop",!1),this.#Q.muted=this.#k("muted",!1),this.#Q.playsInline=!0,this.#A(),this.#T()}get mediaEl(){return this.#Q}#T(){if(this.mediaKind!=="video"){this.#f();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#f(),this.#W=Q;this.#P();return}if(this.#k("controls",!1))this.#S();else this.#f()}#S(){if(this.#W&&this.#W.isConnected){this.#P();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#W=Q,this.#P()}#P(){if(!this.#W||!this.#Q)return;if(this.#L===this.#Q&&this.#G===this.#W)return;this.#C();let Q=this.#W,$=this.#Q;this.#L=$,this.#G=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let X=$.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>$.pause?.(),_=(X)=>{let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;J=Y;try{$.currentTime=Y}catch{}};this.#M=Z,this.#R=j,this.#N=q,this.#z=_,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),Z()}#C(){let Q=this.#L,$=this.#G;if(Q&&this.#M)Q.removeEventListener("play",this.#M),Q.removeEventListener("pause",this.#M),Q.removeEventListener("ended",this.#M),Q.removeEventListener("timeupdate",this.#M),Q.removeEventListener("loadedmetadata",this.#M),Q.removeEventListener("durationchange",this.#M),Q.removeEventListener("seeked",this.#M);if($){if(this.#R)$.removeEventListener("play",this.#R);if(this.#N)$.removeEventListener("pause",this.#N);if(this.#z)$.removeEventListener("seek",this.#z)}this.#L=null,this.#G=null,this.#M=null,this.#R=null,this.#N=null,this.#z=null}#f(){if(this.#C(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#V(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#q?.name)Q.setAttribute("filename",this.#q.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#Y),this.#H(),this.#j.append(Q),this.#J=Q}#b(){if(this.#J)this.#J.removeEventListener("change",this.#Y),this.#J.remove(),this.#J=null}#y(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;if(this.#q=null,this.#_=null,J)this.src="";if(this.#E(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#q=$,this.#Z=URL.createObjectURL($),this.#_=this.#Z,this.#E(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#x(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#x("play")}#g(){this.#x("pause")}#v(){this.#x("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#_||Z===this.#Z);if(this.#$=Z,this.#Z&&!j)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#_=null,this.#q=null;if(this.#E(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#q?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#q.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#F(),this.#E(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#A();if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#V();else if(!Z)this.#b()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#E()}}customElements.define("fig-media",n);class m0 extends n{get mediaKind(){return"image"}}customElements.define("fig-image",m0);class c0 extends n{get mediaKind(){return"video"}}customElements.define("fig-video",c0);class p0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=!1;#_=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#q(),this.#U(),this.#K()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#_)return;if(Q==="playing")this.#U();if(Q==="duration"||Q==="time")this.#K()}#q(){if(this.#_)return;if(this.#_=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=v("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full",""),Z.setAttribute("aria-label","Seek"),Z.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#Y(this.time);let q=(_)=>{let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#Z=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#Z=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#j=Z,this.#J=j}#Y(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#X(Q,$=0){let J=this.#Y(Q);if(!Number.isFinite($)||$<=0)return J;return`${J} of ${this.#Y($)}`}#U(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#j)return;let Q=this.duration;if(Number(this.#j.getAttribute("max"))!==Q)this.#j.setAttribute("max",String(Q));let $=this.time;if(!this.#Z)this.#j.setAttribute("value",String($));if(this.#j.setAttribute("aria-valuetext",this.#X($,Q)),this.#J)this.#J.textContent=this.#Y($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",p0);class u0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#j=null;#J=null;#Z=null;#_=null;get files(){return this.#_}get#q(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#_&&this.#_.length>0){if(this.#_.length===1)return this.#_[0].name;return`${this.#_.length} files`}return this.#q}connectedCallback(){this.#G(),this.addEventListener("dragover",this.#K),this.addEventListener("dragleave",this.#W),this.addEventListener("drop",this.#L)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#X),this.#j?.removeEventListener("click",this.#U),this.removeEventListener("dragover",this.#K),this.removeEventListener("dragleave",this.#W),this.removeEventListener("drop",this.#L)}attributeChangedCallback(Q,$,J){if($===J)return;this.#G()}clear(){if(this.#_=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#G(),this.#Y({cleared:!0})}#Y(Q={}){let $={files:this.#_,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#X=()=>{if(this.#$.files.length>0)this.#_=this.#$.files,this.removeAttribute("url"),this.#G(),this.#Y()};#U=(Q)=>{Q.stopPropagation(),this.clear()};#K=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#W=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#L=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.slice(0,-1)))})}if(!this.hasAttribute("multiple"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#_=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#G(),this.#Y()};#G(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",q=this.#_&&this.#_.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((L)=>L.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#Z.appendChild(X),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#X),this.#Z.appendChild(this.#$),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",J)this.#j.setAttribute("disabled","");this.#j.replaceChildren(v("minus")),this.#j.addEventListener("click",this.#U),N.appendChild(this.#j),this.appendChild(N)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#X),this.#Z.appendChild(this.#$),this.#J)this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",u0);class b extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#J="bezier";#Z=2;#_=null;#q=null;#Y=null;#X=null;#U=null;#K=null;#W=null;#L=null;#G=null;#M=null;#R=null;#N=null;#z=null;#D=0.8;#O=200;#H=200;#B=null;#F=null;#A=null;#k=5;#E=2;#T=10;#S=10;#P=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#C(Q);this.#N=this.#f(),this.#x(),this.#u()}disconnectedCallback(){if(this.#_=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",J),this.#q)this.#s(),this.#c();return}if(Q==="edit"){if(this.isConnected)this.#x();return}if(Q==="value"&&J){let Z=this.#J;if(this.#C(J),this.#N=this.#f(),Z!==this.#J&&this.#y())this.#x();else{if(this.#q)this.#c();this.#l(),this.#p()}}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#J==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#j;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let $=this.#V(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#N}set value(Q){this.setAttribute("value",Q)}#C(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#J="spring",this.#j.stiffness=parseFloat($[1]),this.#j.damping=parseFloat($[2]),this.#j.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#f(){if(this.#J==="bezier"){for(let $ of b.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of b.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#j.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#j.damping-$.spring.damping)<0.001&&Math.abs(this.#j.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#V(){let{stiffness:Q,damping:$,mass:J}=this.#j,Z=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-$*X;if(X+=K/J*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#b(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let G=0;G<=5;G+=0.004){let M=-J*(Y-1)-Z*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:G,value:Y}),G>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let N=X[X.length-1].t||1,L=1;for(let G of X)if(G.value>L)L=G.value;let B=0;for(let G of X)if(G.value<B)B=G.value;let H=Math.max(L-B,1),O=6,U=$-O*2,z=Math.max(1,Math.floor(X.length/30)),A="";for(let G=0;G<X.length;G+=z){let M=O+X[G].t/N*U,D=O+(1-(X[G].value-B)/H)*U;A+=(G===0?"M":"L")+M.toFixed(1)+","+D.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,D,T,P,S)=>{let f=1-S;return f*f*f*M+3*f*f*S*D+3*f*S*S*T+S*S*S*P};for(let M=0;M<=48;M++){let D=M/48;Y.push({x:K(0,Q,J,1,D),y:K(0,$,Z,1,D)})}let N=1/0,L=-1/0,B=1/0,H=-1/0;for(let M of Y){if(M.x<N)N=M.x;if(M.x>L)L=M.x;if(M.y<B)B=M.y;if(M.y>H)H=M.y}let O=Math.max(L-N,0.000001),U=Math.max(H-B,0.000001),z=(M)=>_+(M-N)/O*12,A=(M)=>_+(1-(M-B)/U)*12,G="";for(let M=0;M<Y.length;M++){let D=z(Y[M].x),T=A(Y[M].y);G+=`${M===0?"M":"L"}${D.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${G}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#y(){return this.getAttribute("edit")!=="false"}#x(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#I(),this.innerHTML=this.#v(),this.#n(),this.#q)this.#m(),this.#s(),this.#c();this.#p(),this.#L0()}static#w(Q){return String(Q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#g(){let Q="",$=void 0;for(let J of b.PRESETS){if(!this.#y()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#j;Z=b.#b(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=b.curveIcon(...q)}let j=J.name===this.#N?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#v(){let $=this.#g();if(!this.#y())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#w(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
198
200
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
199
201
|
<line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
|
|
200
202
|
<line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
|
|
201
203
|
<path class="fig-easing-curve-path"/>
|
|
202
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="bounce" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
203
|
-
<foreignObject class="fig-easing-curve-handle fig-easing-curve-duration-bar" data-handle="duration" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
204
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="bounce" width="20" height="20"><fig-handle size="small" drag aria-label="Spring bounce handle"></fig-handle></foreignObject>
|
|
205
|
+
<foreignObject class="fig-easing-curve-handle fig-easing-curve-duration-bar" data-handle="duration" width="20" height="20"><fig-handle size="small" drag drag-axes="x" aria-label="Spring duration handle"></fig-handle></foreignObject>
|
|
204
206
|
</svg></div>${J}`;return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
205
207
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
206
208
|
<line class="fig-easing-curve-diagonal" x1="0" y1="200" x2="200" y2="0"/>
|
|
207
209
|
<line class="fig-easing-curve-arm" data-arm="1"/>
|
|
208
210
|
<line class="fig-easing-curve-arm" data-arm="2"/>
|
|
209
211
|
<path class="fig-easing-curve-path"/>
|
|
210
|
-
<circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#
|
|
211
|
-
<circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#
|
|
212
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
213
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
214
|
-
</svg></div>${J}`}#l(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#J0(){this.#P=this.#l("--easing-bezier-endpoint-radius",this.#P),this.#S=this.#l("--easing-duration-bar-radius",this.#S)}#Z0(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#U=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#G=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector('[data-endpoint="start"]'),this.#N=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#A=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#B=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#r(){let Q=this.#W?.querySelector("fig-handle"),$=this.#G?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#T*2,Z=Q.offsetHeight||this.#T*2;this.#T=Math.max(J,Z)/2,this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#C,Z=$.offsetHeight||this.#E;if(this.#j==="spring")this.#C=J,this.#E=Z;this.#G.setAttribute("width",J),this.#G.setAttribute("height",Z)}}#t(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#c())this.#g()}),this.#F.observe(this)}#c(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#R||J!==this.#D;return this.#R=$,this.#D=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#h(Q,$){return{x:Q*this.#R,y:(1-$)*this.#D}}#a(Q,$){return{x:Q/this.#R,y:1-$/this.#D}}#o={minVal:0,maxVal:1.2,totalTime:1};#m(Q,$){let Z=this.#D-40,{minVal:j,maxVal:q}=this.#o,K=q-j||1;return{x:Q*this.#R,y:20+(1-($-j)/K)*Z}}#g(){if(this.#c(),this.#j==="spring")this.#e();else this.#n()}#i(){this.#K?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===1),this.#U?.classList.toggle("is-active",this.#j==="bezier"&&this.#Z===2)}#n(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#D),this.#H.setAttribute("x2",this.#R),this.#H.setAttribute("y2","0");let Q=this.#h(0,0),$=this.#h(this.#$.x,this.#$.y),J=this.#h(this.#Q.x,this.#Q.y),Z=this.#h(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#U.setAttribute("x1",Z.x),this.#U.setAttribute("y1",Z.y),this.#U.setAttribute("x2",J.x),this.#U.setAttribute("y2",J.y);let j=this.#T;if(this.#W.setAttribute("x",$.x-j),this.#W.setAttribute("y",$.y-j),this.#G.setAttribute("x",J.x-j),this.#G.setAttribute("y",J.y-j),this.#Y)this.#Y.setAttribute("cx",Q.x),this.#Y.setAttribute("cy",Q.y);if(this.#N)this.#N.setAttribute("cx",Z.x),this.#N.setAttribute("cy",Z.y)}#e(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#R),this.#B.setAttribute("height",this.#D);let Q=this.#V();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let G of Q){if(G.value<J)J=G.value;if(G.value>Z)Z=G.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let K=Math.max(0.05,Math.min(0.95,this.#O)),_="";for(let G=0;G<Q.length;G++){let z=Q[G].t/$*K,R=this.#m(z,Q[G].value);_+=(G===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let X=this.#m(K,1),Y=this.#m(1,1);if(_+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${Y.x.toFixed(1)},${Y.y.toFixed(1)}`,this.#X.setAttribute("d",_),this.#z){let G=this.#m(0,1),z=this.#m(1,1);this.#z.setAttribute("x1",G.x),this.#z.setAttribute("y1",G.y),this.#z.setAttribute("x2",z.x),this.#z.setAttribute("y2",z.y)}let N=this.#Q0(Q),L=N.t/$*K,B=this.#m(L,N.value),H=this.#T;this.#W.setAttribute("x",B.x-H),this.#W.setAttribute("y",B.y-H);let M=this.#m(K,1);this.#G.setAttribute("x",M.x-this.#C/2),this.#G.setAttribute("y",M.y-this.#E/2)}#Q0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#p(){if(!this.#L)return;this.#L.value=this.#M,this.#X0()}#v(){if(!this.#A)return;this.#A.setAttribute("value",this.value)}#s(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#K0(Q,$){let J=this.#s(Q);if(!J){if($==="change")this.#v();return}let Z=this.#j;if(this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#y(),Z!==this.#j)this.#f();else if(this.#g(),this.#p(),$==="change")this.#v();this.#u($)}#$0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#X0(){if(!this.#L)return;if(!this.#k())return;let Q=w.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=w.#w(this.#J);this.#$0(this.#L,"Custom bezier",Q),this.#$0(this.#L,"Custom spring",$),this.#$0(this.#L.select,"Custom bezier",Q),this.#$0(this.#L.select,"Custom spring",$)}#u(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#j,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#Y0(){if(this.#_&&this.#j==="bezier"){this.#W.addEventListener("pointerdown",($)=>this.#j0($,1)),this.#G.addEventListener("pointerdown",($)=>this.#j0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#j0($,this.#W0($))})}else if(this.#_){this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#q0($,"bounce")}),this.#G.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#q0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#q0($,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let $=Q.detail,J=w.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#j!=="bezier")this.#j="bezier",this.#f();else if(this.#_)this.#g(),this.#v()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#M=$,this.#j!=="spring")this.#j="spring",this.#f();else if(this.#_)this.#g(),this.#v()}this.#u("input"),this.#u("change")});if(this.#A)this.#A.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#K0($,"input")}),this.#A.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#K0($,"change")})}#_0(Q){let $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#W0(Q){return this.#_0(Q).x<=this.#R/2?1:2}#j0(Q,$){Q.preventDefault(),this.#Z=$,this.#i();let J=(j)=>{if(!this.#Z)return;let q=this.#_0(j),K=this.#a(q.x,q.y);if(K.x=Math.round(K.x*100)/100,K.y=Math.round(K.y*100)/100,K.x=Math.max(0,Math.min(1,K.x)),this.#Z===1)this.#$.x=K.x,this.#$.y=K.y;else this.#Q.x=K.x,this.#Q.y=K.y;this.#g(),this.#M=this.#y(),this.#p(),this.#v(),this.#u("input")},Z=()=>{this.#Z=null,this.#i(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#u("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#q0(Q,$){Q.preventDefault(),this.#Z=$;let J=this.#J.damping,Z=this.#J.stiffness,j=this.#O,q=Q.clientY,K=Q.clientX,_=(Y)=>{if(!this.#Z)return;if($==="bounce"){let N=Y.clientY-q;this.#J.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=Y.clientX-K;this.#O=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#g(),this.#M=this.#y(),this.#p(),this.#v(),this.#u("input")},X=()=>{this.#Z=null,document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",X),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",w);class s0 extends HTMLElement{#$=0;#Q=0;#J=0;#j=1;#q=!1;#Z=!1;#_=null;#X=null;#K=null;#U=null;#W=[];#G={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"1"),x(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),x(this,"--perspective",this.getAttribute("perspective")),x(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#Y(this.getAttribute("transform-origin")),this.#A(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#M(Q);this.#z(),this.#L(this.getAttribute("selected")),this.#N()}disconnectedCallback(){if(this.#q=!1,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#U)}#Y(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#N(){if(!this.#X)return;this.#X.style.cursor=this.#F?"":"default"}#L(Q){if(!this.#_)return;let $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#A(Q){if(!Q||!Q.trim()){this.#W=[];return}let $=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="perspective"){x(this,"--perspective",J);return}if(Q==="perspective-origin"){x(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#Y(J);return}if(Q==="selected"){this.#L(J);return}if(Q==="drag"){this.#N();return}if(Q==="fields"){if(this.#A(J),this.#_)this.#z();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#q)return;this.#M(J),this.#R(),this.#O()}if(Q==="precision")this.#j=parseInt(J||"1")}get value(){let Q=this.#j;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#M(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#z(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#W.map((Z)=>`<fig-input-number
|
|
212
|
+
<circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#E}"/>
|
|
213
|
+
<circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#E}"/>
|
|
214
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" drag aria-label="First easing control point"></fig-handle></foreignObject>
|
|
215
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" drag aria-label="Second easing control point"></fig-handle></foreignObject>
|
|
216
|
+
</svg></div>${J}`}#h(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#I(){this.#E=this.#h("--easing-bezier-endpoint-radius",this.#E),this.#P=this.#h("--easing-duration-bar-radius",this.#P)}#n(){this.#q=this.querySelector(".fig-easing-curve-svg"),this.#Y=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#U=this.querySelector('[data-arm="2"]'),this.#K=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#W=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#L=this.querySelector('[data-endpoint="start"]'),this.#G=this.querySelector('[data-endpoint="end"]'),this.#M=this.querySelector(".fig-easing-curve-dropdown"),this.#R=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#B=this.querySelector(".fig-easing-curve-bounds"),this.#F=this.querySelector(".fig-easing-curve-diagonal")}#m(){let Q=this.#K?.querySelector("fig-handle"),$=this.#W?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#k*2,Z=Q.offsetHeight||this.#k*2;this.#k=Math.max(J,Z)/2,this.#K.setAttribute("width",J),this.#K.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#T,Z=$.offsetHeight||this.#S;if(this.#J==="spring")this.#T=J,this.#S=Z;this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}}#u(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#s())this.#c()}),this.#A.observe(this)}#s(){if(!this.#q)return!1;let Q=this.#q.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#O||J!==this.#H;return this.#O=$,this.#H=J,this.#q.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#a(Q,$){return{x:Q*this.#O,y:(1-$)*this.#H}}#Q0(Q,$){return{x:Q/this.#O,y:1-$/this.#H}}#o={minVal:0,maxVal:1.2,totalTime:1};#d(Q,$){let Z=this.#H-40,{minVal:j,maxVal:q}=this.#o,_=q-j||1;return{x:Q*this.#O,y:20+(1-($-j)/_)*Z}}#c(){if(this.#s(),this.#J==="spring")this.#Z0();else this.#$0()}#e(){this.#X?.classList.toggle("is-active",this.#J==="bezier"&&this.#_===1),this.#U?.classList.toggle("is-active",this.#J==="bezier"&&this.#_===2)}#$0(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#O),this.#B.setAttribute("height",this.#H);if(this.#F)this.#F.setAttribute("x1","0"),this.#F.setAttribute("y1",this.#H),this.#F.setAttribute("x2",this.#O),this.#F.setAttribute("y2","0");let Q=this.#a(0,0),$=this.#a(this.#$.x,this.#$.y),J=this.#a(this.#Q.x,this.#Q.y),Z=this.#a(1,1);this.#Y.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",$.x),this.#X.setAttribute("y2",$.y),this.#U.setAttribute("x1",Z.x),this.#U.setAttribute("y1",Z.y),this.#U.setAttribute("x2",J.x),this.#U.setAttribute("y2",J.y);let j=this.#k;if(this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#W.setAttribute("x",J.x-j),this.#W.setAttribute("y",J.y-j),this.#L)this.#L.setAttribute("cx",Q.x),this.#L.setAttribute("cy",Q.y);if(this.#G)this.#G.setAttribute("cx",Z.x),this.#G.setAttribute("cy",Z.y);this.#J0()}#J0(){if(!this.#q||!this.#K||!this.#W)return;let Q=this.#$.y>=this.#Q.y?[this.#K,this.#W]:[this.#W,this.#K];for(let $ of Q)this.#q.append($)}#Z0(){if(this.#B)this.#B.setAttribute("x","0"),this.#B.setAttribute("y","0"),this.#B.setAttribute("width",this.#O),this.#B.setAttribute("height",this.#H);let Q=this.#V();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let U of Q){if(U.value<J)J=U.value;if(U.value>Z)Z=U.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let _=Math.max(0.05,Math.min(0.95,this.#D)),X="";for(let U=0;U<Q.length;U++){let z=Q[U].t/$*_,A=this.#d(z,Q[U].value);X+=(U===0?"M":"L")+A.x.toFixed(1)+","+A.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.#Y.setAttribute("d",X),this.#z){let U=this.#d(0,1),z=this.#d(1,1);this.#z.setAttribute("x1",U.x),this.#z.setAttribute("y1",U.y),this.#z.setAttribute("x2",z.x),this.#z.setAttribute("y2",z.y)}let N=this.#j0(Q),L=N.t/$*_,B=this.#d(L,N.value),H=this.#k;this.#K.setAttribute("x",B.x-H),this.#K.setAttribute("y",B.y-H);let O=this.#d(_,1);this.#W.setAttribute("x",O.x-this.#T/2),this.#W.setAttribute("y",O.y-this.#S/2)}#j0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#l(){if(!this.#M)return;this.#M.value=this.#N,this.#N0()}#p(){if(!this.#R)return;this.#R.setAttribute("value",this.value)}#t(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#i(Q,$){let J=this.#t(Q);if(!J){if($==="change")this.#p();return}let Z=this.#J;if(this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#N=this.#f(),Z!==this.#J)this.#x();else if(this.#c(),this.#l(),$==="change")this.#p();this.#r($)}#q0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#N0(){if(!this.#M)return;if(!this.#y())return;let Q=b.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=b.#b(this.#j);this.#q0(this.#M,"Custom bezier",Q),this.#q0(this.#M,"Custom spring",$),this.#q0(this.#M.select,"Custom bezier",Q),this.#q0(this.#M.select,"Custom spring",$)}#K0(Q){this.#c(),this.#N=this.#f(),this.#l(),this.#p(),this.#r(Q)}#G0(Q,$){let J=Q.shiftKey?0.1:0.01,Z=$===1?this.#$:this.#Q;switch(Q.key){case"ArrowLeft":Z.x-=J;break;case"ArrowRight":Z.x+=J;break;case"ArrowUp":Z.y+=J;break;case"ArrowDown":Z.y-=J;break;case"Home":Z.x=0,Z.y=0;break;case"End":Z.x=1,Z.y=1;break;default:return!1}return Z.x=Math.max(0,Math.min(1,Math.round(Z.x*100)/100)),Z.y=Math.round(Z.y*100)/100,this.#K0("input"),this.#r("change"),!0}#U0(Q,$){let J=Q.shiftKey?10:1;if($==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-J));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+J));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let Z=J*2;switch(Q.key){case"ArrowLeft":this.#D=Math.max(0.05,this.#D-Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+Z*1.5));break;case"ArrowRight":this.#D=Math.min(0.95,this.#D+Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-Z*1.5));break;case"Home":this.#D=0.05;break;case"End":this.#D=0.95;break;default:return!1}}return this.#K0("input"),this.#r("change"),!0}#_0(Q,$){let J=Q?.querySelector("fig-handle");if(!J)return;J.addEventListener("pointerdown",(Z)=>{if(Z.preventDefault(),Z.stopImmediatePropagation(),this.#J==="bezier")this.#X0(Z,Number($));else this.#Y0(Z,$)},{capture:!0}),J.addEventListener("keydown",(Z)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Z.key))return;if(!(this.#J==="bezier"?this.#G0(Z,Number($)):this.#U0(Z,$)))return;Z.preventDefault(),Z.stopImmediatePropagation()},{capture:!0})}#r(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#N}}))}#L0(){if(this.#q&&this.#J==="bezier"){this.#_0(this.#K,"1"),this.#_0(this.#W,"2"),this.#K.addEventListener("pointerdown",($)=>this.#X0($,1)),this.#W.addEventListener("pointerdown",($)=>this.#X0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0($,this.#M0($))})}else if(this.#q){this.#_0(this.#K,"bounce"),this.#_0(this.#W,"duration"),this.#K.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"bounce")}),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0($,"duration")})}if(this.#M)this.#M.addEventListener("change",(Q)=>{let $=Q.detail,J=b.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#N=$,this.#J!=="bezier")this.#J="bezier",this.#x();else if(this.#q)this.#c(),this.#p()}else if(J.type==="spring"){if(J.spring)this.#j={...J.spring};if(this.#N=$,this.#J!=="spring")this.#J="spring",this.#x();else if(this.#q)this.#c(),this.#p()}this.#r("input"),this.#r("change")});if(this.#R)this.#R.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#i($,"input")}),this.#R.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#i($,"change")})}#W0(Q){let $=this.#q.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#M0(Q){return this.#W0(Q).x<=this.#O/2?1:2}#X0(Q,$){Q.preventDefault(),this.#_=$,this.#e();let J=(j)=>{if(!this.#_)return;let q=this.#W0(j),_=this.#Q0(q.x,q.y);if(_.x=Math.round(_.x*100)/100,_.y=Math.round(_.y*100)/100,_.x=Math.max(0,Math.min(1,_.x)),this.#_===1)this.#$.x=_.x,this.#$.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#c(),this.#N=this.#f(),this.#l(),this.#p(),this.#r("input")},Z=()=>{this.#_=null,this.#e(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#r("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#Y0(Q,$){Q.preventDefault(),this.#_=$;let J=this.#j.damping,Z=this.#j.stiffness,j=this.#D,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#_)return;if($==="bounce"){let N=K.clientY-q;this.#j.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=K.clientX-_;this.#D=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#c(),this.#N=this.#f(),this.#l(),this.#p(),this.#r("input")},Y=()=>{this.#_=null,document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#r("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",b);class s0 extends HTMLElement{#$=0;#Q=0;#j=0;#J=1;#Z=!1;#_=!1;#q=null;#Y=null;#X=null;#U=null;#K=[];#W={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#L(this.getAttribute("transform-origin")),this.#R(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#N(Q);this.#z(),this.#M(this.getAttribute("selected")),this.#G()}disconnectedCallback(){if(this.#Z=!1,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#U)}#L(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#G(){if(!this.#Y)return;this.#Y.style.cursor=this.#A?"":"default"}#M(Q){if(!this.#q)return;let $=this.#q.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#R(Q){if(!Q||!Q.trim()){this.#K=[];return}let $=["rotateX","rotateY","rotateZ"];this.#K=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="perspective"){V(this,"--perspective",J);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#L(J);return}if(Q==="selected"){this.#M(J);return}if(Q==="drag"){this.#G();return}if(Q==="fields"){if(this.#R(J),this.#q)this.#z();return}if(!this.#q)return;if(Q==="value"&&J){if(this.#Z)return;this.#N(J),this.#O(),this.#D()}if(Q==="precision")this.#J=parseInt(J||"1")}get value(){let Q=this.#J;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#j.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#N(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#j=parseFloat(Z[1])}#z(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j},J=this.#K.map((Z)=>`<fig-input-number
|
|
215
217
|
name="${Z}"
|
|
216
218
|
step="1"
|
|
217
219
|
precision="1"
|
|
@@ -229,9 +231,9 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
229
231
|
<div class="fig-3d-rotate-face bottom"></div>
|
|
230
232
|
</div>
|
|
231
233
|
</div>
|
|
232
|
-
</div>${J}`,this.#
|
|
234
|
+
</div>${J}`,this.#Y=this.querySelector(".fig-3d-rotate-container"),this.#q=this.querySelector(".fig-3d-rotate-cube"),this.#W={};for(let Z of this.#K){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#W[Z]=j;let q=(_)=>{_.stopPropagation();let X=parseFloat(_.target.value);if(isNaN(X))return;if(Z==="rotateX")this.#$=X;else if(Z==="rotateY")this.#Q=X;else if(Z==="rotateZ")this.#j=X;this.#O(),this.#H(_.type)};j.addEventListener("input",q),j.addEventListener("change",q)}}this.#O(),this.#F()}#D(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j};for(let $ of this.#K){let J=this.#W[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#J))}}#O(){if(!this.#q)return;this.#q.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#j}deg)`}#H(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j}}))}#B(Q){if(!this.#_)return Q;return Math.round(Q/15)*15}#F(){this.#Y.addEventListener("pointerdown",(Q)=>this.#k(Q)),this.#X=(Q)=>{if(Q.key==="Shift")this.#_=!0},this.#U=(Q)=>{if(Q.key==="Shift")this.#_=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#U)}get#A(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#k(Q){if(!this.#A)return;Q.preventDefault(),this.#Z=!0,this.#Y.classList.add("dragging"),this.#Y.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(X)=>{if(!this.#Z)return;if(X.buttons===0){_();return}let Y=X.clientX-$,K=X.clientY-J;this.#Q=this.#B(j+Y*0.5),this.#$=this.#B(Z-K*0.5),this.#O(),this.#D(),this.setAttribute("value",this.value),this.#H("input")},_=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#Y.classList.remove("dragging"),this.#Y.removeEventListener("pointermove",q),this.#Y.removeEventListener("pointerup",_),this.#Y.removeEventListener("pointercancel",_),this.#Y.removeEventListener("lostpointercapture",_),this.#H("change")};this.#Y.addEventListener("pointermove",q),this.#Y.addEventListener("pointerup",_),this.#Y.addEventListener("pointercancel",_),this.#Y.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",s0);class j0 extends HTMLElement{#$=50;#Q=50;#j=0;#J=null;#Z=[];#_=null;#q=null;#Y=null;#X=!1;#U=!1;#K=null;#W=null;#L=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#O(this.getAttribute("value")),this.#H(),this.#R(),this.#F()}disconnectedCallback(){this.#X=!1,this.#w()}get value(){let Q=this.#j;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#R();return}if(Q==="fields"){this.#H(),this.#R(),this.#F();return}if(Q==="precision"){this.#j=parseInt(J||"0"),this.#B(),this.#F();return}if(Q==="value"){if(this.#U||this.#X)return;this.#O(J),this.#k(),this.#E(),this.#B()}}get#G(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#M(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#R(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#G)}#N(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#D(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#O(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#D($)}#H(){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}">
|
|
233
235
|
<span class="origin-grid-dot"></span>
|
|
234
|
-
</span>`}).join(""),$=this.#$.toFixed(this.#
|
|
236
|
+
</span>`}).join(""),$=this.#$.toFixed(this.#j),J=this.#Q.toFixed(this.#j),Z=this.#M?`<div class="origin-values">
|
|
235
237
|
<fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
|
|
236
238
|
<fig-input-number name="y" value="${J}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
|
|
237
239
|
</div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
|
|
@@ -240,8 +242,8 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
240
242
|
<fig-handle></fig-handle>
|
|
241
243
|
</div>
|
|
242
244
|
</div>
|
|
243
|
-
${Z}`,this.#
|
|
244
|
-
<div class="fig-input-joystick-plane-container"
|
|
245
|
+
${Z}`,this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#_=this.querySelector("fig-handle"),this.#q=this.querySelector('fig-input-number[name="x"]'),this.#Y=this.querySelector('fig-input-number[name="y"]'),this.#k(),this.#E(),this.#B(),this.#v()}#B(){let Q=this.#$.toFixed(this.#j),$=this.#Q.toFixed(this.#j);if(this.#q)this.#q.setAttribute("value",Q);if(this.#Y)this.#Y.setAttribute("value",$)}#F(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#U=!0,this.setAttribute("value",Q),this.#U=!1}#A(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#k(){if(!this.#_)return;let Q=($)=>16.6667+this.#N($)/100*66.6667;this.#_.style.left=`${Q(this.#$)}%`,this.#_.style.top=`${Q(this.#Q)}%`}#E(){if(!this.#_)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#_.classList.toggle("beyond-bounds-x",Q),this.#_.classList.toggle("beyond-bounds-y",$),this.#_.classList.toggle("overflow-left",J),this.#_.classList.toggle("overflow-right",Z),this.#_.classList.toggle("overflow-up",j),this.#_.classList.toggle("overflow-down",q)}#T(Q,$){if(!this.#J)return null;let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#S(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#P(Q){if(this.#S(),Q)Q.classList.add("is-hovered")}#C(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#k(),this.#E(),this.#B(),this.#F(),this.#A(J)}#f(Q,$){if(!this.#J)return{x:this.#$,y:this.#Q};let J=this.#J.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),_=Math.max(1,J.height-j*2),X=(Q-(J.left+Z))/q,Y=($-(J.top+j))/_;return{x:X*100,y:Y*100}}#V(Q,$){if(!this.#J)return{x:50,y:50};let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#b(Q){let J=Q,Z=1/0;for(let j of j0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#y(Q,$){if(!$)return Q;return{x:this.#b(Q.x),y:this.#b(Q.y)}}#x(Q){if(!this.#G)return!1;let $=Q.shiftKey?10:1,J=this.#$,Z=this.#Q;switch(Q.key){case"ArrowLeft":J-=$;break;case"ArrowRight":J+=$;break;case"ArrowUp":Z-=$;break;case"ArrowDown":Z+=$;break;case"Home":J=0,Z=0;break;case"End":J=100,Z=100;break;default:return!1}return this.#C(this.#N(J),this.#N(Z),"input"),this.#A("change"),!0}#w(){if(!this.#J||!this.#W||!this.#L)return;this.#J.removeEventListener("pointermove",this.#W),this.#J.removeEventListener("pointerup",this.#L),this.#J.removeEventListener("pointercancel",this.#L),this.#J.removeEventListener("lostpointercapture",this.#L),this.#W=null,this.#L=null}#g(Q){if(!this.#J||!this.#G)return;Q.preventDefault(),this.#X=!0,this.#K=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#W=(q)=>{if(!this.#X||q.pointerId!==this.#K)return;let _=q.clientX-$,X=q.clientY-J,Y=Math.hypot(_,X);if(!j&&Y<Z)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#S();let K=this.#y(this.#f(q.clientX,q.clientY),q.shiftKey);this.#C(K.x,K.y,"input")},this.#L=(q)=>{if(!this.#X||q.pointerId!==this.#K)return;if(this.#X=!1,this.#K=null,this.#J.classList.remove("is-dragging"),this.#S(),this.#w(),!j){let _=this.#V($,J);this.#C(_.x,_.y,"input")}this.#A("change")},this.#J.addEventListener("pointermove",this.#W),this.#J.addEventListener("pointerup",this.#L),this.#J.addEventListener("pointercancel",this.#L),this.#J.addEventListener("lostpointercapture",this.#L)}#v(){if(!this.#J||!this.#_)return;this.#J.addEventListener("pointerdown",($)=>{let J=this.#T($.clientX,$.clientY);if(this.#P(J),this.#G){this.#g($);return}let Z=this.#V($.clientX,$.clientY);this.#C(Z.x,Z.y,"input"),this.#A("change")}),this.#J.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#T($.clientX,$.clientY);this.#P(J)}),this.#J.addEventListener("pointerleave",()=>{this.#S()}),this.#_.addEventListener("keydown",($)=>{if(!this.#x($))return;$.preventDefault(),$.stopPropagation()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#C(q,this.#Q,"input");else this.#C(this.#$,q,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#A("change")})};Q(this.#q,"x"),Q(this.#Y,"y")}}customElements.define("fig-origin-grid",j0);class d0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#_=null;#q=null;#Y=null;#X=!1;#U={x:0.5,y:0.5};#K=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#F(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#j=(Q)=>this.#A(Q),this.#J=()=>this.#k(),this.#Z=(Q)=>this.#D(Q),this.#_=(Q)=>this.#O(Q),this.#q=()=>this.#H(),this.#Y=()=>this.#H()}connectedCallback(){requestAnimationFrame(()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");this.#G(),this.#N(),this.#S(),this.#P(),this.#C(),this.#K=!0})}#W(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#L(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#G(){this.innerHTML=this.#R()}#M(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/[\s,]+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#R(){let Q=this.#M();return`
|
|
246
|
+
<div class="fig-input-joystick-plane-container">
|
|
245
247
|
${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
|
|
246
248
|
<div class="fig-input-joystick-plane">
|
|
247
249
|
<div class="fig-input-joystick-guides"></div>
|
|
@@ -253,7 +255,7 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
253
255
|
</fig-button>
|
|
254
256
|
</fig-tooltip>
|
|
255
257
|
</div>
|
|
256
|
-
${this.#
|
|
258
|
+
${this.#L?`<div class="joystick-values">
|
|
257
259
|
<fig-input-number
|
|
258
260
|
name="x"
|
|
259
261
|
step="1"
|
|
@@ -273,6 +275,6 @@ var L1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var A1={};var N0=L1(()=>{/*! Vendored from @
|
|
|
273
275
|
<span slot="prepend">Y</span>
|
|
274
276
|
</fig-input-number>
|
|
275
277
|
</div>`:""}
|
|
276
|
-
`}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#j);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#q),this.xInput.addEventListener("change",this.#q),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#j),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#q),this.xInput.removeEventListener("change",this.#q),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#R(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#S(),this.#P()}#D(){this.#S(),this.#C()}#B(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#S()}#H(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#B(J,Z,{syncHandle:!1}),this.#P(),this.#C()}#F(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#B($.px,$.py,{syncHandle:!1}),this.#P()}#T(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#S(),this.#C()}#P(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#Y&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#S(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#I()}#I(){let Q=this.#U,$=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",$),this.style.setProperty("--is-not-default",$?"0":"1")}#y(){this.position={...this.#U},this.#E(),this.#S(),this.#P(),this.#C()}focus(){this.querySelector(".fig-input-joystick-plane-container")?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0.5;let _=K.includes("%"),X=Number.parseFloat(K.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let Y=_||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,Y))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#W)this.#E(),this.#I()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){x(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#N(),this.#M(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#N(),this.#M(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",d0);class q0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q)}static get observedAttributes(){return["duration","playing"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s")}}customElements.define("fig-shimmer",q0);class r0 extends q0{}customElements.define("fig-skeleton",r0);class o0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){let Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#j.bind(this),this.#$.addEventListener("click",this.#Q)}#j(Q){Q.stopPropagation(),this.open=!this.open}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0}))}get visible(){return this.getAttribute("visible")!=="false"}set visible(Q){let $=this.visible;if(Q)this.setAttribute("visible","true");else this.setAttribute("visible","false");if($!==Q)this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Q},bubbles:!0}))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){let Z=J!==null&&J!=="false";this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Z},bubbles:!0}))}if(Q==="visible"){let Z=J!=="false";this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Z},bubbles:!0}))}}}customElements.define("fig-layer",o0);class i0 extends HTMLElement{static observedAttributes=["name","collapsible"];#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>this.#j())}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#J)}attributeChangedCallback(Q,$,J){if($===J)return;this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(this.#$.dataset.generated)j.textContent=J;if(Q){if(!j.querySelector(".fig-group-chevron")){let q=b("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.addEventListener("click",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false")}else{if(this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",i0);class l0 extends HTMLElement{}customElements.define("fig-header",l0);class t0 extends HTMLElement{}customElements.define("fig-footer",t0);class a0 extends HTMLElement{}customElements.define("fig-spinner",a0);class n0 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",n0);var P1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function S1(Q,$="medium"){let J=Q&&P1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class e0 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=S1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",e0);class Q1 extends HTMLElement{}customElements.define("fig-content",Q1);class $1 extends HTMLElement{}customElements.define("fig-tab-content",$1);class J1 extends HTMLElement{}customElements.define("fig-button-combo",J1);class Z1 extends HTMLElement{}customElements.define("fig-input-combo",Z1);class j1 extends HTMLElement{#$=null;#Q=null;#J=null;#j=this.#M.bind(this);#q=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#Z(){return this.getAttribute("control")||"color"}connectedCallback(){this.#U(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#W)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#j),this.#$.removeEventListener("change",this.#q);if(this.#Q)this.#Q.removeEventListener("input",this.#j),this.#Q.removeEventListener("change",this.#q);if(this.#J)this.#J.disconnect(),this.#J=null}#X(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#U(){let Q=this.#Z;if(Q==="add"||Q==="remove"){let _=Q==="add"?"add":"minus";this.innerHTML=`<fig-button icon variant="ghost"><fig-icon name="${_}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#W);return}this.removeEventListener("click",this.#W);let $=(this.getAttribute("value")||"").trim(),J=this.#N($),Z=this.#Y($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),K=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=m()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
|
|
277
|
-
<fig-chit background="${J}"${
|
|
278
|
-
</fig-fill-picker>`:`<fig-chit background="${J}"${K}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#j),this.#$?.addEventListener("change",this.#q),!this.#$)this.#Q?.addEventListener("input",this.#j),this.#Q?.addEventListener("change",this.#q);this.#X()}#W=()=>{let Q=this.#Z;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#G(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#Y(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#N(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#N(J.color)}catch{}if($.startsWith("#"))return this.#G($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#G($);try{let{ctx:J}=J0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#G(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(K)=>Math.max(0,Math.min(255,Number(K))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),$=this.#N(Q),J=this.#Y(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#A(Q,$){let J=this.#N(Q?.color),Z=this.#N(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#L();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#M(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#A(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#U();break;case"value":case"selected":case"disabled":this.#L();break}}get value(){return this.#N(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#N(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",j1);class q1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",q1);class K1 extends HTMLElement{#$=null;#Q=this.#M.bind(this);#J=this.#z.bind(this);#j=this.#R.bind(this);#q=null;#Z=null;#_=null;#X=null;#K=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#U(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#W(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#G))}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#E(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#j),this.#F(),this.#B(),this.#S(),this.#D(),requestAnimationFrame(()=>{this.#N(),this.#R(),this.#Y()})}#Y(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#E(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#j),this.#H(),this.#q?.disconnect(),this.#q=null,this.#Z?.disconnect(),this.#Z=null,this.#T()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#L(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#N());if(Q==="drag")if(this.#W)this.#B();else this.#H();if(Q==="overflow")this.#F()}#N(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#L($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#L(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#A(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#M(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#A(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#O()}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#A(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#O()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#O()}#O(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#R(){if(this.#U==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollWidth-this.clientWidth>$,Z=!J||this.scrollLeft<=$,j=!J||this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}else{let J=this.scrollHeight-this.clientHeight>$,Z=!J||this.scrollTop<=$,j=!J||this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}}#D(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#B(){if(this.#K?.bound)return;if(!this.#W)return;let Q=(q)=>{if(q.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#K.active=!0,this.#K.didDrag=!1,this.#K.startX=q.clientX,this.#K.startY=q.clientY,this.#K.scrollLeft=this.scrollLeft,this.#K.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(q)=>{if(!this.#K.active)return;let K=this.getAttribute("layout")==="horizontal",_=q.clientX-this.#K.startX,X=q.clientY-this.#K.startY;if(!this.#K.didDrag&&Math.abs(K?_:X)>3)this.#K.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#K.didDrag)return;if(K)this.scrollLeft=this.#K.scrollLeft-_;else this.scrollTop=this.#K.scrollTop-X},J=(q)=>{if(!this.#K.active)return;let K=this.#K.didDrag;if(this.#K.active=!1,this.#K.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(K)q.preventDefault(),q.stopPropagation()},Z=(q)=>{if(this.#K?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#K.suppressClick=!1},j=(q)=>{if(this.#K?.didDrag)this.#K.suppressClick=!0,setTimeout(()=>{if(this.#K)this.#K.suppressClick=!1},0)};this.#K={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#H(){if(!this.#K?.bound)return;this.removeEventListener("pointerdown",this.#K.onPointerDown),window.removeEventListener("pointermove",this.#K.onPointerMove),window.removeEventListener("pointerup",this.#K.onPointerUp),this.removeEventListener("pointerup",this.#K.onPointerUpCapture,!0),this.removeEventListener("click",this.#K.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#K=null}#F(){if(this.#U==="scrollbar")this.#T();else this.#P()}#T(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#P(){if(this.#_)return;let Q=()=>{return b("chevron",{size:"small",className:"fig-chooser-nav-chevron"})};this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),this.#_.appendChild(Q()),this.#X=document.createElement("button"),this.#X.className="fig-chooser-nav-end",this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-label","Scroll forward"),this.#X.appendChild(Q()),this.#_.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#C(-1)}),this.#X.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#C(1)}),this.prepend(this.#_),this.append(this.#X)}#C(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#E(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.scrollHeight>this.clientHeight,Z=this.scrollWidth>this.clientWidth;if(!Z&&!J)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),K={behavior:$};if(J){let _=j.top-q.top+this.scrollTop+j.height/2;K.top=_-this.clientHeight/2}if(Z){let _=j.left-q.left+this.scrollLeft+j.width/2;K.left=_-this.clientWidth/2}this.scrollTo(K)})}#S(){this.#q?.disconnect(),this.#q=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#N();else if(!this.#$&&Q.length)this.#N()}),this.#q.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",K1);class _1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode"];#$=!1;#Q=!1;#J=null;#j=!1;#q=null;#Z=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#U(){return!this.hasAttribute("data-no-color-picker")}get#W(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#Y(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#N(Q){let $=this.#Y;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#A(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#s(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#z(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0;let _=K.includes("px"),X=K.includes("%"),Y=parseFloat(K.replace(/[%px]/g,""));if(!Number.isFinite(Y))return 0;if(_)return{px:Y};if(X||Math.abs(Y)>1)return Math.max(0,Math.min(100,Y));return Math.max(0,Math.min(100,Y*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#O(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#z(Q),j=$.getBoundingClientRect(),q=(X,Y)=>{if(X&&typeof X==="object"&&"px"in X)return Math.max(0,Math.min(Y,X.px));return null},K=(X)=>{return`${typeof X==="number"?X:0}%`},_=this.#G;if(this.#R(_),_.x){let X=q(J,j.width);this.style.left=X===null?K(J):`${Math.round(X)}px`}if(_.y){let X=q(Z,j.height);this.style.top=X===null?K(Z):`${Math.round(X)}px`}}#R(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#D(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#B(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let K of $){if(K==="circle"){j=!0;continue}let _=parseFloat(K);if(Number.isFinite(_))q.push(_)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#F(){let Q=this.#H();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#T(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#T(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#B==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#y(Q)}connectedCallback(){this.#S(),this.#F(),this.addEventListener("click",this.#P),document.addEventListener("pointerdown",this.#C),document.addEventListener("keydown",this.#E);let Q=this.getAttribute("value");if(Q)this.#O(Q);if(this.#K)this.#r()}disconnectedCallback(){if(this.#I(),this.#t(),this.#b(),this.#J0(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#P),document.removeEventListener("pointerdown",this.#C),document.removeEventListener("keydown",this.#E)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#P=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#U&&!this.#K){this.#x();return}this.select()};#C=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#Z)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#E=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#U)return;if(Q.preventDefault(),!this.#K)this.#x()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#q&&this.#K==="color"&&J)this.#q.setAttribute("value",J);this.#k()}if(Q==="drag")this.#S();if(Q==="hit-area")this.#F();if(Q==="selected")this.#c();if(Q==="value"&&!this.#j&&!this.#$)this.#O(J);if(Q==="tip"){if(this.#t(),this.#K)this.#b(),this.#r()}}#S(){if(this.#W&&!this.#J)this.#J=(Q)=>this.#y(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#W&&this.#J)this.#I()}#I(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#y(Q){if(!this.#W||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#G,Z=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,K=j.top+j.height/2,_=Q.clientX-q,X=Q.clientY-K,Y=Q.clientX,N=Q.clientY,L=3,B=(G,z,R=!1)=>{let U=$.getBoundingClientRect();Z=U;let A=this.#s(U),D=G-_-U.left,T=z-X-U.top,E=Math.max(0,Math.min(U.width,D)),S=Math.max(0,Math.min(U.height,T)),I=U.width>0?J.x?E/U.width:A.px:0.5,V=U.height>0?J.y?S/U.height:A.py:0.5;if(this.#N(R)){if(J.x)I=this.#L(I);if(J.y)V=this.#L(V);if(J.x&&J.y){let s=this.#A(I,V);I=s.x,V=s.y}}if(this.#R(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(U.width,I*U.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(U.height,V*U.height)))}px`},H=(G)=>{if(!this.#$)return;if(!this.#Q){let z=G.clientX-Y,R=G.clientY-N;if(z*z+R*R<L*L)return;if(this.#Z0(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,B(G.clientX,G.clientY,G.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#s(Z),shiftKey:G.shiftKey}}))},M=(G)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",M),this.#Q){B(G.clientX,G.clientY,G.shiftKey),this.#D(),this.#O(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#s(Z)}));let z=(R)=>{R.stopPropagation(),R.preventDefault()};this.addEventListener("click",z,{capture:!0,once:!0})}else this.#D();this.#Q=!1};window.addEventListener("pointermove",H),window.addEventListener("pointerup",M)}showColorTip(){if(!this.#K)return;if(this.#q){this.#q.style.display="";return}this.#r()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#V(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let K=q.replace("#","").trim();if(K.length===3||K.length===4){let[_,X,Y,N]=K;return{color:`#${_}${_}${X}${X}${Y}${Y}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(K.length===6||K.length===8)return{color:`#${K.slice(0,6)}`.toUpperCase(),opacity:K.length===8?Math.round(parseInt(K.slice(6,8),16)/255*100):100};return $},j=(q,K,_)=>{let X=(Y)=>Math.max(0,Math.min(255,Math.round(Number(Y)))).toString(16).padStart(2,"0");return`#${X(q)}${X(K)}${X(_)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=J0(1,1);q.fillStyle="#000000",q.fillStyle=J;let K=q.fillStyle;if(K.startsWith("#"))return Z(K);let _=K.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(_)return{color:j(_[1],_[2],_[3]),opacity:_[4]!==void 0?Math.round(parseFloat(_[4])*100):100}}catch{}return $}#w(){let{color:Q,opacity:$}=this.#V();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#k(){if(!this.#Z)return;this.#Z.setAttribute("value",this.#w())}#f(){if(!m())return null;if(this.#Z)return this.#Z;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#o),Q.addEventListener("change",this.#m),Q.addEventListener("close",this.#e),this.appendChild(Q),this.#Z=Q,Q}#x(){if(this.hasAttribute("disabled"))return;let Q=this.#f();if(!Q){this.#l();return}this.setAttribute("selected",""),this.#k(),Q.open()}#b(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#o),this.#Z.removeEventListener("change",this.#m),this.#Z.removeEventListener("close",this.#e),this.#Z.close(),this.#Z.remove(),this.#Z=null,this.removeAttribute("selected")}#d(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#n),this.appendChild(Q),this.#_=Q,Q}#l(){let Q=this.#d(),{color:$}=this.#V();Q.value=$,this.setAttribute("selected",""),Q.click()}#J0(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#n),this.#_.remove(),this.#_=null}#Z0(){if(this.getAttribute("type")!=="color")return;this.#Z?.close()}#r(){let Q=this.#K;if(!Q)return;if(this.#q)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#Q0),$.addEventListener("change",this.#p),$.addEventListener("add",this.#v),$.addEventListener("remove",this.#v),this.appendChild($),this.#q=$,this.#c()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#Q0),this.#q.removeEventListener("change",this.#p),this.#q.removeEventListener("add",this.#v),this.#q.removeEventListener("remove",this.#v),this.#q.remove(),this.#q=null}#c(){if(!this.#q||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#h(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=u(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#a(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#o=(Q)=>{Q.stopPropagation();let $=this.#a(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#m=(Q)=>{Q.stopPropagation();let $=this.#a(Q.detail);if(!$)return;this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#g(Q){let{opacity:$}=this.#V();return $<100?{color:Q,opacity:$}:{color:Q}}#i=(Q)=>{Q.stopPropagation();let $=this.#g(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#n=(Q)=>{Q.stopPropagation();let $=this.#g(Q.target.value);this.setAttribute("color",this.#h($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#e=()=>{this.removeAttribute("selected")};#Q0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#p=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#h(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#v=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#s(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,K=J.top-$.top,_=q+Z,X=K+j,Y=$.width>0?_/$.width:0,N=$.height>0?X/$.height:0;return{x:q,y:K,px:Y,py:N}}}customElements.define("fig-handle",_1);class X1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}attributeChangedCallback(){}}customElements.define("fig-menu-item",X1);class Y1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",Y1);class W1 extends HTMLElement{#$=null;#Q=null;#J=null;#j;#q;#Z;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#j=this.#O.bind(this),this.#q=this.#R.bind(this),this.#Z=this.#D.bind(this),this.#_=this.#B.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#K(),this.#U(),this.#W(),this.#G(),this.#N(),this.#z(),this.open)this.#F()}disconnectedCallback(){if(this.#Y(),this.#J)this.#J.disconnect(),this.#J=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#T();else this.#F();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#U(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu");let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#W(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#G(){if(this.addEventListener("keydown",this.#Z),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false");if(this.#$)this.#$.addEventListener("click",this.#q)}#Y(){if(this.removeEventListener("keydown",this.#Z),this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#q)}#N(){this.#J=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#j),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#$.anchor=this.#Q,this.#z()}}}),this.#J.observe(this,{childList:!0})}#L(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item:not([disabled]):not([disabled='true'])"))}#A(){let Q=this.#L();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#L();if(!$.length)return;let J=Math.max(0,Math.min(Q,$.length-1));this.#X=J,$[J].focus()}#z(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#R(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#D(Q){if(!this.open||!this.#$?.matches?.(":open"))return;let $=this.#L();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Enter":case" ":{this.#A();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(J);break}}}#B(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#X=-1}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#F(){if(!this.#$)return;if(this.#$.open=!0,this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#T(){if(!this.#$)return;this.#$.open=!1}}customElements.define("fig-menu",W1);
|
|
278
|
+
`}#N(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#f());if(this.#L&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#q),this.yInput.addEventListener("input",this.#_),this.yInput.addEventListener("change",this.#_),this.yInput.addEventListener("focusout",this.#Y)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#L&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#q),this.yInput.removeEventListener("input",this.#_),this.yInput.removeEventListener("change",this.#_),this.yInput.removeEventListener("focusout",this.#Y)}#D(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#S(),this.#P(),this.#E()}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#S(),this.#P(),this.#E()}#H(){this.#P(),this.#T()}#B(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#S();this.#P()}#F(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#B(J,Z,{syncHandle:!1}),this.#E(),this.#T()}#A(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#B($.px,$.py,{syncHandle:!1}),this.#E()}#k(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#T()}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#S(){let Q=this.#W(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#L&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#C()}#C(){let Q=this.#U,$=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",$),this.style.setProperty("--is-not-default",$?"0":"1")}#f(){this.position={...this.#U},this.#S(),this.#P(),this.#E(),this.#T()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{if(!_)return 0.5;let X=_.includes("%"),Y=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(Y))return 0.5;let K=X||Math.abs(Y)>1?Y/100:Y;return Math.max(0,Math.min(1,K))},j=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#K)this.#S(),this.#C()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#G(),this.#N(),this.#S();if(Q==="axis-labels"&&J!==$)this.#z(),this.#G(),this.#N(),this.#S();if(Q==="coordinates")this.coordinates=J||"screen",this.#S()}}customElements.define("fig-joystick",d0);class q0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#$()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#$()}#$(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}customElements.define("fig-shimmer",q0);class r0 extends q0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",r0);class o0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#$=null;#Q=null;connectedCallback(){this.#Z()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#J),this.#$.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){this.#$?.setAttribute("aria-expanded",String(this.open));return}this.#Z()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#$?.setAttribute("aria-expanded",String(!!Q)),$!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#Z(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(!j.id)j.id=y();if(this.#$.dataset.generated)j.textContent=J;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let q=v("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.addEventListener("click",this.#j),this.#$.setAttribute("role","button"),this.#$.setAttribute("tabindex","0"),this.#$.setAttribute("aria-expanded",String(this.open)),this.#$.removeEventListener("keydown",this.#J),this.#$.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#$.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.removeAttribute("role"),this.#$.removeAttribute("tabindex"),this.#$.removeAttribute("aria-expanded"),this.#$.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",o0);class i0 extends HTMLElement{}customElements.define("fig-header",i0);class l0 extends HTMLElement{}customElements.define("fig-footer",l0);class a0 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",a0);class t0 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",t0);var P1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function E1(Q,$="medium"){let J=Q&&P1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class n0 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=E1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",n0);class e0 extends HTMLElement{}customElements.define("fig-content",e0);class Q1 extends HTMLElement{}customElements.define("fig-tab-content",Q1);class $1 extends HTMLElement{}customElements.define("fig-button-combo",$1);class J1 extends HTMLElement{}customElements.define("fig-input-combo",J1);class Z1 extends HTMLElement{#$=null;#Q=null;#j=null;#J=this.#z.bind(this);#Z=this.#D.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#_(){return this.getAttribute("control")||"color"}connectedCallback(){this.#U(),this.#M()}disconnectedCallback(){this.#q(),this.removeEventListener("click",this.#K)}#q(){if(this.#$)this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#Z);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#Z);if(this.#j)this.#j.disconnect(),this.#j=null}#Y(){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"}#U(){let Q=this.#_;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${Y}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#K),this.#R();return}this.removeEventListener("click",this.#K);let $=(this.getAttribute("value")||"").trim(),J=this.#G($),Z=this.#L($),j=this.#X?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),_=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=m()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
|
|
279
|
+
<fig-chit background="${J}"${_}></fig-chit>
|
|
280
|
+
</fig-fill-picker>`:`<fig-chit background="${J}"${_}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#q(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#Z),!this.#$)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#Z);this.#Y(),this.#R()}#K=()=>{let Q=this.#_;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#W(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#L(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#G(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#G(J.color)}catch{}if($.startsWith("#"))return this.#W($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#W($);try{let{ctx:J}=J0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#W(Z);let j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#M(){let Q=this.getAttribute("value"),$=this.#G(Q),J=this.#L(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){this.#R();let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#X)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#R(),this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#R(){let Q=this.#_,$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",$?"true":"false"),this.setAttribute("aria-pressed",J?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),$)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let Z=this.#$||this.#Q;if(!Z)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)Z.setAttribute("aria-labelledby",q),Z.removeAttribute("aria-label");else Z.setAttribute("aria-label",j),Z.removeAttribute("aria-labelledby");if(_)Z.setAttribute("aria-describedby",_);else Z.removeAttribute("aria-describedby")}#N(Q,$){let J=this.#G(Q?.color),Z=this.#G(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#M();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#z(Q){Q.stopPropagation(),this.#N(Q.detail||{color:Q.target?.value},"input")}#D(Q){Q.stopPropagation(),this.#N(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#U();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#M(),this.#R();break}}get value(){return this.#G(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#G(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",Z1);class j1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",j1);class q1 extends HTMLElement{#$=null;#Q=this.#N.bind(this);#j=this.#z.bind(this);#J=this.#O.bind(this);#Z=null;#_=null;#q=null;#Y=null;#X=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#U(){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"}get choices(){return Array.from(this.querySelectorAll(this.#W))}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#S(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.addEventListener("scroll",this.#J),this.#A(),this.#B(),this.#P(),this.#H(),requestAnimationFrame(()=>{this.#G(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#S(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.removeEventListener("scroll",this.#J),this.#F(),this.#Z?.disconnect(),this.#Z=null,this.#_?.disconnect(),this.#_=null,this.#k()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#M(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#G());if(Q==="drag")if(this.#K)this.#B();else this.#F();if(Q==="overflow")this.#A()}#G(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#M($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#M(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#R(Q){let $=this.#W,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#N(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#R(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#D()}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#W)){let q=this.#R(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#D()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#D()}#D(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#U==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){let J=this.scrollWidth-this.clientWidth>$,Z=!J||this.scrollLeft<=$,j=!J||this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}else{let J=this.scrollHeight-this.clientHeight>$,Z=!J||this.scrollTop<=$,j=!J||this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!Z),this.classList.toggle("overflow-end",!j)}}#H(){this.#_?.disconnect(),this.#_=new ResizeObserver(()=>{this.#O()}),this.#_.observe(this)}#B(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)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=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},J=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},Z=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{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:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#F(){if(!this.#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}#A(){if(this.#U==="scrollbar")this.#k();else this.#E()}#k(){this.#q?.remove(),this.#Y?.remove(),this.#q=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#E(){if(this.#q)return;let Q=()=>{return v("chevron",{size:"small",className:"fig-chooser-nav-chevron"})};this.#q=document.createElement("button"),this.#q.className="fig-chooser-nav-start",this.#q.setAttribute("tabindex","-1"),this.#q.setAttribute("aria-label","Scroll back"),this.#q.appendChild(Q()),this.#Y=document.createElement("button"),this.#Y.className="fig-chooser-nav-end",this.#Y.setAttribute("tabindex","-1"),this.#Y.setAttribute("aria-label","Scroll forward"),this.#Y.appendChild(Q()),this.#q.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#T(-1)}),this.#Y.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#T(1)}),this.prepend(this.#q),this.append(this.#Y)}#T(Q){let $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#S(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.scrollHeight>this.clientHeight,Z=this.scrollWidth>this.clientWidth;if(!Z&&!J)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:$};if(J){let X=j.top-q.top+this.scrollTop+j.height/2;_.top=X-this.clientHeight/2}if(Z){let X=j.left-q.left+this.scrollLeft+j.width/2;_.left=X-this.clientWidth/2}this.scrollTo(_)})}#P(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#G();else if(!this.#$&&Q.length)this.#G()}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",q1);class _1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#$=!1;#Q=!1;#j=null;#J=!1;#Z=null;#_=null;#q=null;#Y=null;get#X(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#U(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#W(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#L(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#G(Q){let $=this.#L;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#M(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}#R(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#N(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#N();if(!Q)return"0% 0%";let{px:$,py:J}=this.#i(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#z(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#D(Q){let $=this.#N();if(!$)return;let{xToken:J,yToken:Z}=this.#z(Q),j=$.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#W;if(this.#O(X),X.x){let Y=q(J,j.width);this.style.left=Y===null?_(J):`${Math.round(Y)}px`}if(X.y){let Y=q(Z,j.height);this.style.top=Y===null?_(Z):`${Math.round(Y)}px`}}#O(Q=this.#W){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#B(){return this.getAttribute("hit-area-mode")||"handle"}#F(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let _ of $){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#A(){let Q=this.#F();if(!Q){if(this.#Y)this.#Y.remove(),this.#Y=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#Y){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#k(J)),this.prepend($),this.#Y=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#Y.style.borderRadius="50%";else this.#Y.style.borderRadius="inherit"}#k(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#Y)return;if(this.#B==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#b(Q)}connectedCallback(){this.#f(),this.#C(),this.#A(),this.addEventListener("click",this.#E),document.addEventListener("pointerdown",this.#T),document.addEventListener("keydown",this.#S);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#X)this.#s()}disconnectedCallback(){if(this.#V(),this.#a(),this.#h(),this.#m(),this.#Y)this.#Y.remove(),this.#Y=null;this.removeEventListener("click",this.#E),document.removeEventListener("pointerdown",this.#T),document.removeEventListener("keydown",this.#S)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#E=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#U&&!this.#X){this.#v();return}this.select()};#T=(Q)=>{if(this.contains(Q.target))return;if((this.#Z||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#S=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#P(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#U&&!this.#X)this.#v();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#U)return;if(Q.preventDefault(),!this.#X)this.#v()};#P(Q){if(this.hasAttribute("disabled"))return!1;let $=this.#N();if(!$)return!1;let J=$.getBoundingClientRect();if(J.width<=0||J.height<=0)return!1;let Z=this.#W,j=this.#i(J),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!Z.x)return!1;_-=q;break;case"ArrowRight":if(!Z.x)return!1;_+=q;break;case"ArrowUp":if(!Z.y)return!1;X-=q;break;case"ArrowDown":if(!Z.y)return!1;X+=q;break;case"Home":if(Z.x)_=0;if(Z.y)X=0;break;case"End":if(Z.x)_=1;if(Z.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#O(Z),Z.x)this.style.left=`${Math.round(_*J.width)}px`;if(Z.y)this.style.top=`${Math.round(X*J.height)}px`;this.#H();let Y={...this.#i(J),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&this.#X==="color"&&J)this.#Z.setAttribute("value",J);this.#w()}if(Q==="drag")this.#C();if(Q==="hit-area")this.#A();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#f();if(Q==="value"&&!this.#J&&!this.#$)this.#D(J);if(Q==="tip"){if(this.#a(),this.#X)this.#h(),this.#s()}}#C(){if(this.#K&&!this.#j)this.#j=(Q)=>this.#b(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#K&&this.#j)this.#V()}#f(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let J=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",J==="color"?"Color handle":J==="add"?"Add handle":J==="remove"?"Remove handle":"Handle")}}#V(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#$=!1}#b(Q){if(!this.#K||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#N();if(!$)return;this.#$=!0;let J=this.#W,Z=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,N=Q.clientY,L=3,B=(U,z,A=!1)=>{let G=$.getBoundingClientRect();Z=G;let M=this.#i(G),D=U-X-G.left,T=z-Y-G.top,P=Math.max(0,Math.min(G.width,D)),S=Math.max(0,Math.min(G.height,T)),f=G.width>0?J.x?P/G.width:M.px:0.5,w=G.height>0?J.y?S/G.height:M.py:0.5;if(this.#G(A)){if(J.x)f=this.#M(f);if(J.y)w=this.#M(w);if(J.x&&J.y){let u=this.#R(f,w);f=u.x,w=u.y}}if(this.#O(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(G.width,f*G.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(G.height,w*G.height)))}px`},H=(U)=>{if(!this.#$)return;if(!this.#Q){let z=U.clientX-K,A=U.clientY-N;if(z*z+A*A<L*L)return;if(this.#u(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,B(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#i(Z),shiftKey:U.shiftKey}}))},O=(U)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",O),this.#Q){B(U.clientX,U.clientY,U.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#i(Z)}));let z=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",z,{capture:!0,once:!0})}else this.#H();this.#Q=!1};window.addEventListener("pointermove",H),window.addEventListener("pointerup",O)}showColorTip(){if(!this.#X)return;if(this.#Z){this.#Z.style.display="";return}this.#s()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#y(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,N]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return $},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if(J.startsWith("#"))return Z(J);try{let{ctx:q}=J0(1,1);q.fillStyle="#000000",q.fillStyle=J;let _=q.fillStyle;if(_.startsWith("#"))return Z(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return $}#x(){let{color:Q,opacity:$}=this.#y();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#w(){if(!this.#_)return;this.#_.setAttribute("value",this.#x())}#g(){if(!m())return null;if(this.#_)return this.#_;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.#x()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#c),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#_=Q,Q}#v(){if(this.hasAttribute("disabled"))return;let Q=this.#g();if(!Q){this.#n();return}this.setAttribute("selected",""),this.#w(),Q.open()}#h(){if(!this.#_)return;this.#_.removeEventListener("input",this.#c),this.#_.removeEventListener("change",this.#e),this.#_.removeEventListener("close",this.#j0),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#I(){if(this.#q)return this.#q;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#J0),Q.addEventListener("change",this.#Z0),this.appendChild(Q),this.#q=Q,Q}#n(){let Q=this.#I(),{color:$}=this.#y();Q.value=$,this.setAttribute("selected",""),Q.click()}#m(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#Z0),this.#q.remove(),this.#q=null}#u(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#X;if(!Q)return;if(this.#Z)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#l),$.addEventListener("change",this.#p),$.addEventListener("add",this.#t),$.addEventListener("remove",this.#t),this.appendChild($),this.#Z=$,this.#Q0()}#a(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#l),this.#Z.removeEventListener("change",this.#p),this.#Z.removeEventListener("add",this.#t),this.#Z.removeEventListener("remove",this.#t),this.#Z.remove(),this.#Z=null}#Q0(){if(!this.#Z||this.#X!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#Z.toggleAttribute("selected",Q)}#o(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=p(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#d(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#c=(Q)=>{Q.stopPropagation();let $=this.#d(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#e=(Q)=>{Q.stopPropagation();let $=this.#d(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#$0(Q){let{opacity:$}=this.#y();return $<100?{color:Q,opacity:$}:{color:Q}}#J0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#Z0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#j0=()=>{this.removeAttribute("selected")};#l=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#p=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#t=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#i(Q){let $=Q||this.#N()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,_=J.top-$.top,X=q+Z,Y=_+j,K=$.width>0?X/$.width:0,N=$.height>0?Y/$.height:0;return{x:q,y:_,px:K,py:N}}}customElements.define("fig-handle",_1);class X1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled")this.#$()}#$(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-menu-item",X1);class Y1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",Y1);class K1 extends HTMLElement{#$=null;#Q=null;#j=null;#J;#Z;#_;#q;#Y=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#J=this.#D.bind(this),this.#Z=this.#O.bind(this),this.#_=this.#H.bind(this),this.#q=this.#B.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#X(),this.#U(),this.#K(),this.#W(),this.#G(),this.#z(),this.open)this.#A()}disconnectedCallback(){if(this.#L(),document.removeEventListener("keydown",this.#_,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#$)this.#$.removeEventListener("close",this.#q),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#k();else this.#A();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#X(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#U(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu"),this.#$.setAttribute("id",this.#$.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#q),this.appendChild(this.#$)}#K(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#W(){if(this.addEventListener("keydown",this.#_),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id"));if(this.#$)this.#$.addEventListener("click",this.#Z),this.#$.addEventListener("keydown",this.#_)}#L(){if(this.removeEventListener("keydown",this.#_),this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#Z),this.#$.removeEventListener("keydown",this.#_)}#G(){this.#j=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#X(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id")),this.#$.anchor=this.#Q,this.#z()}}}),this.#j.observe(this,{childList:!0})}#M(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#R(){let Q=this.#M();if(!Q.length){this.#Y=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#Y=J>=0?J:-1}#N(Q){let $=this.#M();if(!$.length)return;let J=(Q+$.length)%$.length;this.#Y=J,$[J].focus()}#z(){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")}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#O(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#F($)}#H(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#$?.contains(Q.target))return;if(!this.open||!this.#$?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#N(0));return}let $=this.#M();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#R(),this.#N(this.#Y+1);break}case"ArrowUp":{Q.preventDefault(),this.#R(),this.#N(this.#Y-1);break}case"Home":{Q.preventDefault(),this.#N(0);break}case"End":{Q.preventDefault(),this.#N($.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#R();let J=$[this.#Y];if(!J)return;Q.preventDefault(),this.#F(J);break}}}#B(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#Y=-1}#F(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#A(){if(!this.#$)return;if(this.#$.open=!0,document.addEventListener("keydown",this.#_,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#Y=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#N(0)})}#k(){if(!this.#$)return;document.removeEventListener("keydown",this.#_,!0),this.#$.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",K1);
|