@rogieking/figui3 8.11.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fig-lab.js CHANGED
@@ -1,3 +1 @@
1
- function P(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function O(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}var OJ="http://www.w3.org/2000/svg";function YJ(J,Q){let Z=($)=>{if($===null||$===void 0||$===!1)return;if(Array.isArray($)){$.forEach(Z);return}J.append($ instanceof Node?$:String($))};return Z(Q),J}function GJ(J,Q={}){for(let[Z,$]of Object.entries(Q)){if($===null||$===void 0||$===!1)continue;if(Z==="className")if(J.namespaceURI===OJ)J.setAttribute("class",String($));else J.className=String($);else if($===!0)J.setAttribute(Z,"");else J.setAttribute(Z,String($))}return J}function G(J,Q,Z){let $=document.createElement(J);return GJ($,Q),YJ($,Z)}function h(J,Q,Z){let $=document.createElementNS(OJ,J);return GJ($,Q),YJ($,Z)}function n(J,Q){let Z=O(J,"disabled");for(let $ of Q)$?.toggleAttribute("disabled",Z)}function pJ(J,Q,Z){let $=Number(Q),j=Number(Z),_=Number.isFinite($)?Math.max(0,Math.min(1,$)):Number.isFinite(j)?Math.max(0,Math.min(100,j))/100:1,X=Number.isFinite(j)?Math.max(0,Math.min(100,j)):Math.round(_*100);return{color:J,alpha:_,opacity:X}}var $J=new WeakMap;function W(J){let Q=$J.get(J);if(!Q){let Z=document.createElement("fig-menu");Z.setAttribute("position","bottom left"),Z.setAttribute("offset","0 0");let $=document.createElement("fig-menu-item");$.setAttribute("value","reset-default"),$.textContent="Reset",Z.appendChild($);let j=0,_=()=>{if(j)clearTimeout(j),j=0;window.removeEventListener("pointerup",X,!0),window.removeEventListener("pointercancel",X,!0)},X=()=>{_();let Y=Q?.point;if(Y)Z.showAt?.(Y.x,Y.y)};Q={menu:Z,point:null,clearPendingOpen:_,handleContextMenu:(Y)=>{if(O(J,"disabled")||Y.target?.closest?.("fig-menu"))return;Y.preventDefault(),Y.stopPropagation(),Y.stopImmediatePropagation?.(),Q.point={x:Y.clientX,y:Y.clientY},_(),window.addEventListener("pointerup",X,{once:!0,capture:!0}),window.addEventListener("pointercancel",X,{once:!0,capture:!0}),j=window.setTimeout(X,180)},handleChange:(Y)=>{if(Y.stopPropagation(),Y.detail?.value==="reset-default")J.resetToDefault?.()}},$J.set(J,Q)}if(Q.menu.parentElement!==J)J.appendChild(Q.menu);J.removeEventListener("contextmenu",Q.handleContextMenu),J.addEventListener("contextmenu",Q.handleContextMenu),Q.menu.removeEventListener("change",Q.handleChange),Q.menu.addEventListener("change",Q.handleChange)}function R(J){let Q=$J.get(J);if(!Q)return;Q.clearPendingOpen(),J.removeEventListener("contextmenu",Q.handleContextMenu),Q.menu.removeEventListener("change",Q.handleChange)}function MJ(J,Q=J.value){let Z={control:J.localName,value:Q},$=J.getAttribute("name");if($!==null&&$!=="")Z.name=$;return Z}function K(J,Q,Z=J.value,$=null){let j=MJ(J,Z);if($&&typeof $==="object")Object.assign(j,$);J.dispatchEvent(new CustomEvent(Q,{detail:j,bubbles:!0,cancelable:!0,composed:!0}))}function d(J){if(J===null||J===void 0||String(J).trim()==="")return null;let Q=Number(J);return Number.isFinite(Q)?Q:null}function D(J){for(let Q of["input","change"])K(J,Q)}function c(J,Q){if(typeof J==="boolean"||typeof Q==="boolean")return Boolean(J)===Boolean(Q);return String(J??"")===String(Q??"")}function u(J,Q){let Z=($)=>{if(Array.isArray($))return $.map(Z);if($&&typeof $==="object")return Object.keys($).sort().reduce((j,_)=>{return j[_]=Z($[_]),j},{});return $};try{let $=typeof J==="string"?JSON.parse(J):J,j=typeof Q==="string"?JSON.parse(Q):Q;return JSON.stringify(Z($))===JSON.stringify(Z(j))}catch{return c(J,Q)}}function gJ(J,Q,Z=0.179){if(!J||!Q)return null;let $=document.createElement("span");$.style.cssText="position:absolute;visibility:hidden;pointer-events:none;color:"+Q,J.appendChild($);let j=getComputedStyle($).color;$.remove();let _=j.match(/[\d.]+/g)?.slice(0,3).map(Number),X=j.startsWith("rgb")?_:j.startsWith("color(srgb")&&_?_.map((k)=>k*255):null;if(!X||X.length<3||X.some(Number.isNaN))return null;let[q,B,Y]=X.map((k)=>{let N=k/255;return N<=0.04045?N/12.92:((N+0.055)/1.055)**2.4});return 0.2126*q+0.7152*B+0.0722*Y<=Z?"light":"dark"}var BJ=0;function kJ(J="fig-lab"){return BJ+=1,`${J}-${BJ}`}class S extends HTMLElement{get name(){return this.getAttribute("name")??""}set name(J){if(J===null||J===void 0||J==="")this.removeAttribute("name");else this.setAttribute("name",String(J))}}function f(J,Q,Z,$=!1){if(!Q||!Z)return null;let j=J.hasAttribute("label"),_=J.getAttribute("label")??"",X=j&&_.trim()==="";if(!$)Z.textContent=j?_:"Label";if(J.toggleAttribute("data-label-empty",X),X)return Z.remove(),null;if(!Z.id)Z.id=kJ(`${J.localName}-label`);if(Z.parentElement!==Q)Q.prepend(Z);return Z.id}function H(J,Q,Z,$="Label"){if(!Q)return;let j=J.getAttribute("aria-label")?.trim();if(j)Q.setAttribute("aria-label",j),Q.removeAttribute("aria-labelledby");else if(Z)Q.setAttribute("aria-labelledby",Z),Q.removeAttribute("aria-label");else Q.setAttribute("aria-label",$),Q.removeAttribute("aria-labelledby")}class NJ extends HTMLElement{}P("fig-ai-prompt",NJ);class PJ extends HTMLElement{}P("fig-ai-context",PJ);class LJ extends HTMLElement{}P("fig-chat-message",LJ);class UJ extends HTMLElement{#$=null;#Z=null;#J=null;#Q=null;#_=null;#j=null;#B=this.#U.bind(this);#q=this.#K.bind(this);#M=this.#P.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#Z)this.#X();this.#_.removeEventListener("click",this.#B),this.#_.addEventListener("click",this.#B),this.#O(),this.#Y()}disconnectedCallback(){this.#_?.removeEventListener("click",this.#B),this.#G()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;this.#Y()}#X(){this.#$=document.createElement("fig-tooltip"),this.#$.className="fig-attachment-tooltip",this.#Z=document.createElement("fig-image"),this.#Z.setAttribute("aspect-ratio","1/1"),this.#Z.setAttribute("fit","cover"),this.#Z.setAttribute("full",""),this.#J=document.createElement("span"),this.#J.className="fig-attachment-fallback",this.#J.setAttribute("aria-hidden","true"),this.#Q=document.createElement("fig-tooltip"),this.#Q.className="fig-attachment-remove-tooltip",this.#Q.setAttribute("text","Remove attachment"),this.#_=document.createElement("fig-button"),this.#_.className="fig-attachment-remove",this.#_.setAttribute("variant","overlay"),this.#_.setAttribute("size","small"),this.#_.setAttribute("icon","");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("size","small"),this.#_.append(J),this.#Q.append(this.#_),this.#Z.append(this.#J),this.#$.append(this.#Z),this.replaceChildren(this.#$,this.#Q),this.#_.addEventListener("click",this.#B),this.#O()}#O(){let J=this.#Z?.mediaEl;if(!J||J===this.#j)return;this.#G(),this.#j=J,this.#j.addEventListener("load",this.#q),this.#j.addEventListener("error",this.#M)}#G(){if(!this.#j)return;this.#j.removeEventListener("load",this.#q),this.#j.removeEventListener("error",this.#M),this.#j=null}#Y(){let J=this.getAttribute("src")||"",Q=this.getAttribute("name")||"Attachment",Z=!this.hasAttribute("removable")||O(this,"removable"),$=O(this,"disabled");if(this.#$.setAttribute("text",Q),this.#Z.setAttribute("alt",Q),J)this.#Z.setAttribute("src",J);else this.#Z.removeAttribute("src");if(this.#O(),this.#J.textContent=this.#k(Q),this.#_.hidden=!Z,this.#_.toggleAttribute("disabled",$),this.#_.setAttribute("aria-label",`Remove ${Q}`),this.toggleAttribute("data-fallback",!J),$)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#k(J){let Q=J.split(/[\\/]/).pop()||"",Z=Q.lastIndexOf(".");return(Z>0&&Z<Q.length-1?Q.slice(Z+1).toUpperCase():"FILE").slice(0,4)}#K(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#P(){this.setAttribute("data-fallback","")}#U(J){if(J.stopPropagation(),O(this,"disabled")||this.hasAttribute("removable")&&!O(this,"removable"))return;this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,cancelable:!0,composed:!0,detail:{value:this.getAttribute("value"),name:this.getAttribute("name")||"",src:this.getAttribute("src")||"",attachment:this}}))}}P("fig-attachment",UJ);class KJ extends HTMLElement{#$=null;connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","list"),this.setAttribute("data-generated-role","");if(this.#Z(),!this.#$)this.#$=new MutationObserver(()=>this.#Z()),this.#$.observe(this,{childList:!0})}disconnectedCallback(){this.#$?.disconnect(),this.#$=null}#Z(){for(let J of this.querySelectorAll(":scope > fig-attachment"))if(!J.hasAttribute("role"))J.setAttribute("role","listitem"),J.setAttribute("data-generated-role","")}}P("fig-attachments",KJ);class SJ extends S{#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=new Set;#B=null;#q=null;#M=this.#T.bind(this);#X=!1;static get observedAttributes(){return["label","aria-label","variant"]}connectedCallback(){if(!this.#$)this.#O();if(this.#k(),this.#P(),this.#U(),this.removeEventListener("click",this.#M),this.addEventListener("click",this.#M),W(this),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#P()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#N(),this.removeEventListener("click",this.#M),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="variant")this.#P();else if(J==="label"||J==="aria-label")this.#k()}#O(){this.#X=O(this,"checked");let Q=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())).find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=G("div",{className:"propskit-switch-surface"}),$=Q||document.createElement("label");Z.append($),this.#$=Z,this.#Z=$,this.#Q=Boolean(Q),this.replaceChildren(Z),this.#Y()}#G(){return this.getAttribute("variant")==="segmented-control"?"segmented-control":"switch"}#Y(){let J=this.#G()==="segmented-control"?"fig-segmented-control":"fig-switch";if(this.#J?.localName===J)return;this.#N(),this.#J?.remove();let Q=document.createElement(J);if(J==="fig-segmented-control"){let Z=document.createElement("fig-segment"),$=document.createElement("fig-segment");Q.setAttribute("sizing","equal"),Z.setAttribute("value","off"),Z.textContent="Off",$.setAttribute("value","on"),$.textContent="On",Q.append(Z,$)}if(this.#J=Q,this.#j.clear(),this.#$?.append(Q),this.isConnected)this.#U()}#k(){let J=f(this,this.#$,this.#Z,this.#Q);if(H(this,this.#J,J,"Switch"),this.#J?.localName==="fig-switch"&&this.#J.input)H(this,this.#J.input,J,"Switch")}#K(){let J=new Set(["label","direction","size","aria-label","oninput","onchange","class","style","id","checked","value","default","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#P(){if(this.#Y(),!this.#J)return;let J=this.#K(),Q=new Set(J);for(let $ of this.#j)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J)this.#J.setAttribute($,this.getAttribute($)??"");let Z=O(this,"checked");if(this.#J.localName==="fig-switch")this.#J.checked=Z,this.#J.value=Z?"on":"off";else this.#J.setAttribute("value",Z?"on":"off");this.#j=Q,this.#k()}#U(){if(!this.#J)return;this.#B??=this.#L.bind(this,"input"),this.#q??=this.#L.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#q)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#q)this.#J.removeEventListener("change",this.#q)}#L(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#J?.localName==="fig-switch"?Boolean(this.#J.checked):this.#J?.value==="on";this.toggleAttribute("checked",Z),K(this,J)}#T(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-switch, fig-segmented-control, fig-menu"))return;if(this.#J?.localName==="fig-switch")this.#J.click();else{let Q=this.#J?.value==="on"?"off":"on";this.#J?.querySelector(`fig-segment[value="${Q}"]`)?.click()}}get checked(){if(!this.#J)return O(this,"checked");return this.#J.localName==="fig-switch"?Boolean(this.#J.checked):this.#J.value==="on"}set checked(J){let Q=Boolean(J);if(this.toggleAttribute("checked",Q),!this.#J)return;if(this.#J.localName==="fig-switch")this.#J.checked=Q,this.#J.value=Q?"on":"off";else this.#J.value=Q?"on":"off"}get value(){return this.checked}set value(J){let Q=typeof J==="string"?!["","false","off","0"].includes(J.trim().toLowerCase()):Boolean(J);this.checked=Q}get defaultValue(){return this.hasAttribute("default")?O(this,"default"):this.#X}get isDefault(){return this.checked===this.defaultValue}resetToDefault(){let J=this.defaultValue;this.checked=J,D(this)}focus(J){if(this.#J?.localName==="fig-switch")this.#J.focus(J);else(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}P("propskit-switch",SJ);function s(J){let Q=String(J??"").trim();if(/^#[0-9a-fA-F]{8}$/.test(Q))return{color:Q.slice(0,7),alpha:parseInt(Q.slice(7,9),16)/255};if(/^#[0-9a-fA-F]{6}$/.test(Q))return{color:Q,alpha:1};if(/^#[0-9a-fA-F]{3}$/.test(Q))return{color:`#${Q[1]}${Q[1]}${Q[2]}${Q[2]}${Q[3]}${Q[3]}`,alpha:1};return{color:Q||"#D9D9D9",alpha:1}}function cJ(J){let{color:Q,alpha:Z}=s(J);return JSON.stringify({type:"solid",color:Q,alpha:Z})}function ZJ(J){return`url("${String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function mJ(J){let Q=String(J??"").trim();if(!Q||Q.startsWith("{")||Q.startsWith("#"))return!1;if(Q.startsWith("data:video/"))return!0;try{let Z=new URL(Q,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test(Z)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Q)}}function uJ(J){return{type:"video",video:{url:J,scaleMode:"fill",scale:50}}}function v(J){if(J&&typeof J==="object")return J;let Q=String(J??"").trim();if(!Q)return{type:"solid",color:"#D9D9D9",alpha:1};if(Q.startsWith("{"))try{let Z=JSON.parse(Q);if(Z&&typeof Z==="object")return Z}catch{}if(Q.startsWith("#")){let{color:Z,alpha:$}=s(Q);return{type:"solid",color:Z,alpha:$}}if(mJ(Q))return uJ(Q);return{type:"solid",color:"#D9D9D9",alpha:1}}function i(J){if(J==null)return"";return typeof J==="string"?J:JSON.stringify(J)}function vJ(J){if(!J)return"";let Q=[...J.stops||[]].sort((Z,$)=>(Z.position??0)-($.position??0)).map((Z)=>`${Z.color} ${Z.position??0}%`).join(", ");if(!Q)return"";switch(J.type){case"radial":return`radial-gradient(circle, ${Q})`;case"angular":return`conic-gradient(from ${J.angle||0}deg, ${Q})`;default:return`linear-gradient(${J.angle??180}deg, ${Q})`}}function qJ(J,Q){switch(J?.type){case"solid":return J.color||"";case"gradient":return J.css||vJ(J.gradient)||"";case"image":return J.image?.url?ZJ(J.image.url):"";case"video":return J.video?.poster?ZJ(J.video.poster):"";case"webcam":return J.webcam?.snapshot?ZJ(J.webcam.snapshot):"";default:return J?.swatchBackground||J?.background||J?.css||Q?.getAttribute("swatch-background")||""}}function sJ(J){if(!J||typeof J!=="object")return null;if(J.type==="image")return J.image;if(J.type==="video")return J.video;if(J.type==="webcam")return J.webcam;return null}function oJ(J){let Q=sJ(J),Z=Number(Q?.scale);switch(Q?.scaleMode){case"fit":return{size:"contain",position:"center"};case"tile":return{size:`${Number.isFinite(Z)?Z:50}%`,position:"top left"};case"fill":case"crop":return{size:"cover",position:"center"};default:return J?.type==="webcam"||J?.type==="image"||J?.type==="video"?{size:"cover",position:"center"}:null}}function rJ(J){switch(J?.type){case"solid":{if(Number.isFinite(J.alpha))return J.alpha;if(Number.isFinite(J.opacity))return J.opacity/100;return 1}case"gradient":return J.gradient?.opacity??J.opacity??1;case"image":return J.image?.opacity??1;case"video":return J.video?.opacity??1;case"webcam":return J.webcam?.opacity??1;default:return J?.opacity??J?.alpha??1}}class TJ extends S{#$=null;#Z=null;#J=null;#Q=null;#_=!1;#j=null;#B=new Set;#q=null;#M=null;#X=this.#H.bind(this);#O=null;static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#$)this.#G();if(this.#Y(),this.#U(),this.#N(),this.#O===null)this.#O=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#X),this.addEventListener("click",this.#X),W(this),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#Y();if(Z)this.#U()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#L(),this.removeEventListener("click",this.#X),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label")this.#Y()}#G(){let J=Array.from(this.childNodes).filter((X)=>X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())),Q=J.find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),Z=G("div",{className:"propskit-color-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-fill-picker"),_=document.createElement("fig-swatch");j.anchorElement=this,j.append(_),_.setAttribute("tabindex","0");for(let X of J)if(X!==Q)j.appendChild(X);Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#Y(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#_);H(this,this.#J,J,"Color")}#k(){return s(this.getAttribute("value"))}#K(){let{color:J,alpha:Q}=this.#k();return JSON.stringify({type:"solid",color:J,alpha:Q})}#P(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default","value","mode","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#P(),Q=new Set(J);for(let _ of this.#B)if(!Q.has(_))this.#J.removeAttribute(_);for(let _ of J)this.#J.setAttribute(_,this.getAttribute(_)??"");this.#J.setAttribute("mode","solid");let Z=this.#K();if(this.#J.getAttribute("value")!==Z)this.#J.setAttribute("value",Z);let{color:$,alpha:j}=this.#k();if(this.#Q)this.#Q.setAttribute("background",$),this.#Q.setAttribute("alpha",String(j));this.#B=Q}#N(){if(!this.#J)return;this.#q??=this.#W.bind(this,"input"),this.#M??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#q),this.#J.addEventListener("change",this.#M)}#L(){if(!this.#J)return;if(this.#q)this.#J.removeEventListener("input",this.#q);if(this.#M)this.#J.removeEventListener("change",this.#M)}#T(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(typeof Q==="string"&&Q)return s(Q).color;if(Q&&typeof Q==="object"){if(typeof Q.color==="string"&&Q.color)return Q.color;if(typeof Q.value==="string"&&Q.value)return s(Q.value).color;if(typeof Q.hex==="string"&&Q.hex)return Q.hex}let Z=this.#J?.value;if(Z&&typeof Z==="object"&&typeof Z.color==="string")return Z.color;if(typeof Z==="string"&&Z)return s(Z).color;return this.#k().color}#F(J,Q){let Z=J instanceof CustomEvent&&J.detail&&typeof J.detail==="object"?J.detail:void 0,$=Number.isFinite(Z?.alpha)?Math.max(0,Math.min(1,Number(Z.alpha))):this.#k().alpha;return{color:Q,alpha:$,opacity:Math.round($*100)}}#W(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#T(Q),$=this.#F(Q,Z),j=$.alpha<0.996078431372549?Math.round($.alpha*255).toString(16).padStart(2,"0"):"",_=`${$.color.slice(0,7)}${j}`;this.setAttribute("value",_);let X=this.#K();if(this.#J&&this.#J.getAttribute("value")!==X)this.#J.setAttribute("value",X);if(this.#Q)this.#Q.setAttribute("background",$.color),this.#Q.setAttribute("alpha",String($.alpha));K(this,J)}#H(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-fill-picker, fig-swatch"))return;this.focus(),this.#J?.open?.()}get value(){return this.getAttribute("value")??this.#J?.value??this.#J?.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J===""){this.removeAttribute("value"),this.#J?.removeAttribute("value");return}let Q=String(J);this.setAttribute("value",Q),this.#z(Q)}#z(J){if(!this.#J)return;let Q=cJ(J);if(this.#J.getAttribute("value")===Q)this.#J.removeAttribute("value");if(this.#J.setAttribute("value",Q),this.#Q){let Z=s(J);this.#Q.setAttribute("background",Z.color),this.#Q.setAttribute("alpha",String(Z.alpha))}}#V(){return this.getAttribute("default")??this.#O??""}get defaultValue(){return String(this.#V())}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#z(J),D(this)}focus(J){let Q=this.querySelector("fig-swatch");if(Q instanceof HTMLElement)Q.focus(J)}}P("propskit-color",TJ);class FJ extends S{#$=null;#Z=null;#J=null;#Q=null;#_=!1;#j=null;#B=new Set;#q=null;#M=null;#X=this.#R.bind(this);#O=null;static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#$)this.#G();if(this.#Y(),this.#F(),this.#W(),this.#O===null)this.#O=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#X),this.addEventListener("click",this.#X),W(this),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#Y();if(Z)this.#F()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#H(),this.removeEventListener("click",this.#X),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label")this.#Y()}#G(){let J=Array.from(this.childNodes).filter((X)=>X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())),Q=J.find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),Z=G("div",{className:"propskit-fill-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-fill-picker"),_=document.createElement("fig-swatch");j.anchorElement=this,j.append(_),_.setAttribute("tabindex","0");for(let X of J)if(X!==Q)j.appendChild(X);Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#Y(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#_);H(this,this.#J,J,"Fill")}#k(){return v(this.getAttribute("value"))}#K(){return i(this.#k())}#P(){let J=this.#k()?.type;if(!J)return null;return this.querySelector(`[slot="mode-${J}"]`)}#U(){let J=this.#J?.value;if(J&&typeof J==="object")return J;if(typeof J==="string"&&J)return v(J);return null}#N(J){let Q=this.#U();if(!J||typeof J!=="object")return J;if(J.type!=="webcam")return J;let Z=J.webcam?.snapshot||Q?.webcam?.snapshot;if(!Z||J.webcam?.snapshot)return J;return{...J,webcam:{...Q?.webcam&&typeof Q.webcam==="object"?Q.webcam:{},...J.webcam,snapshot:Z}}}#L(J=this.#k()){if(!this.#Q)return;let Q=this.#N(J),Z=qJ(Q,this.#P());if(!Z)Z=qJ(this.#U(),this.#P());if(!Z){let j=this.#Q.getAttribute("background")??"";if(j.startsWith("url("))Z=j}this.#Q.setAttribute("background",Z),this.#Q.setAttribute("alpha",String(rJ(Q)));let $=oJ(Q||J);if($)this.#Q.style.setProperty("--swatch-bg-size",$.size),this.#Q.style.setProperty("--swatch-bg-position",$.position)}#T(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default","value","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#F(){if(!this.#J)return;let J=this.#T(),Q=new Set(J);for(let $ of this.#B)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J)this.#J.setAttribute($,this.getAttribute($)??"");let Z=this.#K();if(this.#J.getAttribute("value")!==Z)this.#J.setAttribute("value",Z);this.#L(),this.#B=Q}#W(){if(!this.#J)return;this.#q??=this.#V.bind(this,"input"),this.#M??=this.#V.bind(this,"change"),this.#J.addEventListener("input",this.#q),this.#J.addEventListener("change",this.#M)}#H(){if(!this.#J)return;if(this.#q)this.#J.removeEventListener("input",this.#q);if(this.#M)this.#J.removeEventListener("change",this.#M)}#z(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(Q&&typeof Q==="object")return Q;if(typeof Q==="string"&&Q)return v(Q);let Z=this.#J?.value;if(Z&&typeof Z==="object")return Z;if(typeof Z==="string"&&Z)return v(Z);return this.#k()}#V(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#N(this.#z(Q)),$=i(Z);if(this.setAttribute("value",$),this.#J&&this.#J.getAttribute("value")!==$)this.#J.setAttribute("value",$);this.#L(Z),K(this,J)}#R(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-fill-picker, fig-swatch"))return;this.focus(),this.#J?.open?.()}get value(){return this.getAttribute("value")??i(this.#J?.value)??""}set value(J){if(J===null||J===void 0||J===""){this.removeAttribute("value"),this.#J?.removeAttribute("value"),this.#L({type:"solid",color:"",alpha:1});return}let Q=i(typeof J==="string"?v(J):J);this.setAttribute("value",Q),this.#y(Q)}#y(J){if(!this.#J)return;let Q=i(v(J));if(this.#J.getAttribute("value")===Q)this.#J.removeAttribute("value");this.#J.setAttribute("value",Q),this.#L(v(Q))}#h(){return this.getAttribute("default")??this.#O??""}get defaultValue(){return String(this.#h())}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#y(J),D(this)}focus(J){let Q=this.querySelector("fig-swatch");if(Q instanceof HTMLElement)Q.focus(J)}}P("propskit-fill",FJ);class zJ extends S{#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=new Set;#B=null;#q=null;#M=this.#L.bind(this);#X=null;static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#$)this.#O();if(this.#G(),this.#k(),this.#K(),this.#X===null)this.#X=this.getAttribute("default")??this.getAttribute("value")??JSON.stringify(this.#J?.value??{});if(this.removeEventListener("click",this.#M),this.addEventListener("click",this.#M),W(this),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#G();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#P(),this.removeEventListener("click",this.#M),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label")this.#G()}#O(){let Q=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())).find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=G("div",{className:"propskit-gradient-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-input-gradient");j.anchorElement=this,Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=Boolean(Q),this.replaceChildren(Z)}#G(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#Q);H(this,this.#J,J,"Gradient")}#Y(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","default","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#Y(),Q=new Set(J);for(let Z of this.#j)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J){let $=this.getAttribute(Z)??"";if(Z==="value"&&this.#J.getAttribute("value")===$)continue;this.#J.setAttribute(Z,$)}if(!this.hasAttribute("edit"))this.#J.setAttribute("edit","picker");this.#j=Q}#K(){if(!this.#J)return;this.#B??=this.#N.bind(this,"input"),this.#q??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#q)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#q)this.#J.removeEventListener("change",this.#q)}#U(J){let Q=J instanceof CustomEvent&&J.detail&&typeof J.detail==="object"?J.detail:this.#J?.value;if(!Q||typeof Q!=="object")return this.value;return JSON.stringify(Q)}#N(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#U(Q);this.setAttribute("value",Z),K(this,J)}#L(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-input-gradient, fig-fill-picker, fig-swatch"))return;this.focus(),this.#J?.querySelector?.("fig-fill-picker")?.open?.()}get value(){return this.getAttribute("value")??JSON.stringify(this.#J?.value??{})}set value(J){if(J===null||J===void 0||J===""){this.removeAttribute("value"),this.#J?.removeAttribute("value");return}let Q=typeof J==="object"?JSON.stringify(J):String(J);if(this.setAttribute("value",Q),this.#J&&this.#J.getAttribute("value")!==Q)this.#J.setAttribute("value",Q)}get defaultValue(){return this.getAttribute("default")??this.#X??""}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,D(this)}focus(J){this.#J?.focus(J)}}P("propskit-gradient",zJ);class jJ extends S{#$=null;#Z=null;#J=null;#Q=[];#_=!1;#j=null;#B=[];#q=void 0;#M=!1;#X=0;#O=null;#G=null;#Y=null;#k=null;#K=this.#u.bind(this);#P=this.#c.bind(this);#U=!1;static get observedAttributes(){return["label","aria-label","options","value","disabled"]}connectedCallback(){if(!this.#$)this.#N(),this.#B=this.#L(this.value);if(this.#D(),this.#f(),this.#w(),this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#P,!0),this.addEventListener("pointerdown",this.#P,!0),W(this),!this.#j)this.#j=new MutationObserver((J)=>{if(J.some(({type:Q,attributeName:Z})=>Q==="attributes"&&Z&&!jJ.observedAttributes.includes(Z)&&!["label","name","options","value","default","size","variant","class","style","id"].includes(Z)&&!Z.startsWith("data-")))this.#f()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#x(),this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#P,!0),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(this.#M&&J==="value")return;if(J==="label"||J==="aria-label")this.#D();else if(J==="options")this.#V();else if(J==="value")this.#h();else if(J==="disabled")this.#f()}#N(){let J=this.querySelector(":scope > label"),Q=G("div",{className:"propskit-palette-surface"}),Z=J||document.createElement("label"),$=document.createElement("fig-select"),j=this.#H([]);j.setAttribute("slot","trigger"),j.setAttribute("data-propskit-palette-trigger",""),j.hidden=!0,$.setAttribute("full",""),$.setAttribute("subtle",""),$.append(j),Q.append(Z,$),this.#$=Q,this.#Z=Z,this.#J=$,this.#O=j,this.#_=Boolean(J),this.replaceChildren(Q),this.#V()}#L(J){if(!Array.isArray(J))return[];return J.map((Q)=>({...Q}))}#T(J){let Q=document.createElement("fig-input-palette");if(typeof J==="string")Q.setAttribute("value",J);else Q.setAttribute("value",JSON.stringify(J??[]));return this.#L(Q.value)}#F(J){return JSON.stringify(this.#T(J))}#W(){try{let J=JSON.parse(this.getAttribute("options")||"[]");if(!Array.isArray(J))return[];return J.filter((Q)=>Array.isArray(Q)).map((Q)=>this.#T(Q))}catch{return[]}}#H(J){let Q=document.createElement("fig-input-palette");return Q.className="propskit-palette-preview",Q.setAttribute("value",JSON.stringify(J)),Q.setAttribute("fixed",""),Q.setAttribute("disabled",""),Q.setAttribute("full",""),Q.setAttribute("aria-hidden","true"),Q}#z(J){if(!this.#O)return;this.#O.setAttribute("value",JSON.stringify(J)),this.#O.hidden=!J.length}#V(){if(!this.#J)return;let J=++this.#X;this.#Q=this.#W();let Q=document.createElement("fig-select-options");Q.setAttribute("slot","panel"),Q.className="propskit-palette-options",this.#Q.forEach((Z,$)=>{let j=document.createElement("fig-select-option"),_=document.createElement("span");j.setAttribute("value",String($)),j.setAttribute("label",`Palette ${$+1}`),j.setAttribute("aria-label",`Palette ${$+1}`),_.setAttribute("slot","prepend"),_.className="propskit-palette-option-preview",_.append(this.#H(Z)),j.append(_),Q.append(j)}),this.#M=!0,this.#J.replaceChildren(this.#O,Q),this.#h(),queueMicrotask(()=>{if(J!==this.#X)return;this.#h(),this.#M=!1})}#R(J){let Q=this.#T(J);return this.#Q.findIndex((Z)=>u(Z,Q))}#y(J){let Q=this.#F(J);if(this.getAttribute("value")===Q)return;let Z=this.#M;this.#M=!0,this.setAttribute("value",Q),this.#M=Z}#h(){if(!this.#J)return;if(!this.#Q.length){this.#J.removeAttribute("value"),this.#z([]);let $=this.#M;this.#M=!0,this.removeAttribute("value"),this.#M=$;return}let J=this.hasAttribute("value")?this.getAttribute("value"):this.#Q[0],Q=this.#R(J),Z=Q>=0?Q:0;this.#J.setAttribute("value",String(Z)),this.#y(this.#Q[Z]),this.#z(this.#Q[Z])}#D(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#_);H(this,this.#J,J,"Palette"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Palette"),this.#J.setAttribute("full","")}#f(){if(!this.#J)return;this.#J.toggleAttribute("disabled",O(this,"disabled"));for(let J of["position","offset","closedby"])if(this.hasAttribute(J))this.#J.setAttribute(J,this.getAttribute(J)??"");else this.#J.removeAttribute(J)}#w(){if(!this.#J)return;this.#G??=this.#A.bind(this,"input"),this.#Y??=this.#A.bind(this,"change"),this.#k??=this.#A.bind(this,"optionhover"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#Y),this.#J.addEventListener("optionhover",this.#k)}#x(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#Y)this.#J.removeEventListener("change",this.#Y);if(this.#k)this.#J.removeEventListener("optionhover",this.#k)}#I(J){return this.#L(this.#Q[J]??[])}#C(J,Q){this.#q=Q;try{K(this,J,Q)}finally{this.#q=void 0}}#A(J,Q){if(Q.target!==this.#J)return;if(Q.stopImmediatePropagation(),this.#M||O(this,"disabled"))return;let Z=J==="optionhover"&&Q instanceof CustomEvent?Q.detail:this.#J.getAttribute("value"),$=this.#I(Number(Z));if(J!=="optionhover")this.#y($),this.#z($);this.#C(J,$)}#E(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#c(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select")){this.#U=!1;return}this.#U=this.#E()}#u(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-menu, fig-select")){this.#U=!1;return}if(!this.#J||O(this.#J,"disabled")){this.#U=!1;return}if(this.#J.focus(),this.#U||this.#E()){this.#U=!1,this.#J.open=!1;return}this.#J.open=!0}get value(){if(this.#q!==void 0)return this.#q;let J=Number(this.#J?.getAttribute("value"));if(Number.isInteger(J)&&J>=0)return this.#I(J);if(this.hasAttribute("value"))return this.#T(this.getAttribute("value"));return[]}set value(J){if(J===null||J===void 0){this.removeAttribute("value");return}this.setAttribute("value",this.#F(J))}get defaultValue(){if(this.hasAttribute("default"))return this.#T(this.getAttribute("default"));return this.#L(this.#B)}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){this.value=this.defaultValue;for(let J of["input","change"])this.#C(J,this.value)}focus(J){this.#J?.focus(J)}}P("propskit-palette",jJ);class WJ extends S{#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=new Set;#B=null;#q=null;#M=null;#X=this.#z.bind(this);#O=this.#H.bind(this);#G=!1;#Y=void 0;#k=null;static get observedAttributes(){return["label","aria-label","options","value"]}connectedCallback(){if(!this.#$)this.#K();if(this.#P(),this.#N(),this.#L(),this.removeEventListener("click",this.#X),this.addEventListener("click",this.#X),this.removeEventListener("pointerdown",this.#O,!0),this.addEventListener("pointerdown",this.#O,!0),W(this),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let j=$.attributeName;if(j==="label"||j==="aria-label")Q=!0;else if(j==="direction")continue;else Z=!0}if(Q)this.#P();if(Z)this.#N()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#T(),this.removeEventListener("click",this.#X),this.removeEventListener("pointerdown",this.#O,!0),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label"){this.#P();return}if(J==="options"||J==="value")this.#N()}#K(){this.#k=this.getAttribute("value")??"";let J=this.querySelector(":scope > label"),Q=this.querySelector(":scope > fig-select-options"),Z=G("div",{className:"propskit-select-surface"}),$=J||document.createElement("label"),j=document.createElement("fig-select");if(j.setAttribute("full",""),Q)j.append(Q);Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=Boolean(J),this.replaceChildren(Z)}#P(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#Q);H(this,this.#J,J,"Select"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full","default","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#U().sort((Z,$)=>{if(Z==="options")return-1;if($==="options")return 1;if(Z==="value")return 1;if($==="value")return-1;return 0}),Q=new Set(J);for(let Z of this.#j)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#j=Q}#L(){if(!this.#J)return;this.#B??=this.#F.bind(this,"input"),this.#q??=this.#F.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#q),this.#M??=this.#F.bind(this,"optionhover"),this.#J.addEventListener("optionhover",this.#M)}#T(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#q)this.#J.removeEventListener("change",this.#q);if(this.#M)this.#J.removeEventListener("optionhover",this.#M)}#F(J,Q){if(Q.target!==this.#J)return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#J?.value??"";if(J!=="optionhover")this.setAttribute("value",String(Z));let $=J==="optionhover"&&Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.value;if(J==="optionhover")this.#Y=$;try{K(this,J,$)}finally{this.#Y=void 0}}#W(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#H(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select")){this.#G=!1;return}this.#G=this.#W()}#z(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select")){this.#G=!1;return}if(!this.#J||O(this.#J,"disabled")){this.#G=!1;return}if(this.#J.focus(),this.#G||this.#W()){this.#G=!1,this.#J.open=!1;return}this.#J.open=!0}get value(){return this.#Y??this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get defaultValue(){return this.getAttribute("default")??this.#k??""}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(this.value=J,this.#J)this.#J.value=J;D(this)}focus(J){this.#J?.focus(J)}}P("propskit-select",WJ);class _J extends S{static observedAttributes=["options","value","default","aria-label","disabled"];#$=null;#Z=null;#J=null;#Q=null;#_=null;#j=null;#B="";#q="";#M=void 0;#X=!1;#O=!1;#G=null;#Y=null;#k=0;#K=new Set;#P=null;#U=this.#XJ.bind(this,"input");#N=this.#XJ.bind(this,"change");#L=this.#XJ.bind(this,"optionhover");#T=this.#JJ.bind(this);#F=this.#NJ.bind(this);#W=this.#r.bind(this);#H=this.#BJ.bind(this);#z=this.#GJ.bind(this);#V=this.#qJ.bind(this);#R=this.#n.bind(this);#y=this.#jJ.bind(this);#h=this.#_J.bind(this);#D=(J)=>J.stopImmediatePropagation();connectedCallback(){if(!this.#$)this.#f();if(this.#E(),this.#$J(),W(this),!this.#G)this.#G=new MutationObserver((J)=>{if(J.some((Q)=>Q.type==="attributes"&&Q.attributeName!=="direction"&&Q.attributeName!=="aria-disabled"&&!Q.attributeName?.startsWith("data-")&&!_J.observedAttributes.includes(Q.attributeName)))this.#c()});this.#G.observe(this,{attributes:!0})}disconnectedCallback(){this.#G?.disconnect(),this.#p(),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="value"&&this.#X)return;if(J==="disabled"){this.#b();return}this.#E()}#f(){this.#q=this.#I(this.getAttribute("value"));let J=G("div",{className:"propskit-editable-select-surface"}),Q=G("fig-select",{subtle:!0}),Z=G("fig-select-options",{className:"propskit-editable-select-options",slot:"panel"});Q.append(Z);let $=this.#w("propskit-editable-select-edit","Edit item","edit"),j=this.#w("propskit-editable-select-add","Add item","add"),_=G("fig-tooltip",{className:"propskit-editable-select-edit-tooltip",text:"Edit item"},$),X=G("fig-tooltip",{className:"propskit-editable-select-add-tooltip",text:"Add item"},j);J.append(Q,_,X),this.#$=J,this.#Z=Q,this.#J=Z,this.#_=$,this.#j=j,this.replaceChildren(J),this.#C(this.#q)}#w(J,Q,Z){return G("fig-button",{className:J,variant:"secondary",icon:!0,"aria-label":Q},G("fig-icon",{name:Z,size:"medium","aria-hidden":"true"}))}#x(J=this.getAttribute("options")){let Q=J;if(typeof J==="string"){let j=J.trim();if(j.startsWith("["))try{Q=JSON.parse(j)}catch{Q=[]}else{let _=j.includes(`
2
- `)?`
3
- `:",";Q=j.split(_).map((X)=>X.trim()).filter(Boolean)}}if(!Array.isArray(Q))return[];let Z=new Set,$=[];for(let j of Q){let _=j&&typeof j==="object"&&!Array.isArray(j),X=_?j.value??j.label??"":j,q=_?j.label??j.value??"":j,B=String(X??"").trim(),Y=String(q??"").trim();if(!B||Z.has(B))continue;Z.add(B),$.push({value:B,label:Y||B})}return $}#I(J){let Q=this.#x(),Z=String(J??"").trim();if(Z&&Q.some(($)=>$.value===Z))return Z;return Q[0]?.value||""}#C(J){let Q=this.#I(J),Z=this.getAttribute("value");this.#X=!0;try{if(Q){if(Z!==Q)this.setAttribute("value",Q)}else if(Z!==null)this.removeAttribute("value")}finally{this.#X=!1}if(this.#Z)this.#Z.value=Q;return Q}#A(){let J=new Set(["options","value","default","disabled","name","label","aria-label","aria-disabled","direction","oninput","onchange","onoptionhover","class","style","id","size","variant","full","subtle","data-editing"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#E(){let J=this.#C(this.getAttribute("value"));if(this.#Q&&(!this.#B||J!==this.#B))this.#kJ(!1);this.#c(),this.#b()}#c(){if(!this.#Z)return;let J=this.#A(),Q=new Set(J);for(let $ of this.#K)if(!Q.has($))this.#Z.removeAttribute($);for(let $ of J)this.#Z.setAttribute($,this.getAttribute($)??"");this.#K=Q,this.#u();let Z=this.getAttribute("aria-label")?.trim()||"Select item";this.#Z.setAttribute("label",Z),this.#Z.setAttribute("aria-label",Z),this.#Z.setAttribute("subtle",""),this.#Z.setAttribute("options",JSON.stringify(this.options)),this.#Z.value=this.#I(this.getAttribute("value"))}#u(){if(!this.#J)return;let J=this.options,Q=JSON.stringify(J);if(Q===this.#P)return;this.#P=Q;for(let $ of this.#J.querySelectorAll(":scope > fig-select-option"))$.remove();let Z=this.#J.querySelector(":scope > .fig-overflow-end");for(let $ of J){let j=G("fig-select-option",{value:$.value,label:$.label,"aria-label":`${$.label}. Press Delete to remove this item.`}),_=G("span",{className:"propskit-editable-select-option-label"},$.label),X=G("fig-button",{className:"propskit-editable-select-delete",variant:"ghost",icon:!0,"aria-label":`Delete ${$.label}`,"aria-hidden":"true","data-value":$.value},G("fig-icon",{name:"trash",size:"small","aria-hidden":"true"})),q=G("fig-tooltip",{className:"propskit-editable-select-delete-tooltip",slot:"append",text:`Delete ${$.label}`},X);if(j.append(_,q),Z)this.#J.insertBefore(j,Z);else this.#J.append(j);let B=X.button||X.shadowRoot?.querySelector("button, [role='button']");if(B instanceof HTMLElement)B.inert=!0,B.style.pointerEvents="none"}}#b(){if(!this.#Z||!this.#_||!this.#j)return;let J=O(this,"disabled"),Q=this.options.length<=1;this.setAttribute("aria-disabled",String(J)),this.#Z.toggleAttribute("disabled",J||Q),this.#Q?.toggleAttribute("disabled",J);for(let Z of this.#J?.querySelectorAll(".propskit-editable-select-delete")||[])Z.toggleAttribute("disabled",J||Q);this.#j.toggleAttribute("disabled",J||Boolean(this.#Q)),this.#_.toggleAttribute("disabled",J||!this.#Q&&!this.value)}#S(){if(!this.#_)return;let J=Boolean(this.#Q);this.toggleAttribute("data-editing",J),this.#_.setAttribute("aria-label",J?"Save item":"Edit item"),this.#_.closest("fig-tooltip")?.setAttribute("text",J?"Save item":"Edit item"),this.#_.setAttribute("variant",J?"primary":"secondary"),this.#_.querySelector("fig-icon")?.setAttribute("name",J?"checkmark":"edit"),this.#b()}#$J(){if(this.#p(),this.#Z?.addEventListener("input",this.#U),this.#Z?.addEventListener("change",this.#N),this.#Z?.addEventListener("optionhover",this.#L),this.#_?.addEventListener("click",this.#T),this.#j?.addEventListener("click",this.#F),this.#J?.addEventListener("pointerdown",this.#H),this.#J?.addEventListener("click",this.#z),this.#J?.addEventListener("keydown",this.#V),this.addEventListener("click",this.#W),this.#m()?.addEventListener("toggle",this.#R),this.#a(),!this.#Y&&typeof ResizeObserver==="function")this.#Y=new ResizeObserver(()=>{if(this.#Z?.open)this.#s()});if(this.#$)this.#Y?.observe(this.#$)}#p(){this.#Z?.removeEventListener("input",this.#U),this.#Z?.removeEventListener("change",this.#N),this.#Z?.removeEventListener("optionhover",this.#L),this.#_?.removeEventListener("click",this.#T),this.#j?.removeEventListener("click",this.#F),this.#J?.removeEventListener("pointerdown",this.#H),this.#J?.removeEventListener("click",this.#z),this.#J?.removeEventListener("keydown",this.#V),this.removeEventListener("click",this.#W),this.#m()?.removeEventListener("toggle",this.#R),this.#Y?.disconnect(),this.#Y=null,cancelAnimationFrame(this.#k),this.#k=0}#m(){return this.#Z?.shadowRoot?.querySelector('dialog[is="fig-popup"]')}#a(){let J=this.#m();if(!J||J.__propskitEditableSelectPositioning||typeof J.positionPopup!=="function")return;let Q=J.positionPopup.bind(J);J.positionPopup=(...Z)=>{let $=Q(...Z);return this.#s(),$},J.__propskitEditableSelectPositioning=!0}#n(J){if(J.newState==="open"||this.#Z?.open)this.#s()}#s(){cancelAnimationFrame(this.#k),this.#k=requestAnimationFrame(()=>{this.#g(),this.#k=requestAnimationFrame(()=>{this.#k=0,this.#g()})})}#g(){let J=this.#m();if(!J||!this.#$||!this.#Z?.open)return;let Q=this.#$.getBoundingClientRect();if(!Q.width)return;J.style.setProperty("box-sizing","border-box","important"),J.style.setProperty("left",`${Q.left}px`,"important"),J.style.setProperty("width",`${Q.width}px`,"important"),J.style.setProperty("min-width",`${Q.width}px`,"important"),J.style.setProperty("max-width",`${Q.width}px`,"important")}#XJ(J,Q){if(Q.target!==this.#Z)return;if(Q.stopImmediatePropagation(),this.#O)return;if(O(this,"disabled"))return;let Z=J==="optionhover"&&Q instanceof CustomEvent?String(Q.detail??""):this.#C(this.#Z.value);this.#o(J,Z)}#o(J,Q=this.value){let Z=String(Q??""),$=this.options.find((j)=>j.value===Z)?.label||"";this.#M=Z;try{K(this,J,Z,{label:$})}finally{this.#M=void 0}}#d(J,Q,Z){let $=this.value,j=this.options.map((X)=>({...X})),_=j.find((X)=>X.value===$)?.label||"";this.dispatchEvent(new CustomEvent("optionschange",{detail:{...MJ(this,$),label:_,action:J,option:{...Q},index:Z,options:j},bubbles:!0,composed:!0}))}#JJ(J){if(J.preventDefault(),J.stopPropagation(),O(this,"disabled"))return;if(this.#Q)this.#QJ();else this.#t()}#r(J){if(this.#Q||!this.#Z||O(this,"disabled")||O(this.#Z,"disabled")||J.target instanceof Element&&J.target.closest(".propskit-editable-select-edit, .propskit-editable-select-add, fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select"))return;J.preventDefault(),this.#Z.open=!0}#NJ(J){if(J.preventDefault(),J.stopPropagation(),O(this,"disabled")||this.#Q)return;let Q=this.options,Z=Q.length,$={value:`item-${Z}`,label:"New item"};this.options=[...Q,$];let j=$.value;this.#C(j),this.#c(),this.#d("add",$,Z);for(let _ of["input","change"])this.#o(_);this.#t()}#BJ(J){if(!(J.target instanceof Element)||!J.target.closest(".propskit-editable-select-delete"))return;J.preventDefault(),J.stopPropagation()}#GJ(J){if(!(J.target instanceof Element))return;let Q=J.target.closest(".propskit-editable-select-delete");if(!Q||!this.#J?.contains(Q))return;if(J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),O(this,"disabled")||O(Q,"disabled"))return;this.#PJ(Q.getAttribute("data-value")||"")}#qJ(J){if(J.key!=="Delete"&&J.key!=="Backspace"||J.altKey||J.ctrlKey||J.metaKey||J.shiftKey||!(J.target instanceof Element))return;let Q=J.target.closest("fig-select-option");if(!Q||Q.parentElement!==this.#J)return;J.preventDefault(),J.stopImmediatePropagation(),this.#PJ(Q.getAttribute("value")||"")}#PJ(J){if(!this.#Z||!this.#J||O(this,"disabled"))return;let Q=this.options;if(Q.length<=1)return;let Z=Q.findIndex((Y)=>Y.value===J);if(Z<0)return;let $={...Q[Z]},j=this.#Z.open,_=this.value,X=Q.filter((Y)=>Y.value!==J),q=Math.min(Z,X.length-1),B=_===J?X[Math.max(0,q)]?.value||"":_;this.#O=!0;try{if(B)this.#C(B);this.options=X,this.#C(B),this.#c()}finally{this.#O=!1}if(this.#d("delete",$,Z),_!==B)for(let Y of["input","change"])this.#o(Y);queueMicrotask(()=>{if(X.length>1){if(j)this.#Z.open=!0;[...this.#J.querySelectorAll(":scope > fig-select-option")][Math.max(0,q)]?.focus()}else this.#Z.open=!1,requestAnimationFrame(()=>this.#j?.focus())})}#t(){if(!this.#$||!this.value||O(this,"disabled"))return;let J=this.options.find((Z)=>Z.value===this.value);if(!J)return;let Q=G("fig-input-text",{type:"text",full:!0,value:J.label,"aria-label":`Rename ${J.label}`});Q.addEventListener("input",this.#D),Q.addEventListener("change",this.#D),Q.addEventListener("keydown",this.#y),Q.addEventListener("focusout",this.#h),this.#B=J.value,this.#Q=Q,this.#Z.replaceWith(Q),this.#S(),queueMicrotask(()=>{Q.focus(),Q.input?.select?.()})}#jJ(J){if(J.key==="Enter")J.preventDefault(),J.stopImmediatePropagation(),this.#QJ();else if(J.key==="Escape")J.preventDefault(),J.stopImmediatePropagation(),this.#kJ()}#_J(J){if(!this.#Q)return;let Q=J.relatedTarget;if(Q instanceof Node&&this.#Q.contains(Q))return;if(Q instanceof Node&&(Q===this.#_||this.#_?.contains(Q)||Q.getRootNode()instanceof ShadowRoot&&Q.getRootNode().host===this.#_))return;this.#QJ(!1)}#MJ(J=!0){if(!this.#$||!this.#Z)return;let Q=this.#Q;if(this.#Q=null,this.#B="",Q?.parentElement===this.#$)Q.replaceWith(this.#Z);else if(this.#Z.parentElement!==this.#$)this.#$.prepend(this.#Z);if(this.#c(),this.#S(),J)queueMicrotask(()=>this.#Z?.focus())}#QJ(J=!0){if(!this.#Q||!this.#B)return;let Q=this.#B,Z=this.options,$=Z.findIndex((X)=>X.value===Q);if($<0){this.#kJ(J);return}let j=String(this.#Q.value??"").trim()||Z[$].label,_=j!==Z[$].label;if(this.#MJ(!1),_){let X={...Z[$],label:j};Z[$]=X,this.options=Z,this.#d("rename",X,$)}if(this.#C(Q),this.#c(),_)for(let X of["input","change"])this.#o(X);if(J)queueMicrotask(()=>this.#Z?.focus())}#kJ(J=!0){this.#MJ(J)}get options(){return this.#x()}set options(J){if(J===null||J===void 0){this.removeAttribute("options");return}this.setAttribute("options",JSON.stringify(this.#x(J)))}get value(){return this.#M??this.#I(this.getAttribute("value")??this.#Z?.value??"")}set value(J){this.#C(J),this.#c()}get defaultValue(){let J=this.hasAttribute("default")?this.getAttribute("default"):this.#q;return this.#I(J)}get isDefault(){return c(this.value,this.defaultValue)}get editing(){return Boolean(this.#Q)}resetToDefault(){this.#kJ(!1),this.value=this.defaultValue;for(let J of["input","change"])this.#o(J)}focus(J){if(O(this,"disabled"))return;if(this.#Q)this.#Q.focus(J);else this.#Z?.focus(J)}}P("propskit-editable-select",_J);class HJ extends S{#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=new Set;#B=null;#q=null;#M=this.#N.bind(this);#X=null;static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#$)this.#O();if(this.#G(),this.#k(),this.#K(),this.removeEventListener("click",this.#M),this.addEventListener("click",this.#M),W(this),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#G();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#P(),this.removeEventListener("click",this.#M),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label")this.#G()}#O(){this.#X=this.getAttribute("value")??"";let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=G("div",{className:"propskit-text-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-input-text");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=Boolean(Q),this.replaceChildren(Z)}#G(){if(!this.#$||!this.#Z||!this.#J)return;let J=f(this,this.#$,this.#Z,this.#Q);H(this,this.#J,J,"Text")}#Y(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","type","aria-label","multiline","autoresize","resizable","default","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#Y(),Q=["multiline","autoresize"],Z=new Set([...J,...Q,"type"]);for(let $ of this.#j)if(!Z.has($))this.#J.removeAttribute($);for(let $ of J)this.#J.setAttribute($,this.getAttribute($)??"");for(let $ of Q)this.#J.setAttribute($,this.getAttribute($)??"");this.#J.setAttribute("type","text"),this.#j=Z}#K(){if(!this.#J)return;this.#B??=this.#U.bind(this,"input"),this.#q??=this.#U.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#q)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#q)this.#J.removeEventListener("change",this.#q)}#U(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#J?.value??"";this.setAttribute("value",String(Z)),K(this,J)}#N(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-text, fig-menu"))return;this.focus()}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0){if(this.removeAttribute("value"),this.#J)this.#J.value=""}else{let Q=String(J);if(this.setAttribute("value",Q),this.#J)this.#J.value=Q}}get defaultValue(){return this.getAttribute("default")??this.#X??""}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,D(this)}focus(J){this.#J?.focus(J)}}P("propskit-text",HJ);class RJ extends S{#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=new Set;#B=null;#q=null;#M=this.#L.bind(this);#X=this.#T.bind(this);#O=null;static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#$)this.#G();if(this.#Y(),this.#K(),this.#P(),this.removeEventListener("click",this.#M),this.addEventListener("click",this.#M),this.removeEventListener("keydown",this.#X),this.addEventListener("keydown",this.#X),W(this),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#Y();if(Z)this.#K()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#M),this.removeEventListener("keydown",this.#X),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="label"||J==="aria-label")this.#Y()}#G(){this.#O=this.getAttribute("value")??this.getAttribute("min")??"0";let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=G("div",{className:"propskit-number-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-input-number");Z.append($,j),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=Boolean(Q),this.replaceChildren(Z);for(let _ of J)if(_!==Q)j.appendChild(_)}#Y(){let J=f(this,this.#$,this.#Z,this.#Q);H(this,this.#J,J,"Number")}#k(){let J=new Set(["label","direction","size","aria-label","oninput","onchange","class","style","id","default","variant"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#k(),Q=new Set(J);for(let Z of this.#j)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#j=Q}#P(){if(!this.#J)return;this.#B??=this.#N.bind(this,"input"),this.#q??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#q)}#U(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#q)this.#J.removeEventListener("change",this.#q)}#N(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=d(this.#J?.value);if(Z===null)this.removeAttribute("value");else this.setAttribute("value",String(Z));K(this,J)}#L(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.focus()}#T(J){if(!["ArrowUp","ArrowDown"].includes(J.key)||!(J.target instanceof Element)||!J.target.closest("fig-input-number"))return;J.stopPropagation();let Q=this.#J?.querySelector("input");queueMicrotask(()=>{if(this.isConnected&&!O(this,"disabled"))Q?.focus({preventScroll:!0})})}get value(){return d(this.#J?.value??this.getAttribute("value"))}set value(J){if(J===null||J===void 0||J===""){if(this.removeAttribute("value"),this.#J)this.#J.value=""}else{let Q=String(J);if(this.setAttribute("value",Q),this.#J)this.#J.value=Q}}get defaultValue(){return this.getAttribute("default")??this.#O??"0"}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,D(this)}focus(J){this.#J?.focus(J)}}P("propskit-number",RJ);class VJ extends S{static observedAttributes=["x","y","default","label","aria-label","units","disabled"];#$=null;#Z=null;#J=!1;#Q=null;#_=null;#j=null;#B=!1;#q=!1;#M=this.#z.bind(this,"input");#X=this.#z.bind(this,"change");#O=this.#V.bind(this);connectedCallback(){if(!this.#B)this.#j=this.#Y(),this.#K(this.#j),this.#B=!0;if(!this.#$)this.#U();this.#N(),this.#L(),this.#W(),this.removeEventListener("click",this.#O),this.addEventListener("click",this.#O),W(this)}disconnectedCallback(){this.#H(),this.removeEventListener("click",this.#O),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#B)return;if((J==="x"||J==="y")&&!this.#q)this.#L();else if(J==="label"||J==="aria-label")this.#N();else if(J==="units")this.#T();else if(J==="disabled")this.#F()}#G(J,Q=50){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#Y(){let J=this.getAttribute("x"),Q=this.getAttribute("y");return{x:J===null||!J.trim()?50:this.#G(J,50),y:Q===null||!Q.trim()?50:this.#G(Q,50)}}#k(J){if(typeof J!=="string"||!J.trim())return null;try{let Q=JSON.parse(J);if(!Q||typeof Q!=="object"||Array.isArray(Q))return null;return{x:this.#G(Q.x,this.#j?.x??50),y:this.#G(Q.y,this.#j?.y??50)}}catch{return null}}#K(J){let Q=this.#Y(),Z={x:this.#G(J?.x,Q.x),y:this.#G(J?.y,Q.y)};return this.#q=!0,this.setAttribute("x",String(Z.x)),this.setAttribute("y",String(Z.y)),this.#q=!1,Z}#P(J,Q){let Z=document.createElement("fig-input-number");if(Z.setAttribute("data-propskit-position-axis",J),Z.setAttribute("value",String(Q)),Z.setAttribute("min","0"),Z.setAttribute("max","100"),Z.setAttribute("step","1"),Z.setAttribute("precision","2"),this.units==="percent")Z.setAttribute("units","%");Z.setAttribute("aria-label",`${J.toUpperCase()} position`);let $=document.createElement("span");if($.setAttribute("slot","prepend"),$.textContent=J.toUpperCase(),Z.append($),O(this,"disabled"))Z.setAttribute("disabled","");return Z}#U(){let J=this.#Y(),Q=this.querySelector(":scope > label"),Z=G("div",{className:"propskit-position-surface",role:"group"}),$=Q||document.createElement("label"),j=this.#P("x",J.x),_=this.#P("y",J.y);Z.append($,j,_),this.#$=Z,this.#Z=$,this.#J=Boolean(Q),this.#Q=j,this.#_=_,this.replaceChildren(Z),W(this)}#N(){let J=f(this,this.#$,this.#Z,this.#J);H(this,this.#$,J,"Position")}#L(){let J=this.#Y();this.#Q?.setAttribute("value",String(J.x)),this.#_?.setAttribute("value",String(J.y)),this.#T(),this.#F()}#T(){let J=this.units==="percent"?"%":null;for(let Q of[this.#Q,this.#_]){if(!Q)continue;if(J)Q.setAttribute("units",J);else Q.removeAttribute("units")}}#F(){let J=O(this,"disabled");this.#Q?.toggleAttribute("disabled",J),this.#_?.toggleAttribute("disabled",J)}#W(){this.#H(),this.#Q?.addEventListener("input",this.#M),this.#Q?.addEventListener("change",this.#X),this.#_?.addEventListener("input",this.#M),this.#_?.addEventListener("change",this.#X)}#H(){this.#Q?.removeEventListener("input",this.#M),this.#Q?.removeEventListener("change",this.#X),this.#_?.removeEventListener("input",this.#M),this.#_?.removeEventListener("change",this.#X)}#z(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=Q.currentTarget?.getAttribute("data-propskit-position-axis");if(Z!=="x"&&Z!=="y")return;let $=this.value;$[Z]=this.#G(Q.currentTarget.value,$[Z]),this.#K($),K(this,J)}#V(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.focus()}get x(){return this.#Y().x}set x(J){this.setAttribute("x",String(this.#G(J,50)))}get y(){return this.#Y().y}set y(J){this.setAttribute("y",String(this.#G(J,50)))}get units(){return this.getAttribute("units")?.trim().toLowerCase()==="percent"?"percent":"none"}set units(J){this.setAttribute("units",String(J).trim().toLowerCase()==="none"?"none":"percent")}get value(){return{...this.#Y()}}set value(J){let Q=this.#K(J);this.#L(Q)}get defaultValue(){return this.#k(this.getAttribute("default"))||{...this.#j||{x:50,y:50}}}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,D(this)}focus(J){this.#Q?.focus(J)}}P("propskit-position",VJ);class fJ extends S{static observedAttributes=["value","default","label","aria-label","axis-labels","coordinates","precision","disabled"];#$=null;#Z=null;#J=!1;#Q=null;#_=null;#j={x:50,y:50};#B=!1;#q=this.#W.bind(this,"input");#M=this.#W.bind(this,"change");connectedCallback(){if(!this.#$)this.#j=this.#O(this.getAttribute("value"),this.#j),this.#G(this.#j),this.#Y();this.#k(),this.#K(),this.#T(),this.#_?.observe(this.#Q,{childList:!0,subtree:!0}),W(this)}disconnectedCallback(){this.#F(),this.#_?.disconnect(),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="value"&&!this.#B)this.#G(this.#O(Z,this.value)),this.#U();else if(J==="label"||J==="aria-label")this.#k();else if(J==="axis-labels"||J==="coordinates"||J==="precision")this.#P();else if(J==="disabled")this.#N()}#X(J,Q=50){let Z=Number(J);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#O(J,Q={x:50,y:50}){let Z=J;if(typeof J==="string"){let $=J.trim();if(!$)return{...Q};try{Z=JSON.parse($)}catch{let j=$.split(/[\s,]+/).filter(Boolean),_=(X,q)=>{if(!X)return q;let B=Number.parseFloat(X.replace(/%/g,""));if(!Number.isFinite(B))return q;return X.includes("%")||Math.abs(B)>1?B:B*100};Z={x:_(j[0],Q.x),y:_(j[1]??j[0],Q.y)}}}if(!Z||typeof Z!=="object"||Array.isArray(Z))return{...Q};return{x:this.#X(Z.x,Q.x),y:this.#X(Z.y,Q.y)}}#G(J){let Q=this.#O(J,this.#j),Z=JSON.stringify(Q);if(this.getAttribute("value")!==Z)this.#B=!0,this.setAttribute("value",Z),this.#B=!1;return Q}#Y(){let J=this.querySelector(":scope > label"),Q=G("div",{className:"propskit-joystick-surface",role:"group"}),Z=J||document.createElement("label"),$=document.createElement("fig-joystick");$.setAttribute("fields","true"),$.setAttribute("aspect-ratio","1 / 1"),Q.append(Z,$),this.#$=Q,this.#Z=Z,this.#J=Boolean(J),this.#Q=$,this.replaceChildren(Q),this.#_=new MutationObserver(()=>this.#L()),this.#_.observe($,{childList:!0,subtree:!0})}#k(){let J=f(this,this.#$,this.#Z,this.#J);H(this,this.#Q,J,"Joystick"),this.#L()}#K(){this.#P(),this.#U(),this.#N()}#P(){if(!this.#Q)return;this.#Q.setAttribute("fields","true"),this.#Q.setAttribute("aspect-ratio","1 / 1");for(let J of["axis-labels","coordinates","precision"])if(this.hasAttribute(J))this.#Q.setAttribute(J,this.getAttribute(J)??"");else this.#Q.removeAttribute(J)}#U(){if(!this.#Q)return;let J=this.value,Q=`${J.x}% ${J.y}%`;if(this.#Q.getAttribute("value")!==Q)this.#Q.setAttribute("value",Q)}#N(){if(!this.#Q||!this.#$)return;let J=O(this,"disabled");this.#$.setAttribute("aria-disabled",String(J)),this.#Q.toggleAttribute("disabled",J),this.#Q.inert=J,this.#L()}#L(){if(!this.#Q)return;let J=O(this,"disabled"),Q=this.#Z?.isConnected?this.#Z.id:"",Z=this.getAttribute("aria-label")?.trim(),$=this.#Q.querySelector("fig-handle");if($)if($.toggleAttribute("disabled",J),Z)$.setAttribute("aria-label",Z),$.removeAttribute("aria-labelledby");else if(Q)$.setAttribute("aria-labelledby",Q),$.removeAttribute("aria-label");else $.setAttribute("aria-label","Joystick"),$.removeAttribute("aria-labelledby");for(let j of this.#Q.querySelectorAll("fig-input-number"))j.toggleAttribute("disabled",J)}#T(){this.#F(),this.#Q?.addEventListener("input",this.#q),this.#Q?.addEventListener("change",this.#M)}#F(){this.#Q?.removeEventListener("input",this.#q),this.#Q?.removeEventListener("change",this.#M)}#W(J,Q){if(Q.stopImmediatePropagation(),Q.target!==this.#Q||O(this,"disabled"))return;let Z=this.#O(Q.detail?.value,this.value);this.#G(Z),this.#U(),K(this,J)}get value(){return this.#O(this.getAttribute("value"),this.#j)}set value(J){this.#G(J),this.#U()}get defaultValue(){return this.#O(this.getAttribute("default"),this.#j)}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){this.value=this.defaultValue,D(this)}focus(J){if(O(this,"disabled"))return;this.#Q?.focus(J)}}P("propskit-joystick",fJ);class CJ extends S{static observedAttributes=["value","default","label","aria-label","precision","drag","disabled"];#$=null;#Z=null;#J=!1;#Q=null;#_=null;#j={x:50,y:50};#B=!1;#q=this.#H.bind(this,"input");#M=this.#H.bind(this,"change");connectedCallback(){if(!this.#$)this.#j=this.#G(this.getAttribute("value"),this.#j),this.#Y(this.#j),this.#k();this.#K(),this.#P(),this.#F(),this.#_?.observe(this.#Q,{childList:!0,subtree:!0}),W(this)}disconnectedCallback(){this.#W(),this.#_?.disconnect(),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="value"&&!this.#B)this.#Y(this.#G(Z,this.value)),this.#N();else if(J==="label"||J==="aria-label")this.#K();else if(J==="precision"||J==="drag")this.#U();else if(J==="disabled")this.#L()}#X(J,Q=50){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#O(J,Q,Z){let $=String(J??"").trim().toLowerCase(),j=Q==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in j)return j[$];let _=Number.parseFloat($.replace(/%/g,""));return Number.isFinite(_)?_:Z}#G(J,Q={x:50,y:50}){let Z=J;if(typeof J==="string"){let $=J.trim();if(!$)return{...Q};try{Z=JSON.parse($)}catch{let j=$.replace(/,/g," ").split(/\s+/).filter(Boolean);Z={x:this.#O(j[0],"x",Q.x),y:this.#O(j[1]??j[0],"y",Q.y)}}}if(!Z||typeof Z!=="object"||Array.isArray(Z))return{...Q};return{x:this.#X(Z.x,Q.x),y:this.#X(Z.y,Q.y)}}#Y(J){let Q=this.#G(J,this.#j),Z=JSON.stringify(Q);if(this.getAttribute("value")!==Z)this.#B=!0,this.setAttribute("value",Z),this.#B=!1;return Q}#k(){let J=this.querySelector(":scope > label"),Q=G("div",{className:"propskit-origin-surface",role:"group"}),Z=J||document.createElement("label"),$=document.createElement("fig-origin-grid");$.setAttribute("fields","true"),$.setAttribute("aspect-ratio","1 / 1"),Q.append(Z,$),this.#$=Q,this.#Z=Z,this.#J=Boolean(J),this.#Q=$,this.replaceChildren(Q),this.#_=new MutationObserver(()=>this.#T()),this.#_.observe($,{childList:!0,subtree:!0})}#K(){let J=f(this,this.#$,this.#Z,this.#J);H(this,this.#Q,J,"Origin"),this.#T()}#P(){this.#U(),this.#N(),this.#L()}#U(){if(!this.#Q)return;this.#Q.setAttribute("fields","true"),this.#Q.setAttribute("aspect-ratio","1 / 1");for(let J of["precision","drag"])if(this.hasAttribute(J))this.#Q.setAttribute(J,this.getAttribute(J)??"");else this.#Q.removeAttribute(J)}#N(){if(!this.#Q)return;let J=this.value,Q=`${J.x}% ${J.y}%`;if(this.#Q.getAttribute("value")!==Q)this.#Q.setAttribute("value",Q)}#L(){if(!this.#Q||!this.#$)return;let J=O(this,"disabled");this.#$.setAttribute("aria-disabled",String(J)),this.#Q.toggleAttribute("disabled",J),this.#Q.inert=J,this.#T()}#T(){if(!this.#Q)return;let J=O(this,"disabled"),Q=this.#Z?.isConnected?this.#Z.id:"",Z=this.getAttribute("aria-label")?.trim(),$=this.#Q.querySelector("fig-handle");if($)if($.toggleAttribute("disabled",J),Z)$.setAttribute("aria-label",Z),$.removeAttribute("aria-labelledby");else if(Q)$.setAttribute("aria-labelledby",Q),$.removeAttribute("aria-label");else $.setAttribute("aria-label","Origin"),$.removeAttribute("aria-labelledby");for(let j of this.#Q.querySelectorAll("fig-input-number"))j.toggleAttribute("disabled",J)}#F(){this.#W(),this.#Q?.addEventListener("input",this.#q),this.#Q?.addEventListener("change",this.#M)}#W(){this.#Q?.removeEventListener("input",this.#q),this.#Q?.removeEventListener("change",this.#M)}#H(J,Q){if(Q.stopImmediatePropagation(),Q.target!==this.#Q||O(this,"disabled"))return;let Z=this.#G(Q.detail,this.value);this.#Y(Z),this.#N(),K(this,J)}get value(){return this.#G(this.getAttribute("value"),this.#j)}set value(J){this.#Y(J),this.#N()}get defaultValue(){return this.#G(this.getAttribute("default"),this.#j)}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){this.value=this.defaultValue,D(this)}focus(J){if(O(this,"disabled"))return;this.#Q?.querySelector("fig-handle")?.focus(J)}}P("propskit-origin",CJ);class XJ extends S{static observedAttributes=["value","default","label","aria-label","precision","edit","disabled"];#$=null;#Z=null;#J=!1;#Q=null;#_=null;#j=null;#B=!1;#q=this.#V.bind(this,"input");#M=this.#V.bind(this,"change");connectedCallback(){if(!this.#$)this.#j=this.#k(this.getAttribute("value"),this.#O()),this.#K(this.#j),this.#P();this.#U(),this.#N(),this.#H(),this.#_?.observe(this.#Q,{childList:!0,subtree:!0}),W(this)}disconnectedCallback(){this.#z(),this.#_?.disconnect(),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="value"&&!this.#B)this.#K(this.#k(Z,this.value)),this.#T();else if(J==="label"||J==="aria-label")this.#U();else if(J==="precision"||J==="edit")this.#L();else if(J==="disabled")this.#F()}#X(){return this.localName==="propskit-spring"}#O(){return this.#X()?{stiffness:200,damping:15,mass:1}:{x1:0.42,y1:0,x2:0.58,y2:1}}#G(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#Y(J,Q){let Z=this.#G(J,Q);return Z>0?Z:Q}#k(J,Q=this.#O()){let Z=J;if(typeof J==="string"){let $=J.trim();if(!$)return{...Q};try{Z=JSON.parse($)}catch{if(this.#X()){let j=$.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);Z=j?{stiffness:Number(j[1]),damping:Number(j[2]),mass:Number(j[3])}:null}else{let _=$.replace(/^cubic-bezier\(\s*/i,"").replace(/\s*\)$/,"").split(",").map((X)=>Number(X.trim()));Z=_.length===4&&_.every(Number.isFinite)?{x1:_[0],y1:_[1],x2:_[2],y2:_[3]}:null}}}if(this.#X()){if(!Z||typeof Z!=="object"||Array.isArray(Z))return{...Q};return{stiffness:this.#Y(Z.stiffness,Q.stiffness),damping:this.#Y(Z.damping,Q.damping),mass:this.#Y(Z.mass,Q.mass)}}if(Array.isArray(Z))Z={x1:Z[0],y1:Z[1],x2:Z[2],y2:Z[3]};if(!Z||typeof Z!=="object")return{...Q};return{x1:Math.max(0,Math.min(1,this.#G(Z.x1,Q.x1))),y1:this.#G(Z.y1,Q.y1),x2:Math.max(0,Math.min(1,this.#G(Z.x2,Q.x2))),y2:this.#G(Z.y2,Q.y2)}}#K(J){let Q=this.#j||this.#O(),Z=this.#k(J,Q),$=JSON.stringify(Z);if(this.getAttribute("value")!==$)this.#B=!0,this.setAttribute("value",$),this.#B=!1;return Z}#P(){let J=this.querySelector(":scope > label"),Q=G("div",{className:`${this.localName}-surface`,role:"group"}),Z=J||document.createElement("label"),$=document.createElement("fig-easing-curve");$.setAttribute("mode",this.#X()?"spring":"bezier"),$.setAttribute("aspect-ratio","1 / 1"),Q.append(Z,$),this.#$=Q,this.#Z=Z,this.#J=Boolean(J),this.#Q=$,this.replaceChildren(Q),this.#_=new MutationObserver(()=>this.#W()),this.#_.observe($,{childList:!0,subtree:!0})}#U(){let J=f(this,this.#$,this.#Z,this.#J);H(this,this.#Q,J,this.#X()?"Spring":"Easing"),this.#W()}#N(){this.#L(),this.#T(),this.#F()}#L(){if(!this.#Q)return;this.#Q.setAttribute("mode",this.#X()?"spring":"bezier"),this.#Q.setAttribute("aspect-ratio","1 / 1");for(let J of["precision","edit"])if(this.hasAttribute(J))this.#Q.setAttribute(J,this.getAttribute(J)??"");else this.#Q.removeAttribute(J)}#T(){if(!this.#Q)return;let J=this.value,Q=this.#X()?`spring(${J.stiffness}, ${J.damping}, ${J.mass})`:`${J.x1}, ${J.y1}, ${J.x2}, ${J.y2}`;if(this.#Q.getAttribute("value")!==Q)this.#Q.setAttribute("value",Q)}#F(){if(!this.#Q||!this.#$)return;let J=O(this,"disabled");this.#$.setAttribute("aria-disabled",String(J)),this.#Q.toggleAttribute("disabled",J),this.#Q.inert=J,this.#W()}#W(){if(!this.#Q)return;let J=O(this,"disabled");this.#Q.querySelector("fig-select")?.setAttribute("variant","ghost");for(let Q of this.#Q.querySelectorAll("fig-handle, fig-select, fig-dropdown, fig-input-text"))Q.toggleAttribute("disabled",J);for(let Q of this.#Q.querySelectorAll("input, select"))Q.disabled=J}#H(){this.#z(),this.#Q?.addEventListener("input",this.#q),this.#Q?.addEventListener("change",this.#M)}#z(){this.#Q?.removeEventListener("input",this.#q),this.#Q?.removeEventListener("change",this.#M)}#V(J,Q){if(Q.stopImmediatePropagation(),Q.target!==this.#Q||O(this,"disabled"))return;let Z=this.#k(Q.detail?.value,this.value);this.#K(Z),this.#T(),K(this,J)}get value(){return this.#k(this.getAttribute("value"),this.#j||this.#O())}set value(J){this.#K(J),this.#T()}get defaultValue(){return this.#k(this.getAttribute("default"),this.#j||this.#O())}get isDefault(){return u(this.value,this.defaultValue)}resetToDefault(){this.value=this.defaultValue,D(this)}focus(J){if(O(this,"disabled"))return;this.#Q?.querySelector("fig-select, fig-dropdown, fig-handle, fig-input-text")?.focus(J)}}class AJ extends XJ{}P("propskit-easing",AJ);class EJ extends XJ{}P("propskit-spring",EJ);class DJ extends S{static observedAttributes=["options","value","default","label","aria-label","disabled"];#$=null;#Z=null;#J=null;#Q=!1;#_=null;#j=null;#B=null;#q=null;#M="";#X=!1;#O=new Set;#G=new Map;#Y=this.#D.bind(this,"input");#k=this.#D.bind(this,"change");#K=(J)=>J.stopImmediatePropagation();#P=this.#f.bind(this);connectedCallback(){if(!this.#$)this.#M=this.#N(this.getAttribute("value")),this.#L(this.#M),this.#T();this.#F(),this.#H(),this.#R(),this.#y(),this.#q?.observe(this.#B,{childList:!0}),this.#V(),W(this)}disconnectedCallback(){this.#h(),this.#q?.disconnect(),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#$)return;if(J==="options")this.#x(),this.#H();else if(J==="value"&&!this.#X)this.#L(Z);else if(J==="label"||J==="aria-label")this.#F();else if(J==="disabled")this.#R()}#U(J=this.getAttribute("options")){let Q=J;if(typeof J==="string")try{Q=JSON.parse(J||"[]")}catch{return[]}if(!Array.isArray(Q))return[];let Z=new Set;for(let $ of Q){if(typeof $!=="string")continue;let j=$.trim();if(j)Z.add(j)}return[...Z]}#N(J){let Q=this.#U(),Z=String(J??"").trim();if(Z&&Q.includes(Z))return Z;return Q[0]||""}#L(J){let Q=this.#N(J),Z=this.getAttribute("value");if(Q){if(Z!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1}else if(Z!==null)this.#X=!0,this.removeAttribute("value"),this.#X=!1;if(this.#B)this.#B.value=Q;return Q}#T(){let J=this.querySelector(":scope > label"),Q=G("div",{className:"propskit-image-surface",role:"group"}),Z=G("div",{className:"propskit-image-header"}),$=J||document.createElement("label"),j=G("fig-tooltip",{className:"propskit-image-upload-tooltip",text:"Upload image"}),_=G("fig-button",{className:"propskit-image-upload",variant:"ghost",type:"upload",icon:!0,"aria-label":"Upload images"}),X=G("fig-icon",{name:"upload","aria-hidden":"true"}),q=G("input",{type:"file",accept:"image/*",multiple:!0,"aria-label":"Upload images"}),B=G("fig-chooser",{className:"propskit-image-chooser",layout:"grid",columns:"2",overflow:"buttons",full:!0});_.append(X,q),j.append(_),Z.append($,j),Q.append(Z,B),this.#$=Q,this.#Z=Z,this.#J=$,this.#Q=Boolean(J),this.#_=_,this.#j=q,this.#B=B,this.#q=new MutationObserver(()=>this.#V()),this.replaceChildren(Q)}#F(){if(!this.#Z||!this.#J||!this.#B||!this.#$)return;let J=f(this,this.#Z,this.#J,this.#Q);H(this,this.#B,J,"Images");let Q=this.getAttribute("aria-label")?.trim();if(Q)this.#$.setAttribute("aria-label",Q),this.#$.removeAttribute("aria-labelledby");else if(J)this.#$.setAttribute("aria-labelledby",J),this.#$.removeAttribute("aria-label");else this.#$.setAttribute("aria-label","Images"),this.#$.removeAttribute("aria-labelledby")}#W(J,Q){let Z=this.#G.get(J);if(Z)return Z;try{let $=new URL(J,document.baseURI).pathname.split("/").filter(Boolean).pop();if($)return decodeURIComponent($)}catch{}return`Image ${Q+1}`}#H(){if(!this.#B)return;let J=this.#U(),Q=this.#N(this.getAttribute("value")),Z=J.map(($,j)=>{let _=this.#W($,j),X=G("fig-choice",{value:$,"aria-label":_,selected:$===Q}),q=G("fig-image",{src:$,alt:"",full:!0,"aspect-ratio":"1 / 1",fit:"cover"}),B=G("fig-tooltip",{className:"propskit-image-remove-tooltip",text:"Remove image"}),Y=G("span",{className:"propskit-image-remove","aria-hidden":"true","data-propskit-image-remove":""}),M=G("fig-icon",{name:"close",size:"small","aria-hidden":"true"});return Y.append(M),Y.addEventListener("click",(k)=>this.#w($,j,k)),X.addEventListener("keydown",(k)=>{if(k.key!=="Delete"&&k.key!=="Backspace")return;this.#w($,j,k)}),B.append(Y),X.dataset.propskitImageLabel=_,X.append(q,B),X});this.#B.replaceChildren(...Z),this.#B.setAttribute("layout","grid"),this.#B.setAttribute("columns","2"),this.#B.setAttribute("overflow","buttons"),this.#B.toggleAttribute("hidden",Z.length===0),this.#L(Q),this.#z(),queueMicrotask(()=>this.#V())}#z(){let J=O(this,"disabled");for(let Q of this.#B?.querySelectorAll(":scope > fig-choice")||[]){if(J)Q.removeAttribute("aria-description"),Q.removeAttribute("aria-keyshortcuts");else Q.setAttribute("aria-description","Press Delete or Backspace to remove this image."),Q.setAttribute("aria-keyshortcuts","Delete Backspace");Q.querySelector(":scope > .propskit-image-remove-tooltip > .propskit-image-remove")?.setAttribute("aria-hidden","true")}}#V(){for(let J of this.#B?.querySelectorAll(":scope > [data-fig-chooser-nav]")||[])J.setAttribute("aria-hidden","true")}#R(){if(!this.#$||!this.#_||!this.#j||!this.#B)return;let J=O(this,"disabled");this.#$.setAttribute("aria-disabled",String(J)),this.#_.toggleAttribute("disabled",J),this.#j.disabled=J,this.#B.toggleAttribute("disabled",J),this.#B.inert=J,this.#z()}#y(){this.#h(),this.#B?.addEventListener("input",this.#Y),this.#B?.addEventListener("change",this.#k),this.#j?.addEventListener("input",this.#K),this.#j?.addEventListener("change",this.#P)}#h(){this.#B?.removeEventListener("input",this.#Y),this.#B?.removeEventListener("change",this.#k),this.#j?.removeEventListener("input",this.#K),this.#j?.removeEventListener("change",this.#P)}#D(J,Q){if(Q.target!==this.#B)return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=this.#L(this.#B.value);K(this,J,Z)}#f(J){if(J.target!==this.#j)return;if(J.stopImmediatePropagation(),O(this,"disabled"))return;let Q=[...this.#j.files||[]].filter(($)=>!$.type||$.type.startsWith("image/"));if(!Q.length)return;let Z=Q.map(($)=>{let j=URL.createObjectURL($);return this.#O.add(j),this.#G.set(j,$.name),j});this.options=[...this.options,...Z],this.value=Z[0],this.#j.value="";for(let $ of["input","change"])K(this,$,this.value)}#w(J,Q,Z){if(Z.preventDefault(),Z.stopImmediatePropagation(),O(this,"disabled"))return;let $=this.options;if(!$.includes(J))return;let j=this.value,_=j===J;this.options=$.filter((q)=>q!==J);let X=this.value;if(X!==j)for(let q of["input","change"])K(this,q,X);queueMicrotask(()=>{let q=[...this.#B?.querySelectorAll(":scope > fig-choice")||[]],B=_?this.#B?.selectedChoice:q[Math.min(Q,q.length-1)];if(B instanceof HTMLElement)B.focus();else this.#j?.focus()})}#x(){let J=new Set(this.#U());for(let Q of this.#O){if(J.has(Q))continue;URL.revokeObjectURL(Q),this.#O.delete(Q),this.#G.delete(Q)}}get options(){return this.#U()}set options(J){if(J===null||J===void 0){this.removeAttribute("options");return}this.setAttribute("options",JSON.stringify(this.#U(J)))}get value(){return this.#N(this.#B?.value??this.getAttribute("value"))}set value(J){this.#L(J)}get defaultValue(){let J=this.#M||this.#N(null);return this.#N(this.hasAttribute("default")?this.getAttribute("default"):J)}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){this.value=this.defaultValue,D(this)}focus(J){if(O(this,"disabled"))return;let Q=this.#B?.selectedChoice||this.#B?.querySelector("fig-choice");if(Q instanceof HTMLElement)Q.focus(J);else this.#j?.focus(J)}}P("propskit-image",DJ);class IJ extends S{static observedAttributes=["label","collapsible","open","disabled","value"];#$=null;#Z=null;#J=null;#Q=!1;#_=!1;#j=!1;#B=this.#N.bind(this,"input");#q=this.#N.bind(this,"change");#M=this.#L.bind(this);connectedCallback(){if(!this.#Q)this.#Y(this.#G()),this.#Q=!0;if(!this.#$)this.#k();this.#K(),this.#P(),this.#U(this.#G()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.addEventListener("change",this.#q),this.removeEventListener("openchange",this.#M),this.addEventListener("openchange",this.#M)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.removeEventListener("openchange",this.#M)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="value"){if(!this.#_){let $=this.#Y(this.#G());this.#U($)}return}if(J==="disabled"){this.#P();return}this.#K()}#X(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#O(J){let Q=J;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}if(!Q||typeof Q!=="object"||Array.isArray(Q))Q={};return{x:this.#X(Q.x,50),y:this.#X(Q.y,50),color:typeof Q.color==="string"&&Q.color.trim()?Q.color.trim():"#D9D9D9"}}#G(){return this.#O(this.getAttribute("value"))}#Y(J){let Q=this.#O(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#_=!0,this.setAttribute("value",Z),this.#_=!1,Q}#k(){let J=this.#G(),Q=document.createElement("fig-group"),Z=document.createElement("propskit-color"),$=document.createElement("propskit-position");Q.setAttribute("compact",""),Z.setAttribute("label","Color"),Z.setAttribute("value",J.color),Z.setAttribute("data-propskit-color-point-control","color"),$.setAttribute("label","Position"),$.setAttribute("x",String(J.x)),$.setAttribute("y",String(J.y)),$.setAttribute("units","percent"),$.setAttribute("data-propskit-color-point-control","position"),this.#$=Q,this.#Z=Z,this.#J=$,this.#K(),this.#P(),Q.append(Z,$),this.replaceChildren(Q)}#K(){if(!this.#$)return;this.#$.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#$.setAttribute("name",J);else this.#$.removeAttribute("name");if(this.#$.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#$.setAttribute("open",String(this.open));else this.#$.removeAttribute("open")}#P(){n(this,[this.#Z,this.#J])}#U(J){let Q=this.#O(J);if(this.#Z)this.#Z.value=Q.color;if(this.#J)this.#J.value={x:Q.x,y:Q.y}}#N(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-color-point-control]");if(!Z||!this.contains(Z))return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let $=this.value,j=Z.getAttribute("data-propskit-color-point-control");if(j==="color")$.color=Z.value||Z.getAttribute("value");else if(j==="position")$.x=this.#X(Z.value?.x,$.x),$.y=this.#X(Z.value?.y,$.y);else return;this.#Y($),K(this,J)}#L(J){if(J.target!==this.#$||this.#j)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#j=!0,this.setAttribute("open",String(Q)),this.#j=!1,this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0,composed:!0}))}get collapsible(){let J=this.getAttribute("collapsible");return J===null||J!=="false"}set collapsible(J){this.setAttribute("collapsible",String(Boolean(J)))}get open(){let J=this.getAttribute("open");return J===null||J!=="false"}set open(J){this.setAttribute("open",String(Boolean(J)))}get value(){return{...this.#G()}}set value(J){let Q=this.#Y(J);this.#U(Q)}focus(J){this.#Z?.focus(J)}}P("propskit-color-point",IJ);class bJ extends S{static observedAttributes=["label","collapsible","open","units","disabled","value"];#$=null;#Z=null;#J=null;#Q=!1;#_=!1;#j=!1;#B=this.#W.bind(this,"input");#q=this.#W.bind(this,"change");#M=this.#H.bind(this);connectedCallback(){if(!this.#Q)this.#k(this.#Y()),this.#Q=!0;if(!this.#$)this.#P();this.#U(),this.#N(),this.#L(),this.#T(this.#Y()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.addEventListener("change",this.#q),this.removeEventListener("openchange",this.#M),this.addEventListener("openchange",this.#M)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.removeEventListener("openchange",this.#M)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="value"){if(!this.#_){let $=this.#k(this.#Y());this.#T($)}return}if(J==="units"){this.#N();return}if(J==="disabled"){this.#L();return}this.#U()}#X(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#O(J){if(typeof J==="string"&&J.trim().endsWith("%")){let Q=Number.parseFloat(J);if(Number.isFinite(Q))return`${Q}%`}return this.#X(J,0)}#G(J){let Q=J;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}if(!Q||typeof Q!=="object"||Array.isArray(Q))Q={};return{x:this.#X(Q.x,50),y:this.#X(Q.y,50),radius:this.#O(Q.radius)}}#Y(){return this.#G(this.getAttribute("value"))}#k(J){let Q=this.#G(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#_=!0,this.setAttribute("value",Z),this.#_=!1,Q}#K(J){let Q=typeof J==="string"&&J.trim().endsWith("%");return{value:Q?Number.parseFloat(J):J,units:Q?"%":"px"}}#P(){let J=this.#Y(),Q=this.#K(J.radius),Z=document.createElement("fig-group"),$=document.createElement("propskit-position"),j=document.createElement("propskit-number");if(Z.setAttribute("compact",""),$.setAttribute("label","Position"),$.setAttribute("x",String(J.x)),$.setAttribute("y",String(J.y)),this.hasAttribute("units"))$.setAttribute("units",this.units);if($.setAttribute("data-propskit-point-radius-control","position"),j.setAttribute("label","Radius"),j.setAttribute("value",String(Q.value)),this.units==="percent")j.setAttribute("units","%");j.setAttribute("units-disallow",""),j.setAttribute("min","0"),j.setAttribute("precision","2"),j.setAttribute("data-propskit-point-radius-control","radius"),this.#$=Z,this.#Z=$,this.#J=j,this.#U(),this.#L(),Z.append($,j),this.replaceChildren(Z)}#U(){if(!this.#$)return;this.#$.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#$.setAttribute("name",J);else this.#$.removeAttribute("name");if(this.#$.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#$.setAttribute("open",String(this.open));else this.#$.removeAttribute("open")}#N(){if(this.hasAttribute("units"))this.#Z?.setAttribute("units",this.units);else this.#Z?.removeAttribute("units");if(this.units==="percent")this.#J?.setAttribute("units","%");else this.#J?.removeAttribute("units")}#L(){n(this,[this.#Z,this.#J])}#T(J){let Q=this.#G(J);if(this.#Z)this.#Z.value={x:Q.x,y:Q.y};if(this.#J){let Z=this.#K(Q.radius);this.#J.value=Z.value}}#F(J,Q){let Z=this.#K(Q).value,$=this.#X(J.value,Z);return(J.querySelector("fig-input-number")?.getAttribute("units")||J.getAttribute("units"))==="%"?`${$}%`:$}#W(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-radius-control]");if(!Z||!this.contains(Z))return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let $=this.value,j=Z.getAttribute("data-propskit-point-radius-control");if(j==="position")$.x=this.#X(Z.value?.x,$.x),$.y=this.#X(Z.value?.y,$.y);else if(j==="radius")$.radius=this.#F(Z,$.radius);else return;this.#k($),K(this,J)}#H(J){if(J.target!==this.#$||this.#j)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#j=!0,this.setAttribute("open",String(Q)),this.#j=!1,this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0,composed:!0}))}get collapsible(){let J=this.getAttribute("collapsible");return J===null||J!=="false"}set collapsible(J){this.setAttribute("collapsible",String(Boolean(J)))}get open(){let J=this.getAttribute("open");return J===null||J!=="false"}set open(J){this.setAttribute("open",String(Boolean(J)))}get units(){return this.getAttribute("units")?.trim().toLowerCase()==="percent"?"percent":"none"}set units(J){this.setAttribute("units",String(J).trim().toLowerCase()==="none"?"none":"percent")}get value(){return{...this.#Y()}}set value(J){let Q=this.#k(J);this.#T(Q)}focus(J){this.#Z?.focus(J)}}P("propskit-point-radius",bJ);class yJ extends S{static observedAttributes=["label","collapsible","open","units","disabled","value"];#$=null;#Z=null;#J=null;#Q=null;#_=!1;#j=!1;#B=!1;#q=this.#H.bind(this,"input");#M=this.#H.bind(this,"change");#X=this.#z.bind(this);connectedCallback(){if(!this.#_)this.#K(this.#k()),this.#_=!0;if(!this.#$)this.#U();this.#N(),this.#L(),this.#T(),this.#F(this.#k()),this.removeEventListener("input",this.#q),this.addEventListener("input",this.#q),this.removeEventListener("change",this.#M),this.addEventListener("change",this.#M),this.removeEventListener("openchange",this.#X),this.addEventListener("openchange",this.#X)}disconnectedCallback(){this.removeEventListener("input",this.#q),this.removeEventListener("change",this.#M),this.removeEventListener("openchange",this.#X)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#_)return;if(J==="value"){if(!this.#j){let $=this.#K(this.#k());this.#F($)}return}if(J==="units"){this.#L();return}if(J==="disabled"){this.#T();return}this.#N()}#O(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#G(J){if(typeof J==="string"&&J.trim().endsWith("%")){let Q=Number.parseFloat(J);if(Number.isFinite(Q))return`${Q}%`}return this.#O(J,0)}#Y(J){let Q=J;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}if(!Q||typeof Q!=="object"||Array.isArray(Q))Q={};return{x:this.#O(Q.x,50),y:this.#O(Q.y,50),radius:this.#G(Q.radius),angle:this.#O(Q.angle,0)}}#k(){return this.#Y(this.getAttribute("value"))}#K(J){let Q=this.#Y(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#j=!0,this.setAttribute("value",Z),this.#j=!1,Q}#P(J){let Q=typeof J==="string"&&J.trim().endsWith("%");return{value:Q?Number.parseFloat(J):J,units:Q?"%":"px"}}#U(){let J=this.#k(),Q=this.#P(J.radius),Z=document.createElement("fig-group"),$=document.createElement("propskit-position"),j=document.createElement("propskit-number"),_=document.createElement("propskit-number");if(Z.setAttribute("compact",""),$.setAttribute("label","Position"),$.setAttribute("x",String(J.x)),$.setAttribute("y",String(J.y)),this.hasAttribute("units"))$.setAttribute("units",this.units);if($.setAttribute("data-propskit-point-radius-angle-control","position"),j.setAttribute("label","Radius"),j.setAttribute("value",String(Q.value)),this.units==="percent")j.setAttribute("units","%");j.setAttribute("units-disallow",""),j.setAttribute("min","0"),j.setAttribute("precision","2"),j.setAttribute("data-propskit-point-radius-angle-control","radius"),_.setAttribute("label","Angle"),_.setAttribute("value",String(J.angle)),_.setAttribute("units","°"),_.setAttribute("units-disallow",""),_.setAttribute("precision","1"),_.setAttribute("data-propskit-point-radius-angle-control","angle"),this.#$=Z,this.#Z=$,this.#J=j,this.#Q=_,this.#N(),this.#T(),Z.append($,j,_),this.replaceChildren(Z)}#N(){if(!this.#$)return;this.#$.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#$.setAttribute("name",J);else this.#$.removeAttribute("name");if(this.#$.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#$.setAttribute("open",String(this.open));else this.#$.removeAttribute("open")}#L(){if(this.hasAttribute("units"))this.#Z?.setAttribute("units",this.units);else this.#Z?.removeAttribute("units");if(this.units==="percent")this.#J?.setAttribute("units","%");else this.#J?.removeAttribute("units")}#T(){n(this,[this.#Z,this.#J,this.#Q])}#F(J){let Q=this.#Y(J);if(this.#Z)this.#Z.value={x:Q.x,y:Q.y};if(this.#J){let Z=this.#P(Q.radius);this.#J.value=Z.value}if(this.#Q)this.#Q.value=Q.angle}#W(J,Q){let Z=this.#P(Q).value,$=this.#O(J.value,Z);return(J.querySelector("fig-input-number")?.getAttribute("units")||J.getAttribute("units"))==="%"?`${$}%`:$}#H(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-radius-angle-control]");if(!Z||!this.contains(Z))return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let $=this.value,j=Z.getAttribute("data-propskit-point-radius-angle-control");if(j==="position")$.x=this.#O(Z.value?.x,$.x),$.y=this.#O(Z.value?.y,$.y);else if(j==="radius")$.radius=this.#W(Z,$.radius);else if(j==="angle")$.angle=this.#O(Z.value,$.angle);else return;this.#K($),K(this,J)}#z(J){if(J.target!==this.#$||this.#B)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#B=!0,this.setAttribute("open",String(Q)),this.#B=!1,this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0,composed:!0}))}get collapsible(){let J=this.getAttribute("collapsible");return J===null||J!=="false"}set collapsible(J){this.setAttribute("collapsible",String(Boolean(J)))}get open(){let J=this.getAttribute("open");return J===null||J!=="false"}set open(J){this.setAttribute("open",String(Boolean(J)))}get units(){return this.getAttribute("units")?.trim().toLowerCase()==="percent"?"percent":"none"}set units(J){this.setAttribute("units",String(J).trim().toLowerCase()==="none"?"none":"percent")}get value(){return{...this.#k()}}set value(J){let Q=this.#K(J);this.#F(Q)}focus(J){this.#Z?.focus(J)}}P("propskit-point-radius-angle",yJ);class xJ extends S{static observedAttributes=["label","collapsible","open","units","disabled","value"];#$=null;#Z=null;#J=null;#Q=!1;#_=!1;#j=!1;#B=this.#T.bind(this,"input");#q=this.#T.bind(this,"change");#M=this.#F.bind(this);connectedCallback(){if(!this.#Q)this.#Y(this.#G()),this.#Q=!0;if(!this.#$)this.#K();this.#P(),this.#U(),this.#N(),this.#L(this.#G()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.addEventListener("change",this.#q),this.removeEventListener("openchange",this.#M),this.addEventListener("openchange",this.#M)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#q),this.removeEventListener("openchange",this.#M)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="value"){if(!this.#_){let $=this.#Y(this.#G());this.#L($)}return}if(J==="units"){this.#U();return}if(J==="disabled"){this.#N();return}this.#P()}#X(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#O(J){let Q=J;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}if(!Q||typeof Q!=="object"||Array.isArray(Q))Q={};return{x:this.#X(Q.x,50),y:this.#X(Q.y,50),x2:this.#X(Q.x2,75),y2:this.#X(Q.y2,75)}}#G(){return this.#O(this.getAttribute("value"))}#Y(J){let Q=this.#O(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#_=!0,this.setAttribute("value",Z),this.#_=!1,Q}#k(J,Q,Z,$){let j=document.createElement("propskit-position");if(j.setAttribute("label",J),j.setAttribute("x",String(Z)),j.setAttribute("y",String($)),this.hasAttribute("units"))j.setAttribute("units",this.units);return j.setAttribute("data-propskit-point-point-control",Q),j}#K(){let J=this.#G(),Q=document.createElement("fig-group"),Z=this.#k("Start","start",J.x,J.y),$=this.#k("End","end",J.x2,J.y2);Q.setAttribute("compact",""),this.#$=Q,this.#Z=Z,this.#J=$,this.#P(),this.#N(),Q.append(Z,$),this.replaceChildren(Q)}#P(){if(!this.#$)return;this.#$.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#$.setAttribute("name",J);else this.#$.removeAttribute("name");if(this.#$.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#$.setAttribute("open",String(this.open));else this.#$.removeAttribute("open")}#U(){for(let J of[this.#Z,this.#J]){if(!J)continue;if(this.hasAttribute("units"))J.setAttribute("units",this.units);else J.removeAttribute("units")}}#N(){n(this,[this.#Z,this.#J])}#L(J){let Q=this.#O(J);if(this.#Z)this.#Z.value={x:Q.x,y:Q.y};if(this.#J)this.#J.value={x:Q.x2,y:Q.y2}}#T(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-point-control]");if(!Z||!this.contains(Z))return;if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let $=this.value,j=Z.value,_=Z.getAttribute("data-propskit-point-point-control");if(_==="start")$.x=this.#X(j?.x,$.x),$.y=this.#X(j?.y,$.y);else if(_==="end")$.x2=this.#X(j?.x,$.x2),$.y2=this.#X(j?.y,$.y2);else return;this.#Y($),K(this,J)}#F(J){if(J.target!==this.#$||this.#j)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#j=!0,this.setAttribute("open",String(Q)),this.#j=!1,this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0,composed:!0}))}get collapsible(){let J=this.getAttribute("collapsible");return J===null||J!=="false"}set collapsible(J){this.setAttribute("collapsible",String(Boolean(J)))}get open(){let J=this.getAttribute("open");return J===null||J!=="false"}set open(J){this.setAttribute("open",String(Boolean(J)))}get units(){return this.getAttribute("units")?.trim().toLowerCase()==="percent"?"percent":"none"}set units(J){this.setAttribute("units",String(J).trim().toLowerCase()==="none"?"none":"percent")}get value(){return{...this.#G()}}set value(J){let Q=this.#Y(J);this.#L(Q)}focus(J){this.#Z?.focus(J)}}P("propskit-point-point",xJ);class t extends S{static observedAttributes=["name","open","show-reset","disabled"];static#$=["propskit-color","propskit-fill","propskit-gradient","propskit-easing","propskit-image","propskit-joystick","propskit-number","propskit-origin","propskit-position","propskit-color-point","propskit-point-radius","propskit-point-radius-angle","propskit-point-point","propskit-editable-select","propskit-select","propskit-slider","propskit-spring","propskit-switch","propskit-text","propskit-wheel","propskit-oscillator"].join(",");#Z=null;#J=null;#Q=null;#_=null;#j=0;#B=()=>this.#X();connectedCallback(){this.#z(),this.#P(),this.#q(),requestAnimationFrame(()=>{this.#L()})}disconnectedCallback(){if(this.#M(),this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#Z?.removeEventListener("click",this.#G),this.#Z?.removeEventListener("keydown",this.#Y),this.#Q?.querySelector("fig-button")?.removeEventListener("click",this.#k)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}if(J==="show-reset"){this.#W(),this.#L();return}if(J==="disabled"){this.#P();return}this.#z()}get open(){let J=this.getAttribute("open");return J!==null&&J!=="false"}set open(J){let Q=this.open;if(J)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!J)),Q!==!!J)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!J},bubbles:!0}))}get showReset(){let J=this.getAttribute("show-reset");if(J===null)return!0;return J!=="false"}set showReset(J){if(J)this.setAttribute("show-reset","true");else this.setAttribute("show-reset","false")}get dirty(){return this.hasAttribute("data-dirty")&&this.getAttribute("data-dirty")!=="false"}resetProperties(){this.#F()}#q(){if(this.removeEventListener("input",this.#B,!0),this.removeEventListener("change",this.#B,!0),this.addEventListener("input",this.#B,!0),this.addEventListener("change",this.#B,!0),!this.#_)this.#_=new MutationObserver(()=>{this.#P(),this.#X()});this.#_.disconnect(),this.#_.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","checked","default","x","y"]})}#M(){this.removeEventListener("input",this.#B,!0),this.removeEventListener("change",this.#B,!0),this.#_?.disconnect()}#X(){if(this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0,this.#L()})}#O(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#G=(J)=>{if(O(this,"disabled"))return;if(this.#O(J.target))return;J.stopPropagation(),this.open=!this.open};#Y=(J)=>{if(O(this,"disabled"))return;if(this.#O(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#k=(J)=>{if(J.preventDefault(),J.stopPropagation(),O(this,"disabled"))return;this.#F()};#K(){return[...this.querySelectorAll(t.#$)].filter((J)=>J.closest("propskit-group")===this&&!J.parentElement?.closest(t.#$))}#P(){let J=O(this,"disabled");for(let Q of this.#K())if(J){if(!O(Q,"disabled"))Q.setAttribute("disabled",""),Q.setAttribute("data-propskit-group-disabled","")}else if(Q.hasAttribute("data-propskit-group-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-propskit-group-disabled");this.#Z?.setAttribute("aria-disabled",String(J)),this.#Z?.setAttribute("tabindex",J?"-1":"0"),this.#Q?.querySelector("fig-button")?.toggleAttribute("disabled",J)}#U(J){return J.isDefault===!1}#N(){for(let J of this.#K())if(this.#U(J))return!0;return!1}#L(){if(this.#N())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#W()}#T(J){if(typeof J.resetToDefault==="function")J.resetToDefault()}#F(){for(let J of this.#K())this.#T(J);this.#L(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#W(){if(!this.showReset){this.#Q?.setAttribute("hidden","");return}this.#H(),this.#Q?.removeAttribute("hidden")}#H(){if(!this.#Z||!this.showReset)return;let J=this.#Z.querySelector(":scope > .propskit-group-reset-tooltip");if(!J){J=document.createElement("fig-tooltip"),J.className="propskit-group-reset-tooltip",J.setAttribute("text","Reset properties");let Q=document.createElement("fig-button");Q.className="propskit-group-reset",Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Reset properties");let Z=document.createElement("fig-icon");Z.setAttribute("name","reset"),Q.appendChild(Z),J.appendChild(Q),this.#Z.appendChild(J),Q.addEventListener("click",this.#k)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#k),Q?.addEventListener("click",this.#k)}this.#Q=J}#z(){let Q=this.getAttribute("name")||"Group",Z=this.querySelector(":scope > fig-header");if(Z)this.#Z=Z;else if(!this.#Z||!this.#Z.dataset.generated||this.#Z.parentElement!==this)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);let $=this.#Z.querySelector(":scope > h3"),j=this.#Z.querySelector(":scope > fig-button.propskit-group-disclosure");if(!$&&j){if($=j.querySelector(":scope > h3"),$)this.#Z.insertBefore($,j);j.remove()}if(!$)$=document.createElement("h3"),this.#Z.prepend($);let _=$.querySelector(":scope > button.propskit-group-disclosure");if(_){while(_.firstChild)$.insertBefore(_.firstChild,_);_.remove()}if(!$.id)$.id=kJ("propskit-group");if(this.#Z.dataset.generated)$.textContent=Q;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",$.id);let X=this.#Z.querySelector(":scope > .propskit-group-chevron")||$.querySelector(":scope > .propskit-group-chevron");if(!X)X=document.createElement("fig-icon"),X.setAttribute("name","chevron"),X.setAttribute("size","small"),X.className="propskit-group-chevron";if(this.#Z.insertBefore(X,$),this.#J=X,this.#W(),this.#Z.setAttribute("role","button"),this.#P(),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("click",this.#G),this.#Z.addEventListener("click",this.#G),this.#Z.removeEventListener("keydown",this.#Y),this.#Z.addEventListener("keydown",this.#Y),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}}P("propskit-group",t);class o extends S{static#$=4;static#Z="propskit-slider-dragging";static#J=null;#Q=null;#_=null;#j=null;#B=!1;#q=null;#M=new Set;#X=0;#O=0;#G=0;#Y=null;#k=!0;#K=0;#P=1;#U=0;#N=null;#L=null;#T=0;#F=null;#W=null;#H=!1;#z=0;#V=null;#R=0;#y=null;#h=0;#D=null;#f=0;#w=0;#x=!1;#I=!1;#C=0;#A=null;#E=null;#c=this.#CJ.bind(this);#u=this.#RJ.bind(this);#b=this.#l.bind(this);#S=this.#HJ.bind(this);#$J=this.#TJ.bind(this);#p=this.#UJ.bind(this);#m=this.#SJ.bind(this);#a=this.#fJ.bind(this);#n=this.#DJ.bind(this);#s=this.#WJ.bind(this);#g=new Set(["variant","color","text","full","elastic","size","name","class","data-wave-index","data-active","data-elastic-dragging","default","style"]);static get observedAttributes(){return["label","aria-label"]}connectedCallback(){if(!this.#Q)this.#XJ();if(this.#d(),this.#JJ(),this.#gJ(),this.#ZJ(),this.#BJ(),this.#GJ(),this.removeEventListener("pointerdown",this.#c,{capture:!0}),this.addEventListener("pointerdown",this.#c,{capture:!0,passive:!0}),this.removeEventListener("pointerdown",this.#S,{capture:!0}),this.addEventListener("pointerdown",this.#S,{capture:!0}),this.removeEventListener("contextmenu",this.#a),this.addEventListener("contextmenu",this.#a),this.removeEventListener("click",this.#s,!0),this.addEventListener("click",this.#s,!0),this.#L?.removeEventListener("change",this.#n),this.#L?.addEventListener("change",this.#n),!this.#q)this.#q=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName==="value"){this.#MJ();continue}if($.attributeName==="color"){Z=!0;continue}if($.attributeName&&this.#g.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="aria-label")Q=!0;else if($.attributeName==="direction")continue;else Z=!0}if(Q)this.#d(),this.#ZJ();if(Z)this.#JJ(),this.#ZJ()});this.#q.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#q?.disconnect(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#O)cancelAnimationFrame(this.#O),this.#O=0;if(this.#G)cancelAnimationFrame(this.#G),this.#G=0;this.#Y?.disconnect(),this.#AJ(),this.#FJ(),clearTimeout(this.#C),this.#C=0,this.#LJ(),this.#zJ(),this.#e(),this.#cJ(),this.removeEventListener("pointerdown",this.#c,{capture:!0}),this.removeEventListener("pointerdown",this.#S,{capture:!0}),this.removeEventListener("contextmenu",this.#a),this.removeEventListener("click",this.#s,!0),this.#L?.removeEventListener("change",this.#n)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="aria-label")this.#d(),this.#ZJ()}#XJ(){let J=(this.getAttribute("type")||"range").toLowerCase();this.#W=this.getAttribute("value")??this.getAttribute("default")??(J==="delta"?"0":this.getAttribute("min")??"0");let Q=Array.from(this.childNodes).filter((X)=>{return X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())}),Z=Q.find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),$=G("div",{className:"propskit-slider-surface"}),j=Z||document.createElement("label"),_=document.createElement("fig-slider");_.setAttribute("text","true");for(let X of this.#QJ()){let q=this.getAttribute(X);_.setAttribute(X,q??"")}$.append(j,_),this.#Q=$,this.#_=j,this.#j=_,this.#B=Boolean(Z),this.replaceChildren($),this.#o();for(let X of Q){if(X===Z)continue;this.#j.appendChild(X)}}#o(){let J=document.createElement("fig-menu");J.setAttribute("position","bottom left"),J.setAttribute("offset","0 0");let Q=document.createElement("fig-menu-item");Q.setAttribute("value","reset-default"),Q.textContent="Reset",J.appendChild(Q),J.addEventListener("change",this.#n),this.#L=J,this.appendChild(J)}#d(){f(this,this.#Q,this.#_,this.#B),this.#GJ()}#JJ(){if(!this.#j)return;let J=this.#QJ(),Q=new Set(J.filter(($)=>$!=="text"&&$!=="value"));for(let $ of this.#M)if(!Q.has($))this.#j.removeAttribute($);for(let $ of J){if($==="text"||$==="value")continue;let j=this.getAttribute($)??"";if(this.#j.getAttribute($)!==j)this.#j.setAttribute($,j)}this.#j.removeAttribute("variant"),this.#j.removeAttribute("color"),this.#j.removeAttribute("transform"),this.#j.removeAttribute("full"),this.#j.setAttribute("text","true");let Z=(this.getAttribute("type")||"range").toLowerCase();if(Z==="delta"){let $=Number(this.#j.min),j=Number(this.#j.max),_=Number.isFinite($)&&Number.isFinite(j)?$+(j-$)/2:0;this.#j.setAttribute("default",String(_))}else this.#j.removeAttribute("default");if(Z==="stepper")this.#j.setAttribute("step",this.getAttribute("step")??"10");else if(!this.hasAttribute("step"))this.#j.removeAttribute("step");if(Z==="opacity")this.#j.style.setProperty("--color",this.getAttribute("color")||"var(--figma-color-bg-secondary)");else this.#j.style.removeProperty("--color");this.#r(Z),this.#M=Q,this.#MJ(),this.#kJ(),this.#k=!0,this.#BJ(),this.#GJ()}#r(J){let Q=this.#j?.querySelector("fig-input-number");if(!(J==="hue"||J==="opacity"&&this.hasAttribute("color"))){Q?.removeAttribute("theme"),this.style.removeProperty("--propskit-slider-filled-text-color");return}let $=Number(this.#j?.min),j=Number(this.#j?.max),_=Number(this.#j?.value),X=Number.isFinite($)&&Number.isFinite(j)&&j>$&&Number.isFinite(_)?Math.max(0,Math.min(1,(_-$)/(j-$))):0,q=this.getAttribute("color"),B=J==="hue"?`hsl(${X*360}deg 100% 50%)`:`color-mix(in srgb, ${q} ${X*100}%, var(--figma-color-bg-secondary))`,Y=getComputedStyle(this).colorScheme.trim().toLowerCase()==="dark",M=gJ(this.#j,B,J==="hue"?0.35:Y?0.2:0.35);if(M){Q?.setAttribute("theme",M);let k=M==="light"&&Y||M==="dark"&&!Y;this.style.setProperty("--propskit-slider-filled-text-color",k?"var(--figma-color-text)":"var(--figma-color-text-oninverse)")}else Q?.removeAttribute("theme"),this.style.removeProperty("--propskit-slider-filled-text-color")}#NJ(){if(!this.#j)return;let J=Number(this.#j.min),Q=Number(this.#j.max),Z=Number(this.#j.value),$=Number.isFinite(J)&&Number.isFinite(Q)&&Q>J&&Number.isFinite(Z)?Math.max(0,Math.min(1,(Z-J)/(Q-J))):0;this.style.setProperty("--propskit-slider-complete",String($)),this.#r((this.getAttribute("type")||"range").toLowerCase()),this.#GJ()}#BJ(){if(!globalThis.ResizeObserver)return;if(!this.#Y)this.#Y=new ResizeObserver(()=>{this.#k=!0,this.#GJ()});this.#Y.disconnect();for(let J of[this,this.#_,this.#j?.querySelector("fig-input-number"),this.#j?.querySelector("fig-input-number input"),this.#j?.querySelector('input[type="range"]')])if(J)this.#Y.observe(J)}#GJ(){if(this.#G)cancelAnimationFrame(this.#G);this.#G=requestAnimationFrame(()=>{this.#G=0,this.#qJ()})}#qJ(){let J=this.#j?.querySelector('input[type="range"]');if(!J||!this.#j)return;let Q=J.getBoundingClientRect();if(!Q.width)return;let Z=Number(J.min||0),$=Number(J.max||100),j=Number(J.value),_=Number.isFinite(Z)&&Number.isFinite($)&&$>Z&&Number.isFinite(j)?Math.max(0,Math.min(1,(j-Z)/($-Z))):0,X=Q.left+_*Q.width;if(this.#k)this.#K=this.#_J("--slider-thumb-width",this.#j)/2,this.#P=Math.max(1,this.#_J("--propskit-slider-handle-fade-start-threshold")),this.#U=Math.min(this.#P,this.#_J("--propskit-slider-handle-fade-end-threshold")),this.#k=!1;let q=this.#K,B=[],Y=this.#_?.parentElement===this.#Q?this.#PJ(this.#_):null,M=this.#j.querySelector("fig-input-number input"),k=M?this.#t(M):null;if(Y?.width&&Y.bottom>Q.top&&Y.top<Q.bottom)B.push(X-q-Y.right);if(k?.width&&k.bottom>Q.top&&k.top<Q.bottom)B.push(k.left-X-q);let N=this.#P,U=this.#U,L=B.length?Math.min(...B):N,T=Math.max(0.001,N-U),V=Math.max(0,Math.min(1,(L-U)/T));this.style.setProperty("--propskit-slider-handle-proximity",String(V))}#PJ(J){let Q=document.createRange();Q.selectNodeContents(J);let Z=[...Q.getClientRects()].filter((q)=>q.width>0&&q.height>0);if(Q.detach?.(),!Z.length)return null;let $=Math.min(...Z.map((q)=>q.left)),j=Math.max(...Z.map((q)=>q.right)),_=Math.min(...Z.map((q)=>q.top)),X=Math.max(...Z.map((q)=>q.bottom));return{left:$,right:j,top:_,bottom:X,width:j-$,height:X-_}}#t(J){let Q=J.value||J.placeholder||"";if(!Q)return null;let Z=J.getBoundingClientRect(),$=getComputedStyle(J),j=this.#jJ(Q,$),_=Z.left+(Number.parseFloat($.borderLeftWidth)||0)+(Number.parseFloat($.paddingLeft)||0),X=Z.right-(Number.parseFloat($.borderRightWidth)||0)-(Number.parseFloat($.paddingRight)||0),q=Math.max(0,X-_),B=Math.min(q,j),Y=$.textAlign,M=_;if(Y==="right"||Y==="end")M=X-B;else if(Y==="center")M=_+(q-B)/2;return{left:M,right:M+B,top:Z.top,bottom:Z.bottom,width:B,height:Z.height}}#jJ(J,Q){if(!o.#J)o.#J=document.createElement("canvas");let Z=o.#J.getContext("2d");if(!Z)return 0;if(Z.font=Q.font||`${Q.fontStyle} ${Q.fontWeight} ${Q.fontSize} ${Q.fontFamily}`,"fontKerning"in Z)Z.fontKerning=Q.fontKerning;if("fontStretch"in Z)Z.fontStretch=Q.fontStretch;if("fontVariantCaps"in Z)Z.fontVariantCaps=Q.fontVariantCaps;if("letterSpacing"in Z)Z.letterSpacing=Q.letterSpacing;return Z.measureText(J).width}#_J(J,Q=this){let Z=document.createElement("div");Z.style.setProperty(J,getComputedStyle(Q).getPropertyValue(J)),Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${J})`}),this.appendChild(Z);let $=Number.parseFloat(getComputedStyle(Z).width);return Z.remove(),Number.isFinite($)?Math.max(0,$):0}#MJ(){if(!this.#j)return;let J=this.hasAttribute("value")?this.getAttribute("value")??"":this.#W??"";if(String(this.#j.value)!==J)this.#j.value=J;this.#NJ()}#QJ(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#kJ(){if(this.#X)cancelAnimationFrame(this.#X);this.#X=requestAnimationFrame(()=>{this.#X=0,this.#pJ(),this.#OJ()})}#ZJ(){if(this.#O)cancelAnimationFrame(this.#O);this.#O=requestAnimationFrame(()=>{this.#O=0,this.#OJ()})}#OJ(){let J=this.#j?.querySelector('input[type="range"]'),Q=this.#j?.querySelector("fig-input-number input");if(J!==this.#N)this.#KJ(J);if(J){J.removeAttribute("tabindex"),J.removeAttribute("aria-hidden");let Z=this.getAttribute("aria-label")?.trim();if(Z)J.setAttribute("aria-label",Z),J.removeAttribute("aria-labelledby");else if(this.#_?.parentElement===this.#Q&&this.#_.id)J.setAttribute("aria-labelledby",this.#_.id),J.removeAttribute("aria-label");else J.setAttribute("aria-label","Slider"),J.removeAttribute("aria-labelledby")}if(Q)Q.removeAttribute("tabindex"),Q.removeAttribute("aria-hidden")}#WJ(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu")){if(this.#I&&J.target.closest("fig-input-number"))J.preventDefault(),J.stopImmediatePropagation(),this.#I=!1;return}this.#i()}#i(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!O(this,"disabled"))this.focus()})})}#KJ(J){if(this.#e(),this.#N=J,!this.#N)return;this.#N.addEventListener("dblclick",this.#m,{capture:!0})}#e(){if(!this.#N)return;this.#N.removeEventListener("dblclick",this.#m,{capture:!0}),this.#N=null}#SJ(J){J.preventDefault(),J.stopImmediatePropagation(),this.#xJ()}#HJ(J){if(J.button!==0||J.altKey||O(this,"disabled")||!(J.target instanceof Element))return;let Q=J.target.closest("fig-input-number input");if(!Q||Q===document.activeElement)return;J.preventDefault(),J.stopImmediatePropagation(),this.#FJ(),this.#D=J.pointerId,this.#f=J.clientX,this.#w=J.clientY,this.#x=!1,window.addEventListener("pointermove",this.#$J),window.addEventListener("pointerup",this.#p,{once:!0}),window.addEventListener("pointercancel",this.#p,{once:!0}),window.addEventListener("blur",this.#p,{once:!0})}#TJ(J){if(J.pointerId!==this.#D)return;if(J.buttons===0){this.#UJ(J);return}if(!this.#x){if(Math.hypot(J.clientX-this.#f,J.clientY-this.#w)<4)return;this.#x=!0,this.setAttribute("data-number-scrubbing",""),this.#YJ(!0)}this.#EJ(this.#wJ(J),"input")}#UJ(J){if(J?.pointerId!==void 0&&this.#D!==null&&J.pointerId!==this.#D)return;let Q=this.#x;if(this.#FJ(),Q){this.#EJ(this.#j?.value,"change"),this.#I=!0,clearTimeout(this.#C),this.#C=window.setTimeout(()=>{this.#I=!1,this.#C=0},0),this.#i();return}this.#j?.querySelector("fig-input-number input")?.focus()}#FJ(){window.removeEventListener("pointermove",this.#$J),window.removeEventListener("pointerup",this.#p),window.removeEventListener("pointercancel",this.#p),window.removeEventListener("blur",this.#p),this.#D=null,this.#x=!1,this.removeAttribute("data-number-scrubbing"),this.#YJ(!1)}#CJ(J){if(J.button!==0||O(this,"disabled"))return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#j?.querySelector('input[type="range"]')??this.#N;if(!Q)return;this.#LJ(),this.#zJ(),this.#N=Q,this.#H=!0,this.#y=J.pointerId,this.#h=J.clientX,this.#z=this.getAttribute("elastic")==="false"?0:this.#IJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#V={left:Z.left,right:Z.right,width:Z.width},this.#R=$.width,window.addEventListener("pointermove",this.#u,{passive:!0}),window.addEventListener("pointerup",this.#b,{once:!0}),window.addEventListener("pointercancel",this.#b,{once:!0}),window.addEventListener("blur",this.#b,{once:!0})}#RJ(J){if(!this.#H)return;if(J.pointerId!==this.#y)return;if(J.buttons===0){this.#l(J);return}if(Math.abs(J.clientX-this.#h)>=o.#$)this.#YJ(!0);if(this.#z)this.#bJ(J.clientX)}#l(J){if(J?.pointerId!==void 0&&this.#y!==null&&J.pointerId!==this.#y)return;let Q=J?.type==="pointerup"||J?.type==="pointermove"&&J.buttons===0;if(this.#LJ(),this.#zJ(),Q)this.#i()}#LJ(){window.removeEventListener("pointermove",this.#u),window.removeEventListener("pointerup",this.#b),window.removeEventListener("pointercancel",this.#b),window.removeEventListener("blur",this.#b),this.#H=!1,this.#y=null,this.#h=0,this.#YJ(!1)}#YJ(J){this.toggleAttribute("data-propskit-slider-dragging",J),document.body.classList.toggle(o.#Z,J)}#fJ(J){if(O(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#AJ(),this.#v(J.clientX,J.clientY)}#v(J,Q){let Z=!1,$=0,j=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",j,!0),requestAnimationFrame(()=>{this.#L?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#DJ(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#xJ()}#AJ(){if(this.#T)clearTimeout(this.#T),this.#T=0;this.#F=null}#IJ(){let J=getComputedStyle(this).getPropertyValue("--propskit-slider-elastic-distance").trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:"var(--propskit-slider-elastic-distance)"}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#bJ(J){let Q=this.#V;if(!Q||!this.#z){this.#zJ();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#VJ();return}let $=Math.max(-this.#z,Math.min(this.#z,Z*0.5)),j=Math.abs($),_=this.#R?(this.#R+j)/this.#R:1;this.dataset.elasticDragging="true",this.style.setProperty("--propskit-slider-elastic-size",`${j}px`),this.style.setProperty("--propskit-slider-elastic-scale",`${_}`),this.style.setProperty("--propskit-slider-elastic-origin",$<0?"right center":"left center")}#zJ(){this.#VJ(),this.#z=0,this.#V=null,this.#R=0,this.#y=null}#VJ(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#wJ(J){let Q=this.#N;if(!Q)return this.#j?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,j=Number(Q.min||0),_=Number(Q.max||100),X=Q.step==="any"?0:Number(Q.step||1),q=j+(_-j)*$;if(!X)return String(q);let B=Math.round((q-j)/X)*X+j,Y=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(Y)))}#yJ(){return this.getAttribute("default")??this.#W??this.#N?.min??"0"}#xJ(){this.#AJ(),this.#EJ(this.#yJ(),"input"),this.#EJ(this.#yJ(),"change")}#EJ(J,Q){if(!this.#j||J===null||J===void 0)return;this.#j.value=J,this.setAttribute("value",String(this.#j.value)),K(this,Q)}#pJ(){if(!this.#j)return;let J=this.#j.querySelector("fig-input-number");if(!J)return;if(!(this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false")){J.removeAttribute("steppers");return}let Z=this.getAttribute("steppers");J.setAttribute("steppers",Z??"")}#gJ(){if(!this.#j)return;if(!this.#A)this.#A=this.#hJ.bind(this,"input");if(!this.#E)this.#E=this.#hJ.bind(this,"change");this.#j.addEventListener("input",this.#A),this.#j.addEventListener("change",this.#E)}#cJ(){if(!this.#j)return;if(this.#A)this.#j.removeEventListener("input",this.#A);if(this.#E)this.#j.removeEventListener("change",this.#E)}#hJ(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;if(J==="change")this.#zJ();if(this.#j?.value!==void 0){let Z=String(this.#j.value);if(this.getAttribute("value")!==Z)this.setAttribute("value",Z)}this.#NJ(),K(this,J)}focus(J){this.#OJ();let Q=this.#j?.querySelector('input[type="range"]');Q?.setAttribute("data-propskit-focus-called",""),Q?.focus(J)}get value(){return d(this.getAttribute("value")??this.#j?.value)}set value(J){if(J===null||J===void 0||J===""){if(this.removeAttribute("value"),this.#j)this.#j.value="";return}let Q=String(J);if(this.setAttribute("value",Q),this.#j)this.#j.value=Q}get defaultValue(){return this.#yJ()}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){this.#xJ()}}P("propskit-slider",o);class C extends HTMLElement{static#$=33;static#Z=60;static#J=0.55;static#Q=1.5;static#_=80;static#j=4;static#B="fig-input-wheel-dragging";#q=null;#M=null;#X=null;#O=null;#G=null;#Y=null;#k=null;#K=0;#P=0;#U=0;#N=0;#L=0;#T=null;#F=!1;#W=null;#H=0;#z=0;#V=!1;#R=null;#y=0;#h=null;#D=0;#f=0;#w=this.#qJ.bind(this);#x=this.#PJ.bind(this);#I=this.#jJ.bind(this);#C=this.#SJ.bind(this);#A=this.#HJ.bind(this);static get observedAttributes(){return["value","disabled","step","min","max","spin"]}connectedCallback(){if(!this.#q)this.#E();if(this.#d(),this.#XJ(),this.#BJ(),this.#T?.disconnect(),globalThis.ResizeObserver)this.#T=new ResizeObserver((J)=>{let Q=J.at(-1)?.contentRect;if(Q)this.#JJ(Q.width,Q.height)}),this.#T.observe(this);this.#r()}disconnectedCallback(){if(this.#T?.disconnect(),this.#U)cancelAnimationFrame(this.#U);this.#U=0,this.#UJ(),this.#GJ(),this.#_J()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#q)return;if(J==="disabled")this.#d();if(J==="value"&&!this.#F)this.#XJ();if(J==="step")this.#o(),this.#r();if(J==="spin")this.#r();if(J==="min"||J==="max")this.#g(this.#S())}#E(){if(this.#q=this,this.#M=this,this.#X=this,this.setAttribute("role","spinbutton"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Value");this.setAttribute("tabindex","0");let J=h("svg",{className:"fig-input-wheel-svg","aria-hidden":"true"}),Q=G("div",{className:"fig-input-wheel-handle"});this.#O=J,this.replaceChildren(J,Q);let Z=document.createElement("div");Z.setAttribute("aria-hidden","true"),Z.style.cssText="position:absolute;visibility:hidden;pointer-events:none;left:0;top:0";let $=document.createElement("div");$.style.height="var(--fig-input-wheel-tick-height)";let j=document.createElement("div");j.style.height="var(--fig-input-wheel-tick-height-min)";let _=document.createElement("div");_.style.width="var(--fig-input-wheel-tick-width)";let X=document.createElement("div");X.style.width="var(--fig-input-wheel-tick-width-min)",Z.append($,j,_,X),this.append(Z),this.#k={maxEl:$,minEl:j,maxWidthEl:_,minWidthEl:X},this.#c()}#c(){if(!this.#O||this.#G)return;this.#G=h("path",{className:"fig-input-wheel-tick"}),this.#O.append(this.#G)}#u(){if(this.#Y)return this.#Y;return this.#Y={maxH:this.#k?.maxEl.getBoundingClientRect().height||8,minH:this.#k?.minEl.getBoundingClientRect().height||4,maxW:this.#k?.maxWidthEl.getBoundingClientRect().width||2,minW:this.#k?.minWidthEl.getBoundingClientRect().width||1},this.#Y}#b(){if(this.hasAttribute("step")){let J=Number(this.getAttribute("step"));if(J>0)return J}return 1}#S(){let J=Number(this.getAttribute("value")??0);return Number.isFinite(J)?J:0}#$J(J){if(!this.hasAttribute(J))return null;let Q=this.getAttribute(J);if(Q===null||Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#p(){return this.#$J("min")}#m(){return this.#$J("max")}#a(J,Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute(J);return}let Z=Number(Q);if(!Number.isFinite(Z)){this.removeAttribute(J);return}this.setAttribute(J,String(Z))}#n(J){let Q=J,Z=this.#p(),$=this.#m();if(Z!==null)Q=Math.max(Z,Q);if($!==null)Q=Math.min($,Q);return Q}#s(J){let Q=this.#b();if(Q<=0)return J;let Z=this.#p()??0,$=Math.round((J-Z)/Q)*Q+Z;return Number($.toPrecision(15))}#g(J,{snap:Q=!1,emit:Z=null}={}){let $=Q?this.#s(J):J;$=this.#n($);let j=String($);if(this.getAttribute("value")!==j)this.setAttribute("value",j);if(this.#o($),this.#r(),Z)this.dispatchEvent(new CustomEvent(Z,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#XJ(){let J=this.#S(),Q=this.#n(J);if(Q!==J||this.getAttribute("value")!==String(Q)){this.#g(Q);return}this.#o(J),this.#r()}#o(J=this.#S()){if(!this.#X)return;let Q=this.#p(),Z=this.#m();if(this.#X.setAttribute("aria-valuenow",String(J)),this.#X.setAttribute("aria-valuetext",String(J)),Q===null)this.#X.removeAttribute("aria-valuemin");else this.#X.setAttribute("aria-valuemin",String(Q));if(Z===null)this.#X.removeAttribute("aria-valuemax");else this.#X.setAttribute("aria-valuemax",String(Z))}#d(){let J=O(this,"disabled");if(!this.#X)return;if(J){if(this.#F)this.#_J();this.#UJ(),this.setAttribute("aria-disabled","true"),this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-disabled","true")}else this.removeAttribute("aria-disabled"),this.#X.setAttribute("tabindex","0"),this.#X.removeAttribute("aria-disabled")}#JJ(J,Q){if(!this.#O||J<1||Q<1)return;if(J===this.#K&&Q===this.#P)return;this.#K=J,this.#P=Q,this.#Y=null,this.#O.setAttribute("viewBox",`0 0 ${J} ${Q}`),this.#O.setAttribute("width",String(J)),this.#O.setAttribute("height",String(Q)),this.#r()}#r(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(!this.isConnected){this.#U=0;return}if(this.#K<1||this.#P<1){let J=this.#X?.getBoundingClientRect();if(J)this.#JJ(J.width,J.height)}this.#NJ(),this.#U=0})}#NJ(){if(!this.#G)return;let J=this.#K,Q=this.#P;if(J<1||Q<1)return;let Z=this.getAttribute("spin")==="false"?this.#p()??0:this.#R??this.#S(),$=360/C.#$,j=this.#b(),_=this.#p()??0,X=(Z-_)/j*$,q=C.#J,B=J/2,Y=Q/2,{maxH:M,minH:k,maxW:N,minW:U}=this.#u(),L=C.#Z,T=Math.max(J/2,1),V=T*0.84,I=[];for(let A=0;A<C.#$;A+=1){let z=X+A*$;if(z=((z+180)%360+360)%360-180,z<-L||z>=L)continue;let b=z*Math.PI/180,E=B+V*Math.sin(b)/(1-q*Math.cos(b)),y=Math.min(1,Math.abs(E-B)/Math.max(T,1)),w=Math.cos(y*Math.PI*0.5),x=k+(M-k)*w,e=U+(N-U)*w,a=x/2,p=e/2,g=Y-a,r=Y+a,JJ=E-p,QJ=E+p;I.push(`M ${E} ${g} Q ${QJ} ${g} ${QJ} ${g+p} V ${r-p} Q ${QJ} ${r} ${E} ${r} Q ${JJ} ${r} ${JJ} ${r-p} V ${g+p} Q ${JJ} ${g} ${E} ${g} Z`)}this.#G.setAttribute("d",I.join(" "))}#BJ(){this.#q?.addEventListener("pointerdown",this.#w),this.#X?.addEventListener("wheel",this.#C,{passive:!1}),this.#X?.addEventListener("keydown",this.#A)}#GJ(){this.#q?.removeEventListener("pointerdown",this.#w),this.#X?.removeEventListener("wheel",this.#C),this.#X?.removeEventListener("keydown",this.#A),window.removeEventListener("pointermove",this.#x),window.removeEventListener("pointerup",this.#I),window.removeEventListener("pointercancel",this.#I)}#qJ(J){if(O(this,"disabled"))return;if(J.button!==0)return;if(J.preventDefault(),!this.beginScrub(J))return;this.#q?.setPointerCapture?.(J.pointerId),window.addEventListener("pointermove",this.#x),window.addEventListener("pointerup",this.#I),window.addEventListener("pointercancel",this.#I)}beginScrub(J={}){if(O(this,"disabled"))return!1;let Q=typeof J==="number"?J:Number(J?.clientX??J?.x);if(!Number.isFinite(Q))return!1;this.#UJ(),this.#F=!0,this.#W=J&&typeof J==="object"&&J.pointerId!==void 0?J.pointerId:null,this.#H=Q;let Z=J&&typeof J==="object"?Number(J.startValue):Number.NaN;return this.#z=Number.isFinite(Z)?this.#n(Z):this.#S(),this.#V=!1,this.#WJ(Q),this.#MJ(),this.setAttribute("data-fig-input-wheel-active",""),document.body.classList.remove(C.#B),this.focus(),!0}updateScrub(J,Q){if(!this.#F)return this.#S();let Z=typeof J==="number"?J:Number(J?.clientX??J?.x);if(!Number.isFinite(Z))return this.#S();let $=Q??(typeof J==="object"&&J?.shiftKey?10:1);return this.#t(Z,$),this.#S()}endScrub(J=!0){if(!this.#F)return this.#S();if(J&&this.#S()!==this.#z)this.#g(this.#S(),{snap:!0,emit:"change"});return this.#_J(),this.#S()}#PJ(J){if(!this.#F)return;if(this.#W!==null&&J.pointerId!==this.#W)return;this.updateScrub(J)}#t(J,Q=1){if(!this.#V&&Math.abs(J-this.#H)>=C.#j)this.#V=!0,document.body.classList.add(C.#B);let Z=this.#X?.clientWidth||1,$=C.#$*(C.#Z*2/360),j=this.#b()*$,_=(J-this.#H)*(j/Z)*Q,X=this.#R??this.#z,q=this.#n(this.#z+_);this.#i(J,Q,q!==X),this.#R=q,this.#g(q,{snap:!0,emit:"input"}),this.#kJ(J)}#jJ(J){if(!this.#F)return;if(this.#W!==null&&J.pointerId!==this.#W)return;this.endScrub()}#_J(){this.#F=!1,this.#W=null,this.#V=!1,this.#R=null,this.removeAttribute("data-fig-input-wheel-active"),document.body.classList.remove(C.#B),this.#KJ(),this.#ZJ(),window.removeEventListener("pointermove",this.#x),window.removeEventListener("pointerup",this.#I),window.removeEventListener("pointercancel",this.#I),this.#r()}#MJ(){this.#ZJ(),this.#y=this.#QJ("--fig-input-wheel-handle-drag-max")}#QJ(J){let Q=getComputedStyle(this).getPropertyValue(J).trim();if(Q.includes("var(")||!Q.endsWith("px")){let $=document.createElement("div");Object.assign($.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${J})`}),this.appendChild($),Q=getComputedStyle($).width,$.remove()}let Z=Number.parseFloat(Q);return Number.isFinite(Z)?Math.max(0,Z):0}#kJ(J){if(!this.#y){this.#OJ();return}let Q=J-this.#H;if(!Q){this.#OJ();return}let Z=this.#y*Math.tanh(Q/Math.max(1,this.#y*3));this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${Z}px`)}#ZJ(){this.#OJ(),this.#y=0}#OJ(){this.style.removeProperty("--fig-input-wheel-handle-drag-offset")}#WJ(J){this.#KJ(),this.#h=J,this.#D=performance.now()}#i(J,Q,Z){let $=performance.now(),j=$-this.#D,_=this.#h===null?0:Math.abs(J-this.#h);this.#h=J,this.#D=$;let X=j>0?_/j*Math.max(1,Math.abs(Q)):0;if(!Z||X<C.#Q){this.#e();return}this.toggleAttribute("data-fig-input-wheel-fast",!0),clearTimeout(this.#f),this.#f=window.setTimeout(()=>{this.#e()},C.#_)}#KJ(){this.#h=null,this.#D=0,this.#e()}#e(){clearTimeout(this.#f),this.#f=0,this.removeAttribute("data-fig-input-wheel-fast")}#SJ(J){if(O(this,"disabled"))return;J.preventDefault();let Q=J.deltaY===0?Math.sign(J.deltaX):Math.sign(J.deltaY);if(!Q)return;let Z=J.shiftKey?10:1;this.#g(this.#S()+this.#b()*Z*Q,{snap:!0,emit:"input"}),this.#g(this.#S(),{emit:"change"})}#HJ(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number"))return;if(J.key==="Home"){let _=this.#p();if(_===null)return;J.preventDefault(),this.#g(_,{snap:!0,emit:"input"}),this.#g(this.#S(),{emit:"change"});return}if(J.key==="End"){let _=this.#m();if(_===null)return;J.preventDefault(),this.#g(_,{snap:!0,emit:"input"}),this.#g(this.#S(),{emit:"change"});return}if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(J.key))return;J.preventDefault();let Z=J.key==="ArrowRight"||J.key==="ArrowUp"?1:-1,$=J.shiftKey?10:1,j=this.#S();this.#g(j+this.#b()*$*Z,{snap:!0,emit:"input"}),this.#TJ(j,this.#S(),Z,$),this.#g(this.#S(),{emit:"change"})}#TJ(J,Q,Z,$,j=!0){if(J===Q||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this.#UJ();return}if(this.#N)cancelAnimationFrame(this.#N),this.#N=0;clearTimeout(this.#L),this.#L=0,this.removeAttribute("data-fig-input-wheel-keyboard-settling");let _=this.#R??J,X=Number.parseFloat(this.style.getPropertyValue("--fig-input-wheel-handle-drag-offset"))||0,q=$>1?120:90,B=performance.now(),Y=j;this.setAttribute("data-fig-input-wheel-keyboard-moving","");let M=(k)=>{let N=Math.min(1,(k-B)/q);if(this.#R=_+(Q-_)*N,Y){let U=Math.sin(N*Math.PI/2),L=X+(Z*4-X)*U;this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${L}px`)}if(this.#NJ(),N<1){this.#N=requestAnimationFrame(M);return}this.#N=0,this.#R=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.setAttribute("data-fig-input-wheel-keyboard-settling",""),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.#L=window.setTimeout(()=>{this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.#L=0},140),this.#r()};this.#N=requestAnimationFrame(M)}#UJ(){if(this.#N)cancelAnimationFrame(this.#N),this.#N=0;if(clearTimeout(this.#L),this.#L=0,this.#R=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.isConnected)this.#r()}get value(){return this.getAttribute("value")??"0"}set value(J){if(J===null||J===void 0||J===""){this.#g(0);return}let Q=Number(J);this.#g(Number.isFinite(Q)?Q:0)}spinTo(J,{animateHandle:Q=!1}={}){let Z=this.#S();this.value=J;let $=this.#S();if(this.getAttribute("spin")==="false")return this.#UJ(),$;let j=Math.sign($-Z);return this.#TJ(Z,$,j,Math.abs($-Z)>this.#b()?10:1,Q),$}get min(){return this.#p()}set min(J){this.#a("min",J)}get max(){return this.#m()}set max(J){this.#a("max",J)}get step(){return this.#b()}focus(J){HTMLElement.prototype.focus.call(this,J)}}P("fig-input-wheel",C);class l extends S{static#$=new Set(["label","size","disabled","variant","elastic","spin","text","default","class","style","id","oninput","onchange"]);static get observedAttributes(){return["label","aria-label","units","value","disabled","step","precision","min","max","elastic","spin","text"]}#Z=null;#J=null;#Q=null;#_=null;#j=!1;#B=null;#q=new Set;#M=null;#X=null;#O=0;#G=null;#Y=0;#k=null;#K=null;#P=0;#U=0;#N=0;#L=!1;#T=!1;#F=0;#W=!1;#H=this.#r.bind(this,"input");#z=this.#r.bind(this,"change");#V=this.#NJ.bind(this,"input");#R=this.#NJ.bind(this,"change");#y=this.#BJ.bind(this);#h=this.#WJ.bind(this);#D=this.#i.bind(this);#f=this.#KJ.bind(this);#w=this.#GJ.bind(this);#x=this.#qJ.bind(this);#I=this.#PJ.bind(this);#C=this.#_J.bind(this);#A=this.#MJ.bind(this);#E=this.#SJ.bind(this);connectedCallback(){if(!this.#Z)this.#c();this.#u(),this.#b(),this.#$J(),this.#g(),this.#XJ(),W(this),this.#B?.disconnect(),this.#B=new MutationObserver((J)=>{if(J.some(({type:Q,attributeName:Z})=>Q==="attributes"&&Z&&!l.#$.has(Z)&&!l.observedAttributes.includes(Z)&&!Z.startsWith("data-")))this.#g()}),this.#B.observe(this,{attributes:!0})}disconnectedCallback(){this.#B?.disconnect(),this.#t(),this.#ZJ(),this.#o(),this.#e(),clearTimeout(this.#F),this.#F=0,this.#J?.endScrub(!1),R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="aria-label")this.#u();if(J==="text")this.#b();if(J==="elastic"&&Z==="false")this.#ZJ();if(["units","value","disabled","step","min","max","elastic","spin"].includes(J))this.#$J();if(["units","value","disabled","step","precision","min","max"].includes(J))this.#g()}#c(){this.#M=this.getAttribute("value")??"0";let J=Array.from(this.childNodes).filter((X)=>X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())),Q=J.find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),Z=G("div",{className:"propskit-wheel-surface"}),$=Q||document.createElement("label"),j=document.createElement("fig-input-wheel"),_=document.createElement("fig-input-number");Z.append($,j,_),this.#Z=Z,this.#J=j,this.#Q=$,this.#_=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let X of J)if(X!==Q)_.appendChild(X)}#u(){let J=f(this,this.#Z,this.#Q,this.#j);H(this,this.#J,J,"Wheel"),H(this,this.#_,J,"Number")}#b(){if(!this.#Z||!this.#_)return;let J=this.getAttribute("text")!=="false",Q=this.#_.parentElement===this.#Z;if(J&&!Q)this.#Z.append(this.#_);else if(!J&&Q)this.#_.remove()}#S(J){if(!this.#J)return;if(this.hasAttribute(J))this.#J.setAttribute(J,this.getAttribute(J)??"");else this.#J.removeAttribute(J)}#$J(){if(!this.#J)return;this.#J.removeAttribute("units");for(let $ of["min","max","spin"])this.#S($);if(this.hasAttribute("step"))this.#S("step");else this.#J.setAttribute("step",String(this.#a()));this.#J.toggleAttribute("disabled",O(this,"disabled"));let J=d(this.getAttribute("value"));this.#J.value=J??0;let Q=String(this.#J.value);if(J!==null&&this.getAttribute("value")!==Q)this.setAttribute("value",Q);let Z=J===null?"":Q;if(this.#_?.getAttribute("value")!==Z)this.#_?.setAttribute("value",Z);this.#s()}#p(){return this.getAttributeNames().filter((J)=>!l.#$.has(J)&&!l.observedAttributes.includes(J)&&!J.startsWith("data-"))}#m(){let J=(this.getAttribute("units")||"").trim(),Q=J.toLowerCase();if(Q==="ms"||Q==="millisecond"||Q==="milliseconds")return"ms";if(Q==="s"||Q==="second"||Q==="seconds")return"s";return J}#a(){let J=this.#m();if(J==="s")return 0.1;if(J==="ms")return 100;return 1}#n(){return this.#m()==="s"?2:0}#s(){if(!this.#J)return;let J=Number(this.#J.value),Q=this.#m();this.#J.setAttribute("aria-valuetext",Q?`${J} ${Q==="s"?"seconds":Q==="ms"?"milliseconds":Q}`:String(J))}#g(){if(!this.#_||!this.#J)return;let J=this.#p(),Q=new Set(J);for(let $ of this.#q)if(!Q.has($))this.#_.removeAttribute($);for(let $ of J)this.#_.setAttribute($,this.getAttribute($)??"");let Z=this.#m();if(Z)this.#_.setAttribute("units",Z);else this.#_.removeAttribute("units");if(this.#_.setAttribute("step",String(this.#J.step)),this.hasAttribute("precision"))this.#_.setAttribute("precision",this.getAttribute("precision")??"");else this.#_.setAttribute("precision",String(this.#n()));for(let $ of["min","max"]){let j=this.#J[$];if(j===null)this.#_.removeAttribute($);else this.#_.setAttribute($,String(j))}this.#_.toggleAttribute("disabled",O(this,"disabled")),this.#_.setAttribute("value",String(this.value??"")),this.#q=Q}#XJ(){this.#o(),this.#J?.addEventListener("input",this.#H),this.#J?.addEventListener("change",this.#z),this.#_?.addEventListener("input",this.#V),this.#_?.addEventListener("change",this.#R),this.#_?.addEventListener("keydown",this.#y,{capture:!0}),this.addEventListener("pointerdown",this.#w,{capture:!0}),this.addEventListener("pointerdown",this.#h,{capture:!0}),this.addEventListener("click",this.#E,!0)}#o(){this.#J?.removeEventListener("input",this.#H),this.#J?.removeEventListener("change",this.#z),this.#_?.removeEventListener("input",this.#V),this.#_?.removeEventListener("change",this.#R),this.#_?.removeEventListener("keydown",this.#y,{capture:!0}),this.removeEventListener("pointerdown",this.#w,{capture:!0}),this.removeEventListener("pointerdown",this.#h,{capture:!0}),this.removeEventListener("click",this.#E,!0)}#d(J,{spin:Q=!1,animateHandle:Z=!1}={}){let $=d(J);if($===null){if(this.removeAttribute("value"),this.#J)this.#J.value=0;return this.#_?.setAttribute("value",""),this.#s(),null}if(!this.#J)return this.setAttribute("value",String($)),$;if(Q)this.#J.spinTo($,{animateHandle:Z});else this.#J.value=$;let j=this.#J.value;if(this.getAttribute("value")!==j)this.setAttribute("value",j);if(this.#_?.getAttribute("value")!==j)this.#_?.setAttribute("value",j);return this.#s(),Number(j)}#JJ(J){K(this,J)}#r(J,Q){Q.stopImmediatePropagation(),this.#d(Q.detail),this.#JJ(J)}#NJ(J,Q){if(Q.stopImmediatePropagation(),O(this,"disabled"))return;let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#_?.value;if(this.#d(Z,{spin:J==="input",animateHandle:J==="input"&&this.#W}),J==="input")this.#W=!1;this.#JJ(J)}#BJ(J){this.#W=!O(this,"disabled")&&(J.key==="ArrowUp"||J.key==="ArrowDown"),window.setTimeout(()=>{this.#W=!1},0)}#GJ(J){if(J.button!==0||O(this,"disabled")||!(J.target instanceof Element)||J.target.closest("fig-input-number")||J.target.closest(".propskit-wheel-surface")!==this.#Z)return;if(J.preventDefault(),J.stopImmediatePropagation(),this.#t(),!this.#J?.beginScrub({clientX:J.clientX,pointerId:J.pointerId,startValue:Number(this.#J.value)}))return;this.#k=J.pointerId,this.#jJ(J.pointerId),window.addEventListener("pointermove",this.#x),window.addEventListener("pointerup",this.#I),window.addEventListener("pointercancel",this.#I),window.addEventListener("blur",this.#I)}#qJ(J){if(J.pointerId!==this.#k)return;if(J.buttons===0){this.#PJ(J);return}this.#J?.updateScrub(J)}#PJ(J){if(J?.pointerId!==void 0&&this.#k!==null&&J.pointerId!==this.#k)return;this.#J?.endScrub(),this.#t(),this.#ZJ()}#t(){window.removeEventListener("pointermove",this.#x),window.removeEventListener("pointerup",this.#I),window.removeEventListener("pointercancel",this.#I),window.removeEventListener("blur",this.#I),this.#k=null}#jJ(J){if(this.#ZJ(),this.getAttribute("elastic")==="false")return;this.#X=J,this.#O=this.#kJ("--propskit-wheel-elastic-distance");let Q=this.getBoundingClientRect();if(Q)this.#G={left:Q.left,right:Q.right};this.#Y=this.getBoundingClientRect().width,window.addEventListener("pointermove",this.#C,{passive:!0}),window.addEventListener("pointerup",this.#A),window.addEventListener("pointercancel",this.#A),window.addEventListener("blur",this.#A)}#_J(J){if(J.pointerId!==this.#X)return;if(J.buttons===0){this.#MJ(J);return}this.#QJ(J.clientX)}#MJ(J){if(J?.pointerId!==void 0&&this.#X!==null&&J.pointerId!==this.#X)return;this.#ZJ()}#QJ(J){let Q=this.#G;if(!Q||!this.#O){this.#OJ();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#OJ();return}let $=Math.min(this.#O,Math.abs(Z)*0.5),j=this.#Y?(this.#Y+$)/this.#Y:1;this.toggleAttribute("data-propskit-wheel-elastic-dragging",!0),this.style.setProperty("--propskit-wheel-elastic-scale",String(j)),this.style.setProperty("--propskit-wheel-elastic-origin",Z<0?"right center":"left center")}#kJ(J){let Q=getComputedStyle(this).getPropertyValue(J).trim();if(Q.includes("var(")||!Q.endsWith("px")){let $=document.createElement("div");Object.assign($.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${J})`}),this.appendChild($),Q=getComputedStyle($).width,$.remove()}let Z=Number.parseFloat(Q);return Number.isFinite(Z)?Math.max(0,Z):0}#ZJ(){window.removeEventListener("pointermove",this.#C),window.removeEventListener("pointerup",this.#A),window.removeEventListener("pointercancel",this.#A),window.removeEventListener("blur",this.#A),this.#X=null,this.#O=0,this.#G=null,this.#Y=0,this.#OJ()}#OJ(){this.removeAttribute("data-propskit-wheel-elastic-dragging"),this.style.removeProperty("--propskit-wheel-elastic-scale"),this.style.removeProperty("--propskit-wheel-elastic-origin")}#WJ(J){if(J.button!==0||J.altKey||O(this,"disabled")||!(J.target instanceof Element))return;let Q=J.target.closest("fig-input-number input");if(!Q||Q===document.activeElement)return;J.preventDefault(),J.stopImmediatePropagation(),this.#e(),this.#K=J.pointerId,this.#P=J.clientX,this.#U=J.clientY,this.#N=Number(this.#J?.value??0),window.addEventListener("pointermove",this.#D),window.addEventListener("pointerup",this.#f,{once:!0}),window.addEventListener("pointercancel",this.#f,{once:!0}),window.addEventListener("blur",this.#f,{once:!0})}#i(J){if(J.pointerId!==this.#K)return;if(J.buttons===0){this.#KJ(J);return}if(!this.#L){if(Math.hypot(J.clientX-this.#P,J.clientY-this.#U)<4)return;this.#L=!0,this.setAttribute("data-number-scrubbing",""),this.#jJ(J.pointerId),this.#J?.beginScrub({clientX:this.#P,pointerId:J.pointerId,startValue:this.#N})}this.#J?.updateScrub(J),this.#QJ(J.clientX)}#KJ(J){if(J?.pointerId!==void 0&&this.#K!==null&&J.pointerId!==this.#K)return;let Q=this.#L;if(this.#ZJ(),this.#e(),Q){this.#J?.endScrub(),this.#T=!0,clearTimeout(this.#F),this.#F=window.setTimeout(()=>{this.#T=!1,this.#F=0},0),requestAnimationFrame(()=>this.#J?.focus());return}this.#_?.querySelector("input")?.focus()}#e(){window.removeEventListener("pointermove",this.#D),window.removeEventListener("pointerup",this.#f),window.removeEventListener("pointercancel",this.#f),window.removeEventListener("blur",this.#f),this.#K=null,this.#L=!1,this.removeAttribute("data-number-scrubbing")}#SJ(J){if(O(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu")){if(this.#T&&J.target.closest("fig-input-number"))J.preventDefault(),J.stopImmediatePropagation(),this.#T=!1;return}if(!(J.target instanceof Element)||!J.target.closest("fig-input-wheel"))this.#J?.focus()}get value(){return d(this.getAttribute("value"))}set value(J){this.#d(J)}get min(){return this.#J?.min??null}set min(J){if(J===null||J===void 0||J==="")this.removeAttribute("min");else{let Q=Number(J);if(Number.isFinite(Q))this.setAttribute("min",String(Q));else this.removeAttribute("min")}}get max(){return this.#J?.max??null}set max(J){if(J===null||J===void 0||J==="")this.removeAttribute("max");else{let Q=Number(J);if(Number.isFinite(Q))this.setAttribute("max",String(Q));else this.removeAttribute("max")}}get defaultValue(){return this.getAttribute("default")??this.#M??"0"}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){this.#d(this.defaultValue),D(this)}focus(J){this.#J?.focus(J)}}P("propskit-wheel",l);class hJ extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping","precision"];#$=50;#Z=50;#J=75;#Q=75;#_=0;#j=!1;#B=0;#q=null;#M=null;#X=null;#O=null;#G=null;#Y=null;#k=null;#K=null;#P=null;#U=!1;#N=!1;#L=!1;#T=!1;#F=null;#W="";#H="";#z=null;#V=null;#R=null;#y="";#h="";#D=null;#f=null;#w=null;get#x(){return this.getAttribute("type")||"point"}get#I(){return this.#x==="point-radius"||this.#x==="point-radius-angle"}get#C(){return this.#x==="point-radius-angle"}get#A(){return this.#x==="point-point"}get#E(){return this.#x==="point-radius-angle"||this.#x==="point-point"}get#c(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#u(){let J=this.getAttribute("snapping");if(J===null)return"false";let Q=J.trim().toLowerCase();if(Q==="modifier")return"modifier";if(Q===""||Q==="true")return"true";return"false"}get#b(){let J=Number(this.getAttribute("precision")??2);if(!Number.isFinite(J))return 2;return Math.max(0,Math.min(8,Math.trunc(J)))}#S(J){let Q=10**this.#b,Z=Math.round(J*Q)/Q;return Object.is(Z,-0)?0:Z}#$J(){let J=this.getAttribute("precision");for(let Q of[this.#q,this.#X,this.#M]){if(!Q)continue;if(J===null)Q.removeAttribute("precision");else Q.setAttribute("precision",String(this.#b))}}#p(J){let Q=this.#u;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#m(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${this.#S(this.#$)}%, ${this.#S(this.#Z)}%`}get#a(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${this.#S(this.#J)}%, ${this.#S(this.#Q)}%`}get#n(){return this.getAttribute("drag-surface")||"parent"}get#s(){let J=this.#n;if(J==="parent")return this.parentElement;return this.closest(J)}get#g(){let J=this.#n;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#XJ(J){if(this.#j)return this.#_/100*J;return this.#_}#o(){let J=this.#S(this.#_);if(this.#j)return`Radius ${J}%`;return`Radius ${J}`}connectedCallback(){this.#d(),this.#JJ()}disconnectedCallback(){this.#VJ(),this.#bJ(),this.#BJ(),this.#t(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#U&&!this.#N&&!this.#L&&!this.#T)if(this.#d(),this.#q)this.#l();else this.#JJ();if(J==="type")this.#VJ(),this.#d(),this.#JJ();if(J==="color"&&this.#q)if(Z)this.#q.setAttribute("color",Z);else this.#q.removeAttribute("color");if(J==="disabled")this.#VJ(),this.#JJ();if(J==="tooltips")this.#JJ();if(J==="snapping"&&this.#q){if(this.#q.setAttribute("drag-snapping",Z||"false"),this.#M)this.#M.setAttribute("drag-snapping",Z||"false")}if(J==="precision"){if(!this.isConnected)return;this.#$J(),this.#$=this.#S(this.#$),this.#Z=this.#S(this.#Z),this.#J=this.#S(this.#J),this.#Q=this.#S(this.#Q),this.#_=this.#S(this.#_),this.#B=this.#S(this.#B),this.#l(),this.#v()}if(J==="name"){if(this.#Y)this.#Y.setAttribute("text",this.#m);if(this.#k)this.#k.setAttribute("text",this.#a)}}#d(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#$=this.#S(Q.x);if(typeof Q.y==="number")this.#Z=this.#S(Q.y);if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#j=!0,this.#_=this.#S(parseFloat(Z));else this.#j=!1,this.#_=this.#S(parseFloat(Z));if(!Number.isFinite(this.#_))this.#_=0}if(typeof Q.angle==="number")this.#B=this.#S(Q.angle);if(typeof Q.x2==="number")this.#J=this.#S(Q.x2);if(typeof Q.y2==="number")this.#Q=this.#S(Q.y2);if(this.#x==="color"&&typeof Q.color==="string"&&Q.color.trim()&&this.getAttribute("color")!==Q.color.trim())this.setAttribute("color",Q.color.trim())}catch{}}get value(){let J={x:this.#S(this.#$),y:this.#S(this.#Z)};if(this.#x==="color"){let Q=this.getAttribute("color")||this.#q?.getAttribute("color");if(Q)J.color=Q}if(this.#I){let Q=this.#S(this.#_);J.radius=this.#j?`${Q}%`:Q}if(this.#C)J.angle=this.#S(this.#B);if(this.#A)J.x2=this.#S(this.#J),J.y2=this.#S(this.#Q);return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#JJ(){this.#VJ(),this.replaceChildren(),this.#q=null,this.#M=null,this.#X=null,this.#O=null,this.#G=null,this.#Y=null,this.#k=null,this.#K=null,this.#P=null;let J=O(this,"disabled"),Q=this.#x,Z=this.#c,$=this.#g,j=document.createElement("fig-handle");if(j.setAttribute("drag","true"),j.setAttribute("drag-surface",$),j.setAttribute("drag-axes","x,y"),j.setAttribute("drag-snapping",this.#u),j.setAttribute("value",`${this.#$}% ${this.#Z}%`),this.hasAttribute("precision"))j.setAttribute("precision",String(this.#b));if(J)j.setAttribute("disabled","");if(Q==="color"){j.setAttribute("type","color");let _=this.getAttribute("color");if(_)j.setAttribute("color",_)}else j.setAttribute("type","canvas");if(this.#A)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#q=j,this.#I)this.#ZJ();if(this.#E)this.#OJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#m),_.appendChild(j),this.appendChild(_),this.#Y=_}else this.appendChild(j);if(this.#C)this.#i(J,Z,$);if(this.#A)this.#KJ(J,Z,$);this.#r(this.#q),this.#r(this.#X),this.#r(this.#M),this.#DJ(),this.#MJ(),requestAnimationFrame(()=>this.#l())}#r(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#PJ(Q,J);else this.#NJ(Q)},{capture:!0})}#NJ(J){if(O(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#F===null)this.#W=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#F=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#z)this.#z=(Q)=>{if(Q?.pointerId!==void 0&&this.#F!==null&&Q.pointerId!==this.#F)return;if(Q?.type==="blur")this.#BJ();else requestAnimationFrame(()=>this.#BJ())};window.addEventListener("pointerup",this.#z),window.addEventListener("pointercancel",this.#z),window.addEventListener("blur",this.#z)}#BJ(){if(this.#F===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#W)document.body.style.setProperty("cursor",this.#W,this.#H);else document.body.style.removeProperty("cursor");if(this.#F=null,this.#W="",this.#H="",this.#z)window.removeEventListener("pointerup",this.#z),window.removeEventListener("pointercancel",this.#z),window.removeEventListener("blur",this.#z)}#GJ(J){if(!J)return 0;if(J===this.#X)return this.#B;if(!this.#A)return 0;let Q=this.#FJ();return J===this.#q?Q+180:Q}#qJ(){if(this.#V===null)return;let J=this.#SJ(this.#GJ(this.#R));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#PJ(J,Q){if(O(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#V===null)this.#y=document.body.style.getPropertyValue("cursor"),this.#h=document.body.style.getPropertyPriority("cursor");if(this.#V=J?.pointerId??-1,this.#R=Q,document.body.classList.add("fig-lab-rotate-active"),this.#qJ(),!this.#D)this.#D=(Z)=>{if(Z?.pointerId!==void 0&&this.#V!==null&&Z.pointerId!==this.#V)return;if(Z?.type==="blur")this.#t();else requestAnimationFrame(()=>this.#t())};window.addEventListener("pointerup",this.#D),window.addEventListener("pointercancel",this.#D),window.addEventListener("blur",this.#D)}#t(){if(this.#V===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#y)document.body.style.setProperty("cursor",this.#y,this.#h);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#R=null,this.#y="",this.#h="",this.#D)window.removeEventListener("pointerup",this.#D),window.removeEventListener("pointercancel",this.#D),window.removeEventListener("blur",this.#D)}#jJ(J,Q,Z,$){if(!J)return;let j=()=>!!$?.(),_=()=>{let B=Q();if(!B)return;B.removeAttribute("show"),B.hidePopup?.()},X=()=>{if(j()){_();return}let B=Q();if(!B)return;if(Z)B.setAttribute("text",Z());B.setAttribute("show","true"),B.showPopup?.()},q=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",q)}#_J(){return this.#U||this.#N||this.#L||this.#T}#MJ(){if(this.#q)this.#jJ(this.#q,()=>this.#Y,()=>this.#m,()=>this.#_J()||!!this.#q?.querySelector("fig-color-tip"));if(this.#X)this.#jJ(this.#X,()=>this.#P,()=>`Angle ${this.#S(this.#B)}°`,()=>this.#_J());if(this.#M)this.#jJ(this.#M,()=>this.#k,()=>this.#a,()=>this.#_J());if(this.#O){let J=this.#O.querySelector(".fig-canvas-control-radius-hit");this.#kJ(J||this.#O)}if(this.#x==="color"&&this.#q&&this.#Y)new MutationObserver(()=>{if(this.#q?.querySelector("fig-color-tip"))this.#Y?.removeAttribute("show"),this.#Y?.hidePopup?.()}).observe(this.#q,{childList:!0,subtree:!0})}#QJ(J,Q){let Z=this.#K;if(!Z?.popup)return;let $=Q-8;Z.popup.anchor={getBoundingClientRect:()=>({left:J,top:$,right:J,bottom:$,width:0,height:0,x:J,y:$})},Z.popup.queueReposition?.()}#kJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#K;if(!Z)return;Z.setAttribute("text",this.#o()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#QJ(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#L)return;this.#QJ(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#L)return;let Q=this.#K;if(!Q)return;Q.removeAttribute("show")})}#ZJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");Q.classList.add("fig-canvas-control-radius"),Q.setAttribute("overflow","visible");let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-hit"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");$.classList.add("fig-canvas-control-radius-halo"),Q.appendChild($);let j=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(j),this.#O=Q,this.#c){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#o()),_.appendChild(Q),this.appendChild(_),this.#K=_}else this.appendChild(Q);this.#IJ(Z)}#OJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#A){let j=document.createElementNS("http://www.w3.org/2000/svg","line");j.classList.add("fig-canvas-control-angle-line-hit"),j.setAttribute("stroke","transparent"),j.setAttribute("stroke-width","12"),j.setAttribute("stroke-linecap","round"),j.style.pointerEvents="stroke",Q.appendChild(j),this.#WJ(j)}let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line-halo"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line"),Q.appendChild($),this.#G=Q,this.appendChild(Q)}#WJ(J){J.addEventListener("pointerdown",(Q)=>{if(O(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#s;if(!Z)return;let{clientX:$,clientY:j}=Q,_=this.#$,X=this.#Z,q=this.#J,B=this.#Q;this.#U=!0,this.#N=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let Y=(k)=>{let N=Z.getBoundingClientRect(),U=N.width>0?(k.clientX-$)/N.width*100:0,L=N.height>0?(k.clientY-j)/N.height*100:0,T=-Math.min(_,q),V=100-Math.max(_,q),I=-Math.min(X,B),A=100-Math.max(X,B),z=Math.max(T,Math.min(V,U)),b=Math.max(I,Math.min(A,L));this.#$=this.#S(_+z),this.#Z=this.#S(X+b),this.#J=this.#S(q+z),this.#Q=this.#S(B+b),this.#l(),this.#LJ()},M=this.#zJ((k)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#U=!1,this.#N=!1,k)this.#v(),this.#YJ()});window.addEventListener("pointermove",Y,{signal:M.signal}),window.addEventListener("pointerup",()=>M.finish(!0),{signal:M.signal}),window.addEventListener("pointercancel",()=>M.finish(!1),{signal:M.signal})})}#i(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),this.hasAttribute("precision"))$.setAttribute("precision",String(this.#b));if(J)$.setAttribute("disabled","");if(this.#X=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",`${this.#S(this.#B)}°`),j.appendChild($),this.appendChild(j),this.#P=j}else this.appendChild($)}#KJ(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#u),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#Q}%`),this.hasAttribute("precision"))$.setAttribute("precision",String(this.#b));if(J)$.setAttribute("disabled","");if(this.#M=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#a),j.appendChild($),this.appendChild(j),this.#k=j}else this.appendChild($)}#e(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.1212 16.9998L11.5607 17.4394C12.1465 18.0252 12.1464 18.975 11.5606 19.5607C10.9748 20.1465 10.0251 20.1465 9.4393 19.5606L6.4393 16.5604C5.85354 15.9746 5.85357 15.0249 6.43938 14.4391L9.43938 11.4393C10.0252 10.8535 10.9749 10.8536 11.5607 11.4394C12.1465 12.0252 12.1464 12.9749 11.5606 13.5607L11.1215 13.9998L20.8786 13.9999L20.4394 13.5607C19.8536 12.9749 19.8535 12.0252 20.4393 11.4394C21.0251 10.8536 21.9749 10.8536 22.5606 11.4394L25.5606 14.4393C25.842 14.7206 26 15.1021 26 15.4999C26 15.8978 25.842 16.2793 25.5607 16.5606L22.5607 19.5607C21.9749 20.1465 21.0251 20.1465 20.4393 19.5607C19.8536 18.9749 19.8535 18.0252 20.4393 17.4394L20.8788 16.9999L11.1212 16.9998Z' fill='white'/%3E%3C/g%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.8536 12.1465C11.0488 12.3417 11.0488 12.6583 10.8535 12.8536L8.70715 14.9998L23.2929 14.9999L21.1465 12.8536C20.9512 12.6583 20.9512 12.3417 21.1464 12.1465C21.3417 11.9512 21.6583 11.9512 21.8535 12.1465L24.8535 15.1464C24.9473 15.2402 25 15.3673 25 15.4999C25 15.6326 24.9473 15.7597 24.8536 15.8535L21.8536 18.8536C21.6583 19.0488 21.3417 19.0488 21.1465 18.8536C20.9512 18.6583 20.9512 18.3417 21.1464 18.1465L23.2929 15.9999L8.70705 15.9998L10.8536 18.1465C11.0488 18.3417 11.0488 18.6583 10.8535 18.8536C10.6583 19.0488 10.3417 19.0488 10.1464 18.8535L7.14643 15.8533C6.95118 15.658 6.95119 15.3415 7.14646 15.1462L10.1465 12.1464C10.3417 11.9512 10.6583 11.9512 10.8536 12.1465Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='3' y='9' width='26' height='15' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, nwse-resize`}#SJ(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#HJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#TJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#HJ(Z,this.#SJ(Q)),this.#R===J)this.#qJ()}#UJ(){if(!this.#X||!this.#C)return;this.#TJ(this.#X,this.#B)}#FJ(){return Math.atan2(this.#Q-this.#Z,this.#J-this.#$)*180/Math.PI}#CJ(){if(!this.#A)return;let J=this.#FJ();this.#q?.style.removeProperty("cursor"),this.#M?.style.removeProperty("cursor"),this.#TJ(this.#q,J+180),this.#TJ(this.#M,J)}#RJ(J,Q,Z,$){J.style.setProperty("--fig-handle-position-translate","-50% -50%"),J.style.left=`${Q/100*$.width}px`,J.style.top=`${Z/100*$.height}px`}#l(){let J=this.#s;if(!J||!this.#q)return;let Q=J.getBoundingClientRect();if(this.#RJ(this.#q,this.#$,this.#Z,Q),this.#O){let Z=this.#$/100*Q.width,$=this.#Z/100*Q.height,j=this.#XJ(Q.width),_=this.#O,X=Math.max(j*2,1);_.style.position="absolute",_.style.width=`${X}px`,_.style.height=`${X}px`,_.style.left=`${Z-j}px`,_.style.top=`${$-j}px`,_.setAttribute("viewBox",`0 0 ${X} ${X}`);let q=_.querySelectorAll("circle");for(let B of q)B.setAttribute("cx",String(j)),B.setAttribute("cy",String(j)),B.setAttribute("r",String(Math.max(j-1,0)))}if(this.#G&&this.#E){let Z=this.#$/100*Q.width,$=this.#Z/100*Q.height,j,_;if(this.#A)j=this.#J/100*Q.width,_=this.#Q/100*Q.height;else{let B=this.#XJ(Q.width),Y=this.#B*Math.PI/180;j=Z+B*Math.cos(Y),_=$+B*Math.sin(Y)}let X=this.#G;X.style.width=`${Q.width}px`,X.style.height=`${Q.height}px`,X.style.left="0",X.style.top="0",X.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let q=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of q)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#X&&this.#C){let Z=this.#$/100*Q.width,$=this.#Z/100*Q.height,j=this.#XJ(Q.width),_=this.#B*Math.PI/180,X=Z+j*Math.cos(_),q=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,Y=Q.height>0?q/Q.height*100:0;this.#RJ(this.#X,B,Y,Q)}if(this.#M&&this.#A)this.#RJ(this.#M,this.#J,this.#Q,Q);this.#UJ(),this.#CJ()}#LJ(J=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:J}))}#YJ(J=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:J}))}#fJ(J){return{...this.value,...pJ(J.color,J.alpha,J.opacity)}}#v(){this.setAttribute("value",JSON.stringify(this.value))}#DJ(){if(!this.#q)return;if(this.#q.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#q.getAttribute("color")||J.detail.color),this.#LJ(this.#fJ(J.detail));return}this.#U=!0;let Q=J.detail?.px??this.#$/100,Z=J.detail?.py??this.#Z/100;if(this.#$=this.#S(Math.max(0,Math.min(100,Q*100))),this.#Z=this.#S(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();this.#l(),this.#LJ()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#q.getAttribute("color")||J.detail.color),this.#YJ(this.#fJ(J.detail));return}let Q=J.detail?.px??this.#$/100,Z=J.detail?.py??this.#Z/100;if(this.#$=this.#S(Math.max(0,Math.min(100,Q*100))),this.#Z=this.#S(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show");this.#l(),this.#v(),this.#YJ(),requestAnimationFrame(()=>{this.#U=!1})}),this.#X)this.#X.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#s;if(!Q)return;this.#T=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#$/100*Z.width,j=this.#Z/100*Z.height,_=J.detail?.x??0,X=J.detail?.y??0,q=this.#X.offsetWidth/2,B=this.#X.offsetHeight/2,Y=_+q-$,M=X+B-j,k=Math.atan2(M,Y)*180/Math.PI;if(this.#p(J.detail?.shiftKey))k=Math.round(k/15)*15;this.#B=this.#S(k);let N=Math.sqrt(Y*Y+M*M);if(this.#p(J.detail?.shiftKey)){let U=this.#j?5:10;if(this.#j){let L=N/Z.width*100;L=Math.round(L/U)*U,N=L/100*Z.width}else N=Math.round(N/U)*U}if(this.#j)this.#_=this.#S(Math.max(0,N/Z.width*100));else this.#_=this.#S(Math.max(0,N));if(this.#P)this.#P.setAttribute("text",`Angle ${this.#S(this.#B)}°`),this.#P.setAttribute("show","true"),this.#P.showPopup?.();this.#l(),this.#LJ()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#P)this.#P.removeAttribute("show");this.#l(),this.#v(),this.#YJ(),requestAnimationFrame(()=>{this.#T=!1})}),this.#X.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#s;if(!Z)return;if(this.#T=!0,this.classList.add("fig-canvas-control-ring-active"),this.#X.setAttribute("selected",""),this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),q=this.#$/100*X.width,B=this.#Z/100*X.height,Y=_.clientX-X.left-q,M=_.clientY-X.top-B,k=Math.atan2(M,Y)*180/Math.PI;if(this.#p(_.shiftKey))k=Math.round(k/15)*15;if(this.#B=this.#S(k),this.#P)this.#P.setAttribute("text",`Angle ${this.#S(k)}°`);this.#l(),this.#LJ()},j=this.#zJ((_)=>{if(this.#T=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#X.removeAttribute("selected"),this.#P)this.#P.removeAttribute("show");if(_)this.#v(),this.#YJ()});window.addEventListener("pointermove",$,{signal:j.signal}),window.addEventListener("pointerup",()=>j.finish(!0),{signal:j.signal}),window.addEventListener("pointercancel",()=>j.finish(!1),{signal:j.signal})});if(this.#M)this.#M.addEventListener("input",(J)=>{J.stopPropagation(),this.#N=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#Q/100;if(this.#J=this.#S(Math.max(0,Math.min(100,Q*100))),this.#Q=this.#S(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show"),this.#k.hidePopup?.();this.#l(),this.#LJ()}),this.#M.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#k)this.#k.removeAttribute("show");this.#l(),this.#v(),this.#YJ(),requestAnimationFrame(()=>{this.#N=!1})}),this.#AJ(this.#q,!0),this.#AJ(this.#M,!1)}#AJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let j=this.#s;if(!j)return;this.#U=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#$,q=Q?this.#Q:this.#Z,B=Q?this.#$:this.#J,Y=Q?this.#Z:this.#Q,M=X/100*_.width,k=q/100*_.height,N=B/100*_.width,U=Y/100*_.height,L=Math.sqrt((N-M)**2+(U-k)**2),T=Q?this.#Y:this.#k;if(T)T.removeAttribute("show"),T.hidePopup?.();let V=(A)=>{let z=j.getBoundingClientRect(),b=X/100*z.width,E=q/100*z.height,y=A.clientX-z.left-b,w=A.clientY-z.top-E,x=Math.atan2(w,y);if(this.#p(A.shiftKey))x=Math.round(x*180/Math.PI/15)*15*Math.PI/180;let e=b+L*Math.cos(x),a=E+L*Math.sin(x),p=Math.max(0,Math.min(100,e/z.width*100)),g=Math.max(0,Math.min(100,a/z.height*100));if(Q)this.#$=this.#S(p),this.#Z=this.#S(g);else this.#J=this.#S(p),this.#Q=this.#S(g);this.#l(),this.#LJ()},I=this.#zJ((A)=>{if(this.#U=!1,T)T.removeAttribute("show");if(A)this.#v(),this.#YJ()});window.addEventListener("pointermove",V,{signal:I.signal}),window.addEventListener("pointerup",()=>I.finish(!0),{signal:I.signal}),window.addEventListener("pointercancel",()=>I.finish(!1),{signal:I.signal})})}#IJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#L)return;let $=this.#s;if(!$)return;let j=$.getBoundingClientRect(),_=this.#$/100*j.width,X=this.#Z/100*j.height,q=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#HJ(J,this.#e(q))});let Q=(Z)=>{if(O(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#s;if(!$)return;if(this.#K)this.#K.setAttribute("show","true"),this.#K.showPopup?.(),this.#QJ(Z.clientX,Z.clientY);if(this.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();let j=this.#X?.style.pointerEvents,_=this.#X?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#X)this.#X.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let q=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),Y=this.#$/100*B.width,M=this.#Z/100*B.height,k=Math.atan2(Z.clientY-B.top-M,Z.clientX-B.left-Y)*180/Math.PI,N=Math.round(k);document.body.style.cursor=this.#e(N);let U=(T)=>{let V=$.getBoundingClientRect(),I=this.#$/100*V.width,A=this.#Z/100*V.height,z=T.clientX-V.left-I,b=T.clientY-V.top-A,E=Math.round(Math.atan2(b,z)*180/Math.PI);if(E!==N)N=E,document.body.style.cursor=this.#e(E);let y=Math.sqrt(z*z+b*b);if(this.#p(T.shiftKey)){let w=this.#j?5:10;if(this.#j){let x=y/V.width*100;x=Math.round(x/w)*w,y=x/100*V.width}else y=Math.round(y/w)*w}if(this.#j)this.#_=this.#S(Math.max(0,y/V.width*100));else this.#_=this.#S(Math.max(0,y));if(this.#K)this.#K.setAttribute("text",this.#o()),this.#QJ(T.clientX,T.clientY);this.#l(),this.#LJ()},L=this.#zJ((T)=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#X)this.#X.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=q,this.#K)this.#K.removeAttribute("show");if(T)this.#v(),this.#YJ()});window.addEventListener("pointermove",U,{signal:L.signal}),window.addEventListener("pointerup",()=>L.finish(!0),{signal:L.signal}),window.addEventListener("pointercancel",()=>L.finish(!1),{signal:L.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#bJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#zJ(J){this.#VJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#f===Q)this.#f=null,this.#w=null;J(j)};return this.#f=Q,this.#w=$,{signal:Q.signal,finish:$}}#VJ(){this.#w?.(!1),this.#f?.abort(),this.#f=null,this.#w=null}}P("fig-canvas-control",hJ);class F extends S{#$=[F.#R()];#Z=0;#J=2;#Q=240;#_=120;#j={min:-1,max:1};#B=null;#q=null;#M=null;#X=null;#O=0;#G=null;#Y=null;#k=null;#K=null;#P=[];#U=[];#N=[];#L=[];#T=new Set;#F=null;#W=null;#H=null;#z=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#R(J="sine"){return{type:J,frequency:1,amplitude:1,phase:0,offset:0}}static get observedAttributes(){return["value","precision","aspect-ratio","edit","disabled"]}connectedCallback(){if(this.#V===null)this.#V=this.getAttribute("default")??this.getAttribute("value")??JSON.stringify({waves:[F.#R()]});this.#J=this.#y("precision",2),this.#x(this.getAttribute("value")),this.#w(),this.#a(),this.#NJ(),W(this)}disconnectedCallback(){if(this.#FJ(),this.#MJ(),this.#F)this.#F.disconnect(),this.#F=null;R(this)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#x(Z),this.isConnected)this.#a();return}if(J==="precision"){if(this.#J=this.#y("precision",2),this.isConnected)this.#l();return}if(J==="aspect-ratio"){if(this.#w(),this.#q)this.#jJ();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#a()}}get value(){return JSON.stringify(this.data)}set value(J){this.setAttribute("value",typeof J==="object"&&J!==null?JSON.stringify(J):J)}get defaultValue(){return this.getAttribute("default")??this.#V??""}get isDefault(){let J=this.#I(this.defaultValue);if(!J)return!1;return JSON.stringify(this.data.waves)===JSON.stringify(J.map((Q)=>this.#A(Q)))}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,this.#v("input"),this.#v("change")}get data(){return{waves:this.#$.map((J)=>this.#A(J))}}get preset(){let J=this.#E;return F.TYPES.find((Q)=>Q.value===J.type)?.name}#y(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#h(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#D(){return this.getAttribute("edit")!=="false"}#f(){return this.#h("disabled",!1)}#w(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#x(J){let Q=this.#I(J);if(!Q)return!1;if(this.#$=Q,!this.#$.length)this.#$=[F.#R()];return this.#Z=Math.min(this.#Z,this.#$.length-1),!0}#I(J){if(!J)return null;let Q=null;if(typeof J==="string")try{Q=JSON.parse(J)}catch{return null}else if(typeof J==="object")Q=J;if(!Q)return null;return(Array.isArray(Q)?Q:Array.isArray(Q.waves)?Q.waves:[Q]).map(($)=>this.#C($))}#C(J={}){return{type:this.#c(J.type),frequency:this.#u(J.frequency,1,0.1,16),amplitude:this.#u(J.amplitude,1,-4,4),phase:this.#u(J.phase,0,-360,360),offset:this.#u(J.offset,0,-4,4)}}#A(J){return{type:J.type,frequency:this.#b(J.frequency),amplitude:this.#b(J.amplitude),phase:this.#b(J.phase),offset:this.#b(J.offset)}}get#E(){if(!this.#$[this.#Z])this.#Z=0;return this.#$[this.#Z]||F.#R()}#c(J){let Q=String(J||"").toLowerCase();return F.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#u(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#b(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#S(J){return F.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static#$J(J,Q=24){let j=Q-10,_="";for(let X=0;X<=32;X++){let q=X/32,B=F.#m(J,q),Y=5+q*j,M=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${Y.toFixed(1)},${M.toFixed(1)}`}return _}static#p(J,Q=24){return h("svg",{width:Q,height:Q,viewBox:`0 0 ${Q} ${Q}`,fill:"none"},h("path",{d:F.#$J(J,Q),stroke:"currentColor","stroke-width":"1","stroke-linecap":"round","stroke-linejoin":"round"}))}static waveIcon(J,Q=24){let Z=F.#$J(J,Q);return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${Z}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#m(J,Q,Z=0){let $=Q+Z/360,j=$-Math.floor($),_=$*Math.PI*2;switch(J){case"square":return Math.sin(_)>=0?1:-1;case"sawtooth":return j*2-1;case"triangle":return 1-Math.abs(j*4-2);default:return Math.sin(_)}}#a(){if(this.#FJ(),this.#MJ(),this.replaceChildren(...this.#s()),this.#d(),this.#BJ(),this.#jJ(),this.#WJ(),!this.#f())this.#_J();W(this)}#n(J,Q){return h("foreignObject",{className:`propskit-oscillator-handle propskit-oscillator-${J}-handle`,"data-handle":J,width:"20",height:"20"},G("div",{className:"propskit-oscillator-handle-inner"},G("fig-tooltip",{text:Q},G("fig-handle",{size:"small",type:"minimal","aria-label":`Oscillator ${J} handle`}))))}#s(){let J=this.#D()&&!this.#f(),Q=[h("rect",{className:"propskit-oscillator-bounds",x:"0",y:"0",width:this.#Q,height:this.#_}),h("line",{className:"propskit-oscillator-baseline"}),h("path",{className:"propskit-oscillator-path"}),h("circle",{className:"propskit-oscillator-playhead"})];if(J)Q.push(this.#n("amplitude","Amplitude"),this.#n("frequency","Frequency"));let Z=h("svg",{viewBox:`0 0 ${this.#Q} ${this.#_}`,className:"propskit-oscillator-svg"},Q),$=[G("div",{className:"propskit-oscillator-svg-container"},Z)];if(this.#D())$.push(G("div",{className:"propskit-oscillator-waves"},this.#$.map((j,_)=>this.#g(j,_,!J))));return $}#g(J,Q,Z){let $=Z||this.#$.length<=1,j=Q===this.#Z,_=F.#S(J.type),X=G("fig-tooltip",{text:"Remove form"},G("fig-button",{className:"propskit-oscillator-remove-button",variant:"ghost",icon:!0,"data-wave-index":Q,"aria-label":"Remove form",disabled:$},G("fig-icon",{name:"minus"}))),q=G("fig-header",{borderless:!0},[G("h3",{},_),X,this.#XJ(Z,Q)]),B=G("div",{className:"propskit-oscillator-fields","data-wave-index":Q,"data-active":j},[this.#o(Q,"frequency","Frequency",0.1,16,0.1,""),this.#o(Q,"amplitude","Amplitude",-4,4,0.1,""),this.#o(Q,"phase","Phase",-360,360,1,"°"),this.#o(Q,"offset","Offset",-4,4,0.1,"")]);return G("fig-group",{className:"propskit-oscillator-wave",collapsible:!0,borderless:!0,compact:"true",open:this.#T.has(Q)?"true":"false","data-wave-index":Q},[q,B])}#XJ(J,Q){let Z=G("fig-tooltip",{text:"Add form"},G("fig-button",{className:"propskit-oscillator-add-type-button",variant:"ghost",icon:!0,"fig-menu-trigger":!0,"aria-label":"Add form",disabled:J},G("fig-icon",{name:"plus"}))),$=F.TYPES.map((j)=>G("fig-menu-item",{value:j.value},[F.#p(j.value,24),G("span",{},j.name)]));return G("fig-menu",{className:"propskit-oscillator-add-type",position:"bottom right","data-wave-index":Q,disabled:J},[Z,$])}#o(J,Q,Z,$,j,_,X){let q=this.#$[J]||F.#R(),B=Q==="amplitude"||Q==="offset";return G("propskit-slider",{className:"propskit-oscillator-field",label:Z,name:Q,"data-wave-index":J,value:this.#b(q[Q]),min:$,max:j,step:_,precision:this.#J,elastic:"false",type:B?"delta":null,default:B?"0":null,units:X||null,disabled:this.#f()})}#d(){this.#q=this.querySelector(".propskit-oscillator-svg"),this.#M=this.querySelector(".propskit-oscillator-path"),this.#X=this.querySelector(".propskit-oscillator-playhead"),this.#G=this.querySelector(".propskit-oscillator-baseline"),this.#Y=this.querySelector(".propskit-oscillator-bounds"),this.#k=this.querySelector('[data-handle="amplitude"]'),this.#K=this.querySelector('[data-handle="frequency"]'),this.#U=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#P=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#L=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#N=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#JJ(J){let Q=new Set;for(let Z of this.#T)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#T=Q}#r(J){let Q=new Set;for(let Z of this.#T)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#T=Q}#NJ(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#BJ())this.#jJ()}),this.#F.observe(this)}#BJ(){if(!this.#q)return!1;let J=this.#q.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#Q||Z!==this.#_;return this.#Q=Q,this.#_=Z,this.#q.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#GJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#t(Z/Q)));return{min:-J,max:J}}#qJ(J){let{min:Q,max:Z}=this.#j;return this.#_-(J-Q)/(Z-Q)*this.#_}#PJ(J){let{min:Q,max:Z}=this.#j;return Q+(1-J/this.#_)*(Z-Q)}#t(J){return this.#$.reduce((Q,Z)=>{let $=J*Z.frequency,j=F.#m(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#jJ(){if(!this.#q||!this.#M)return;if(this.#BJ(),this.#j=this.#GJ(),this.#Y)this.#Y.setAttribute("width",this.#Q),this.#Y.setAttribute("height",this.#_);let J=Math.max(...this.#$.map((_)=>_.frequency)),Z=this.#$.some((_)=>_.type==="square"||_.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let _=0;_<=Z;_++){let X=_/Z,q=X*this.#Q,B=this.#qJ(this.#t(X));$+=`${_===0?"M":"L"}${q.toFixed(1)},${B.toFixed(1)}`}this.#M.setAttribute("d",$);let j=this.#qJ(0);this.#G?.setAttribute("x1","0"),this.#G?.setAttribute("y1",j),this.#G?.setAttribute("x2",this.#Q),this.#G?.setAttribute("y2",j),this.#kJ()}#_J(){if(this.#O||!this.#X)return;let J=(Q)=>{if(!this.isConnected||!this.#X){this.#O=0;return}this.#QJ(Q%1000/1000),this.#O=requestAnimationFrame(J)};this.#O=requestAnimationFrame(J)}#MJ(){if(!this.#O)return;cancelAnimationFrame(this.#O),this.#O=0}#QJ(J){if(!this.#X)return;let Q=J*this.#Q,Z=this.#qJ(this.#t(J));this.#X.setAttribute("cx",Q.toFixed(1)),this.#X.setAttribute("cy",Z.toFixed(1))}#kJ(){let Q=this.#E,Z=this.#ZJ(),$=Math.max(8,Math.min(this.#Q-8,this.#Q/Q.frequency)),j=this.#qJ(this.#t(Z/this.#Q)),_=this.#qJ(this.#t($/this.#Q));this.#OJ(this.#k,Z,j,8),this.#OJ(this.#K,$,_,8)}#ZJ(){let J=this.#E,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let j=($-Q)/Z;while(j<0)j+=1/Z;while(j>1)j-=1/Z;if(j<0||j>1||!Number.isFinite(j))j=0.25;return Math.max(8,Math.min(this.#Q-8,j*this.#Q))}#OJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#WJ(){if(!this.#D()||this.#f())return;for(let Q of this.#U)Q.addEventListener("change",(Z)=>{if(this.#f())return;let $=this.#i(Q);this.#e($),this.#$[$].type=this.#c(Z.detail??Z.target?.value),this.#l(),this.#v("input"),this.#v("change")});for(let Q of this.#P)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#W=Q;try{this.#SJ(this.#i(Q),Q.getAttribute("name"),Z.detail?.value??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#W=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#SJ(this.#i(Q),Q.getAttribute("name"),Z.detail?.value??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#L)Q.addEventListener("pointerdown",()=>{this.#e(this.#i(Q))}),Q.addEventListener("focusin",()=>{this.#e(this.#i(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#i(Q);if(Z.detail?.open)this.#T.add($);else this.#T.delete($)});for(let Q of this.querySelectorAll(".propskit-oscillator-add-type")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.addEventListener("change",($)=>{if($.target!==Q)return;if(this.#f())return;let _=this.#i(Q)+1,X=this.#c($.detail?.value??Q.value);this.#$.splice(_,0,F.#R(X)),this.#r(_),this.#Z=_,this.#a(),this.#v("input"),this.#v("change")})}for(let Q of this.querySelectorAll(".propskit-oscillator-add-type-button")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.closest("fig-tooltip")?.addEventListener("pointerdown",Z),Q.closest("fig-tooltip")?.addEventListener("click",Z)}for(let Q of this.querySelectorAll(".propskit-oscillator-remove-button"))Q.addEventListener("pointerdown",(Z)=>{Z.stopPropagation()}),Q.addEventListener("click",(Z)=>{if(Z.stopPropagation(),this.#f()||this.#$.length<=1)return;let $=this.#i(Q);this.#$.splice($,1),this.#JJ($),this.#Z=Math.min(this.#Z,this.#$.length-1),this.#a(),this.#v("input"),this.#v("change")});for(let Q of[this.#k,this.#K])this.#KJ(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#f())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#UJ(Q,"offset")})}#i(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#$.length-1,Math.max(0,Q)):0}#KJ(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#f())return;$.preventDefault(),$.stopImmediatePropagation(),this.#UJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#f())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#HJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#e(J){let Q=Math.min(this.#$.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#fJ(),this.#kJ()}#SJ(J,Q,Z,$){if(this.#f())return;this.#e(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#YJ();return}this.#$[J]=this.#C({...this.#$[J],[Q]:j}),this.#l({skipFieldSync:$=="input"}),this.#v($)}#HJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#E;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#$[this.#Z]=this.#C($),this.#l(),this.#v("input"),this.#v("change"),!0}#TJ(J){let Q=this.#q?.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*J.clientX+Z.c*J.clientY+Z.e,y:Z.b*J.clientX+Z.d*J.clientY+Z.f}}#UJ(J,Q){this.#FJ(),this.#B=Q,this.#q?.classList.add("dragging");let Z=Q==="frequency"?"ew-resize":Q==="amplitude"?"ns-resize":"",$=document.body.style.cursor;if(Z)document.body.style.cursor=Z;let j=(q)=>{if(!this.#B)return;let B=this.#TJ(q),Y=this.#E;if(Q==="frequency"){let M=Math.max(1,Math.min(this.#Q,B.x));Y.frequency=this.#Q/M}else if(Q==="offset"){let M=this.#u(B.x/this.#Q,0,0,1),k=this.#RJ(Y,M);Y.offset=this.#PJ(B.y)-this.#CJ(this.#Z,M)-k*Y.amplitude}else if(Q==="amplitude"){let M=this.#u(B.x/this.#Q,0,0,1),k=this.#RJ(Y,M),N=this.#PJ(B.y)-this.#CJ(this.#Z,M)-Y.offset;Y.amplitude=Math.abs(k)<0.001?Y.amplitude:N/k}this.#$[this.#Z]=this.#C(Y),this.#l(),this.#v("input")},_=new AbortController,X=(q=!1)=>{if(this.#B=null,this.#q?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#H===_)this.#H=null,this.#z=null;if(q)this.#v("change")};this.#H=_,this.#z=X,document.addEventListener("pointermove",j,{signal:_.signal}),document.addEventListener("pointerup",()=>X(!0),{signal:_.signal}),document.addEventListener("pointercancel",()=>X(!1),{signal:_.signal}),window.addEventListener("blur",()=>X(!1),{signal:_.signal})}#FJ(){this.#z?.(!1),this.#H?.abort(),this.#H=null,this.#z=null,this.#B=null,this.#q?.classList.remove("dragging")}#CJ(J,Q){return this.#$.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=F.#m($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#RJ(J,Q){return F.#m(J.type,Q*J.frequency,J.phase)}#l({skipFieldSync:J=!1}={}){if(this.#LJ(),!J)this.#YJ();this.#fJ(),this.#jJ()}#LJ(){for(let J of this.#U){let Q=this.#i(J);J.value=this.#$[Q]?.type||"sine"}}#YJ(){for(let J of this.#P){if(J===this.#W)continue;let Q=this.#i(J),Z=J.getAttribute("name"),$=this.#b(this.#$[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#fJ(){for(let J of this.#N)if(this.#i(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#v(J){K(this,J)}}P("propskit-oscillator",F);class wJ extends HTMLElement{#$;#Z;#J=null;#Q;#_;#j;#B;#q;#M;#X;#O=null;#G=null;constructor(){super();this.angle=0,this.#$=1,this.#Z=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#Q=this.#h.bind(this),this.#_=this.#c.bind(this),this.#j=this.#u.bind(this),this.#B=this.#$J.bind(this),this.#q=this.#p.bind(this),this.#M=this.#D.bind(this),this.#X=this.#S.bind(this)}connectedCallback(){requestAnimationFrame(()=>{if(!this.isConnected)return;this.precision=this.getAttribute("precision")||1,this.precision=parseInt(this.precision),this.text=this.getAttribute("text")==="true";let J=this.getAttribute("units")||"°";if(J==="deg")J="°";if(this.units=J,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):null,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):null,this.dial=this.#k("dial",!0),this.showRotations=this.#K(),this.#Y(),this.#R(),this.#E(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#b(),this.#y()}#Y(){this.#b(),this.#y();let J=this.#W(),Q=this.#U(),Z=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",$=this.min??this.#z(0),j=this.max??this.#z(360),_=[];if(this.dial)_.push(G("div",{className:"fig-input-angle-plane",role:"slider",tabindex:Q?"-1":"0","aria-label":Z,"aria-valuemin":$,"aria-valuemax":j,"aria-valuenow":this.angle,"aria-valuetext":`${this.angle.toFixed(this.precision)}${this.units}`,"aria-disabled":Q?"true":null},G("div",{className:"fig-input-angle-handle"})));if(this.text)_.push(G("fig-input-number",{name:"angle",step:J,value:this.angle,min:this.min,max:this.max,units:this.units,"aria-label":Z,disabled:Q},this.showRotations?G("span",{slot:"append",className:"fig-input-angle-rotations"}):null));this.replaceChildren(..._)}#k(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#K(){if(this.hasAttribute("rotations"))return this.#k("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#k("show-rotations",!1);return!1}#P(){let J=Math.abs(this.#H(this.angle));return Math.floor(J/360)}#U(){return O(this,"disabled")}#N(J){let Q=Number(J);if(!Number.isFinite(Q))return this.angle;if(this.min!==null&&Number.isFinite(this.min))Q=Math.max(this.min,Q);if(this.max!==null&&Number.isFinite(this.max))Q=Math.min(this.max,Q);return Q}#L(J,{reflect:Q=!0}={}){let Z=this.#N(J);if(this.angle=Z,this.#f(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#E(),this.angleInput)this.angleInput.value=Z.toFixed(this.precision);this.#T(),this.#F()}#T(){if(!this.plane)return;this.plane.setAttribute("aria-valuenow",String(this.angle)),this.plane.setAttribute("aria-valuetext",`${this.angle.toFixed(this.precision)}${this.units}`)}#F(){if(!this.rotationSpan)return;let J=this.#P();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#W(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#H(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#z(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#V(J,Q,Z){let $;switch(Q){case"rad":$=J*180/Math.PI;break;case"turn":$=J*360;break;default:$=J}switch(Z){case"rad":return $*Math.PI/180;case"turn":return $/360;default:return $}}#R(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#F(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#j),this.plane?.addEventListener("keydown",this.#X),window.addEventListener("keydown",this.#B),window.addEventListener("keyup",this.#q),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#M),this.angleInput.addEventListener("change",this.#M);this.addEventListener("change",this.#Q,!0)}#y(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#j),this.plane?.removeEventListener("keydown",this.#X),window.removeEventListener("keydown",this.#B),window.removeEventListener("keyup",this.#q),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#M),this.angleInput.removeEventListener("change",this.#M);this.removeEventListener("change",this.#Q,!0)}#h(J){if(!J.target?.matches?.("input"))return;let Z=J.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(Z){let $=parseFloat(Z[1]),j=Z[2].toLowerCase();if(j==="deg")j="°";if(j!==this.units){let _=this.#V($,j,this.units);J.target.value=String(_)}}}#D(J){if(J.stopPropagation(),this.#U())return;if(this.#L(Number(J.target.value)),J.type==="change")this.#A();else this.#C()}#f(){let Q=this.#H(this.angle)*Math.PI/180;this.#$=Math.cos(Q),this.#Z=Math.sin(Q)}#w(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#x(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,j=J.clientX-Z,_=J.clientY-$;return Math.atan2(_,j)*180/Math.PI}#I(J){let Z=(this.#x(J)%360+360)%360;if(Z=this.#w(Z),this.min!==null||this.max!==null)this.angle=this.#N(this.#z(Z));else if(this.#J===null){this.#J=Z;let _=(this.#H(this.angle)%360+360)%360,X=Z-_;if(X>180)X-=360;if(X<-180)X+=360;this.angle=this.#N(this.angle+this.#z(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#N(this.angle+this.#z(j)),this.#J=Z}if(this.#f(),this.setAttribute("value",String(this.angle)),this.#E(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#F(),this.#T(),this.#C()}#C(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#E(){if(this.handle){let Q=this.#H(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,j=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${j}px)`}}#c(J){if(this.#U()||J.button!==0)return;this.#b(),this.isDragging=!0,this.#J=null,this.#I(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#I(j)},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#O===Z)this.#O=null,this.#G=null;if(j)this.#A()};this.#O=Z,this.#G=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#u(J){if(this.#U())return;J.preventDefault(),this.#b(),this.isDragging=!0,this.#J=null,this.#I(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#I(j.touches[0])},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#O===Z)this.#O=null,this.#G=null;if(j)this.#A()};this.#O=Z,this.#G=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#b(){this.#G?.(!1),this.#O?.abort(),this.#O=null,this.#G=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#S(J){if(this.#U())return;let Q=this.#W()*(J.shiftKey?10:1),Z=this.angle;if(J.key==="ArrowLeft"||J.key==="ArrowDown")Z-=Q;else if(J.key==="ArrowRight"||J.key==="ArrowUp")Z+=Q;else if(J.key==="Home")Z=this.min??this.#z(0);else if(J.key==="End")Z=this.max??this.#z(360);else return;J.preventDefault(),J.stopPropagation(),this.#L(Z),this.#C(),this.#A()}#$J(J){if(J.key==="Shift")this.isShiftHeld=!0}#p(J){if(J.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations","disabled","aria-label","name"]}get value(){return this.angle}get adjacent(){return this.#$}get opposite(){return this.#Z}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}this.#L(Number(J))}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;if(Z!==null)this.#L(Number(Z),{reflect:!1});break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#Y(),this.#R(),this.#E()}break;case"dial":if(this.dial=this.#k("dial",!0),this.isConnected)this.#Y(),this.#R(),this.#E();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#Y(),this.#R(),this.#E();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#Y(),this.#R(),this.#E();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#Y(),this.#R(),this.#E();break;case"disabled":if(this.#b(),this.isConnected)this.#Y(),this.#R(),this.#E();break;case"aria-label":case"name":if(this.isConnected)this.#Y(),this.#R(),this.#E();break;case"rotations":case"show-rotations":if(this.showRotations=this.#K(),this.isConnected)this.#Y(),this.#R(),this.#E();break}}}P("fig-input-angle",wJ);class m extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#$=6;static#Z=['[draggable]:not([draggable="false"])','img:not([draggable="false"])','a[href]:not([draggable="false"])','input[type="range"]',"fig-handle","fig-slider","fig-input-number","fig-input-gradient","fig-easing-curve","fig-input-angle","fig-input-wheel","fig-joystick","fig-origin-grid","fig-chooser","fig-canvas-control","propskit-color-point","propskit-image","propskit-number","propskit-point-point","propskit-point-radius","propskit-point-radius-angle","propskit-position","propskit-editable-select","propskit-slider","propskit-oscillator"];#J=null;#Q=new Map;#_=null;#j=null;#B=null;connectedCallback(){if(this.style.display="contents",!this.hasAttribute("role"))this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Reorderable list");this.#T(),this.#G(),this.#J=new MutationObserver(()=>this.#G()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#A(),this.#E(),this.#w(),this.#B?.remove(),this.#B=null}attributeChangedCallback(){if(this.isConnected){if(this.#q)this.#E();this.#G()}}get#q(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#M(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#X(){return(this.getAttribute("handle")||"").trim()}#O(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#G(){let J=this.#O(),Q=new Set(J);for(let[Z,$]of this.#Q)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#L($),this.#Q.delete(Z);if(this.#K(J),this.#Y(J),this.#q||J.length<2){this.#A();return}for(let Z of J){let $=this.#U(Z),j=this.#Q.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#Q.delete(Z);if(!$)continue;this.#N(Z,$)}this.#P(J),this.#k(J)}#Y(J){for(let Q of J)if(Q.removeAttribute("data-reorder-item"),Q.hasAttribute("data-reorder-generated-role"))Q.removeAttribute("role"),Q.removeAttribute("data-reorder-generated-role")}#k(J){for(let Q of J)if(Q.setAttribute("data-reorder-item",""),!Q.hasAttribute("role"))Q.setAttribute("role","listitem"),Q.setAttribute("data-reorder-generated-role","")}#K(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>{Z.removeAttribute("data-reorder-handle"),Z.removeAttribute("aria-roledescription")})}#P(J){if(!this.#X)return;for(let Q of J){let Z=Q.querySelector(this.#X);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#U(J){if(this.#X)return J.querySelector(this.#X);return J}#N(J,Q){let Z=(B)=>{if(this.#q||this.#O().length<2)return;if(B.button!==0)return;if(!this.#X&&this.#W(B.target,J))return;this.#V(B,J,Q)},$=Q.getAttribute("tabindex"),j=Q.getAttribute("aria-label"),_=Q.getAttribute("role"),X=J.getAttribute("aria-label")||J.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";if(Q.setAttribute("tabindex","0"),Q.setAttribute("aria-label",`Move ${X}`),Q!==J&&!Q.hasAttribute("role"))Q.setAttribute("role","button");let q=(B)=>{if(this.#q)return;let Y=this.#M==="horizontal",M=Y?"ArrowLeft":"ArrowUp",k=Y?"ArrowRight":"ArrowDown";if(B.key!==M&&B.key!==k&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let N=this.#O(),U=N.indexOf(J),L=U;if(B.key===M)L=Math.max(0,U-1);else if(B.key===k)L=Math.min(N.length-1,U+1);else if(B.key==="Home")L=0;else if(B.key==="End")L=N.length-1;if(L===U){this.#F(`${X}, position ${U+1} of ${N.length}`);return}this.#I(J,L),this.#G(),this.#U(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:U,newIndex:L,item:J}})),this.#F(`${X}, position ${L+1} of ${N.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",q),this.#Q.set(J,{target:Q,onPointerDown:Z,onKeyDown:q,originalTabIndex:$,originalAriaLabel:j,originalRole:_})}#L(J){let{target:Q,originalTabIndex:Z,originalAriaLabel:$,originalRole:j}=J;if(Z===null)Q.removeAttribute("tabindex");else Q.setAttribute("tabindex",Z);if($===null)Q.removeAttribute("aria-label");else Q.setAttribute("aria-label",$);if(j===null)Q.removeAttribute("role");else Q.setAttribute("role",j)}#T(){if(this.#B?.isConnected)return;let J=document.createElement("span");J.setAttribute("data-reorder-live",""),J.setAttribute("role","status"),J.setAttribute("aria-live","polite"),J.setAttribute("aria-atomic","true"),Object.assign(J.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),this.#B=J,document.body.appendChild(J)}#F(J){if(!this.#B)return;this.#B.textContent="",requestAnimationFrame(()=>{if(this.#B)this.#B.textContent=J})}#W(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of m.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#H="fig-reorder-dragging";static#z(J){document.body.classList.toggle(m.#H,J)}#V(J,Q,Z){this.#E();let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#O().indexOf(Q),targetIndex:this.#O().indexOf(Q),startX:J.clientX,startY:J.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};$.onMove=(j)=>{if(j.pointerId!==$.pointerId)return;let _=j.clientX-$.startX,X=j.clientY-$.startY;if(!$.active){if(_*_+X*X<m.#$*m.#$)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging"),m.#z(!0);try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let q=this.#M==="horizontal"?j.clientX:j.clientY,B=this.#R(q);$.targetIndex=B,this.#f(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#C($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#C($,j.type==="pointercancel")},this.#_=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#R(J){let Q=this.#O(),Z=this.#M==="horizontal";for(let $=0;$<Q.length;$++){let j=Q[$].getBoundingClientRect(),_=Z?j.left+j.width/2:j.top+j.height/2;if(J<_)return $}return Q.length}#y(J,Q){let Z=this.#O(),$=Z.indexOf(J);if($===-1)return!1;let j=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(j>=Z.length&&$===Z.length-1)return!1;return!0}#h(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,j=-1/0;for(let _ of J){let X=_.getBoundingClientRect();Q=Math.min(Q,X.left),Z=Math.max(Z,X.right),$=Math.min($,X.top),j=Math.max(j,X.bottom)}return{left:Q,top:$,width:Z-Q,height:j-$}}#D(){if(this.#j)return this.#j;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#M),document.body.appendChild(J),this.#j=J,J}#f(J,Q){let Z=this.#O();if(!this.#y(Q,J)){this.#w();return}let $=this.#h(Z);if(!$){this.#w();return}let j=this.#D();if(j.setAttribute("data-axis",this.#M),this.#M==="horizontal"){let X;if(J<=0)X=Z[0].getBoundingClientRect().left;else if(J>=Z.length)X=Z[Z.length-1].getBoundingClientRect().right;else X=Z[J].getBoundingClientRect().left;j.style.left=`${X-1}px`,j.style.top=`${$.top}px`,j.style.width="2px",j.style.height=`${$.height}px`;return}let _;if(J<=0)_=Z[0].getBoundingClientRect().top;else if(J>=Z.length)_=Z[Z.length-1].getBoundingClientRect().bottom;else _=Z[J].getBoundingClientRect().top;j.style.left=`${$.left}px`,j.style.top=`${_-1}px`,j.style.width=`${$.width}px`,j.style.height="2px"}#w(){this.#j?.remove(),this.#j=null}#x(J,Q){let Z=this.#O(),$=Math.max(0,Math.min(Q,Z.length));if($>=Z.length){if(Z[Z.length-1]!==J)this.appendChild(J);return}let j=Z[$];if(j!==J)this.insertBefore(J,j)}#I(J,Q){let $=this.#O().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#C(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:q}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",q),j){if(!Q){this.#x(Z,J.targetIndex);let B=this.#O().indexOf(Z);if(B!==-1&&B!==$){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}));let Y=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#F(`${Y}, position ${B+1} of ${this.#O().length}`)}}}if(Z.classList.remove("dragging"),m.#z(!1),this.#w(),this.#_===J)this.#_=null}#A(){for(let[,J]of this.#Q)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#L(J);this.#Q.clear()}#E(){if(!this.#_)return;this.#C(this.#_,!0)}}P("fig-reorder",m);
1
+ function A(q,J){if(!customElements.get(q))customElements.define(q,J)}function U(q,J){return q.hasAttribute(J)&&q.getAttribute(J)!=="false"}var v="http://www.w3.org/2000/svg";function h(q,J){let Q=(Z)=>{if(Z===null||Z===void 0||Z===!1)return;if(Array.isArray(Z)){Z.forEach(Q);return}q.append(Z instanceof Node?Z:String(Z))};return Q(J),q}function p(q,J={}){for(let[Q,Z]of Object.entries(J)){if(Z===null||Z===void 0||Z===!1)continue;if(Q==="className")if(q.namespaceURI===v)q.setAttribute("class",String(Z));else q.className=String(Z);else if(Z===!0)q.setAttribute(Q,"");else q.setAttribute(Q,String(Z))}return q}function b(q,J,Q){let Z=document.createElement(q);return p(Z,J),h(Z,Q)}function m(q,J,Q){let Z=document.createElementNS(v,q);return p(Z,J),h(Z,Q)}function r(q,J,Q){let Z=Number(J),$=Number(Q),W=Number.isFinite(Z)?Math.max(0,Math.min(1,Z)):Number.isFinite($)?Math.max(0,Math.min(100,$))/100:1,j=Number.isFinite($)?Math.max(0,Math.min(100,$)):Math.round(W*100);return{color:q,alpha:W,opacity:j}}class u extends HTMLElement{}A("fig-ai-prompt",u);class g extends HTMLElement{}A("fig-ai-context",g);class c extends HTMLElement{}A("fig-chat-message",c);class s extends HTMLElement{#Z=null;#Q=null;#N=null;#_=null;#W=null;#B=null;#k=this.#z.bind(this);#$=this.#F.bind(this);#Y=this.#X.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#Q)this.#J();this.#W.removeEventListener("click",this.#k),this.#W.addEventListener("click",this.#k),this.#j(),this.#O()}disconnectedCallback(){this.#W?.removeEventListener("click",this.#k),this.#M()}attributeChangedCallback(q,J,Q){if(J===Q||!this.#Q)return;this.#O()}#J(){this.#Z=document.createElement("fig-tooltip"),this.#Z.className="fig-attachment-tooltip",this.#Q=document.createElement("fig-image"),this.#Q.setAttribute("aspect-ratio","1/1"),this.#Q.setAttribute("fit","cover"),this.#Q.setAttribute("full",""),this.#N=document.createElement("span"),this.#N.className="fig-attachment-fallback",this.#N.setAttribute("aria-hidden","true"),this.#_=document.createElement("fig-tooltip"),this.#_.className="fig-attachment-remove-tooltip",this.#_.setAttribute("text","Remove attachment"),this.#W=document.createElement("fig-button"),this.#W.className="fig-attachment-remove",this.#W.setAttribute("variant","overlay"),this.#W.setAttribute("size","small"),this.#W.setAttribute("icon","");let q=document.createElement("fig-icon");q.setAttribute("name","close"),q.setAttribute("size","small"),this.#W.append(q),this.#_.append(this.#W),this.#Q.append(this.#N),this.#Z.append(this.#Q),this.replaceChildren(this.#Z,this.#_),this.#W.addEventListener("click",this.#k),this.#j()}#j(){let q=this.#Q?.mediaEl;if(!q||q===this.#B)return;this.#M(),this.#B=q,this.#B.addEventListener("load",this.#$),this.#B.addEventListener("error",this.#Y)}#M(){if(!this.#B)return;this.#B.removeEventListener("load",this.#$),this.#B.removeEventListener("error",this.#Y),this.#B=null}#O(){let q=this.getAttribute("src")||"",J=this.getAttribute("name")||"Attachment",Q=!this.hasAttribute("removable")||U(this,"removable"),Z=U(this,"disabled");if(this.#Z.setAttribute("text",J),this.#Q.setAttribute("alt",J),q)this.#Q.setAttribute("src",q);else this.#Q.removeAttribute("src");if(this.#j(),this.#N.textContent=this.#G(J),this.#W.hidden=!Q,this.#W.toggleAttribute("disabled",Z),this.#W.setAttribute("aria-label",`Remove ${J}`),this.toggleAttribute("data-fallback",!q),Z)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#G(q){let J=q.split(/[\\/]/).pop()||"",Q=J.lastIndexOf(".");return(Q>0&&Q<J.length-1?J.slice(Q+1).toUpperCase():"FILE").slice(0,4)}#F(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#X(){this.setAttribute("data-fallback","")}#z(q){if(q.stopPropagation(),U(this,"disabled")||this.hasAttribute("removable")&&!U(this,"removable"))return;this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,cancelable:!0,composed:!0,detail:{value:this.getAttribute("value"),name:this.getAttribute("name")||"",src:this.getAttribute("src")||"",attachment:this}}))}}A("fig-attachment",s);class d extends HTMLElement{#Z=null;connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","list"),this.setAttribute("data-generated-role","");if(this.#Q(),!this.#Z)this.#Z=new MutationObserver(()=>this.#Q()),this.#Z.observe(this,{childList:!0})}disconnectedCallback(){this.#Z?.disconnect(),this.#Z=null}#Q(){for(let q of this.querySelectorAll(":scope > fig-attachment"))if(!q.hasAttribute("role"))q.setAttribute("role","listitem"),q.setAttribute("data-generated-role","")}}A("fig-attachments",d);class K extends HTMLElement{static#Z=33;static#Q=60;static#N=0.55;static#_=1.5;static#W=80;static#B=4;static#k="fig-input-wheel-dragging";#$=null;#Y=null;#J=null;#j=null;#M=null;#O=null;#G=null;#F=0;#X=0;#z=0;#S=0;#L=0;#R=null;#E=!1;#A=null;#H=0;#U=0;#C=!1;#K=null;#D=0;#h=null;#I=0;#y=0;#v=this.#Xq.bind(this);#P=this.#Lq.bind(this);#w=this.#kq.bind(this);#x=this.#Mq.bind(this);#f=this.#Uq.bind(this);static get observedAttributes(){return["value","disabled","step","min","max","spin"]}connectedCallback(){if(!this.#$)this.#V();if(this.#$q(),this.#Zq(),this.#Nq(),this.#R?.disconnect(),globalThis.ResizeObserver)this.#R=new ResizeObserver((q)=>{let J=q.at(-1)?.contentRect;if(J)this.#s(J.width,J.height)}),this.#R.observe(this);this.#p()}disconnectedCallback(){if(this.#R?.disconnect(),this.#z)cancelAnimationFrame(this.#z);this.#z=0,this.#e(),this.#Fq(),this.#t()}attributeChangedCallback(q,J,Q){if(J===Q||!this.#$)return;if(q==="disabled")this.#$q();if(q==="value"&&!this.#E)this.#Zq();if(q==="step")this.#i(),this.#p();if(q==="spin")this.#p();if(q==="min"||q==="max")this.#b(this.#q())}#V(){if(this.#$=this,this.#Y=this,this.#J=this,this.setAttribute("role","spinbutton"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Value");this.setAttribute("tabindex","0");let q=m("svg",{className:"fig-input-wheel-svg","aria-hidden":"true"}),J=b("div",{className:"fig-input-wheel-handle"});this.#j=q,this.replaceChildren(q,J);let Q=document.createElement("div");Q.setAttribute("aria-hidden","true"),Q.style.cssText="position:absolute;visibility:hidden;pointer-events:none;left:0;top:0";let Z=document.createElement("div");Z.style.height="var(--fig-input-wheel-tick-height)";let $=document.createElement("div");$.style.height="var(--fig-input-wheel-tick-height-min)";let W=document.createElement("div");W.style.width="var(--fig-input-wheel-tick-width)";let j=document.createElement("div");j.style.width="var(--fig-input-wheel-tick-width-min)",Q.append(Z,$,W,j),this.append(Q),this.#G={maxEl:Z,minEl:$,maxWidthEl:W,minWidthEl:j},this.#qq()}#qq(){if(!this.#j||this.#M)return;this.#M=m("path",{className:"fig-input-wheel-tick"}),this.#j.append(this.#M)}#r(){if(this.#O)return this.#O;return this.#O={maxH:this.#G?.maxEl.getBoundingClientRect().height||8,minH:this.#G?.minEl.getBoundingClientRect().height||4,maxW:this.#G?.maxWidthEl.getBoundingClientRect().width||2,minW:this.#G?.minWidthEl.getBoundingClientRect().width||1},this.#O}#T(){if(this.hasAttribute("step")){let q=Number(this.getAttribute("step"));if(q>0)return q}return 1}#q(){let q=Number(this.getAttribute("value")??0);return Number.isFinite(q)?q:0}#Jq(q){if(!this.hasAttribute(q))return null;let J=this.getAttribute(q);if(J===null||J.trim()==="")return null;let Q=Number(J);return Number.isFinite(Q)?Q:null}#m(){return this.#Jq("min")}#c(){return this.#Jq("max")}#Qq(q,J){if(J===null||J===void 0||J===""){this.removeAttribute(q);return}let Q=Number(J);if(!Number.isFinite(Q)){this.removeAttribute(q);return}this.setAttribute(q,String(Q))}#a(q){let J=q,Q=this.#m(),Z=this.#c();if(Q!==null)J=Math.max(Q,J);if(Z!==null)J=Math.min(Z,J);return J}#g(q){let J=this.#T();if(J<=0)return q;let Q=this.#m()??0,Z=Math.round((q-Q)/J)*J+Q;return Number(Z.toPrecision(15))}#b(q,{snap:J=!1,emit:Q=null}={}){let Z=J?this.#g(q):q;Z=this.#a(Z);let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.#i(Z),this.#p(),Q)this.dispatchEvent(new CustomEvent(Q,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#Zq(){let q=this.#q(),J=this.#a(q);if(J!==q||this.getAttribute("value")!==String(J)){this.#b(J);return}this.#i(q),this.#p()}#i(q=this.#q()){if(!this.#J)return;let J=this.#m(),Q=this.#c();if(this.#J.setAttribute("aria-valuenow",String(q)),this.#J.setAttribute("aria-valuetext",String(q)),J===null)this.#J.removeAttribute("aria-valuemin");else this.#J.setAttribute("aria-valuemin",String(J));if(Q===null)this.#J.removeAttribute("aria-valuemax");else this.#J.setAttribute("aria-valuemax",String(Q))}#$q(){let q=U(this,"disabled");if(!this.#J)return;if(q){if(this.#E)this.#t();this.#e(),this.setAttribute("aria-disabled","true"),this.#J.setAttribute("tabindex","-1"),this.#J.setAttribute("aria-disabled","true")}else this.removeAttribute("aria-disabled"),this.#J.setAttribute("tabindex","0"),this.#J.removeAttribute("aria-disabled")}#s(q,J){if(!this.#j||q<1||J<1)return;if(q===this.#F&&J===this.#X)return;this.#F=q,this.#X=J,this.#O=null,this.#j.setAttribute("viewBox",`0 0 ${q} ${J}`),this.#j.setAttribute("width",String(q)),this.#j.setAttribute("height",String(J)),this.#p()}#p(){if(this.#z)return;this.#z=requestAnimationFrame(()=>{if(!this.isConnected){this.#z=0;return}if(this.#F<1||this.#X<1){let q=this.#J?.getBoundingClientRect();if(q)this.#s(q.width,q.height)}this.#Bq(),this.#z=0})}#Bq(){if(!this.#M)return;let q=this.#F,J=this.#X;if(q<1||J<1)return;let Q=this.getAttribute("spin")==="false"?this.#m()??0:this.#K??this.#q(),Z=360/K.#Z,$=this.#T(),W=this.#m()??0,j=(Q-W)/$*Z,_=K.#N,N=q/2,Y=J/2,{maxH:X,minH:B,maxW:k,minW:z}=this.#r(),O=K.#Q,M=Math.max(q/2,1),F=M*0.84,E=[];for(let L=0;L<K.#Z;L+=1){let G=j+L*Z;if(G=((G+180)%360+360)%360-180,G<-O||G>=O)continue;let V=G*Math.PI/180,S=N+F*Math.sin(V)/(1-_*Math.cos(V)),f=Math.min(1,Math.abs(S-N)/Math.max(M,1)),I=Math.cos(f*Math.PI*0.5),T=B+(X-B)*I,D=z+(k-z)*I,H=T/2,P=D/2,R=Y-H,w=Y+H,y=S-P,x=S+P;E.push(`M ${S} ${R} Q ${x} ${R} ${x} ${R+P} V ${w-P} Q ${x} ${w} ${S} ${w} Q ${y} ${w} ${y} ${w-P} V ${R+P} Q ${y} ${R} ${S} ${R} Z`)}this.#M.setAttribute("d",E.join(" "))}#Nq(){this.#$?.addEventListener("pointerdown",this.#v),this.#J?.addEventListener("wheel",this.#x,{passive:!1}),this.#J?.addEventListener("keydown",this.#f)}#Fq(){this.#$?.removeEventListener("pointerdown",this.#v),this.#J?.removeEventListener("wheel",this.#x),this.#J?.removeEventListener("keydown",this.#f),window.removeEventListener("pointermove",this.#P),window.removeEventListener("pointerup",this.#w),window.removeEventListener("pointercancel",this.#w)}#Xq(q){if(U(this,"disabled"))return;if(q.button!==0)return;if(q.preventDefault(),!this.beginScrub(q))return;this.#$?.setPointerCapture?.(q.pointerId),window.addEventListener("pointermove",this.#P),window.addEventListener("pointerup",this.#w),window.addEventListener("pointercancel",this.#w)}beginScrub(q={}){if(U(this,"disabled"))return!1;let J=typeof q==="number"?q:Number(q?.clientX??q?.x);if(!Number.isFinite(J))return!1;this.#e(),this.#E=!0,this.#A=q&&typeof q==="object"&&q.pointerId!==void 0?q.pointerId:null,this.#H=J;let Q=q&&typeof q==="object"?Number(q.startValue):Number.NaN;return this.#U=Number.isFinite(Q)?this.#a(Q):this.#q(),this.#C=!1,this.#Vq(J),this.#Sq(),this.setAttribute("data-fig-input-wheel-active",""),document.body.classList.remove(K.#k),this.focus(),!0}updateScrub(q,J){if(!this.#E)return this.#q();let Q=typeof q==="number"?q:Number(q?.clientX??q?.x);if(!Number.isFinite(Q))return this.#q();let Z=J??(typeof q==="object"&&q?.shiftKey?10:1);return this.#_q(Q,Z),this.#q()}endScrub(q=!0){if(!this.#E)return this.#q();if(q&&this.#q()!==this.#U)this.#b(this.#q(),{snap:!0,emit:"change"});return this.#t(),this.#q()}#Lq(q){if(!this.#E)return;if(this.#A!==null&&q.pointerId!==this.#A)return;this.updateScrub(q)}#_q(q,J=1){if(!this.#C&&Math.abs(q-this.#H)>=K.#B)this.#C=!0,document.body.classList.add(K.#k);let Q=this.#J?.clientWidth||1,Z=K.#Z*(K.#Q*2/360),$=this.#T()*Z,W=(q-this.#H)*($/Q)*J,j=this.#K??this.#U,_=this.#a(this.#U+W);this.#fq(q,J,_!==j),this.#K=_,this.#b(_,{snap:!0,emit:"input"}),this.#Eq(q)}#kq(q){if(!this.#E)return;if(this.#A!==null&&q.pointerId!==this.#A)return;this.endScrub()}#t(){this.#E=!1,this.#A=null,this.#C=!1,this.#K=null,this.removeAttribute("data-fig-input-wheel-active"),document.body.classList.remove(K.#k),this.#Gq(),this.#zq(),window.removeEventListener("pointermove",this.#P),window.removeEventListener("pointerup",this.#w),window.removeEventListener("pointercancel",this.#w),this.#p()}#Sq(){this.#zq(),this.#D=this.#Wq("--fig-input-wheel-handle-drag-max")}#Wq(q){let J=getComputedStyle(this).getPropertyValue(q).trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:`var(${q})`}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#Eq(q){if(!this.#D){this.#Oq();return}let J=q-this.#H;if(!J){this.#Oq();return}let Q=this.#D*Math.tanh(J/Math.max(1,this.#D*3));this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${Q}px`)}#zq(){this.#Oq(),this.#D=0}#Oq(){this.style.removeProperty("--fig-input-wheel-handle-drag-offset")}#Vq(q){this.#Gq(),this.#h=q,this.#I=performance.now()}#fq(q,J,Q){let Z=performance.now(),$=Z-this.#I,W=this.#h===null?0:Math.abs(q-this.#h);this.#h=q,this.#I=Z;let j=$>0?W/$*Math.max(1,Math.abs(J)):0;if(!Q||j<K.#_){this.#n();return}this.toggleAttribute("data-fig-input-wheel-fast",!0),clearTimeout(this.#y),this.#y=window.setTimeout(()=>{this.#n()},K.#W)}#Gq(){this.#h=null,this.#I=0,this.#n()}#n(){clearTimeout(this.#y),this.#y=0,this.removeAttribute("data-fig-input-wheel-fast")}#Mq(q){if(U(this,"disabled"))return;q.preventDefault();let J=q.deltaY===0?Math.sign(q.deltaX):Math.sign(q.deltaY);if(!J)return;let Q=q.shiftKey?10:1;this.#b(this.#q()+this.#T()*Q*J,{snap:!0,emit:"input"}),this.#b(this.#q(),{emit:"change"})}#Uq(q){if(U(this,"disabled"))return;if(q.target instanceof Element&&q.target.closest("fig-input-number"))return;if(q.key==="Home"){let W=this.#m();if(W===null)return;q.preventDefault(),this.#b(W,{snap:!0,emit:"input"}),this.#b(this.#q(),{emit:"change"});return}if(q.key==="End"){let W=this.#c();if(W===null)return;q.preventDefault(),this.#b(W,{snap:!0,emit:"input"}),this.#b(this.#q(),{emit:"change"});return}if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(q.key))return;q.preventDefault();let Q=q.key==="ArrowRight"||q.key==="ArrowUp"?1:-1,Z=q.shiftKey?10:1,$=this.#q();this.#b($+this.#T()*Z*Q,{snap:!0,emit:"input"}),this.#jq($,this.#q(),Q,Z),this.#b(this.#q(),{emit:"change"})}#jq(q,J,Q,Z,$=!0){if(q===J||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches){this.#e();return}if(this.#S)cancelAnimationFrame(this.#S),this.#S=0;clearTimeout(this.#L),this.#L=0,this.removeAttribute("data-fig-input-wheel-keyboard-settling");let W=this.#K??q,j=Number.parseFloat(this.style.getPropertyValue("--fig-input-wheel-handle-drag-offset"))||0,_=Z>1?120:90,N=performance.now(),Y=$;this.setAttribute("data-fig-input-wheel-keyboard-moving","");let X=(B)=>{let k=Math.min(1,(B-N)/_);if(this.#K=W+(J-W)*k,Y){let z=Math.sin(k*Math.PI/2),O=j+(Q*4-j)*z;this.style.setProperty("--fig-input-wheel-handle-drag-offset",`${O}px`)}if(this.#Bq(),k<1){this.#S=requestAnimationFrame(X);return}this.#S=0,this.#K=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.setAttribute("data-fig-input-wheel-keyboard-settling",""),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.#L=window.setTimeout(()=>{this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.#L=0},140),this.#p()};this.#S=requestAnimationFrame(X)}#e(){if(this.#S)cancelAnimationFrame(this.#S),this.#S=0;if(clearTimeout(this.#L),this.#L=0,this.#K=null,this.removeAttribute("data-fig-input-wheel-keyboard-moving"),this.removeAttribute("data-fig-input-wheel-keyboard-settling"),this.style.removeProperty("--fig-input-wheel-handle-drag-offset"),this.isConnected)this.#p()}get value(){return this.getAttribute("value")??"0"}set value(q){if(q===null||q===void 0||q===""){this.#b(0);return}let J=Number(q);this.#b(Number.isFinite(J)?J:0)}spinTo(q,{animateHandle:J=!1}={}){let Q=this.#q();this.value=q;let Z=this.#q();if(this.getAttribute("spin")==="false")return this.#e(),Z;let $=Math.sign(Z-Q);return this.#jq(Q,Z,$,Math.abs(Z-Q)>this.#T()?10:1,J),Z}get min(){return this.#m()}set min(q){this.#Qq("min",q)}get max(){return this.#c()}set max(q){this.#Qq("max",q)}get step(){return this.#T()}focus(q){HTMLElement.prototype.focus.call(this,q)}}A("fig-input-wheel",K);class o extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping","precision"];#Z=50;#Q=50;#N=75;#_=75;#W=0;#B=!1;#k=0;#$=null;#Y=null;#J=null;#j=null;#M=null;#O=null;#G=null;#F=null;#X=null;#z=!1;#S=!1;#L=!1;#R=!1;#E=null;#A="";#H="";#U=null;#C=null;#K=null;#D="";#h="";#I=null;#y=null;#v=null;get#P(){return this.getAttribute("type")||"point"}get#w(){return this.#P==="point-radius"||this.#P==="point-radius-angle"}get#x(){return this.#P==="point-radius-angle"}get#f(){return this.#P==="point-point"}get#V(){return this.#P==="point-radius-angle"||this.#P==="point-point"}get#qq(){let q=this.getAttribute("tooltips");return q===null||q!=="false"}get#r(){let q=this.getAttribute("snapping");if(q===null)return"false";let J=q.trim().toLowerCase();if(J==="modifier")return"modifier";if(J===""||J==="true")return"true";return"false"}get#T(){let q=Number(this.getAttribute("precision")??2);if(!Number.isFinite(q))return 2;return Math.max(0,Math.min(8,Math.trunc(q)))}#q(q){let J=10**this.#T,Q=Math.round(q*J)/J;return Object.is(Q,-0)?0:Q}#Jq(){let q=this.getAttribute("precision");for(let J of[this.#$,this.#J,this.#Y]){if(!J)continue;if(q===null)J.removeAttribute("precision");else J.setAttribute("precision",String(this.#T))}}#m(q){let J=this.#r;if(J==="true")return!0;if(J==="modifier")return!!q;return!1}get#c(){let q=this.getAttribute("name");if(q)return q.split(",")[0].trim();return`${this.#q(this.#Z)}%, ${this.#q(this.#Q)}%`}get#Qq(){let q=this.getAttribute("name");if(q){let J=q.split(",");if(J.length>1)return J[1].trim()}return`${this.#q(this.#N)}%, ${this.#q(this.#_)}%`}get#a(){return this.getAttribute("drag-surface")||"parent"}get#g(){let q=this.#a;if(q==="parent")return this.parentElement;return this.closest(q)}get#b(){let q=this.#a;if(q==="parent"){let J=this.parentElement;if(J)return J.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return q}#Zq(q){if(this.#B)return this.#W/100*q;return this.#W}#i(){let q=this.#q(this.#W);if(this.#B)return`Radius ${q}%`;return`Radius ${q}`}connectedCallback(){this.#$q(),this.#s()}disconnectedCallback(){this.#Yq(),this.#bq(),this.#Nq(),this.#_q(),document.body.classList.remove("fig-lab-move-active"),document.body.classList.remove("fig-lab-rotate-active")}attributeChangedCallback(q,J,Q){if(J===Q)return;if(q==="value"&&!this.#z&&!this.#S&&!this.#L&&!this.#R)if(this.#$q(),this.#$)this.#u();else this.#s();if(q==="type")this.#Yq(),this.#$q(),this.#s();if(q==="color"&&this.#$)if(Q)this.#$.setAttribute("color",Q);else this.#$.removeAttribute("color");if(q==="disabled")this.#Yq(),this.#s();if(q==="tooltips")this.#s();if(q==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Q||"false"),this.#Y)this.#Y.setAttribute("drag-snapping",Q||"false")}if(q==="precision"){if(!this.isConnected)return;this.#Jq(),this.#Z=this.#q(this.#Z),this.#Q=this.#q(this.#Q),this.#N=this.#q(this.#N),this.#_=this.#q(this.#_),this.#W=this.#q(this.#W),this.#k=this.#q(this.#k),this.#u(),this.#l()}if(q==="name"){if(this.#O)this.#O.setAttribute("text",this.#c);if(this.#G)this.#G.setAttribute("text",this.#Qq)}}#$q(){let q=this.getAttribute("value");if(!q)return;try{let J=JSON.parse(q);if(typeof J.x==="number")this.#Z=this.#q(J.x);if(typeof J.y==="number")this.#Q=this.#q(J.y);if(J.radius!==void 0){let Q=String(J.radius);if(Q.endsWith("%"))this.#B=!0,this.#W=this.#q(parseFloat(Q));else this.#B=!1,this.#W=this.#q(parseFloat(Q));if(!Number.isFinite(this.#W))this.#W=0}if(typeof J.angle==="number")this.#k=this.#q(J.angle);if(typeof J.x2==="number")this.#N=this.#q(J.x2);if(typeof J.y2==="number")this.#_=this.#q(J.y2);if(this.#P==="color"&&typeof J.color==="string"&&J.color.trim()&&this.getAttribute("color")!==J.color.trim())this.setAttribute("color",J.color.trim())}catch{}}get value(){let q={x:this.#q(this.#Z),y:this.#q(this.#Q)};if(this.#P==="color"){let J=this.getAttribute("color")||this.#$?.getAttribute("color");if(J)q.color=J}if(this.#w){let J=this.#q(this.#W);q.radius=this.#B?`${J}%`:J}if(this.#x)q.angle=this.#q(this.#k);if(this.#f)q.x2=this.#q(this.#N),q.y2=this.#q(this.#_);return q}set value(q){if(typeof q==="object")this.setAttribute("value",JSON.stringify(q));else if(typeof q==="string")this.setAttribute("value",q)}#s(){this.#Yq(),this.replaceChildren(),this.#$=null,this.#Y=null,this.#J=null,this.#j=null,this.#M=null,this.#O=null,this.#G=null,this.#F=null,this.#X=null;let q=U(this,"disabled"),J=this.#P,Q=this.#qq,Z=this.#b,$=document.createElement("fig-handle");if($.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#r),$.setAttribute("value",`${this.#Z}% ${this.#Q}%`),this.hasAttribute("precision"))$.setAttribute("precision",String(this.#T));if(q)$.setAttribute("disabled","");if(J==="color"){$.setAttribute("type","color");let W=this.getAttribute("color");if(W)$.setAttribute("color",W)}else $.setAttribute("type","canvas");if(this.#f)$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate");if(this.#$=$,this.#w)this.#zq();if(this.#V)this.#Oq();if(Q){let W=document.createElement("fig-tooltip");W.setAttribute("action","manual"),W.setAttribute("theme","canvas"),W.setAttribute("pointer","false"),W.setAttribute("text",this.#c),W.appendChild($),this.appendChild(W),this.#O=W}else this.appendChild($);if(this.#x)this.#fq(q,Q,Z);if(this.#f)this.#Gq(q,Q,Z);this.#p(this.#$),this.#p(this.#J),this.#p(this.#Y),this.#Cq(),this.#Sq(),requestAnimationFrame(()=>this.#u())}#p(q){if(!q)return;q.addEventListener("pointerdown",(J)=>{if(J.target?.classList?.contains("fig-handle-hit-area")&&q.querySelector(".fig-handle-hit-area"))this.#Lq(J,q);else this.#Bq(J)},{capture:!0})}#Bq(q){if(U(this,"disabled"))return;if(q?.button!==void 0&&q.button!==0)return;if(q?.isPrimary===!1)return;if(this.#E===null)this.#A=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#E=q?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#U)this.#U=(J)=>{if(J?.pointerId!==void 0&&this.#E!==null&&J.pointerId!==this.#E)return;if(J?.type==="blur")this.#Nq();else requestAnimationFrame(()=>this.#Nq())};window.addEventListener("pointerup",this.#U),window.addEventListener("pointercancel",this.#U),window.addEventListener("blur",this.#U)}#Nq(){if(this.#E===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#A)document.body.style.setProperty("cursor",this.#A,this.#H);else document.body.style.removeProperty("cursor");if(this.#E=null,this.#A="",this.#H="",this.#U)window.removeEventListener("pointerup",this.#U),window.removeEventListener("pointercancel",this.#U),window.removeEventListener("blur",this.#U)}#Fq(q){if(!q)return 0;if(q===this.#J)return this.#k;if(!this.#f)return 0;let J=this.#Iq();return q===this.#$?J+180:J}#Xq(){if(this.#C===null)return;let q=this.#Mq(this.#Fq(this.#K));document.body.style.setProperty("--fig-lab-cursor-rotate",q),document.body.style.setProperty("cursor",q,"important")}#Lq(q,J){if(U(this,"disabled"))return;if(q?.button!==void 0&&q.button!==0)return;if(q?.isPrimary===!1)return;if(this.#C===null)this.#D=document.body.style.getPropertyValue("cursor"),this.#h=document.body.style.getPropertyPriority("cursor");if(this.#C=q?.pointerId??-1,this.#K=J,document.body.classList.add("fig-lab-rotate-active"),this.#Xq(),!this.#I)this.#I=(Q)=>{if(Q?.pointerId!==void 0&&this.#C!==null&&Q.pointerId!==this.#C)return;if(Q?.type==="blur")this.#_q();else requestAnimationFrame(()=>this.#_q())};window.addEventListener("pointerup",this.#I),window.addEventListener("pointercancel",this.#I),window.addEventListener("blur",this.#I)}#_q(){if(this.#C===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#D)document.body.style.setProperty("cursor",this.#D,this.#h);else document.body.style.removeProperty("cursor");if(this.#C=null,this.#K=null,this.#D="",this.#h="",this.#I)window.removeEventListener("pointerup",this.#I),window.removeEventListener("pointercancel",this.#I),window.removeEventListener("blur",this.#I)}#kq(q,J,Q,Z){if(!q)return;let $=()=>!!Z?.(),W=()=>{let N=J();if(!N)return;N.removeAttribute("show"),N.hidePopup?.()},j=()=>{if($()){W();return}let N=J();if(!N)return;if(Q)N.setAttribute("text",Q());N.setAttribute("show","true"),N.showPopup?.()},_=()=>{W()};q.addEventListener("pointerenter",j),q.addEventListener("pointerleave",_)}#t(){return this.#z||this.#S||this.#L||this.#R}#Sq(){if(this.#$)this.#kq(this.#$,()=>this.#O,()=>this.#c,()=>this.#t()||!!this.#$?.querySelector("fig-color-tip"));if(this.#J)this.#kq(this.#J,()=>this.#X,()=>`Angle ${this.#q(this.#k)}°`,()=>this.#t());if(this.#Y)this.#kq(this.#Y,()=>this.#G,()=>this.#Qq,()=>this.#t());if(this.#j){let q=this.#j.querySelector(".fig-canvas-control-radius-hit");this.#Eq(q||this.#j)}if(this.#P==="color"&&this.#$&&this.#O)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#O?.removeAttribute("show"),this.#O?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#Wq(q,J){let Q=this.#F;if(!Q?.popup)return;let Z=J-8;Q.popup.anchor={getBoundingClientRect:()=>({left:q,top:Z,right:q,bottom:Z,width:0,height:0,x:q,y:Z})},Q.popup.queueReposition?.()}#Eq(q){if(!q)return;q.addEventListener("pointerenter",(J)=>{let Q=this.#F;if(!Q)return;Q.setAttribute("text",this.#i()),Q.setAttribute("show","true"),Q.showPopup?.(),this.#Wq(J.clientX,J.clientY)}),q.addEventListener("pointermove",(J)=>{if(this.#L)return;this.#Wq(J.clientX,J.clientY)}),q.addEventListener("pointerleave",()=>{if(this.#L)return;let J=this.#F;if(!J)return;J.removeAttribute("show")})}#zq(){let J=document.createElementNS("http://www.w3.org/2000/svg","svg");J.classList.add("fig-canvas-control-radius"),J.setAttribute("overflow","visible");let Q=document.createElementNS("http://www.w3.org/2000/svg","circle");Q.classList.add("fig-canvas-control-radius-hit"),J.appendChild(Q);let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-halo"),J.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");if(J.appendChild($),this.#j=J,this.#qq){let W=document.createElement("fig-tooltip");W.setAttribute("action","manual"),W.setAttribute("theme","canvas"),W.setAttribute("pointer","false"),W.setAttribute("text",this.#i()),W.appendChild(J),this.appendChild(W),this.#F=W}else this.appendChild(J);this.#wq(Q)}#Oq(){let J=document.createElementNS("http://www.w3.org/2000/svg","svg");if(J.classList.add("fig-canvas-control-angle-svg"),J.setAttribute("overflow","visible"),J.style.position="absolute",J.style.pointerEvents="none",this.#f){let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line-hit"),$.setAttribute("stroke","transparent"),$.setAttribute("stroke-width","12"),$.setAttribute("stroke-linecap","round"),$.style.pointerEvents="stroke",J.appendChild($),this.#Vq($)}let Q=document.createElementNS("http://www.w3.org/2000/svg","line");Q.classList.add("fig-canvas-control-angle-line-halo"),J.appendChild(Q);let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line"),J.appendChild(Z),this.#M=J,this.appendChild(J)}#Vq(q){q.addEventListener("pointerdown",(J)=>{if(U(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=this.#g;if(!Q)return;let{clientX:Z,clientY:$}=J,W=this.#Z,j=this.#Q,_=this.#N,N=this.#_;this.#z=!0,this.#S=!0,document.body.classList.add("fig-lab-move-active"),q.style.pointerEvents="none";let Y=(B)=>{let k=Q.getBoundingClientRect(),z=k.width>0?(B.clientX-Z)/k.width*100:0,O=k.height>0?(B.clientY-$)/k.height*100:0,M=-Math.min(W,_),F=100-Math.max(W,_),E=-Math.min(j,N),L=100-Math.max(j,N),G=Math.max(M,Math.min(F,z)),V=Math.max(E,Math.min(L,O));this.#Z=this.#q(W+G),this.#Q=this.#q(j+V),this.#N=this.#q(_+G),this.#_=this.#q(N+V),this.#u(),this.#d()},X=this.#Kq((B)=>{if(document.body.classList.remove("fig-lab-move-active"),q.style.pointerEvents="stroke",this.#z=!1,this.#S=!1,B)this.#l(),this.#o()});window.addEventListener("pointermove",Y,{signal:X.signal}),window.addEventListener("pointerup",()=>X.finish(!0),{signal:X.signal}),window.addEventListener("pointercancel",()=>X.finish(!1),{signal:X.signal})})}#fq(q,J,Q){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",Q),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("size","small"),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(q)Z.setAttribute("disabled","");if(this.#J=Z,J){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",`${this.#q(this.#k)}°`),$.appendChild(Z),this.appendChild($),this.#X=$}else this.appendChild(Z)}#Gq(q,J,Q){let Z=document.createElement("fig-handle");if(Z.setAttribute("type","canvas"),Z.setAttribute("drag","true"),Z.setAttribute("drag-surface",Q),Z.setAttribute("drag-axes","x,y"),Z.setAttribute("drag-snapping",this.#r),Z.setAttribute("hit-area","12 circle"),Z.setAttribute("hit-area-mode","delegate"),Z.setAttribute("value",`${this.#N}% ${this.#_}%`),this.hasAttribute("precision"))Z.setAttribute("precision",String(this.#T));if(q)Z.setAttribute("disabled","");if(this.#Y=Z,J){let $=document.createElement("fig-tooltip");$.setAttribute("action","manual"),$.setAttribute("theme","canvas"),$.setAttribute("pointer","false"),$.setAttribute("text",this.#Qq),$.appendChild(Z),this.appendChild($),this.#G=$}else this.appendChild(Z)}#n(q){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(q)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.1212 16.9998L11.5607 17.4394C12.1465 18.0252 12.1464 18.975 11.5606 19.5607C10.9748 20.1465 10.0251 20.1465 9.4393 19.5606L6.4393 16.5604C5.85354 15.9746 5.85357 15.0249 6.43938 14.4391L9.43938 11.4393C10.0252 10.8535 10.9749 10.8536 11.5607 11.4394C12.1465 12.0252 12.1464 12.9749 11.5606 13.5607L11.1215 13.9998L20.8786 13.9999L20.4394 13.5607C19.8536 12.9749 19.8535 12.0252 20.4393 11.4394C21.0251 10.8536 21.9749 10.8536 22.5606 11.4394L25.5606 14.4393C25.842 14.7206 26 15.1021 26 15.4999C26 15.8978 25.842 16.2793 25.5607 16.5606L22.5607 19.5607C21.9749 20.1465 21.0251 20.1465 20.4393 19.5607C19.8536 18.9749 19.8535 18.0252 20.4393 17.4394L20.8788 16.9999L11.1212 16.9998Z' fill='white'/%3E%3C/g%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.8536 12.1465C11.0488 12.3417 11.0488 12.6583 10.8535 12.8536L8.70715 14.9998L23.2929 14.9999L21.1465 12.8536C20.9512 12.6583 20.9512 12.3417 21.1464 12.1465C21.3417 11.9512 21.6583 11.9512 21.8535 12.1465L24.8535 15.1464C24.9473 15.2402 25 15.3673 25 15.4999C25 15.6326 24.9473 15.7597 24.8536 15.8535L21.8536 18.8536C21.6583 19.0488 21.3417 19.0488 21.1465 18.8536C20.9512 18.6583 20.9512 18.3417 21.1464 18.1465L23.2929 15.9999L8.70705 15.9998L10.8536 18.1465C11.0488 18.3417 11.0488 18.6583 10.8535 18.8536C10.6583 19.0488 10.3417 19.0488 10.1464 18.8535L7.14643 15.8533C6.95118 15.658 6.95119 15.3415 7.14646 15.1462L10.1465 12.1464C10.3417 11.9512 10.6583 11.9512 10.8536 12.1465Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='3' y='9' width='26' height='15' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, nwse-resize`}#Mq(q){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(q-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#Uq(q,J){if(!q)return;q.style.setProperty("cursor",J,"important")}#jq(q,J){if(!q)return;let Q=q.querySelector(".fig-handle-hit-area");if(!Q)return;if(Q.setAttribute("data-cursor","rotate"),this.#Uq(Q,this.#Mq(J)),this.#K===q)this.#Xq()}#e(){if(!this.#J||!this.#x)return;this.#jq(this.#J,this.#k)}#Iq(){return Math.atan2(this.#_-this.#Q,this.#N-this.#Z)*180/Math.PI}#Aq(){if(!this.#f)return;let q=this.#Iq();this.#$?.style.removeProperty("cursor"),this.#Y?.style.removeProperty("cursor"),this.#jq(this.#$,q+180),this.#jq(this.#Y,q)}#Tq(q,J,Q,Z){q.style.setProperty("--fig-handle-position-translate","-50% -50%"),q.style.left=`${J/100*Z.width}px`,q.style.top=`${Q/100*Z.height}px`}#u(){let q=this.#g;if(!q||!this.#$)return;let J=q.getBoundingClientRect();if(this.#Tq(this.#$,this.#Z,this.#Q,J),this.#j){let Q=this.#Z/100*J.width,Z=this.#Q/100*J.height,$=this.#Zq(J.width),W=this.#j,j=Math.max($*2,1);W.style.position="absolute",W.style.width=`${j}px`,W.style.height=`${j}px`,W.style.left=`${Q-$}px`,W.style.top=`${Z-$}px`,W.setAttribute("viewBox",`0 0 ${j} ${j}`);let _=W.querySelectorAll("circle");for(let N of _)N.setAttribute("cx",String($)),N.setAttribute("cy",String($)),N.setAttribute("r",String(Math.max($-1,0)))}if(this.#M&&this.#V){let Q=this.#Z/100*J.width,Z=this.#Q/100*J.height,$,W;if(this.#f)$=this.#N/100*J.width,W=this.#_/100*J.height;else{let N=this.#Zq(J.width),Y=this.#k*Math.PI/180;$=Q+N*Math.cos(Y),W=Z+N*Math.sin(Y)}let j=this.#M;j.style.width=`${J.width}px`,j.style.height=`${J.height}px`,j.style.left="0",j.style.top="0",j.setAttribute("viewBox",`0 0 ${J.width} ${J.height}`);let _=j.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let N of _)N.setAttribute("x1",String(Q)),N.setAttribute("y1",String(Z)),N.setAttribute("x2",String($)),N.setAttribute("y2",String(W))}if(this.#J&&this.#x){let Q=this.#Z/100*J.width,Z=this.#Q/100*J.height,$=this.#Zq(J.width),W=this.#k*Math.PI/180,j=Q+$*Math.cos(W),_=Z+$*Math.sin(W),N=J.width>0?j/J.width*100:0,Y=J.height>0?_/J.height*100:0;this.#Tq(this.#J,N,Y,J)}if(this.#Y&&this.#f)this.#Tq(this.#Y,this.#N,this.#_,J);this.#e(),this.#Aq()}#d(q=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:q}))}#o(q=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:q}))}#Pq(q){return{...this.value,...r(q.color,q.alpha,q.opacity)}}#l(){this.setAttribute("value",JSON.stringify(this.value))}#Cq(){if(!this.#$)return;if(this.#$.addEventListener("input",(q)=>{if(q.stopPropagation(),q.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||q.detail.color),this.#d(this.#Pq(q.detail));return}this.#z=!0;let J=q.detail?.px??this.#Z/100,Q=q.detail?.py??this.#Q/100;if(this.#Z=this.#q(Math.max(0,Math.min(100,J*100))),this.#Q=this.#q(Math.max(0,Math.min(100,Q*100))),this.#O)this.#O.removeAttribute("show"),this.#O.hidePopup?.();this.#u(),this.#d()}),this.#$.addEventListener("change",(q)=>{if(q.stopPropagation(),q.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||q.detail.color),this.#o(this.#Pq(q.detail));return}let J=q.detail?.px??this.#Z/100,Q=q.detail?.py??this.#Q/100;if(this.#Z=this.#q(Math.max(0,Math.min(100,J*100))),this.#Q=this.#q(Math.max(0,Math.min(100,Q*100))),this.#O)this.#O.removeAttribute("show");this.#u(),this.#l(),this.#o(),requestAnimationFrame(()=>{this.#z=!1})}),this.#J)this.#J.addEventListener("input",(q)=>{q.stopPropagation();let J=this.#g;if(!J)return;this.#R=!0,this.classList.add("fig-canvas-control-ring-active");let Q=J.getBoundingClientRect(),Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,W=q.detail?.x??0,j=q.detail?.y??0,_=this.#J.offsetWidth/2,N=this.#J.offsetHeight/2,Y=W+_-Z,X=j+N-$,B=Math.atan2(X,Y)*180/Math.PI;if(this.#m(q.detail?.shiftKey))B=Math.round(B/15)*15;this.#k=this.#q(B);let k=Math.sqrt(Y*Y+X*X);if(this.#m(q.detail?.shiftKey)){let z=this.#B?5:10;if(this.#B){let O=k/Q.width*100;O=Math.round(O/z)*z,k=O/100*Q.width}else k=Math.round(k/z)*z}if(this.#B)this.#W=this.#q(Math.max(0,k/Q.width*100));else this.#W=this.#q(Math.max(0,k));if(this.#X)this.#X.setAttribute("text",`Angle ${this.#q(this.#k)}°`),this.#X.setAttribute("show","true"),this.#X.showPopup?.();this.#u(),this.#d()}),this.#J.addEventListener("change",(q)=>{if(q.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#X)this.#X.removeAttribute("show");this.#u(),this.#l(),this.#o(),requestAnimationFrame(()=>{this.#R=!1})}),this.#J.addEventListener("hitareadown",(q)=>{q.stopPropagation();let J=q.detail?.originalEvent;if(!J)return;J.preventDefault();let Q=this.#g;if(!Q)return;if(this.#R=!0,this.classList.add("fig-canvas-control-ring-active"),this.#J.setAttribute("selected",""),this.#X)this.#X.setAttribute("show","true"),this.#X.showPopup?.();let Z=(W)=>{let j=Q.getBoundingClientRect(),_=this.#Z/100*j.width,N=this.#Q/100*j.height,Y=W.clientX-j.left-_,X=W.clientY-j.top-N,B=Math.atan2(X,Y)*180/Math.PI;if(this.#m(W.shiftKey))B=Math.round(B/15)*15;if(this.#k=this.#q(B),this.#X)this.#X.setAttribute("text",`Angle ${this.#q(B)}°`);this.#u(),this.#d()},$=this.#Kq((W)=>{if(this.#R=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#J.removeAttribute("selected"),this.#X)this.#X.removeAttribute("show");if(W)this.#l(),this.#o()});window.addEventListener("pointermove",Z,{signal:$.signal}),window.addEventListener("pointerup",()=>$.finish(!0),{signal:$.signal}),window.addEventListener("pointercancel",()=>$.finish(!1),{signal:$.signal})});if(this.#Y)this.#Y.addEventListener("input",(q)=>{q.stopPropagation(),this.#S=!0;let J=q.detail?.px??this.#N/100,Q=q.detail?.py??this.#_/100;if(this.#N=this.#q(Math.max(0,Math.min(100,J*100))),this.#_=this.#q(Math.max(0,Math.min(100,Q*100))),this.#G)this.#G.removeAttribute("show"),this.#G.hidePopup?.();this.#u(),this.#d()}),this.#Y.addEventListener("change",(q)=>{if(q.stopPropagation(),this.#G)this.#G.removeAttribute("show");this.#u(),this.#l(),this.#o(),requestAnimationFrame(()=>{this.#S=!1})}),this.#Rq(this.#$,!0),this.#Rq(this.#Y,!1)}#Rq(q,J){if(!q)return;q.addEventListener("hitareadown",(Q)=>{Q.stopPropagation();let Z=Q.detail?.originalEvent;if(!Z)return;Z.preventDefault();let $=this.#g;if(!$)return;this.#z=!0;let W=$.getBoundingClientRect(),j=J?this.#N:this.#Z,_=J?this.#_:this.#Q,N=J?this.#Z:this.#N,Y=J?this.#Q:this.#_,X=j/100*W.width,B=_/100*W.height,k=N/100*W.width,z=Y/100*W.height,O=Math.sqrt((k-X)**2+(z-B)**2),M=J?this.#O:this.#G;if(M)M.removeAttribute("show"),M.hidePopup?.();let F=(L)=>{let G=$.getBoundingClientRect(),V=j/100*G.width,S=_/100*G.height,f=L.clientX-G.left-V,I=L.clientY-G.top-S,T=Math.atan2(I,f);if(this.#m(L.shiftKey))T=Math.round(T*180/Math.PI/15)*15*Math.PI/180;let D=V+O*Math.cos(T),H=S+O*Math.sin(T),P=Math.max(0,Math.min(100,D/G.width*100)),R=Math.max(0,Math.min(100,H/G.height*100));if(J)this.#Z=this.#q(P),this.#Q=this.#q(R);else this.#N=this.#q(P),this.#_=this.#q(R);this.#u(),this.#d()},E=this.#Kq((L)=>{if(this.#z=!1,M)M.removeAttribute("show");if(L)this.#l(),this.#o()});window.addEventListener("pointermove",F,{signal:E.signal}),window.addEventListener("pointerup",()=>E.finish(!0),{signal:E.signal}),window.addEventListener("pointercancel",()=>E.finish(!1),{signal:E.signal})})}#wq(q){if(!q)return;q.addEventListener("pointermove",(Q)=>{if(this.#L)return;let Z=this.#g;if(!Z)return;let $=Z.getBoundingClientRect(),W=this.#Z/100*$.width,j=this.#Q/100*$.height,_=Math.atan2(Q.clientY-$.top-j,Q.clientX-$.left-W)*180/Math.PI;this.#Uq(q,this.#n(_))});let J=(Q)=>{if(U(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation(),this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=this.#g;if(!Z)return;if(this.#F)this.#F.setAttribute("show","true"),this.#F.showPopup?.(),this.#Wq(Q.clientX,Q.clientY);if(this.#X)this.#X.removeAttribute("show"),this.#X.hidePopup?.();let $=this.#J?.style.pointerEvents,W=this.#J?.querySelector(".fig-handle-hit-area"),j=W?.style.pointerEvents;if(this.#J)this.#J.style.pointerEvents="none";if(W)W.style.pointerEvents="none";let _=document.body.style.cursor;q.style.pointerEvents="none";let N=Z.getBoundingClientRect(),Y=this.#Z/100*N.width,X=this.#Q/100*N.height,B=Math.atan2(Q.clientY-N.top-X,Q.clientX-N.left-Y)*180/Math.PI,k=Math.round(B);document.body.style.cursor=this.#n(k);let z=(M)=>{let F=Z.getBoundingClientRect(),E=this.#Z/100*F.width,L=this.#Q/100*F.height,G=M.clientX-F.left-E,V=M.clientY-F.top-L,S=Math.round(Math.atan2(V,G)*180/Math.PI);if(S!==k)k=S,document.body.style.cursor=this.#n(S);let f=Math.sqrt(G*G+V*V);if(this.#m(M.shiftKey)){let I=this.#B?5:10;if(this.#B){let T=f/F.width*100;T=Math.round(T/I)*I,f=T/100*F.width}else f=Math.round(f/I)*I}if(this.#B)this.#W=this.#q(Math.max(0,f/F.width*100));else this.#W=this.#q(Math.max(0,f));if(this.#F)this.#F.setAttribute("text",this.#i()),this.#Wq(M.clientX,M.clientY);this.#u(),this.#d()},O=this.#Kq((M)=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),q.style.pointerEvents="",this.#J)this.#J.style.pointerEvents=$??"";if(W)W.style.pointerEvents=j??"";if(document.body.style.cursor=_,this.#F)this.#F.removeAttribute("show");if(M)this.#l(),this.#o()});window.addEventListener("pointermove",z,{signal:O.signal}),window.addEventListener("pointerup",()=>O.finish(!0),{signal:O.signal}),window.addEventListener("pointercancel",()=>O.finish(!1),{signal:O.signal})};q.addEventListener("pointerdown",J),this._radiusDragCleanup=()=>q.removeEventListener("pointerdown",J)}#bq(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#Kq(q){this.#Yq();let J=new AbortController,Q=!1,Z=($=!1)=>{if(Q)return;if(Q=!0,J.abort(),this.#y===J)this.#y=null,this.#v=null;q($)};return this.#y=J,this.#v=Z,{signal:J.signal,finish:Z}}#Yq(){this.#v?.(!1),this.#y?.abort(),this.#y=null,this.#v=null}}A("fig-canvas-control",o);class l extends HTMLElement{#Z;#Q;#N=null;#_;#W;#B;#k;#$;#Y;#J;#j=null;#M=null;constructor(){super();this.angle=0,this.#Z=1,this.#Q=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#_=this.#h.bind(this),this.#W=this.#qq.bind(this),this.#B=this.#r.bind(this),this.#k=this.#Jq.bind(this),this.#$=this.#m.bind(this),this.#Y=this.#I.bind(this),this.#J=this.#q.bind(this)}connectedCallback(){requestAnimationFrame(()=>{if(!this.isConnected)return;this.precision=this.getAttribute("precision")||1,this.precision=parseInt(this.precision),this.text=this.getAttribute("text")==="true";let q=this.getAttribute("units")||"°";if(q==="deg")q="°";if(this.units=q,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):null,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):null,this.dial=this.#G("dial",!0),this.showRotations=this.#F(),this.#O(),this.#K(),this.#V(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#T(),this.#D()}#O(){this.#T(),this.#D();let q=this.#A(),J=this.#z(),Q=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",Z=this.min??this.#U(0),$=this.max??this.#U(360),W=[];if(this.dial)W.push(b("div",{className:"fig-input-angle-plane",role:"slider",tabindex:J?"-1":"0","aria-label":Q,"aria-valuemin":Z,"aria-valuemax":$,"aria-valuenow":this.angle,"aria-valuetext":`${this.angle.toFixed(this.precision)}${this.units}`,"aria-disabled":J?"true":null},b("div",{className:"fig-input-angle-handle"})));if(this.text)W.push(b("fig-input-number",{name:"angle",step:q,value:this.angle,min:this.min,max:this.max,units:this.units,"aria-label":Q,disabled:J},this.showRotations?b("span",{slot:"append",className:"fig-input-angle-rotations"}):null));this.replaceChildren(...W)}#G(q,J=!1){let Q=this.getAttribute(q);if(Q===null)return J;let Z=Q.trim().toLowerCase();if(Z===""||Z==="true")return!0;if(Z==="false")return!1;return!0}#F(){if(this.hasAttribute("rotations"))return this.#G("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#G("show-rotations",!1);return!1}#X(){let q=Math.abs(this.#H(this.angle));return Math.floor(q/360)}#z(){return U(this,"disabled")}#S(q){let J=Number(q);if(!Number.isFinite(J))return this.angle;if(this.min!==null&&Number.isFinite(this.min))J=Math.max(this.min,J);if(this.max!==null&&Number.isFinite(this.max))J=Math.min(this.max,J);return J}#L(q,{reflect:J=!0}={}){let Q=this.#S(q);if(this.angle=Q,this.#y(),J){let Z=String(Q);if(this.getAttribute("value")!==Z)this.setAttribute("value",Z)}if(this.#V(),this.angleInput)this.angleInput.value=Q.toFixed(this.precision);this.#R(),this.#E()}#R(){if(!this.plane)return;this.plane.setAttribute("aria-valuenow",String(this.angle)),this.plane.setAttribute("aria-valuetext",`${this.angle.toFixed(this.precision)}${this.units}`)}#E(){if(!this.rotationSpan)return;let q=this.#X();if(q>1)this.rotationSpan.textContent=`×${q}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#A(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#H(q){switch(this.units){case"rad":return q*180/Math.PI;case"turn":return q*360;default:return q}}#U(q){switch(this.units){case"rad":return q*Math.PI/180;case"turn":return q/360;default:return q}}#C(q,J,Q){let Z;switch(J){case"rad":Z=q*180/Math.PI;break;case"turn":Z=q*360;break;default:Z=q}switch(Q){case"rad":return Z*Math.PI/180;case"turn":return Z/360;default:return Z}}#K(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#E(),this.plane?.addEventListener("mousedown",this.#W),this.plane?.addEventListener("touchstart",this.#B),this.plane?.addEventListener("keydown",this.#J),window.addEventListener("keydown",this.#k),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#Y),this.angleInput.addEventListener("change",this.#Y);this.addEventListener("change",this.#_,!0)}#D(){if(this.plane?.removeEventListener("mousedown",this.#W),this.plane?.removeEventListener("touchstart",this.#B),this.plane?.removeEventListener("keydown",this.#J),window.removeEventListener("keydown",this.#k),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#Y),this.angleInput.removeEventListener("change",this.#Y);this.removeEventListener("change",this.#_,!0)}#h(q){if(!q.target?.matches?.("input"))return;let Q=q.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(Q){let Z=parseFloat(Q[1]),$=Q[2].toLowerCase();if($==="deg")$="°";if($!==this.units){let W=this.#C(Z,$,this.units);q.target.value=String(W)}}}#I(q){if(q.stopPropagation(),this.#z())return;if(this.#L(Number(q.target.value)),q.type==="change")this.#f();else this.#x()}#y(){let J=this.#H(this.angle)*Math.PI/180;this.#Z=Math.cos(J),this.#Q=Math.sin(J)}#v(q){if(!this.isShiftHeld)return q;let J=45;return Math.round(q/J)*J}#P(q){let J=this.plane.getBoundingClientRect(),Q=J.left+J.width/2,Z=J.top+J.height/2,$=q.clientX-Q,W=q.clientY-Z;return Math.atan2(W,$)*180/Math.PI}#w(q){let Q=(this.#P(q)%360+360)%360;if(Q=this.#v(Q),this.min!==null||this.max!==null)this.angle=this.#S(this.#U(Q));else if(this.#N===null){this.#N=Q;let W=(this.#H(this.angle)%360+360)%360,j=Q-W;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#S(this.angle+this.#U(j))}else{let $=Q-this.#N;if($>180)$-=360;if($<-180)$+=360;this.angle=this.#S(this.angle+this.#U($)),this.#N=Q}if(this.#y(),this.setAttribute("value",String(this.angle)),this.#V(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#E(),this.#R(),this.#x()}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#V(){if(this.handle){let J=this.#H(this.angle)*Math.PI/180,Q=this.plane.offsetWidth/2-this.handle.offsetWidth/2,Z=Math.cos(J)*Q,$=Math.sin(J)*Q;this.handle.style.transform=`translate(${Z}px, ${$}px)`}}#qq(q){if(this.#z()||q.button!==0)return;this.#T(),this.isDragging=!0,this.#N=null,this.#w(q);let J=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#w($)},Q=new AbortController,Z=($=!1)=>{if(this.isDragging=!1,this.#N=null,this.plane.classList.remove("dragging"),Q.abort(),this.#j===Q)this.#j=null,this.#M=null;if($)this.#f()};this.#j=Q,this.#M=Z,window.addEventListener("mousemove",J,{signal:Q.signal}),window.addEventListener("mouseup",()=>Z(!0),{signal:Q.signal}),window.addEventListener("blur",()=>Z(!1),{signal:Q.signal})}#r(q){if(this.#z())return;q.preventDefault(),this.#T(),this.isDragging=!0,this.#N=null,this.#w(q.touches[0]);let J=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#w($.touches[0])},Q=new AbortController,Z=($=!1)=>{if(this.isDragging=!1,this.#N=null,this.plane.classList.remove("dragging"),Q.abort(),this.#j===Q)this.#j=null,this.#M=null;if($)this.#f()};this.#j=Q,this.#M=Z,window.addEventListener("touchmove",J,{signal:Q.signal}),window.addEventListener("touchend",()=>Z(!0),{signal:Q.signal}),window.addEventListener("touchcancel",()=>Z(!1),{signal:Q.signal})}#T(){this.#M?.(!1),this.#j?.abort(),this.#j=null,this.#M=null,this.isDragging=!1,this.#N=null,this.plane?.classList.remove("dragging")}#q(q){if(this.#z())return;let J=this.#A()*(q.shiftKey?10:1),Q=this.angle;if(q.key==="ArrowLeft"||q.key==="ArrowDown")Q-=J;else if(q.key==="ArrowRight"||q.key==="ArrowUp")Q+=J;else if(q.key==="Home")Q=this.min??this.#U(0);else if(q.key==="End")Q=this.max??this.#U(360);else return;q.preventDefault(),q.stopPropagation(),this.#L(Q),this.#x(),this.#f()}#Jq(q){if(q.key==="Shift")this.isShiftHeld=!0}#m(q){if(q.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations","disabled","aria-label","name"]}get value(){return this.angle}get adjacent(){return this.#Z}get opposite(){return this.#Q}set value(q){if(isNaN(q)){console.error("Invalid value: must be a number.");return}this.#L(Number(q))}attributeChangedCallback(q,J,Q){switch(q){case"value":if(this.isDragging)break;if(Q!==null)this.#L(Number(Q),{reflect:!1});break;case"precision":this.precision=parseInt(Q);break;case"text":if(Q!==J){if(this.text=Q?.toLowerCase()==="true",this.isConnected)this.#O(),this.#K(),this.#V()}break;case"dial":if(this.dial=this.#G("dial",!0),this.isConnected)this.#O(),this.#K(),this.#V();break;case"units":{let Z=Q||"°";if(Z==="deg")Z="°";if(this.units=Z,this.isConnected)this.#O(),this.#K(),this.#V();break}case"min":if(this.min=Q!==null?Number(Q):null,this.#L(this.angle),this.isConnected)this.#O(),this.#K(),this.#V();break;case"max":if(this.max=Q!==null?Number(Q):null,this.#L(this.angle),this.isConnected)this.#O(),this.#K(),this.#V();break;case"disabled":if(this.#T(),this.isConnected)this.#O(),this.#K(),this.#V();break;case"aria-label":case"name":if(this.isConnected)this.#O(),this.#K(),this.#V();break;case"rotations":case"show-rotations":if(this.showRotations=this.#F(),this.isConnected)this.#O(),this.#K(),this.#V();break}}}A("fig-input-angle",l);class C extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Z=6;static#Q=['[draggable]:not([draggable="false"])','img:not([draggable="false"])','a[href]:not([draggable="false"])','input[type="range"]',"fig-handle","fig-slider","fig-input-number","fig-input-gradient","fig-easing-curve","fig-input-angle","fig-input-wheel","fig-joystick","fig-origin-grid","fig-chooser","fig-canvas-control"];#N=null;#_=new Map;#W=null;#B=null;#k=null;connectedCallback(){if(this.style.display="contents",!this.hasAttribute("role"))this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Reorderable list");this.#R(),this.#M(),this.#N=new MutationObserver(()=>this.#M()),this.#N.observe(this,{childList:!0})}disconnectedCallback(){this.#N?.disconnect(),this.#N=null,this.#f(),this.#V(),this.#v(),this.#k?.remove(),this.#k=null}attributeChangedCallback(){if(this.isConnected){if(this.#$)this.#V();this.#M()}}get#$(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#Y(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#J(){return(this.getAttribute("handle")||"").trim()}#j(){return[...this.children].filter((q)=>q.nodeType===Node.ELEMENT_NODE&&!q.hasAttribute("data-reorder-live"))}#M(){let q=this.#j(),J=new Set(q);for(let[Q,Z]of this.#_)if(!J.has(Q))Z.target.removeEventListener("pointerdown",Z.onPointerDown,!0),Z.target.removeEventListener("keydown",Z.onKeyDown),this.#L(Z),this.#_.delete(Q);if(this.#F(q),this.#O(q),this.#$||q.length<2){this.#f();return}for(let Q of q){let Z=this.#z(Q),$=this.#_.get(Q);if($&&$.target===Z)continue;if($)$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#_.delete(Q);if(!Z)continue;this.#S(Q,Z)}this.#X(q),this.#G(q)}#O(q){for(let J of q)if(J.removeAttribute("data-reorder-item"),J.hasAttribute("data-reorder-generated-role"))J.removeAttribute("role"),J.removeAttribute("data-reorder-generated-role")}#G(q){for(let J of q)if(J.setAttribute("data-reorder-item",""),!J.hasAttribute("role"))J.setAttribute("role","listitem"),J.setAttribute("data-reorder-generated-role","")}#F(q){for(let J of q)J.querySelectorAll("[data-reorder-handle]").forEach((Q)=>{Q.removeAttribute("data-reorder-handle"),Q.removeAttribute("aria-roledescription")})}#X(q){if(!this.#J)return;for(let J of q){let Q=J.querySelector(this.#J);if(Q)Q.setAttribute("data-reorder-handle",""),Q.setAttribute("aria-roledescription","reorder handle")}}#z(q){if(this.#J)return q.querySelector(this.#J);return q}#S(q,J){let Q=(N)=>{if(this.#$||this.#j().length<2)return;if(N.button!==0)return;if(!this.#J&&this.#A(N.target,q))return;this.#C(N,q,J)},Z=J.getAttribute("tabindex"),$=J.getAttribute("aria-label"),W=J.getAttribute("role"),j=q.getAttribute("aria-label")||q.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";if(J.setAttribute("tabindex","0"),J.setAttribute("aria-label",`Move ${j}`),J!==q&&!J.hasAttribute("role"))J.setAttribute("role","button");let _=(N)=>{if(this.#$)return;let Y=this.#Y==="horizontal",X=Y?"ArrowLeft":"ArrowUp",B=Y?"ArrowRight":"ArrowDown";if(N.key!==X&&N.key!==B&&N.key!=="Home"&&N.key!=="End")return;N.preventDefault(),N.stopPropagation();let k=this.#j(),z=k.indexOf(q),O=z;if(N.key===X)O=Math.max(0,z-1);else if(N.key===B)O=Math.min(k.length-1,z+1);else if(N.key==="Home")O=0;else if(N.key==="End")O=k.length-1;if(O===z){this.#E(`${j}, position ${z+1} of ${k.length}`);return}this.#w(q,O),this.#M(),this.#z(q)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:z,newIndex:O,item:q}})),this.#E(`${j}, position ${O+1} of ${k.length}`)};J.addEventListener("pointerdown",Q,!0),J.addEventListener("keydown",_),this.#_.set(q,{target:J,onPointerDown:Q,onKeyDown:_,originalTabIndex:Z,originalAriaLabel:$,originalRole:W})}#L(q){let{target:J,originalTabIndex:Q,originalAriaLabel:Z,originalRole:$}=q;if(Q===null)J.removeAttribute("tabindex");else J.setAttribute("tabindex",Q);if(Z===null)J.removeAttribute("aria-label");else J.setAttribute("aria-label",Z);if($===null)J.removeAttribute("role");else J.setAttribute("role",$)}#R(){if(this.#k?.isConnected)return;let q=document.createElement("span");q.setAttribute("data-reorder-live",""),q.setAttribute("role","status"),q.setAttribute("aria-live","polite"),q.setAttribute("aria-atomic","true"),Object.assign(q.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),this.#k=q,document.body.appendChild(q)}#E(q){if(!this.#k)return;this.#k.textContent="",requestAnimationFrame(()=>{if(this.#k)this.#k.textContent=q})}#A(q,J){let Q=q;while(Q&&Q!==J){if(Q instanceof Element){for(let Z of C.#Q)if(Q.matches(Z))return!0}Q=Q.parentElement}return!1}static#H="fig-reorder-dragging";static#U(q){document.body.classList.toggle(C.#H,q)}#C(q,J,Q){this.#V();let Z={item:J,target:Q,pointerId:q.pointerId,oldIndex:this.#j().indexOf(J),targetIndex:this.#j().indexOf(J),startX:q.clientX,startY:q.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};Z.onMove=($)=>{if($.pointerId!==Z.pointerId)return;let W=$.clientX-Z.startX,j=$.clientY-Z.startY;if(!Z.active){if(W*W+j*j<C.#Z*C.#Z)return;Z.active=!0,q.preventDefault(),q.stopPropagation(),J.classList.add("dragging"),C.#U(!0);try{Q.setPointerCapture(Z.pointerId)}catch{}}$.preventDefault();let _=this.#Y==="horizontal"?$.clientX:$.clientY,N=this.#K(_);Z.targetIndex=N,this.#y(N,J)},Z.onKeyDown=($)=>{if($.key!=="Escape"||!Z.active)return;$.preventDefault(),this.#x(Z,!0)},Z.onUp=($)=>{if($.pointerId!==Z.pointerId)return;this.#x(Z,$.type==="pointercancel")},this.#W=Z,window.addEventListener("pointermove",Z.onMove),window.addEventListener("pointerup",Z.onUp),window.addEventListener("pointercancel",Z.onUp),window.addEventListener("keydown",Z.onKeyDown)}#K(q){let J=this.#j(),Q=this.#Y==="horizontal";for(let Z=0;Z<J.length;Z++){let $=J[Z].getBoundingClientRect(),W=Q?$.left+$.width/2:$.top+$.height/2;if(q<W)return Z}return J.length}#D(q,J){let Q=this.#j(),Z=Q.indexOf(q);if(Z===-1)return!1;let $=Math.max(0,Math.min(J,Q.length));if(J===Z)return!1;if($>=Q.length&&Z===Q.length-1)return!1;return!0}#h(q){if(!q.length)return null;let J=1/0,Q=-1/0,Z=1/0,$=-1/0;for(let W of q){let j=W.getBoundingClientRect();J=Math.min(J,j.left),Q=Math.max(Q,j.right),Z=Math.min(Z,j.top),$=Math.max($,j.bottom)}return{left:J,top:Z,width:Q-J,height:$-Z}}#I(){if(this.#B)return this.#B;let q=document.createElement("div");return q.className="fig-reorder-indicator",q.setAttribute("data-axis",this.#Y),document.body.appendChild(q),this.#B=q,q}#y(q,J){let Q=this.#j();if(!this.#D(J,q)){this.#v();return}let Z=this.#h(Q);if(!Z){this.#v();return}let $=this.#I();if($.setAttribute("data-axis",this.#Y),this.#Y==="horizontal"){let j;if(q<=0)j=Q[0].getBoundingClientRect().left;else if(q>=Q.length)j=Q[Q.length-1].getBoundingClientRect().right;else j=Q[q].getBoundingClientRect().left;$.style.left=`${j-1}px`,$.style.top=`${Z.top}px`,$.style.width="2px",$.style.height=`${Z.height}px`;return}let W;if(q<=0)W=Q[0].getBoundingClientRect().top;else if(q>=Q.length)W=Q[Q.length-1].getBoundingClientRect().bottom;else W=Q[q].getBoundingClientRect().top;$.style.left=`${Z.left}px`,$.style.top=`${W-1}px`,$.style.width=`${Z.width}px`,$.style.height="2px"}#v(){this.#B?.remove(),this.#B=null}#P(q,J){let Q=this.#j(),Z=Math.max(0,Math.min(J,Q.length));if(Z>=Q.length){if(Q[Q.length-1]!==q)this.appendChild(q);return}let $=Q[Z];if($!==q)this.insertBefore(q,$)}#w(q,J){let Z=this.#j().filter(($)=>$!==q)[J]??null;if(Z)this.insertBefore(q,Z);else this.appendChild(q)}#x(q,J){let{item:Q,oldIndex:Z,active:$,onMove:W,onUp:j,onKeyDown:_}=q;if(window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("keydown",_),$){if(!J){this.#P(Q,q.targetIndex);let N=this.#j().indexOf(Q);if(N!==-1&&N!==Z){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:Z,newIndex:N,item:Q}}));let Y=Q.getAttribute("aria-label")||Q.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#E(`${Y}, position ${N+1} of ${this.#j().length}`)}}}if(Q.classList.remove("dragging"),C.#U(!1),this.#v(),this.#W===q)this.#W=null}#f(){for(let[,q]of this.#_)q.target.removeEventListener("pointerdown",q.onPointerDown,!0),q.target.removeEventListener("keydown",q.onKeyDown),this.#L(q);this.#_.clear()}#V(){if(!this.#W)return;this.#x(this.#W,!0)}}A("fig-reorder",C);