@rogieking/figui3 8.0.2 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -0
- package/dist/fig-editor.css +1 -1
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +14 -14
- package/dist/fig.js +1 -1
- package/fig-editor.css +0 -1
- package/fig-lab.css +115 -17
- package/fig-lab.js +1475 -1
- package/fig.js +3 -12
- package/package.json +1 -1
package/dist/fig-lab.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function K(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function e(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 x=new WeakMap;function C(J){let Q=x.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 q=Q?.point;if(q)Z.showAt?.(q.x,q.y)};Q={menu:Z,point:null,clearPendingOpen:_,handleContextMenu:(q)=>{if(U(J,"disabled")||q.target?.closest?.("fig-menu"))return;q.preventDefault(),q.stopPropagation(),q.stopImmediatePropagation?.(),Q.point={x:q.clientX,y:q.clientY},_(),window.addEventListener("pointerup",X,{once:!0,capture:!0}),window.addEventListener("pointercancel",X,{once:!0,capture:!0}),j=window.setTimeout(X,180)},handleChange:(q)=>{if(q.stopPropagation(),q.detail?.value==="reset-default")J.resetToDefault?.()}},x.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 f(J){let Q=x.get(J);if(!Q)return;Q.clearPendingOpen(),J.removeEventListener("contextmenu",Q.handleContextMenu),Q.menu.removeEventListener("change",Q.handleChange)}function y(J,Q){for(let Z of["input","change"])J.dispatchEvent(new CustomEvent(Z,{detail:Q,bubbles:!0,cancelable:!0,composed:!0}))}function I(J,Q){if(typeof J==="boolean"||typeof Q==="boolean")return Boolean(J)===Boolean(Q);return String(J??"")===String(Q??"")}function JJ(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 I(J,Q)}}function QJ(J,Q){if(!J||!Q)return null;let Z=document.createElement("span");Z.style.cssText="position:absolute;visibility:hidden;pointer-events:none;color:"+Q,J.appendChild(Z);let $=getComputedStyle(Z).color;if(Z.remove(),!$.startsWith("rgb"))return null;let j=$.match(/[\d.]+/g)?.slice(0,3).map(Number);if(!j||j.length<3||j.some(Number.isNaN))return null;let[_,X,O]=j.map((q)=>{let Y=q/255;return Y<=0.04045?Y/12.92:((Y+0.055)/1.055)**2.4});return 0.2126*_+0.7152*X+0.0722*O<=0.179?"light":"dark"}var g=0;function ZJ(J="fig-lab"){return g+=1,`${J}-${g}`}class c extends HTMLElement{}K("fig-ai-prompt",c);class m extends HTMLElement{}K("fig-chat-message",m);class u extends HTMLElement{#Z=null;#Q=null;#J=null;#_=null;#j=null;#O=null;#X=this.#M.bind(this);#$=this.#U.bind(this);#B=this.#P.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#Q)this.#q();this.#j.removeEventListener("click",this.#X),this.#j.addEventListener("click",this.#X),this.#Y(),this.#G()}disconnectedCallback(){this.#j?.removeEventListener("click",this.#X),this.#k()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;this.#G()}#q(){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.#J=document.createElement("span"),this.#J.className="fig-attachment-fallback",this.#J.setAttribute("aria-hidden","true"),this.#_=document.createElement("fig-tooltip"),this.#_.className="fig-attachment-remove-tooltip",this.#_.setAttribute("text","Remove attachment"),this.#j=document.createElement("fig-button"),this.#j.className="fig-attachment-remove",this.#j.setAttribute("variant","overlay"),this.#j.setAttribute("size","small"),this.#j.setAttribute("icon","");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("size","small"),this.#j.append(J),this.#_.append(this.#j),this.#Q.append(this.#J),this.#Z.append(this.#Q),this.replaceChildren(this.#Z,this.#_),this.#j.addEventListener("click",this.#X),this.#Y()}#Y(){let J=this.#Q?.mediaEl;if(!J||J===this.#O)return;this.#k(),this.#O=J,this.#O.addEventListener("load",this.#$),this.#O.addEventListener("error",this.#B)}#k(){if(!this.#O)return;this.#O.removeEventListener("load",this.#$),this.#O.removeEventListener("error",this.#B),this.#O=null}#G(){let J=this.getAttribute("src")||"",Q=this.getAttribute("name")||"Attachment",Z=!this.hasAttribute("removable")||U(this,"removable"),$=U(this,"disabled");if(this.#Z.setAttribute("text",Q),this.#Q.setAttribute("alt",Q),J)this.#Q.setAttribute("src",J);else this.#Q.removeAttribute("src");if(this.#Y(),this.#J.textContent=this.#N(Q),this.#j.hidden=!Z,this.#j.toggleAttribute("disabled",$),this.#j.setAttribute("aria-label",`Remove ${Q}`),this.toggleAttribute("data-fallback",!J),$)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#N(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)}#U(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#P(){this.setAttribute("data-fallback","")}#M(J){if(J.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}}))}}K("fig-attachment",u);class v 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 J of this.querySelectorAll(":scope > fig-attachment"))if(!J.hasAttribute("role"))J.setAttribute("role","listitem"),J.setAttribute("data-generated-role","")}}K("fig-attachments",v);class s extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=null;#$=null;#B=this.#K.bind(this);#q=!1;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),C(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==="direction")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#P(),this.removeEventListener("click",this.#B),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#Y(){this.#q=U(this,"checked");let Q=Array.from(this.childNodes).filter((O)=>O.nodeType!==Node.TEXT_NODE||Boolean(O.textContent?.trim())).find((O)=>O.nodeType===Node.ELEMENT_NODE&&O.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-segmented-control"),_=document.createElement("fig-segment"),X=document.createElement("fig-segment");j.setAttribute("sizing","equal"),_.setAttribute("value","off"),_.textContent="Off",X.setAttribute("value","on"),X.textContent="On",j.append(_,X),Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#G(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","checked","value","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",U(this,"checked")?"on":"off"),this.#O=Q}#U(){if(!this.#J)return;this.#X??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value==="on";this.toggleAttribute("checked",Z);let $={checked:Z,value:this.getAttribute("value")??""};this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){if(J.target instanceof Element&&J.target.closest("fig-segmented-control, fig-menu"))return;let Q=this.#J?.value==="on"?"off":"on";this.#J?.querySelector(`fig-segment[value="${Q}"]`)?.click()}get checked(){return this.#J?this.#J.value==="on":U(this,"checked")}set checked(J){let Q=Boolean(J);if(this.toggleAttribute("checked",Q),this.#J)this.#J.value=Q?"on":"off"}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){this.setAttribute("value",J??"")}get defaultValue(){return this.hasAttribute("default")?U(this,"default"):this.#q}get isDefault(){return this.checked===this.defaultValue}resetToDefault(){let J=this.defaultValue;this.checked=J,y(this,{checked:J,value:this.getAttribute("value")??""})}focus(J){(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}K("propskit-switch",s);class o extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=null;#$=null;#B=this.#S.bind(this);#q=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#k(),this.#N(),this.#U(),this.#q===null)this.#q=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),C(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==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#P(),this.removeEventListener("click",this.#B),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#Y(){let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-color");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#O)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,$)}this.#J.setAttribute("text","true"),this.#O=Q}#U(){if(!this.#J)return;this.#X??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(typeof Q==="string"&&Q)return Q;if(Q&&typeof Q==="object"){if(typeof Q.value==="string"&&Q.value)return Q.value;if(typeof Q.hex==="string"&&Q.hex)return Q.hex;if(typeof Q.color==="string"&&Q.color)return Q.color}if(typeof this.#J?.value==="string"&&this.#J.value)return this.#J.value;return this.#J?.getAttribute("value")??""}#K(J,Q){Q.stopImmediatePropagation();let Z=this.#M(Q);if(this.setAttribute("value",Z),this.#J&&this.#J.getAttribute("value")!==Z)this.#J.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#S(J){if(J.target instanceof Element&&J.target.closest("fig-input-color, fig-menu"))return;this.focus()}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);if(this.setAttribute("value",Q),this.#J&&this.#J.getAttribute("value")!==Q)this.#J.setAttribute("value",Q)}#z(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#L(){return this.getAttribute("default")??this.#q??""}get defaultValue(){return String(this.#L())}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#z(J),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}K("propskit-color",o);class r extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=null;#$=null;#B=this.#S.bind(this);#q=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#k(),this.#N(),this.#U(),this.#q===null)this.#q=this.getAttribute("default")??this.getAttribute("value")??JSON.stringify(this.#J?.value??{});if(this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),C(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==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#P(),this.removeEventListener("click",this.#B),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#Y(){let Q=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())).find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-gradient");Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Gradient")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#O)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","true");this.#O=Q}#U(){if(!this.#J)return;this.#X??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(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)}#K(J,Q){Q.stopImmediatePropagation();let Z=this.#M(Q);this.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#S(J){if(J.target instanceof Element&&J.target.closest("fig-input-gradient, fig-menu"))return;this.focus()}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.#q??""}get isDefault(){return JJ(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J;let Q=this.#J?.value;y(this,Q)}focus(J){this.#J?.focus(J)}}K("propskit-gradient",r);class A extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=!1;#O=null;#X=new Set;#$=null;#B=null;#q=null;#Y=this.#R.bind(this);#k=this.#A.bind(this);#G=!1;#N=null;static get observedAttributes(){return["label","direction","aria-label","options","value"]}static#U(){return["fig-select","fig-select-options","fig-select-option"].every((J)=>{let Q=customElements.get(J);return typeof Q==="function"&&Q.prototype instanceof HTMLElement})}static#P(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
|
|
1
|
+
function M(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function N(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function _J(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 x=new WeakMap;function T(J){let Q=x.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 q=Q?.point;if(q)Z.showAt?.(q.x,q.y)};Q={menu:Z,point:null,clearPendingOpen:_,handleContextMenu:(q)=>{if(N(J,"disabled")||q.target?.closest?.("fig-menu"))return;q.preventDefault(),q.stopPropagation(),q.stopImmediatePropagation?.(),Q.point={x:q.clientX,y:q.clientY},_(),window.addEventListener("pointerup",X,{once:!0,capture:!0}),window.addEventListener("pointercancel",X,{once:!0,capture:!0}),j=window.setTimeout(X,180)},handleChange:(q)=>{if(q.stopPropagation(),q.detail?.value==="reset-default")J.resetToDefault?.()}},x.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 f(J){let Q=x.get(J);if(!Q)return;Q.clearPendingOpen(),J.removeEventListener("contextmenu",Q.handleContextMenu),Q.menu.removeEventListener("change",Q.handleChange)}function I(J,Q){for(let Z of["input","change"])J.dispatchEvent(new CustomEvent(Z,{detail:Q,bubbles:!0,cancelable:!0,composed:!0}))}function b(J,Q){if(typeof J==="boolean"||typeof Q==="boolean")return Boolean(J)===Boolean(Q);return String(J??"")===String(Q??"")}function c(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 b(J,Q)}}function XJ(J,Q){if(!J||!Q)return null;let Z=document.createElement("span");Z.style.cssText="position:absolute;visibility:hidden;pointer-events:none;color:"+Q,J.appendChild(Z);let $=getComputedStyle(Z).color;if(Z.remove(),!$.startsWith("rgb"))return null;let j=$.match(/[\d.]+/g)?.slice(0,3).map(Number);if(!j||j.length<3||j.some(Number.isNaN))return null;let[_,X,O]=j.map((q)=>{let Y=q/255;return Y<=0.04045?Y/12.92:((Y+0.055)/1.055)**2.4});return 0.2126*_+0.7152*X+0.0722*O<=0.179?"light":"dark"}var g=0;function BJ(J="fig-lab"){return g+=1,`${J}-${g}`}class m extends HTMLElement{}M("fig-ai-prompt",m);class u extends HTMLElement{}M("fig-chat-message",u);class v extends HTMLElement{#Z=null;#Q=null;#J=null;#_=null;#X=null;#Y=null;#B=this.#M.bind(this);#$=this.#U.bind(this);#q=this.#P.bind(this);static get observedAttributes(){return["src","name","value","removable","disabled"]}connectedCallback(){if(!this.#Q)this.#j();this.#X.removeEventListener("click",this.#B),this.#X.addEventListener("click",this.#B),this.#O(),this.#G()}disconnectedCallback(){this.#X?.removeEventListener("click",this.#B),this.#k()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;this.#G()}#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.#J=document.createElement("span"),this.#J.className="fig-attachment-fallback",this.#J.setAttribute("aria-hidden","true"),this.#_=document.createElement("fig-tooltip"),this.#_.className="fig-attachment-remove-tooltip",this.#_.setAttribute("text","Remove attachment"),this.#X=document.createElement("fig-button"),this.#X.className="fig-attachment-remove",this.#X.setAttribute("variant","overlay"),this.#X.setAttribute("size","small"),this.#X.setAttribute("icon","");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("size","small"),this.#X.append(J),this.#_.append(this.#X),this.#Q.append(this.#J),this.#Z.append(this.#Q),this.replaceChildren(this.#Z,this.#_),this.#X.addEventListener("click",this.#B),this.#O()}#O(){let J=this.#Q?.mediaEl;if(!J||J===this.#Y)return;this.#k(),this.#Y=J,this.#Y.addEventListener("load",this.#$),this.#Y.addEventListener("error",this.#q)}#k(){if(!this.#Y)return;this.#Y.removeEventListener("load",this.#$),this.#Y.removeEventListener("error",this.#q),this.#Y=null}#G(){let J=this.getAttribute("src")||"",Q=this.getAttribute("name")||"Attachment",Z=!this.hasAttribute("removable")||N(this,"removable"),$=N(this,"disabled");if(this.#Z.setAttribute("text",Q),this.#Q.setAttribute("alt",Q),J)this.#Q.setAttribute("src",J);else this.#Q.removeAttribute("src");if(this.#O(),this.#J.textContent=this.#N(Q),this.#X.hidden=!Z,this.#X.toggleAttribute("disabled",$),this.#X.setAttribute("aria-label",`Remove ${Q}`),this.toggleAttribute("data-fallback",!J),$)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled")}#N(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)}#U(){if(this.getAttribute("src"))this.removeAttribute("data-fallback")}#P(){this.setAttribute("data-fallback","")}#M(J){if(J.stopPropagation(),N(this,"disabled")||this.hasAttribute("removable")&&!N(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}}))}}M("fig-attachment",v);class s 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 J of this.querySelectorAll(":scope > fig-attachment"))if(!J.hasAttribute("role"))J.setAttribute("role","listitem"),J.setAttribute("data-generated-role","")}}M("fig-attachments",s);class o extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=null;#$=null;#q=this.#K.bind(this);#j=!1;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#O();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#P(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#O(){this.#j=N(this,"checked");let Q=Array.from(this.childNodes).filter((O)=>O.nodeType!==Node.TEXT_NODE||Boolean(O.textContent?.trim())).find((O)=>O.nodeType===Node.ELEMENT_NODE&&O.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-segmented-control"),_=document.createElement("fig-segment"),X=document.createElement("fig-segment");j.setAttribute("sizing","equal"),_.setAttribute("value","off"),_.textContent="Off",X.setAttribute("value","on"),X.textContent="On",j.append(_,X),Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#G(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","checked","value","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",N(this,"checked")?"on":"off"),this.#Y=Q}#U(){if(!this.#J)return;this.#B??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value==="on";this.toggleAttribute("checked",Z);let $={checked:Z,value:this.getAttribute("value")??""};this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){if(J.target instanceof Element&&J.target.closest("fig-segmented-control, fig-menu"))return;let Q=this.#J?.value==="on"?"off":"on";this.#J?.querySelector(`fig-segment[value="${Q}"]`)?.click()}get checked(){return this.#J?this.#J.value==="on":N(this,"checked")}set checked(J){let Q=Boolean(J);if(this.toggleAttribute("checked",Q),this.#J)this.#J.value=Q?"on":"off"}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){this.setAttribute("value",J??"")}get defaultValue(){return this.hasAttribute("default")?N(this,"default"):this.#j}get isDefault(){return this.checked===this.defaultValue}resetToDefault(){let J=this.defaultValue;this.checked=J,I(this,{checked:J,value:this.getAttribute("value")??""})}focus(J){(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}M("propskit-switch",o);class r extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=null;#$=null;#q=this.#L.bind(this);#j=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#O();if(this.#k(),this.#N(),this.#U(),this.#j===null)this.#j=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#P(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#O(){let J=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-color");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#Y)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,$)}this.#J.setAttribute("text","true"),this.#Y=Q}#U(){if(!this.#J)return;this.#B??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J){let Q=J instanceof CustomEvent&&J.detail!==void 0?J.detail:void 0;if(typeof Q==="string"&&Q)return Q;if(Q&&typeof Q==="object"){if(typeof Q.value==="string"&&Q.value)return Q.value;if(typeof Q.hex==="string"&&Q.hex)return Q.hex;if(typeof Q.color==="string"&&Q.color)return Q.color}if(typeof this.#J?.value==="string"&&this.#J.value)return this.#J.value;return this.#J?.getAttribute("value")??""}#K(J,Q){Q.stopImmediatePropagation();let Z=this.#M(Q);if(this.setAttribute("value",Z),this.#J&&this.#J.getAttribute("value")!==Z)this.#J.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#L(J){if(J.target instanceof Element&&J.target.closest("fig-input-color, fig-menu"))return;this.focus()}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);if(this.setAttribute("value",Q),this.#J&&this.#J.getAttribute("value")!==Q)this.#J.setAttribute("value",Q)}#z(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#S(){return this.getAttribute("default")??this.#j??""}get defaultValue(){return String(this.#S())}get isDefault(){return b(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#z(J),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}M("propskit-color",r);class l extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=null;#$=null;#q=this.#L.bind(this);#j=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#O();if(this.#k(),this.#N(),this.#U(),this.#j===null)this.#j=this.getAttribute("default")??this.getAttribute("value")??JSON.stringify(this.#J?.value??{});if(this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#P(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#O(){let Q=Array.from(this.childNodes).filter((_)=>_.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())).find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-gradient");Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Gradient")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#Y)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","true");this.#Y=Q}#U(){if(!this.#J)return;this.#B??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(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)}#K(J,Q){Q.stopImmediatePropagation();let Z=this.#M(Q);this.setAttribute("value",Z);let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#L(J){if(J.target instanceof Element&&J.target.closest("fig-input-gradient, fig-menu"))return;this.focus()}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.#j??""}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J;let Q=this.#J?.value;I(this,Q)}focus(J){this.#J?.focus(J)}}M("propskit-gradient",l);class A extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=!1;#Y=null;#B=new Set;#$=null;#q=null;#j=null;#O=this.#V.bind(this);#k=this.#A.bind(this);#G=!1;#N=null;static get observedAttributes(){return["label","direction","aria-label","options","value"]}static#U(){return["fig-select","fig-select-options","fig-select-option"].every((J)=>{let Q=customElements.get(J);return typeof Q==="function"&&Q.prototype instanceof HTMLElement})}static#P(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
|
|
2
2
|
`)?`
|
|
3
|
-
`:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}static#M(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}static#K(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}connectedCallback(){if(!this.#Z)this.#S();if(this.#z(),this.#W(),this.#F(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#k,!0),this.addEventListener("pointerdown",this.#k,!0),C(this),!this.#O)this.#O=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let j=$.attributeName;if(j==="label"||j==="direction"||j==="aria-label")Q=!0;else Z=!0}if(Q)this.#z();if(Z)this.#W()});this.#O.observe(this,{attributes:!0})}disconnectedCallback(){this.#O?.disconnect(),this.#V(),this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#k,!0),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#z();return}if(J==="options"||J==="value")this.#W()}#S(){this.#N=this.getAttribute("value")??"";let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label");this.#_=A.#U();let $=document.createElement(this.#_?"fig-select":"fig-dropdown");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#j=Boolean(J),this.replaceChildren(Q)}#z(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#L(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full","default"]);if(!this.#_)J.add("options");return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#E(){if(!this.#J||this.#_)return;let J=A.#P(this.getAttribute("options"));for(let Z of[...this.#J.children])if(Z.localName==="option"||Z.localName==="optgroup")Z.remove();for(let Z of J){let $=document.createElement("option");$.value=A.#M(Z),$.textContent=A.#K(Z),this.#J.appendChild($)}let Q=this.getAttribute("value");if(Q!=null){let Z=()=>{if(this.#J?.setAttribute("value",Q),this.#J&&"value"in this.#J)this.#J.value=Q};Z(),queueMicrotask(Z)}}#W(){if(!this.#J)return;if(!this.#_)this.#E();let J=this.#L().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.#X)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#X=Q}#F(){if(!this.#J)return;if(this.#$??=this.#T.bind(this,"input"),this.#B??=this.#T.bind(this,"change"),this.#J.addEventListener("input",this.#$),this.#J.addEventListener("change",this.#B),this.#_)this.#q??=this.#T.bind(this,"optionhover"),this.#J.addEventListener("optionhover",this.#q)}#V(){if(!this.#J)return;if(this.#$)this.#J.removeEventListener("input",this.#$);if(this.#B)this.#J.removeEventListener("change",this.#B);if(this.#q)this.#J.removeEventListener("optionhover",this.#q)}#T(J,Q){if(Q.target!==this.#J)return;Q.stopImmediatePropagation();let Z=this.#J?.value??"";if(J!=="optionhover")this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#y(){if(!this.#J||!this.#_)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"))}#A(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select, fig-dropdown")){this.#G=!1;return}if(!this.#_)return;this.#G=this.#y()}#R(J){if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select, fig-dropdown")){this.#G=!1;return}if(!this.#J||U(this.#J,"disabled")){this.#G=!1;return}if(this.#J.focus(),!this.#_)return;if(this.#G||this.#y()){this.#G=!1,this.#J.open=!1;return}this.#J.open=!0}get value(){return 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.#N??""}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(this.value=J,this.#J)this.#J.value=J;y(this,J)}focus(J){this.#J?.focus(J)}}K("propskit-select",A);class l extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=null;#$=null;#B=this.#K.bind(this);#q=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),C(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==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#P(),this.removeEventListener("click",this.#B),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#Y(){this.#q=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=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-text");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","multiline","resizable","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#U(){if(!this.#J)return;this.#X??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value??"";this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){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.#q??""}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,y(this,J)}focus(J){this.#J?.focus(J)}}K("propskit-text",l);class d extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=null;#$=null;#B=this.#K.bind(this);#q=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#Y();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),C(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==="direction")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#P(),this.removeEventListener("click",this.#B),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#Y(){this.#q=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=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-number");Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z);for(let _ of J)if(_!==Q)j.appendChild(_)}#k(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#G(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#U(){if(!this.#J)return;this.#X??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;if(this.#J?.value!==void 0)this.setAttribute("value",String(this.#J.value));this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.focus()}get value(){return 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.#q??"0"}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,y(this,this.#J?.value??J)}focus(J){this.#J?.focus(J)}}K("propskit-number",d);class h extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-gradient","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","propskit-oscillator"].join(",");#Q=null;#J=null;#_=null;#j=null;#O=0;#X=()=>this.#q();connectedCallback(){this.#W(),this.#$(),requestAnimationFrame(()=>{this.#K()})}disconnectedCallback(){if(this.#B(),this.#O)cancelAnimationFrame(this.#O),this.#O=0;this.#Q?.removeEventListener("click",this.#k),this.#Q?.removeEventListener("keydown",this.#G),this.#_?.querySelector("fig-button")?.removeEventListener("click",this.#N)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}if(J==="show-reset"){this.#L(),this.#K();return}this.#W()}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.#Q?.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.#z()}#$(){if(this.removeEventListener("input",this.#X,!0),this.removeEventListener("change",this.#X,!0),this.addEventListener("input",this.#X,!0),this.addEventListener("change",this.#X,!0),!this.#j)this.#j=new MutationObserver(()=>{this.#q()});this.#j.disconnect(),this.#j.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","checked","default"]})}#B(){this.removeEventListener("input",this.#X,!0),this.removeEventListener("change",this.#X,!0),this.#j?.disconnect()}#q(){if(this.#O)return;this.#O=requestAnimationFrame(()=>{this.#O=0,this.#K()})}#Y(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#k=(J)=>{if(this.#Y(J.target))return;J.stopPropagation(),this.open=!this.open};#G=(J)=>{if(this.#Y(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#N=(J)=>{J.preventDefault(),J.stopPropagation(),this.#z()};#U(){return[...this.querySelectorAll(h.#Z)].filter((J)=>J.closest("propskit-group")===this&&!J.parentElement?.closest(h.#Z))}#P(J){return J.isDefault===!1}#M(){for(let J of this.#U())if(this.#P(J))return!0;return!1}#K(){if(this.#M())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#L()}#S(J){if(typeof J.resetToDefault==="function")J.resetToDefault()}#z(){for(let J of this.#U())this.#S(J);this.#K(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#L(){if(!this.showReset){this.#_?.setAttribute("hidden","");return}this.#E(),this.#_?.removeAttribute("hidden")}#E(){if(!this.#Q||!this.showReset)return;let J=this.#Q.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.#Q.appendChild(J),Q.addEventListener("click",this.#N)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#N),Q?.addEventListener("click",this.#N)}this.#_=J}#W(){let Q=this.getAttribute("name")||"Group",Z=this.querySelector(":scope > fig-header");if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated||this.#Q.parentElement!==this)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector(":scope > h3"),j=this.#Q.querySelector(":scope > fig-button.propskit-group-disclosure");if(!$&&j){if($=j.querySelector(":scope > h3"),$)this.#Q.insertBefore($,j);j.remove()}if(!$)$=document.createElement("h3"),this.#Q.prepend($);let _=$.querySelector(":scope > button.propskit-group-disclosure");if(_){while(_.firstChild)$.insertBefore(_.firstChild,_);_.remove()}if(!$.id)$.id=ZJ("propskit-group");if(this.#Q.dataset.generated){let X=$.querySelector(".propskit-group-chevron");if($.textContent=Q,X)$.prepend(X)}if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",$.id);if(!$.querySelector(".propskit-group-chevron")){let X=document.createElement("fig-icon");X.setAttribute("name","chevron"),X.setAttribute("size","small"),X.className="propskit-group-chevron",$.prepend(X)}if(this.#J=$.querySelector(".propskit-group-chevron"),this.#L(),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("click",this.#k),this.#Q.addEventListener("click",this.#k),this.#Q.removeEventListener("keydown",this.#G),this.#Q.addEventListener("keydown",this.#G),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}K("propskit-group",h);class i extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#j=null;#O=new Set;#X=0;#$=0;#B=null;#q=null;#Y=0;#k=null;#G=null;#N=!1;#U=0;#P=null;#M=0;#K=null;#S=null;#z=0;#L=0;#E=!1;#W=!1;#F=0;#V=null;#T=null;#y=this.#a.bind(this);#A=this.#YJ.bind(this);#R=this.#$J.bind(this);#H=this.#OJ.bind(this);#x=this.#zJ.bind(this);#C=this.#d.bind(this);#o=this.#SJ.bind(this);#b=this.#TJ.bind(this);#f=this.#FJ.bind(this);#I=this.#l.bind(this);#v=new Set(["variant","color","text","full","elastic","size","name","class","data-wave-index","data-active","data-elastic-dragging","style"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#D();if(this.#r(),this.#u(),this.#p(),this.#BJ(),this.removeEventListener("pointerdown",this.#y,{capture:!0}),this.addEventListener("pointerdown",this.#y,{capture:!0,passive:!0}),this.removeEventListener("pointerdown",this.#H,{capture:!0}),this.addEventListener("pointerdown",this.#H,{capture:!0}),this.removeEventListener("contextmenu",this.#b),this.addEventListener("contextmenu",this.#b),this.removeEventListener("click",this.#I,!0),this.addEventListener("click",this.#I,!0),this.#q?.removeEventListener("change",this.#f),this.#q?.addEventListener("change",this.#f),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName==="value"){this.#h();continue}if($.attributeName==="color"){Z=!0;continue}if($.attributeName&&this.#v.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#r();if(Z)this.#u(),this.#BJ()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#kJ(),this.#t(),clearTimeout(this.#F),this.#F=0,this.#GJ(),this.#n(),this.#qJ(),this.#s(),this.removeEventListener("pointerdown",this.#y,{capture:!0}),this.removeEventListener("pointerdown",this.#H,{capture:!0}),this.removeEventListener("contextmenu",this.#b),this.removeEventListener("click",this.#I,!0),this.#q?.removeEventListener("change",this.#f)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#r()}#D(){this.#G=this.getAttribute("value")??this.getAttribute("min")??"0";let J=Array.from(this.childNodes).filter((_)=>{return _.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())}),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-slider");j.setAttribute("text","true");for(let _ of this.#XJ()){let X=this.getAttribute(_);j.setAttribute(_,X??"")}Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z),this.#c();for(let _ of J){if(_===Q)continue;this.#J.appendChild(_)}}#c(){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.#f),this.#q=J,this.appendChild(J)}#r(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Q.parentElement===this.#Z)this.#Q.remove()}else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#u(){if(!this.#J)return;let J=this.#XJ(),Q=new Set(J.filter(($)=>$!=="text"&&$!=="value"));for(let $ of this.#O)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"||Z==="stepper")this.#J.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))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.#i(Z),this.#O=Q,this.#h(),this.#UJ()}#i(J){let Q=this.#J?.querySelector("fig-input-number");if(!Q)return;if(J!=="opacity"||!this.hasAttribute("color")){Q.removeAttribute("theme");return}let Z=QJ(this.#J,this.getAttribute("color"));if(Z)Q.setAttribute("theme",Z);else Q.removeAttribute("theme")}#h(){if(!this.#J)return;let J=this.getAttribute("value")??"";if(String(this.#J.value)!==J)this.#J.value=J}#XJ(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#v.has(Q))}#UJ(){if(this.#X)cancelAnimationFrame(this.#X);this.#X=requestAnimationFrame(()=>{this.#X=0,this.#_J(),this.#QJ()})}#BJ(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#QJ()})}#QJ(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#B)this.#LJ(J);if(J){J.removeAttribute("tabindex"),J.removeAttribute("aria-hidden");let Z=this.getAttribute("aria-label")||this.#Q?.textContent?.trim()||"Slider";if(!J.hasAttribute("aria-label")&&!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-label",Z)}if(Q)Q.removeAttribute("tabindex"),Q.removeAttribute("aria-hidden")}#l(J){if(U(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu")){if(this.#W&&J.target.closest("fig-input-number"))J.preventDefault(),J.stopImmediatePropagation(),this.#W=!1;return}this.#ZJ()}#ZJ(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!U(this,"disabled"))this.focus()})})}#LJ(J){if(this.#qJ(),this.#B=J,!this.#B)return;this.#B.addEventListener("dblclick",this.#o,{capture:!0})}#qJ(){if(!this.#B)return;this.#B.removeEventListener("dblclick",this.#o,{capture:!0}),this.#B=null}#SJ(J){J.preventDefault(),J.stopImmediatePropagation(),this.#PJ()}#OJ(J){if(J.button!==0||J.altKey||U(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.#t(),this.#S=J.pointerId,this.#z=J.clientX,this.#L=J.clientY,this.#E=!1,window.addEventListener("pointermove",this.#x),window.addEventListener("pointerup",this.#C,{once:!0}),window.addEventListener("pointercancel",this.#C,{once:!0}),window.addEventListener("blur",this.#C,{once:!0})}#zJ(J){if(J.pointerId!==this.#S)return;if(J.buttons===0){this.#d(J);return}if(!this.#E){if(Math.hypot(J.clientX-this.#z,J.clientY-this.#L)<4)return;this.#E=!0,this.setAttribute("data-number-scrubbing","")}this.#jJ(this.#NJ(J),"input")}#d(J){if(J?.pointerId!==void 0&&this.#S!==null&&J.pointerId!==this.#S)return;let Q=this.#E;if(this.#t(),Q){this.#jJ(this.#J?.value,"change"),this.#W=!0,clearTimeout(this.#F),this.#F=window.setTimeout(()=>{this.#W=!1,this.#F=0},0),this.#ZJ();return}this.#J?.querySelector("fig-input-number input")?.focus()}#t(){window.removeEventListener("pointermove",this.#x),window.removeEventListener("pointerup",this.#C),window.removeEventListener("pointercancel",this.#C),window.removeEventListener("blur",this.#C),this.#S=null,this.#E=!1,this.removeAttribute("data-number-scrubbing")}#a(J){if(J.button!==0||U(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#B;if(!Q)return;this.#GJ(),this.#n(),this.#B=Q,this.#N=!0,this.#K=J.pointerId,this.#U=this.#WJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#P={left:Z.left,right:Z.right,width:Z.width},this.#M=$.width,window.addEventListener("pointermove",this.#A,{passive:!0}),window.addEventListener("pointerup",this.#R,{once:!0}),window.addEventListener("pointercancel",this.#R,{once:!0}),window.addEventListener("blur",this.#R,{once:!0})}#YJ(J){if(!this.#N)return;if(J.pointerId!==this.#K)return;if(J.buttons===0){this.#$J(J);return}this.#w(J.clientX)}#$J(J){if(J?.pointerId!==void 0&&this.#K!==null&&J.pointerId!==this.#K)return;let Q=J?.type==="pointerup"||J?.type==="pointermove"&&J.buttons===0;if(this.#GJ(),this.#n(),Q)this.#ZJ()}#GJ(){window.removeEventListener("pointermove",this.#A),window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R),this.#N=!1,this.#K=null}#TJ(J){if(U(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#kJ(),this.#KJ(J.clientX,J.clientY)}#KJ(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.#q?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#FJ(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#PJ()}#kJ(){if(this.#Y)clearTimeout(this.#Y),this.#Y=0;this.#k=null}#WJ(){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}#w(J){let Q=this.#P;if(!Q||!this.#U){this.#n();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#e();return}let $=Math.max(-this.#U,Math.min(this.#U,Z*0.5)),j=Math.abs($),_=this.#M?(this.#M+j)/this.#M: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")}#n(){this.#e(),this.#U=0,this.#P=null,this.#M=0,this.#K=null}#e(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#NJ(J){let Q=this.#B;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),O=j+(_-j)*$;if(!X)return String(O);let B=Math.round((O-j)/X)*X+j,q=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(q)))}#MJ(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.#G??this.#B?.min??"0"}#PJ(){this.#kJ(),this.#jJ(this.#MJ(),"input"),this.#jJ(this.#MJ(),"change")}#jJ(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.setAttribute("value",String(this.#J.value)),this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#_J(){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??"")}#p(){if(!this.#J)return;if(!this.#V)this.#V=this.#g.bind(this,"input");if(!this.#T)this.#T=this.#g.bind(this,"change");this.#J.addEventListener("input",this.#V),this.#J.addEventListener("change",this.#T)}#s(){if(!this.#J)return;if(this.#V)this.#J.removeEventListener("input",this.#V);if(this.#T)this.#J.removeEventListener("change",this.#T)}#g(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#n();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;if(this.#J?.value!==void 0){let $=String(this.#J.value);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#QJ();let Q=this.#J?.querySelector('input[type="range"]');Q?.setAttribute("data-propskit-focus-called",""),Q?.focus(J)}get value(){return 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.#MJ()}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){this.#PJ()}}K("propskit-slider",i);class a extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#_=75;#j=0;#O=!1;#X=0;#$=null;#B=null;#q=null;#Y=null;#k=null;#G=null;#N=null;#U=null;#P=null;#M=!1;#K=!1;#S=!1;#z=!1;#L=null;#E="";#W="";#F=null;#V=null;#T=null;#y="";#A="";#R=null;#H=null;#x=null;get#C(){return this.getAttribute("type")||"point"}get#o(){return this.#C==="point-radius"||this.#C==="point-radius-angle"}get#b(){return this.#C==="point-radius-angle"}get#f(){return this.#C==="point-point"}get#I(){return this.#C==="point-radius-angle"||this.#C==="point-point"}get#v(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#D(){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"}#c(J){let Q=this.#D;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#r(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#u(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#_)}%`}get#i(){return this.getAttribute("drag-surface")||"parent"}get#h(){let J=this.#i;if(J==="parent")return this.parentElement;return this.closest(J)}get#XJ(){let J=this.#i;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#UJ(J){if(this.#O)return this.#j/100*J;return this.#j}#BJ(){if(this.#O)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}connectedCallback(){this.#QJ(),this.#l()}disconnectedCallback(){this.#RJ(),this.#DJ(),this.#qJ(),this.#d(),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.#M&&!this.#K&&!this.#S&&!this.#z)if(this.#QJ(),this.#$)this.#p();else this.#l();if(J==="type")this.#RJ(),this.#QJ(),this.#l();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#RJ(),this.#l();if(J==="tooltips")this.#l();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#B)this.#B.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#G)this.#G.setAttribute("text",this.#r);if(this.#N)this.#N.setAttribute("text",this.#u)}}#QJ(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#O=!0,this.#j=parseFloat(Z);else this.#O=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#X=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#_=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#C==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#o)J.radius=this.#O?`${this.#j}%`:this.#j;if(this.#b)J.angle=this.#X;if(this.#f)J.x2=this.#J,J.y2=this.#_;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#l(){this.#RJ(),this.innerHTML="",this.#$=null,this.#B=null,this.#q=null,this.#Y=null,this.#k=null,this.#G=null,this.#N=null,this.#U=null,this.#P=null;let J=U(this,"disabled"),Q=this.#C,Z=this.#v,$=this.#XJ,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.#D),j.setAttribute("value",`${this.#Z}% ${this.#Q}%`),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.#f)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#$=j,this.#o)this.#TJ();if(this.#I)this.#KJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#r),_.appendChild(j),this.appendChild(_),this.#G=_}else this.appendChild(j);if(this.#b)this.#kJ(J,Z,$);if(this.#f)this.#WJ(J,Z,$);this.#ZJ(this.#$),this.#ZJ(this.#q),this.#ZJ(this.#B),this.#HJ(),this.#YJ(),requestAnimationFrame(()=>this.#p())}#ZJ(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#zJ(Q,J);else this.#LJ(Q)},{capture:!0})}#LJ(J){if(U(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#L===null)this.#E=document.body.style.getPropertyValue("cursor"),this.#W=document.body.style.getPropertyPriority("cursor");if(this.#L=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#F)this.#F=(Q)=>{if(Q?.pointerId!==void 0&&this.#L!==null&&Q.pointerId!==this.#L)return;if(Q?.type==="blur")this.#qJ();else requestAnimationFrame(()=>this.#qJ())};window.addEventListener("pointerup",this.#F),window.addEventListener("pointercancel",this.#F),window.addEventListener("blur",this.#F)}#qJ(){if(this.#L===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#E)document.body.style.setProperty("cursor",this.#E,this.#W);else document.body.style.removeProperty("cursor");if(this.#L=null,this.#E="",this.#W="",this.#F)window.removeEventListener("pointerup",this.#F),window.removeEventListener("pointercancel",this.#F),window.removeEventListener("blur",this.#F)}#SJ(J){if(!J)return 0;if(J===this.#q)return this.#X;if(!this.#f)return 0;let Q=this.#PJ();return J===this.#$?Q+180:Q}#OJ(){if(this.#V===null)return;let J=this.#n(this.#SJ(this.#T));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#zJ(J,Q){if(U(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.#A=document.body.style.getPropertyPriority("cursor");if(this.#V=J?.pointerId??-1,this.#T=Q,document.body.classList.add("fig-lab-rotate-active"),this.#OJ(),!this.#R)this.#R=(Z)=>{if(Z?.pointerId!==void 0&&this.#V!==null&&Z.pointerId!==this.#V)return;if(Z?.type==="blur")this.#d();else requestAnimationFrame(()=>this.#d())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#d(){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.#A);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#T=null,this.#y="",this.#A="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#t(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?.()},O=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",O)}#a(){return this.#M||this.#K||this.#S||this.#z}#YJ(){if(this.#$)this.#t(this.#$,()=>this.#G,()=>this.#r,()=>this.#a()||!!this.#$?.querySelector("fig-color-tip"));if(this.#q)this.#t(this.#q,()=>this.#P,()=>`Angle ${Math.round(this.#X)}°`,()=>this.#a());if(this.#B)this.#t(this.#B,()=>this.#N,()=>this.#u,()=>this.#a());if(this.#Y){let J=this.#Y.querySelector(".fig-canvas-control-radius-hit");this.#GJ(J||this.#Y)}if(this.#C==="color"&&this.#$&&this.#G)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#G?.removeAttribute("show"),this.#G?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#$J(J,Q){let Z=this.#U;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?.()}#GJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#BJ()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#$J(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#S)return;this.#$J(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#S)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#TJ(){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.#Y=Q,this.#v){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#BJ()),_.appendChild(Q),this.appendChild(_),this.#U=_}else this.appendChild(Q);this.#fJ(Z)}#KJ(){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.#f){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.#FJ(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.#k=Q,this.appendChild(Q)}#FJ(J){J.addEventListener("pointerdown",(Q)=>{if(U(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#h;if(!Z)return;let{clientX:$,clientY:j}=Q,_=this.#Z,X=this.#Q,O=this.#J,B=this.#_;this.#M=!0,this.#K=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let q=(G)=>{let k=Z.getBoundingClientRect(),M=k.width>0?(G.clientX-$)/k.width*100:0,N=k.height>0?(G.clientY-j)/k.height*100:0,L=-Math.min(_,O),z=100-Math.max(_,O),T=-Math.min(X,B),F=100-Math.max(X,B),S=Math.max(L,Math.min(z,M)),W=Math.max(T,Math.min(F,N));this.#Z=_+S,this.#Q=X+W,this.#J=O+S,this.#_=B+W,this.#p(),this.#s()},Y=this.#CJ((G)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#M=!1,this.#K=!1,G)this.#JJ(),this.#g()});window.addEventListener("pointermove",q,{signal:Y.signal}),window.addEventListener("pointerup",()=>Y.finish(!0),{signal:Y.signal}),window.addEventListener("pointercancel",()=>Y.finish(!1),{signal:Y.signal})})}#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("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),J)$.setAttribute("disabled","");if(this.#q=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",`${Math.round(this.#X)}°`),j.appendChild($),this.appendChild(j),this.#P=j}else this.appendChild($)}#WJ(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.#D),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#_}%`),J)$.setAttribute("disabled","");if(this.#B=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#u),j.appendChild($),this.appendChild(j),this.#N=j}else this.appendChild($)}#w(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`}#n(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`}#e(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#NJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#e(Z,this.#n(Q)),this.#T===J)this.#OJ()}#MJ(){if(!this.#q||!this.#b)return;this.#NJ(this.#q,this.#X)}#PJ(){return Math.atan2(this.#_-this.#Q,this.#J-this.#Z)*180/Math.PI}#jJ(){if(!this.#f)return;let J=this.#PJ();this.#$?.style.removeProperty("cursor"),this.#B?.style.removeProperty("cursor"),this.#NJ(this.#$,J+180),this.#NJ(this.#B,J)}#_J(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`}#p(){let J=this.#h;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#_J(this.#$,this.#Z,this.#Q,Q),this.#Y){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#UJ(Q.width),_=this.#Y,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 O=_.querySelectorAll("circle");for(let B of O)B.setAttribute("cx",String(j)),B.setAttribute("cy",String(j)),B.setAttribute("r",String(Math.max(j-1,0)))}if(this.#k&&this.#I){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j,_;if(this.#f)j=this.#J/100*Q.width,_=this.#_/100*Q.height;else{let B=this.#UJ(Q.width),q=this.#X*Math.PI/180;j=Z+B*Math.cos(q),_=$+B*Math.sin(q)}let X=this.#k;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 O=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of O)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#q&&this.#b){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#UJ(Q.width),_=this.#X*Math.PI/180,X=Z+j*Math.cos(_),O=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,q=Q.height>0?O/Q.height*100:0;this.#_J(this.#q,B,q,Q)}if(this.#B&&this.#f)this.#_J(this.#B,this.#J,this.#_,Q);this.#MJ(),this.#jJ()}#s(J=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:J}))}#g(J=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:J}))}#VJ(J){return{...this.value,...e(J.color,J.alpha,J.opacity)}}#JJ(){this.setAttribute("value",JSON.stringify(this.value))}#HJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#s(this.#VJ(J.detail));return}this.#M=!0;let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#G)this.#G.removeAttribute("show"),this.#G.hidePopup?.();this.#p(),this.#s()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#g(this.#VJ(J.detail));return}let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#G)this.#G.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#M=!1})}),this.#q)this.#q.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#h;if(!Q)return;this.#z=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,j=this.#Q/100*Z.height,_=J.detail?.x??0,X=J.detail?.y??0,O=this.#q.offsetWidth/2,B=this.#q.offsetHeight/2,q=_+O-$,Y=X+B-j,G=Math.atan2(Y,q)*180/Math.PI;if(this.#c(J.detail?.shiftKey))G=Math.round(G/15)*15;this.#X=G;let k=Math.sqrt(q*q+Y*Y);if(this.#c(J.detail?.shiftKey)){let M=this.#O?5:10;if(this.#O){let N=k/Z.width*100;N=Math.round(N/M)*M,k=N/100*Z.width}else k=Math.round(k/M)*M}if(this.#O)this.#j=Math.max(0,k/Z.width*100);else this.#j=Math.max(0,k);if(this.#P)this.#P.setAttribute("text",`Angle ${Math.round(this.#X)}°`),this.#P.setAttribute("show","true"),this.#P.showPopup?.();this.#p(),this.#s()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#P)this.#P.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#z=!1})}),this.#q.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#h;if(!Z)return;if(this.#z=!0,this.classList.add("fig-canvas-control-ring-active"),this.#q.setAttribute("selected",""),this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),O=this.#Z/100*X.width,B=this.#Q/100*X.height,q=_.clientX-X.left-O,Y=_.clientY-X.top-B,G=Math.atan2(Y,q)*180/Math.PI;if(this.#c(_.shiftKey))G=Math.round(G/15)*15;if(this.#X=G,this.#P)this.#P.setAttribute("text",`Angle ${Math.round(G)}°`);this.#p(),this.#s()},j=this.#CJ((_)=>{if(this.#z=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#q.removeAttribute("selected"),this.#P)this.#P.removeAttribute("show");if(_)this.#JJ(),this.#g()});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.#B)this.#B.addEventListener("input",(J)=>{J.stopPropagation(),this.#K=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#_/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#_=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#p(),this.#s()}),this.#B.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#N)this.#N.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#K=!1})}),this.#m(this.#$,!0),this.#m(this.#B,!1)}#m(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let j=this.#h;if(!j)return;this.#M=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#Z,O=Q?this.#_:this.#Q,B=Q?this.#Z:this.#J,q=Q?this.#Q:this.#_,Y=X/100*_.width,G=O/100*_.height,k=B/100*_.width,M=q/100*_.height,N=Math.sqrt((k-Y)**2+(M-G)**2),L=Q?this.#G:this.#N;if(L)L.removeAttribute("show"),L.hidePopup?.();let z=(F)=>{let S=j.getBoundingClientRect(),W=X/100*S.width,D=O/100*S.height,R=F.clientX-S.left-W,E=F.clientY-S.top-D,V=Math.atan2(E,R);if(this.#c(F.shiftKey))V=Math.round(V*180/Math.PI/15)*15*Math.PI/180;let t=W+N*Math.cos(V),n=D+N*Math.sin(V),w=Math.max(0,Math.min(100,t/S.width*100)),p=Math.max(0,Math.min(100,n/S.height*100));if(Q)this.#Z=w,this.#Q=p;else this.#J=w,this.#_=p;this.#p(),this.#s()},T=this.#CJ((F)=>{if(this.#M=!1,L)L.removeAttribute("show");if(F)this.#JJ(),this.#g()});window.addEventListener("pointermove",z,{signal:T.signal}),window.addEventListener("pointerup",()=>T.finish(!0),{signal:T.signal}),window.addEventListener("pointercancel",()=>T.finish(!1),{signal:T.signal})})}#fJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#S)return;let $=this.#h;if(!$)return;let j=$.getBoundingClientRect(),_=this.#Z/100*j.width,X=this.#Q/100*j.height,O=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#e(J,this.#w(O))});let Q=(Z)=>{if(U(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#S=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#h;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#$J(Z.clientX,Z.clientY);if(this.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();let j=this.#q?.style.pointerEvents,_=this.#q?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#q)this.#q.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let O=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),q=this.#Z/100*B.width,Y=this.#Q/100*B.height,G=Math.atan2(Z.clientY-B.top-Y,Z.clientX-B.left-q)*180/Math.PI,k=Math.round(G);document.body.style.cursor=this.#w(k);let M=(L)=>{let z=$.getBoundingClientRect(),T=this.#Z/100*z.width,F=this.#Q/100*z.height,S=L.clientX-z.left-T,W=L.clientY-z.top-F,D=Math.round(Math.atan2(W,S)*180/Math.PI);if(D!==k)k=D,document.body.style.cursor=this.#w(D);let R=Math.sqrt(S*S+W*W);if(this.#c(L.shiftKey)){let E=this.#O?5:10;if(this.#O){let V=R/z.width*100;V=Math.round(V/E)*E,R=V/100*z.width}else R=Math.round(R/E)*E}if(this.#O)this.#j=Math.max(0,R/z.width*100);else this.#j=Math.max(0,R);if(this.#U)this.#U.setAttribute("text",this.#BJ()),this.#$J(L.clientX,L.clientY);this.#p(),this.#s()},N=this.#CJ((L)=>{if(this.#S=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#q)this.#q.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=O,this.#U)this.#U.removeAttribute("show");if(L)this.#JJ(),this.#g()});window.addEventListener("pointermove",M,{signal:N.signal}),window.addEventListener("pointerup",()=>N.finish(!0),{signal:N.signal}),window.addEventListener("pointercancel",()=>N.finish(!1),{signal:N.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#DJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#CJ(J){this.#RJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#H===Q)this.#H=null,this.#x=null;J(j)};return this.#H=Q,this.#x=$,{signal:Q.signal,finish:$}}#RJ(){this.#x?.(!1),this.#H?.abort(),this.#H=null,this.#x=null}}K("fig-canvas-control",a);class P extends HTMLElement{#Z=[P.#T()];#Q=0;#J=2;#_=240;#j=120;#O={min:-1,max:1};#X=null;#$=null;#B=null;#q=null;#Y=0;#k=null;#G=null;#N=null;#U=null;#P=[];#M=[];#K=[];#S=[];#z=new Set;#L=null;#E=null;#W=null;#F=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#T(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:[P.#T()]});this.#J=this.#y("precision",2),this.#C(this.getAttribute("value")),this.#x(),this.#h(),this.#SJ(),C(this)}disconnectedCallback(){if(this.#_J(),this.#GJ(),this.#L)this.#L.disconnect(),this.#L=null;f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#C(Z),this.isConnected)this.#h();return}if(J==="precision"){if(this.#J=this.#y("precision",2),this.isConnected)this.#g();return}if(J==="aspect-ratio"){if(this.#x(),this.#$)this.#YJ();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#h()}}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.#o(this.defaultValue);if(!J)return!1;return JSON.stringify(this.data.waves)===JSON.stringify(J.map((Q)=>this.#f(Q)))}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,this.#m("input"),this.#m("change")}get data(){return{waves:this.#Z.map((J)=>this.#f(J))}}get preset(){let J=this.#I;return P.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}#A(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}#R(){return this.getAttribute("edit")!=="false"}#H(){return this.#A("disabled",!1)}#x(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#C(J){let Q=this.#o(J);if(!Q)return!1;if(this.#Z=Q,!this.#Z.length)this.#Z=[P.#T()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#o(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.#b($))}#b(J={}){return{type:this.#v(J.type),frequency:this.#D(J.frequency,1,0.1,16),amplitude:this.#D(J.amplitude,1,-4,4),phase:this.#D(J.phase,0,-360,360),offset:this.#D(J.offset,0,-4,4)}}#f(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||P.#T()}#v(J){let Q=String(J||"").toLowerCase();return P.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#D(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#c(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#r(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#u(J){return P.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let j=Q-10,_="";for(let X=0;X<=32;X++){let O=X/32,B=P.#i(J,O),q=5+O*j,Y=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${q.toFixed(1)},${Y.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${_}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#i(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(_)}}#h(){this.#_J(),this.#GJ(),this.innerHTML=this.#XJ(),this.#ZJ(),this.#OJ(),this.#YJ(),this.#WJ(),this.#$J(),C(this)}#XJ(){let J=this.#R()&&!this.#H(),Q=J?"":" disabled";return`<div class="propskit-oscillator-svg-container">
|
|
4
|
-
<svg viewBox="0 0 ${this.#_} ${this.#
|
|
5
|
-
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#_}" height="${this.#
|
|
3
|
+
`:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}static#M(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}static#K(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}connectedCallback(){if(!this.#Z)this.#L();if(this.#z(),this.#T(),this.#R(),this.removeEventListener("click",this.#O),this.addEventListener("click",this.#O),this.removeEventListener("pointerdown",this.#k,!0),this.addEventListener("pointerdown",this.#k,!0),T(this),!this.#Y)this.#Y=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let j=$.attributeName;if(j==="label"||j==="direction"||j==="aria-label")Q=!0;else Z=!0}if(Q)this.#z();if(Z)this.#T()});this.#Y.observe(this,{attributes:!0})}disconnectedCallback(){this.#Y?.disconnect(),this.#H(),this.removeEventListener("click",this.#O),this.removeEventListener("pointerdown",this.#k,!0),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#z();return}if(J==="options"||J==="value")this.#T()}#L(){this.#N=this.getAttribute("value")??"";let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label");this.#_=A.#U();let $=document.createElement(this.#_?"fig-select":"fig-dropdown");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#X=Boolean(J),this.replaceChildren(Q)}#z(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#X)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#S(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full","default"]);if(!this.#_)J.add("options");return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#F(){if(!this.#J||this.#_)return;let J=A.#P(this.getAttribute("options"));for(let Z of[...this.#J.children])if(Z.localName==="option"||Z.localName==="optgroup")Z.remove();for(let Z of J){let $=document.createElement("option");$.value=A.#M(Z),$.textContent=A.#K(Z),this.#J.appendChild($)}let Q=this.getAttribute("value");if(Q!=null){let Z=()=>{if(this.#J?.setAttribute("value",Q),this.#J&&"value"in this.#J)this.#J.value=Q};Z(),queueMicrotask(Z)}}#T(){if(!this.#J)return;if(!this.#_)this.#F();let J=this.#S().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.#B)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#B=Q}#R(){if(!this.#J)return;if(this.#$??=this.#W.bind(this,"input"),this.#q??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#$),this.#J.addEventListener("change",this.#q),this.#_)this.#j??=this.#W.bind(this,"optionhover"),this.#J.addEventListener("optionhover",this.#j)}#H(){if(!this.#J)return;if(this.#$)this.#J.removeEventListener("input",this.#$);if(this.#q)this.#J.removeEventListener("change",this.#q);if(this.#j)this.#J.removeEventListener("optionhover",this.#j)}#W(J,Q){if(Q.target!==this.#J)return;Q.stopImmediatePropagation();let Z=this.#J?.value??"";if(J!=="optionhover")this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#y(){if(!this.#J||!this.#_)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"))}#A(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select, fig-dropdown")){this.#G=!1;return}if(!this.#_)return;this.#G=this.#y()}#V(J){if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select, fig-dropdown")){this.#G=!1;return}if(!this.#J||N(this.#J,"disabled")){this.#G=!1;return}if(this.#J.focus(),!this.#_)return;if(this.#G||this.#y()){this.#G=!1,this.#J.open=!1;return}this.#J.open=!0}get value(){return 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.#N??""}get isDefault(){return b(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;if(this.value=J,this.#J)this.#J.value=J;I(this,J)}focus(J){this.#J?.focus(J)}}M("propskit-select",A);class d extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=null;#$=null;#q=this.#K.bind(this);#j=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#O();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#P(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#O(){this.#j=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=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-text");for(let _ of J)if(_!==Q)j.appendChild(_);Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z)}#k(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#G(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","multiline","resizable","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#U(){if(!this.#J)return;this.#B??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.value??"";this.setAttribute("value",String(Z));let $=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:Z;this.dispatchEvent(new CustomEvent(J,{detail:$,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){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.#j??""}get isDefault(){return b(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,I(this,J)}focus(J){this.#J?.focus(J)}}M("propskit-text",d);class i extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=null;#$=null;#q=this.#K.bind(this);#j=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#O();if(this.#k(),this.#N(),this.#U(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#k();if(Z)this.#N()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#P(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#O(){this.#j=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=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-input-number");Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z);for(let _ of J)if(_!==Q)j.appendChild(_)}#k(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#G(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#N(){if(!this.#J)return;let J=this.#G(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#U(){if(!this.#J)return;this.#B??=this.#M.bind(this,"input"),this.#$??=this.#M.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#P(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#M(J,Q){Q.stopImmediatePropagation();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;if(this.#J?.value!==void 0)this.setAttribute("value",String(this.#J.value));this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#K(J){if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.focus()}get value(){return 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.#j??"0"}get isDefault(){return b(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,I(this,this.#J?.value??J)}focus(J){this.#J?.focus(J)}}M("propskit-number",i);class a extends HTMLElement{static observedAttributes=["x","y","default","label","units","disabled","size"];#Z=null;#Q=null;#J=null;#_=null;#X=!1;#Y=!1;#B=this.#F.bind(this,"input");#$=this.#F.bind(this,"change");#q=this.#T.bind(this);connectedCallback(){if(!this.#X)this.#_=this.#O(),this.#G(this.#_),this.#X=!0;if(!this.#Z)this.#U();this.#P(),this.#M(),this.#z(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),T(this)}disconnectedCallback(){this.#S(),this.removeEventListener("click",this.#q),f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#X)return;if((J==="x"||J==="y")&&!this.#Y)this.#M();else if(J==="label")this.#P();else if(J==="units")this.#K();else if(J==="disabled")this.#L()}#j(J,Q=50){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#O(){let J=this.getAttribute("x"),Q=this.getAttribute("y");return{x:J===null||!J.trim()?50:this.#j(J,50),y:Q===null||!Q.trim()?50:this.#j(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.#j(Q.x,this.#_?.x??50),y:this.#j(Q.y,this.#_?.y??50)}}catch{return null}}#G(J){let Q=this.#O(),Z={x:this.#j(J?.x,Q.x),y:this.#j(J?.y,Q.y)};return this.#Y=!0,this.setAttribute("x",String(Z.x)),this.setAttribute("y",String(Z.y)),this.#Y=!1,Z}#N(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($),N(this,"disabled"))Z.setAttribute("disabled","");return Z}#U(){let J=this.#O(),Q=document.createElement("fig-field");Q.className="propskit-position-row",Q.setAttribute("direction","horizontal");let Z=document.createElement("label"),$=this.#N("x",J.x),j=this.#N("y",J.y);Q.append(Z,$,j),this.#Z=Q,this.#Q=$,this.#J=j,this.replaceChildren(Q),T(this)}#P(){let J=this.#Z?.querySelector(":scope > label");if(!J)return;let Q=this.getAttribute("label");J.textContent=Q?.trim()||"Position"}#M(){let J=this.#O();this.#Q?.setAttribute("value",String(J.x)),this.#J?.setAttribute("value",String(J.y)),this.#K(),this.#L()}#K(){let J=this.units==="percent"?"%":null;for(let Q of[this.#Q,this.#J]){if(!Q)continue;if(J)Q.setAttribute("units",J);else Q.removeAttribute("units")}}#L(){let J=N(this,"disabled");this.#Q?.toggleAttribute("disabled",J),this.#J?.toggleAttribute("disabled",J)}#z(){this.#S(),this.#Q?.addEventListener("input",this.#B),this.#Q?.addEventListener("change",this.#$),this.#J?.addEventListener("input",this.#B),this.#J?.addEventListener("change",this.#$)}#S(){this.#Q?.removeEventListener("input",this.#B),this.#Q?.removeEventListener("change",this.#$),this.#J?.removeEventListener("input",this.#B),this.#J?.removeEventListener("change",this.#$)}#F(J,Q){if(Q.stopImmediatePropagation(),N(this,"disabled"))return;let Z=Q.currentTarget?.getAttribute("data-propskit-position-axis");if(Z!=="x"&&Z!=="y")return;let $=this.value;$[Z]=this.#j(Q.currentTarget.value,$[Z]);let j=this.#G($);this.dispatchEvent(new CustomEvent(J,{detail:{...j,units:this.units},bubbles:!0,cancelable:!0,composed:!0}))}#T(J){if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.focus()}get x(){return this.#O().x}set x(J){this.setAttribute("x",String(this.#j(J,50)))}get y(){return this.#O().y}set y(J){this.setAttribute("y",String(this.#j(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.#O()}}set value(J){let Q=this.#G(J);this.#M(Q)}get defaultValue(){return this.#k(this.getAttribute("default"))||{...this.#_||{x:50,y:50}}}get isDefault(){return c(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.value=J,I(this,{...J,units:this.units})}focus(J){this.#Q?.focus(J)}}M("propskit-position",a);class t extends HTMLElement{static observedAttributes=["label","collapsible","open","size","value"];#Z=null;#Q=null;#J=null;#_=!1;#X=!1;#Y=!1;#B=this.#K.bind(this,"input");#$=this.#K.bind(this,"change");#q=this.#L.bind(this);connectedCallback(){if(!this.#_)this.#G(this.#k()),this.#_=!0;if(!this.#Z)this.#N();this.#U(),this.#P(),this.#M(this.#k()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.addEventListener("change",this.#$),this.removeEventListener("openchange",this.#q),this.addEventListener("openchange",this.#q)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.removeEventListener("openchange",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#_)return;if(J==="value"){if(!this.#X){let $=this.#G(this.#k());this.#M($)}return}if(J==="size"){this.#P();return}this.#U()}#j(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.#j(Q.x,50),y:this.#j(Q.y,50),color:typeof Q.color==="string"&&Q.color.trim()?Q.color.trim():"#D9D9D9"}}#k(){return this.#O(this.getAttribute("value"))}#G(J){let Q=this.#O(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#X=!0,this.setAttribute("value",Z),this.#X=!1,Q}#N(){let J=this.#k(),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.#Z=Q,this.#Q=Z,this.#J=$,this.#U(),this.#P(),Q.append(Z,$),this.replaceChildren(Q)}#U(){if(!this.#Z)return;this.#Z.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#Z.setAttribute("name",J);else this.#Z.removeAttribute("name");if(this.#Z.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#Z.setAttribute("open",String(this.open));else this.#Z.removeAttribute("open")}#P(){let J=this.getAttribute("size");for(let Q of[this.#Q,this.#J]){if(!Q)continue;if(J===null)Q.removeAttribute("size");else Q.setAttribute("size",J)}}#M(J){let Q=this.#O(J);if(this.#Q)this.#Q.value=Q.color;if(this.#J)this.#J.value={x:Q.x,y:Q.y}}#K(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-color-point-control]");if(!Z||!this.contains(Z))return;Q.stopImmediatePropagation();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.#j(Z.value?.x,$.x),$.y=this.#j(Z.value?.y,$.y);else return;let _=this.#G($);this.dispatchEvent(new CustomEvent(J,{detail:{..._,units:"percent"},bubbles:!0,cancelable:!0,composed:!0}))}#L(J){if(J.target!==this.#Z||this.#Y)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#Y=!0,this.setAttribute("open",String(Q)),this.#Y=!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.#k()}}set value(J){let Q=this.#G(J);this.#M(Q)}focus(J){this.#Q?.focus(J)}}M("propskit-color-point",t);class n extends HTMLElement{static observedAttributes=["label","collapsible","open","size","units","value"];#Z=null;#Q=null;#J=null;#_=!1;#X=!1;#Y=!1;#B=this.#F.bind(this,"input");#$=this.#F.bind(this,"change");#q=this.#T.bind(this);connectedCallback(){if(!this.#_)this.#N(this.#G()),this.#_=!0;if(!this.#Z)this.#P();this.#M(),this.#K(),this.#L(),this.#z(this.#G()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.addEventListener("change",this.#$),this.removeEventListener("openchange",this.#q),this.addEventListener("openchange",this.#q)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.removeEventListener("openchange",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#_)return;if(J==="value"){if(!this.#X){let $=this.#N(this.#G());this.#z($)}return}if(J==="size"){this.#K();return}if(J==="units"){this.#L();return}this.#M()}#j(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.#j(J,0)}#k(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.#j(Q.x,50),y:this.#j(Q.y,50),radius:this.#O(Q.radius)}}#G(){return this.#k(this.getAttribute("value"))}#N(J){let Q=this.#k(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#X=!0,this.setAttribute("value",Z),this.#X=!1,Q}#U(J){let Q=typeof J==="string"&&J.trim().endsWith("%");return{value:Q?Number.parseFloat(J):J,units:Q?"%":"px"}}#P(){let J=this.#G(),Q=this.#U(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=Z,this.#Q=$,this.#J=j,this.#M(),this.#K(),Z.append($,j),this.replaceChildren(Z)}#M(){if(!this.#Z)return;this.#Z.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#Z.setAttribute("name",J);else this.#Z.removeAttribute("name");if(this.#Z.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#Z.setAttribute("open",String(this.open));else this.#Z.removeAttribute("open")}#K(){let J=this.getAttribute("size");for(let Q of[this.#Q,this.#J]){if(!Q)continue;if(J===null)Q.removeAttribute("size");else Q.setAttribute("size",J)}}#L(){if(this.hasAttribute("units"))this.#Q?.setAttribute("units",this.units);else this.#Q?.removeAttribute("units");if(this.units==="percent")this.#J?.setAttribute("units","%");else this.#J?.removeAttribute("units")}#z(J){let Q=this.#k(J);if(this.#Q)this.#Q.value={x:Q.x,y:Q.y};if(this.#J){let Z=this.#U(Q.radius);this.#J.value=Z.value}}#S(J,Q){let Z=this.#U(Q).value,$=this.#j(J.value,Z);return(J.querySelector("fig-input-number")?.getAttribute("units")||J.getAttribute("units"))==="%"?`${$}%`:$}#F(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-radius-control]");if(!Z||!this.contains(Z))return;Q.stopImmediatePropagation();let $=this.value,j=Z.getAttribute("data-propskit-point-radius-control");if(j==="position")$.x=this.#j(Z.value?.x,$.x),$.y=this.#j(Z.value?.y,$.y);else if(j==="radius")$.radius=this.#S(Z,$.radius);else return;let _=this.#N($);this.dispatchEvent(new CustomEvent(J,{detail:{..._,radius:this.#U(_.radius).value,units:this.units},bubbles:!0,cancelable:!0,composed:!0}))}#T(J){if(J.target!==this.#Z||this.#Y)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#Y=!0,this.setAttribute("open",String(Q)),this.#Y=!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.#N(J);this.#z(Q)}focus(J){this.#Q?.focus(J)}}M("propskit-point-radius",n);class e extends HTMLElement{static observedAttributes=["label","collapsible","open","size","units","value"];#Z=null;#Q=null;#J=null;#_=null;#X=!1;#Y=!1;#B=!1;#$=this.#T.bind(this,"input");#q=this.#T.bind(this,"change");#j=this.#R.bind(this);connectedCallback(){if(!this.#X)this.#U(this.#N()),this.#X=!0;if(!this.#Z)this.#M();this.#K(),this.#L(),this.#z(),this.#S(this.#N()),this.removeEventListener("input",this.#$),this.addEventListener("input",this.#$),this.removeEventListener("change",this.#q),this.addEventListener("change",this.#q),this.removeEventListener("openchange",this.#j),this.addEventListener("openchange",this.#j)}disconnectedCallback(){this.removeEventListener("input",this.#$),this.removeEventListener("change",this.#q),this.removeEventListener("openchange",this.#j)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#X)return;if(J==="value"){if(!this.#Y){let $=this.#U(this.#N());this.#S($)}return}if(J==="size"){this.#L();return}if(J==="units"){this.#z();return}this.#K()}#O(J,Q){let Z=Number(J);return Number.isFinite(Z)?Z:Q}#k(J){if(typeof J==="string"&&J.trim().endsWith("%")){let Q=Number.parseFloat(J);if(Number.isFinite(Q))return`${Q}%`}return this.#O(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.#O(Q.x,50),y:this.#O(Q.y,50),radius:this.#k(Q.radius),angle:this.#O(Q.angle,0)}}#N(){return this.#G(this.getAttribute("value"))}#U(J){let Q=this.#G(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#Y=!0,this.setAttribute("value",Z),this.#Y=!1,Q}#P(J){let Q=typeof J==="string"&&J.trim().endsWith("%");return{value:Q?Number.parseFloat(J):J,units:Q?"%":"px"}}#M(){let J=this.#N(),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=Z,this.#Q=$,this.#J=j,this.#_=_,this.#K(),this.#L(),Z.append($,j,_),this.replaceChildren(Z)}#K(){if(!this.#Z)return;this.#Z.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#Z.setAttribute("name",J);else this.#Z.removeAttribute("name");if(this.#Z.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#Z.setAttribute("open",String(this.open));else this.#Z.removeAttribute("open")}#L(){let J=this.getAttribute("size");for(let Q of[this.#Q,this.#J,this.#_]){if(!Q)continue;if(J===null)Q.removeAttribute("size");else Q.setAttribute("size",J)}}#z(){if(this.hasAttribute("units"))this.#Q?.setAttribute("units",this.units);else this.#Q?.removeAttribute("units");if(this.units==="percent")this.#J?.setAttribute("units","%");else this.#J?.removeAttribute("units")}#S(J){let Q=this.#G(J);if(this.#Q)this.#Q.value={x:Q.x,y:Q.y};if(this.#J){let Z=this.#P(Q.radius);this.#J.value=Z.value}if(this.#_)this.#_.value=Q.angle}#F(J,Q){let Z=this.#P(Q).value,$=this.#O(J.value,Z);return(J.querySelector("fig-input-number")?.getAttribute("units")||J.getAttribute("units"))==="%"?`${$}%`:$}#T(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-radius-angle-control]");if(!Z||!this.contains(Z))return;Q.stopImmediatePropagation();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.#F(Z,$.radius);else if(j==="angle")$.angle=this.#O(Z.value,$.angle);else return;let _=this.#U($);this.dispatchEvent(new CustomEvent(J,{detail:{..._,radius:this.#P(_.radius).value,units:this.units},bubbles:!0,cancelable:!0,composed:!0}))}#R(J){if(J.target!==this.#Z||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.#N()}}set value(J){let Q=this.#U(J);this.#S(Q)}focus(J){this.#Q?.focus(J)}}M("propskit-point-radius-angle",e);class JJ extends HTMLElement{static observedAttributes=["label","collapsible","open","size","units","value"];#Z=null;#Q=null;#J=null;#_=!1;#X=!1;#Y=!1;#B=this.#z.bind(this,"input");#$=this.#z.bind(this,"change");#q=this.#S.bind(this);connectedCallback(){if(!this.#_)this.#G(this.#k()),this.#_=!0;if(!this.#Z)this.#U();this.#P(),this.#M(),this.#K(),this.#L(this.#k()),this.removeEventListener("input",this.#B),this.addEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.addEventListener("change",this.#$),this.removeEventListener("openchange",this.#q),this.addEventListener("openchange",this.#q)}disconnectedCallback(){this.removeEventListener("input",this.#B),this.removeEventListener("change",this.#$),this.removeEventListener("openchange",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#_)return;if(J==="value"){if(!this.#X){let $=this.#G(this.#k());this.#L($)}return}if(J==="size"){this.#M();return}if(J==="units"){this.#K();return}this.#P()}#j(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.#j(Q.x,50),y:this.#j(Q.y,50),x2:this.#j(Q.x2,75),y2:this.#j(Q.y2,75)}}#k(){return this.#O(this.getAttribute("value"))}#G(J){let Q=this.#O(J),Z=JSON.stringify(Q);if(this.getAttribute("value")===Z)return Q;return this.#X=!0,this.setAttribute("value",Z),this.#X=!1,Q}#N(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}#U(){let J=this.#k(),Q=document.createElement("fig-group"),Z=this.#N("Start","start",J.x,J.y),$=this.#N("End","end",J.x2,J.y2);Q.setAttribute("compact",""),this.#Z=Q,this.#Q=Z,this.#J=$,this.#P(),this.#M(),Q.append(Z,$),this.replaceChildren(Q)}#P(){if(!this.#Z)return;this.#Z.setAttribute("compact","");let J=this.getAttribute("label")?.trim();if(J)this.#Z.setAttribute("name",J);else this.#Z.removeAttribute("name");if(this.#Z.toggleAttribute("collapsible",this.collapsible),this.collapsible)this.#Z.setAttribute("open",String(this.open));else this.#Z.removeAttribute("open")}#M(){let J=this.getAttribute("size");for(let Q of[this.#Q,this.#J]){if(!Q)continue;if(J===null)Q.removeAttribute("size");else Q.setAttribute("size",J)}}#K(){for(let J of[this.#Q,this.#J]){if(!J)continue;if(this.hasAttribute("units"))J.setAttribute("units",this.units);else J.removeAttribute("units")}}#L(J){let Q=this.#O(J);if(this.#Q)this.#Q.value={x:Q.x,y:Q.y};if(this.#J)this.#J.value={x:Q.x2,y:Q.y2}}#z(J,Q){if(Q.target===this)return;let Z=Q.target?.closest?.("[data-propskit-point-point-control]");if(!Z||!this.contains(Z))return;Q.stopImmediatePropagation();let $=this.value,j=Z.value,_=Z.getAttribute("data-propskit-point-point-control");if(_==="start")$.x=this.#j(j?.x,$.x),$.y=this.#j(j?.y,$.y);else if(_==="end")$.x2=this.#j(j?.x,$.x2),$.y2=this.#j(j?.y,$.y2);else return;let X=this.#G($);this.dispatchEvent(new CustomEvent(J,{detail:{...X,units:this.units},bubbles:!0,cancelable:!0,composed:!0}))}#S(J){if(J.target!==this.#Z||this.#Y)return;J.stopImmediatePropagation();let Q=Boolean(J.detail?.open);this.#Y=!0,this.setAttribute("open",String(Q)),this.#Y=!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.#G(J);this.#L(Q)}focus(J){this.#Q?.focus(J)}}M("propskit-point-point",JJ);class h extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-gradient","propskit-number","propskit-position","propskit-select","propskit-slider","propskit-switch","propskit-text","propskit-oscillator"].join(",");#Q=null;#J=null;#_=null;#X=null;#Y=0;#B=()=>this.#j();connectedCallback(){this.#T(),this.#$(),requestAnimationFrame(()=>{this.#K()})}disconnectedCallback(){if(this.#q(),this.#Y)cancelAnimationFrame(this.#Y),this.#Y=0;this.#Q?.removeEventListener("click",this.#k),this.#Q?.removeEventListener("keydown",this.#G),this.#_?.querySelector("fig-button")?.removeEventListener("click",this.#N)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}if(J==="show-reset"){this.#S(),this.#K();return}this.#T()}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.#Q?.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.#z()}#$(){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.#X)this.#X=new MutationObserver(()=>{this.#j()});this.#X.disconnect(),this.#X.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","checked","default","x","y"]})}#q(){this.removeEventListener("input",this.#B,!0),this.removeEventListener("change",this.#B,!0),this.#X?.disconnect()}#j(){if(this.#Y)return;this.#Y=requestAnimationFrame(()=>{this.#Y=0,this.#K()})}#O(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#k=(J)=>{if(this.#O(J.target))return;J.stopPropagation(),this.open=!this.open};#G=(J)=>{if(this.#O(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#N=(J)=>{J.preventDefault(),J.stopPropagation(),this.#z()};#U(){return[...this.querySelectorAll(h.#Z)].filter((J)=>J.closest("propskit-group")===this&&!J.parentElement?.closest(h.#Z))}#P(J){return J.isDefault===!1}#M(){for(let J of this.#U())if(this.#P(J))return!0;return!1}#K(){if(this.#M())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#S()}#L(J){if(typeof J.resetToDefault==="function")J.resetToDefault()}#z(){for(let J of this.#U())this.#L(J);this.#K(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#S(){if(!this.showReset){this.#_?.setAttribute("hidden","");return}this.#F(),this.#_?.removeAttribute("hidden")}#F(){if(!this.#Q||!this.showReset)return;let J=this.#Q.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.#Q.appendChild(J),Q.addEventListener("click",this.#N)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#N),Q?.addEventListener("click",this.#N)}this.#_=J}#T(){let Q=this.getAttribute("name")||"Group",Z=this.querySelector(":scope > fig-header");if(Z)this.#Q=Z;else if(!this.#Q||!this.#Q.dataset.generated||this.#Q.parentElement!==this)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector(":scope > h3"),j=this.#Q.querySelector(":scope > fig-button.propskit-group-disclosure");if(!$&&j){if($=j.querySelector(":scope > h3"),$)this.#Q.insertBefore($,j);j.remove()}if(!$)$=document.createElement("h3"),this.#Q.prepend($);let _=$.querySelector(":scope > button.propskit-group-disclosure");if(_){while(_.firstChild)$.insertBefore(_.firstChild,_);_.remove()}if(!$.id)$.id=BJ("propskit-group");if(this.#Q.dataset.generated){let X=$.querySelector(".propskit-group-chevron");if($.textContent=Q,X)$.prepend(X)}if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",$.id);if(!$.querySelector(".propskit-group-chevron")){let X=document.createElement("fig-icon");X.setAttribute("name","chevron"),X.setAttribute("size","small"),X.className="propskit-group-chevron",$.prepend(X)}if(this.#J=$.querySelector(".propskit-group-chevron"),this.#S(),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("click",this.#k),this.#Q.addEventListener("click",this.#k),this.#Q.removeEventListener("keydown",this.#G),this.#Q.addEventListener("keydown",this.#G),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}M("propskit-group",h);class QJ extends HTMLElement{#Z=null;#Q=null;#J=null;#_=!1;#X=null;#Y=new Set;#B=0;#$=0;#q=null;#j=null;#O=0;#k=null;#G=null;#N=!1;#U=0;#P=null;#M=0;#K=null;#L=null;#z=0;#S=0;#F=!1;#T=!1;#R=0;#H=null;#W=null;#y=this.#a.bind(this);#A=this.#YJ.bind(this);#V=this.#$J.bind(this);#f=this.#OJ.bind(this);#x=this.#zJ.bind(this);#C=this.#d.bind(this);#o=this.#SJ.bind(this);#b=this.#TJ.bind(this);#D=this.#FJ.bind(this);#I=this.#l.bind(this);#v=new Set(["variant","color","text","full","elastic","size","name","class","data-wave-index","data-active","data-elastic-dragging","style"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#E();if(this.#r(),this.#u(),this.#p(),this.#BJ(),this.removeEventListener("pointerdown",this.#y,{capture:!0}),this.addEventListener("pointerdown",this.#y,{capture:!0,passive:!0}),this.removeEventListener("pointerdown",this.#f,{capture:!0}),this.addEventListener("pointerdown",this.#f,{capture:!0}),this.removeEventListener("contextmenu",this.#b),this.addEventListener("contextmenu",this.#b),this.removeEventListener("click",this.#I,!0),this.addEventListener("click",this.#I,!0),this.#j?.removeEventListener("change",this.#D),this.#j?.addEventListener("change",this.#D),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName==="value"){this.#h();continue}if($.attributeName==="color"){Z=!0;continue}if($.attributeName&&this.#v.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#r();if(Z)this.#u(),this.#BJ()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#X?.disconnect(),this.#B)cancelAnimationFrame(this.#B),this.#B=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#kJ(),this.#t(),clearTimeout(this.#R),this.#R=0,this.#GJ(),this.#n(),this.#qJ(),this.#s(),this.removeEventListener("pointerdown",this.#y,{capture:!0}),this.removeEventListener("pointerdown",this.#f,{capture:!0}),this.removeEventListener("contextmenu",this.#b),this.removeEventListener("click",this.#I,!0),this.#j?.removeEventListener("change",this.#D)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#r()}#E(){this.#G=this.getAttribute("value")??this.getAttribute("min")??"0";let J=Array.from(this.childNodes).filter((_)=>{return _.nodeType!==Node.TEXT_NODE||Boolean(_.textContent?.trim())}),Q=J.find((_)=>_.nodeType===Node.ELEMENT_NODE&&_.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),j=document.createElement("fig-slider");j.setAttribute("text","true");for(let _ of this.#XJ()){let X=this.getAttribute(_);j.setAttribute(_,X??"")}Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#_=Boolean(Q),this.replaceChildren(Z),this.#c();for(let _ of J){if(_===Q)continue;this.#J.appendChild(_)}}#c(){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.#D),this.#j=J,this.appendChild(J)}#r(){if(!this.#Z||!this.#Q)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Q.parentElement===this.#Z)this.#Q.remove()}else{if(!this.#_)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#u(){if(!this.#J)return;let J=this.#XJ(),Q=new Set(J.filter(($)=>$!=="text"&&$!=="value"));for(let $ of this.#Y)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"||Z==="stepper")this.#J.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))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.#i(Z),this.#Y=Q,this.#h(),this.#UJ()}#i(J){let Q=this.#J?.querySelector("fig-input-number");if(!Q)return;if(J!=="opacity"||!this.hasAttribute("color")){Q.removeAttribute("theme");return}let Z=XJ(this.#J,this.getAttribute("color"));if(Z)Q.setAttribute("theme",Z);else Q.removeAttribute("theme")}#h(){if(!this.#J)return;let J=this.getAttribute("value")??"";if(String(this.#J.value)!==J)this.#J.value=J}#XJ(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#v.has(Q))}#UJ(){if(this.#B)cancelAnimationFrame(this.#B);this.#B=requestAnimationFrame(()=>{this.#B=0,this.#_J(),this.#QJ()})}#BJ(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#QJ()})}#QJ(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#q)this.#LJ(J);if(J){J.removeAttribute("tabindex"),J.removeAttribute("aria-hidden");let Z=this.getAttribute("aria-label")||this.#Q?.textContent?.trim()||"Slider";if(!J.hasAttribute("aria-label")&&!J.hasAttribute("aria-labelledby"))J.setAttribute("aria-label",Z)}if(Q)Q.removeAttribute("tabindex"),Q.removeAttribute("aria-hidden")}#l(J){if(N(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}this.#ZJ()}#ZJ(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!N(this,"disabled"))this.focus()})})}#LJ(J){if(this.#qJ(),this.#q=J,!this.#q)return;this.#q.addEventListener("dblclick",this.#o,{capture:!0})}#qJ(){if(!this.#q)return;this.#q.removeEventListener("dblclick",this.#o,{capture:!0}),this.#q=null}#SJ(J){J.preventDefault(),J.stopImmediatePropagation(),this.#PJ()}#OJ(J){if(J.button!==0||J.altKey||N(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.#t(),this.#L=J.pointerId,this.#z=J.clientX,this.#S=J.clientY,this.#F=!1,window.addEventListener("pointermove",this.#x),window.addEventListener("pointerup",this.#C,{once:!0}),window.addEventListener("pointercancel",this.#C,{once:!0}),window.addEventListener("blur",this.#C,{once:!0})}#zJ(J){if(J.pointerId!==this.#L)return;if(J.buttons===0){this.#d(J);return}if(!this.#F){if(Math.hypot(J.clientX-this.#z,J.clientY-this.#S)<4)return;this.#F=!0,this.setAttribute("data-number-scrubbing","")}this.#jJ(this.#NJ(J),"input")}#d(J){if(J?.pointerId!==void 0&&this.#L!==null&&J.pointerId!==this.#L)return;let Q=this.#F;if(this.#t(),Q){this.#jJ(this.#J?.value,"change"),this.#T=!0,clearTimeout(this.#R),this.#R=window.setTimeout(()=>{this.#T=!1,this.#R=0},0),this.#ZJ();return}this.#J?.querySelector("fig-input-number input")?.focus()}#t(){window.removeEventListener("pointermove",this.#x),window.removeEventListener("pointerup",this.#C),window.removeEventListener("pointercancel",this.#C),window.removeEventListener("blur",this.#C),this.#L=null,this.#F=!1,this.removeAttribute("data-number-scrubbing")}#a(J){if(J.button!==0||N(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#q;if(!Q)return;this.#GJ(),this.#n(),this.#q=Q,this.#N=!0,this.#K=J.pointerId,this.#U=this.#WJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#P={left:Z.left,right:Z.right,width:Z.width},this.#M=$.width,window.addEventListener("pointermove",this.#A,{passive:!0}),window.addEventListener("pointerup",this.#V,{once:!0}),window.addEventListener("pointercancel",this.#V,{once:!0}),window.addEventListener("blur",this.#V,{once:!0})}#YJ(J){if(!this.#N)return;if(J.pointerId!==this.#K)return;if(J.buttons===0){this.#$J(J);return}this.#w(J.clientX)}#$J(J){if(J?.pointerId!==void 0&&this.#K!==null&&J.pointerId!==this.#K)return;let Q=J?.type==="pointerup"||J?.type==="pointermove"&&J.buttons===0;if(this.#GJ(),this.#n(),Q)this.#ZJ()}#GJ(){window.removeEventListener("pointermove",this.#A),window.removeEventListener("pointerup",this.#V),window.removeEventListener("pointercancel",this.#V),window.removeEventListener("blur",this.#V),this.#N=!1,this.#K=null}#TJ(J){if(N(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#kJ(),this.#KJ(J.clientX,J.clientY)}#KJ(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.#j?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#FJ(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#PJ()}#kJ(){if(this.#O)clearTimeout(this.#O),this.#O=0;this.#k=null}#WJ(){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}#w(J){let Q=this.#P;if(!Q||!this.#U){this.#n();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#e();return}let $=Math.max(-this.#U,Math.min(this.#U,Z*0.5)),j=Math.abs($),_=this.#M?(this.#M+j)/this.#M: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")}#n(){this.#e(),this.#U=0,this.#P=null,this.#M=0,this.#K=null}#e(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#NJ(J){let Q=this.#q;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),O=j+(_-j)*$;if(!X)return String(O);let B=Math.round((O-j)/X)*X+j,q=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(q)))}#MJ(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.#G??this.#q?.min??"0"}#PJ(){this.#kJ(),this.#jJ(this.#MJ(),"input"),this.#jJ(this.#MJ(),"change")}#jJ(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.setAttribute("value",String(this.#J.value)),this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#_J(){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??"")}#p(){if(!this.#J)return;if(!this.#H)this.#H=this.#g.bind(this,"input");if(!this.#W)this.#W=this.#g.bind(this,"change");this.#J.addEventListener("input",this.#H),this.#J.addEventListener("change",this.#W)}#s(){if(!this.#J)return;if(this.#H)this.#J.removeEventListener("input",this.#H);if(this.#W)this.#J.removeEventListener("change",this.#W)}#g(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#n();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;if(this.#J?.value!==void 0){let $=String(this.#J.value);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#QJ();let Q=this.#J?.querySelector('input[type="range"]');Q?.setAttribute("data-propskit-focus-called",""),Q?.focus(J)}get value(){return 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.#MJ()}get isDefault(){return b(this.value,this.defaultValue)}resetToDefault(){this.#PJ()}}M("propskit-slider",QJ);class ZJ extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#_=75;#X=0;#Y=!1;#B=0;#$=null;#q=null;#j=null;#O=null;#k=null;#G=null;#N=null;#U=null;#P=null;#M=!1;#K=!1;#L=!1;#z=!1;#S=null;#F="";#T="";#R=null;#H=null;#W=null;#y="";#A="";#V=null;#f=null;#x=null;get#C(){return this.getAttribute("type")||"point"}get#o(){return this.#C==="point-radius"||this.#C==="point-radius-angle"}get#b(){return this.#C==="point-radius-angle"}get#D(){return this.#C==="point-point"}get#I(){return this.#C==="point-radius-angle"||this.#C==="point-point"}get#v(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#E(){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"}#c(J){let Q=this.#E;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#r(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#u(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#_)}%`}get#i(){return this.getAttribute("drag-surface")||"parent"}get#h(){let J=this.#i;if(J==="parent")return this.parentElement;return this.closest(J)}get#XJ(){let J=this.#i;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#UJ(J){if(this.#Y)return this.#X/100*J;return this.#X}#BJ(){if(this.#Y)return`Radius ${Math.round(this.#X)}%`;return`Radius ${Math.round(this.#X)}`}connectedCallback(){this.#QJ(),this.#l()}disconnectedCallback(){this.#RJ(),this.#DJ(),this.#qJ(),this.#d(),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.#M&&!this.#K&&!this.#L&&!this.#z)if(this.#QJ(),this.#$)this.#p();else this.#l();if(J==="type")this.#RJ(),this.#QJ(),this.#l();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#RJ(),this.#l();if(J==="tooltips")this.#l();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#q)this.#q.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#G)this.#G.setAttribute("text",this.#r);if(this.#N)this.#N.setAttribute("text",this.#u)}}#QJ(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#Y=!0,this.#X=parseFloat(Z);else this.#Y=!1,this.#X=parseFloat(Z);if(!Number.isFinite(this.#X))this.#X=0}if(typeof Q.angle==="number")this.#B=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#_=Q.y2;if(this.#C==="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.#Z,y:this.#Q};if(this.#C==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#o)J.radius=this.#Y?`${this.#X}%`:this.#X;if(this.#b)J.angle=this.#B;if(this.#D)J.x2=this.#J,J.y2=this.#_;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#l(){this.#RJ(),this.innerHTML="",this.#$=null,this.#q=null,this.#j=null,this.#O=null,this.#k=null,this.#G=null,this.#N=null,this.#U=null,this.#P=null;let J=N(this,"disabled"),Q=this.#C,Z=this.#v,$=this.#XJ,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.#E),j.setAttribute("value",`${this.#Z}% ${this.#Q}%`),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.#D)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#$=j,this.#o)this.#TJ();if(this.#I)this.#KJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#r),_.appendChild(j),this.appendChild(_),this.#G=_}else this.appendChild(j);if(this.#b)this.#kJ(J,Z,$);if(this.#D)this.#WJ(J,Z,$);this.#ZJ(this.#$),this.#ZJ(this.#j),this.#ZJ(this.#q),this.#HJ(),this.#YJ(),requestAnimationFrame(()=>this.#p())}#ZJ(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#zJ(Q,J);else this.#LJ(Q)},{capture:!0})}#LJ(J){if(N(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#S===null)this.#F=document.body.style.getPropertyValue("cursor"),this.#T=document.body.style.getPropertyPriority("cursor");if(this.#S=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#R)this.#R=(Q)=>{if(Q?.pointerId!==void 0&&this.#S!==null&&Q.pointerId!==this.#S)return;if(Q?.type==="blur")this.#qJ();else requestAnimationFrame(()=>this.#qJ())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#qJ(){if(this.#S===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#F)document.body.style.setProperty("cursor",this.#F,this.#T);else document.body.style.removeProperty("cursor");if(this.#S=null,this.#F="",this.#T="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#SJ(J){if(!J)return 0;if(J===this.#j)return this.#B;if(!this.#D)return 0;let Q=this.#PJ();return J===this.#$?Q+180:Q}#OJ(){if(this.#H===null)return;let J=this.#n(this.#SJ(this.#W));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#zJ(J,Q){if(N(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#H===null)this.#y=document.body.style.getPropertyValue("cursor"),this.#A=document.body.style.getPropertyPriority("cursor");if(this.#H=J?.pointerId??-1,this.#W=Q,document.body.classList.add("fig-lab-rotate-active"),this.#OJ(),!this.#V)this.#V=(Z)=>{if(Z?.pointerId!==void 0&&this.#H!==null&&Z.pointerId!==this.#H)return;if(Z?.type==="blur")this.#d();else requestAnimationFrame(()=>this.#d())};window.addEventListener("pointerup",this.#V),window.addEventListener("pointercancel",this.#V),window.addEventListener("blur",this.#V)}#d(){if(this.#H===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.#A);else document.body.style.removeProperty("cursor");if(this.#H=null,this.#W=null,this.#y="",this.#A="",this.#V)window.removeEventListener("pointerup",this.#V),window.removeEventListener("pointercancel",this.#V),window.removeEventListener("blur",this.#V)}#t(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?.()},O=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",O)}#a(){return this.#M||this.#K||this.#L||this.#z}#YJ(){if(this.#$)this.#t(this.#$,()=>this.#G,()=>this.#r,()=>this.#a()||!!this.#$?.querySelector("fig-color-tip"));if(this.#j)this.#t(this.#j,()=>this.#P,()=>`Angle ${Math.round(this.#B)}°`,()=>this.#a());if(this.#q)this.#t(this.#q,()=>this.#N,()=>this.#u,()=>this.#a());if(this.#O){let J=this.#O.querySelector(".fig-canvas-control-radius-hit");this.#GJ(J||this.#O)}if(this.#C==="color"&&this.#$&&this.#G)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#G?.removeAttribute("show"),this.#G?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#$J(J,Q){let Z=this.#U;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?.()}#GJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#BJ()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#$J(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#L)return;this.#$J(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#L)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#TJ(){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.#v){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#BJ()),_.appendChild(Q),this.appendChild(_),this.#U=_}else this.appendChild(Q);this.#fJ(Z)}#KJ(){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.#D){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.#FJ(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.#k=Q,this.appendChild(Q)}#FJ(J){J.addEventListener("pointerdown",(Q)=>{if(N(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#h;if(!Z)return;let{clientX:$,clientY:j}=Q,_=this.#Z,X=this.#Q,O=this.#J,B=this.#_;this.#M=!0,this.#K=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let q=(G)=>{let k=Z.getBoundingClientRect(),K=k.width>0?(G.clientX-$)/k.width*100:0,P=k.height>0?(G.clientY-j)/k.height*100:0,L=-Math.min(_,O),z=100-Math.max(_,O),F=-Math.min(X,B),W=100-Math.max(X,B),S=Math.max(L,Math.min(z,K)),R=Math.max(F,Math.min(W,P));this.#Z=_+S,this.#Q=X+R,this.#J=O+S,this.#_=B+R,this.#p(),this.#s()},Y=this.#CJ((G)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#M=!1,this.#K=!1,G)this.#JJ(),this.#g()});window.addEventListener("pointermove",q,{signal:Y.signal}),window.addEventListener("pointerup",()=>Y.finish(!0),{signal:Y.signal}),window.addEventListener("pointercancel",()=>Y.finish(!1),{signal:Y.signal})})}#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("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),J)$.setAttribute("disabled","");if(this.#j=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",`${Math.round(this.#B)}°`),j.appendChild($),this.appendChild(j),this.#P=j}else this.appendChild($)}#WJ(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.#E),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#_}%`),J)$.setAttribute("disabled","");if(this.#q=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#u),j.appendChild($),this.appendChild(j),this.#N=j}else this.appendChild($)}#w(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`}#n(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`}#e(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#NJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#e(Z,this.#n(Q)),this.#W===J)this.#OJ()}#MJ(){if(!this.#j||!this.#b)return;this.#NJ(this.#j,this.#B)}#PJ(){return Math.atan2(this.#_-this.#Q,this.#J-this.#Z)*180/Math.PI}#jJ(){if(!this.#D)return;let J=this.#PJ();this.#$?.style.removeProperty("cursor"),this.#q?.style.removeProperty("cursor"),this.#NJ(this.#$,J+180),this.#NJ(this.#q,J)}#_J(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`}#p(){let J=this.#h;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#_J(this.#$,this.#Z,this.#Q,Q),this.#O){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#UJ(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 O=_.querySelectorAll("circle");for(let B of O)B.setAttribute("cx",String(j)),B.setAttribute("cy",String(j)),B.setAttribute("r",String(Math.max(j-1,0)))}if(this.#k&&this.#I){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j,_;if(this.#D)j=this.#J/100*Q.width,_=this.#_/100*Q.height;else{let B=this.#UJ(Q.width),q=this.#B*Math.PI/180;j=Z+B*Math.cos(q),_=$+B*Math.sin(q)}let X=this.#k;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 O=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of O)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#j&&this.#b){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#UJ(Q.width),_=this.#B*Math.PI/180,X=Z+j*Math.cos(_),O=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,q=Q.height>0?O/Q.height*100:0;this.#_J(this.#j,B,q,Q)}if(this.#q&&this.#D)this.#_J(this.#q,this.#J,this.#_,Q);this.#MJ(),this.#jJ()}#s(J=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:J}))}#g(J=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:J}))}#VJ(J){return{...this.value,..._J(J.color,J.alpha,J.opacity)}}#JJ(){this.setAttribute("value",JSON.stringify(this.value))}#HJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#s(this.#VJ(J.detail));return}this.#M=!0;let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#G)this.#G.removeAttribute("show"),this.#G.hidePopup?.();this.#p(),this.#s()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#g(this.#VJ(J.detail));return}let Q=J.detail?.px??this.#Z/100,Z=J.detail?.py??this.#Q/100;if(this.#Z=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Q=Math.round(Math.max(0,Math.min(100,Z*100))),this.#G)this.#G.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#M=!1})}),this.#j)this.#j.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#h;if(!Q)return;this.#z=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,j=this.#Q/100*Z.height,_=J.detail?.x??0,X=J.detail?.y??0,O=this.#j.offsetWidth/2,B=this.#j.offsetHeight/2,q=_+O-$,Y=X+B-j,G=Math.atan2(Y,q)*180/Math.PI;if(this.#c(J.detail?.shiftKey))G=Math.round(G/15)*15;this.#B=G;let k=Math.sqrt(q*q+Y*Y);if(this.#c(J.detail?.shiftKey)){let K=this.#Y?5:10;if(this.#Y){let P=k/Z.width*100;P=Math.round(P/K)*K,k=P/100*Z.width}else k=Math.round(k/K)*K}if(this.#Y)this.#X=Math.max(0,k/Z.width*100);else this.#X=Math.max(0,k);if(this.#P)this.#P.setAttribute("text",`Angle ${Math.round(this.#B)}°`),this.#P.setAttribute("show","true"),this.#P.showPopup?.();this.#p(),this.#s()}),this.#j.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#P)this.#P.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#z=!1})}),this.#j.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#h;if(!Z)return;if(this.#z=!0,this.classList.add("fig-canvas-control-ring-active"),this.#j.setAttribute("selected",""),this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),O=this.#Z/100*X.width,B=this.#Q/100*X.height,q=_.clientX-X.left-O,Y=_.clientY-X.top-B,G=Math.atan2(Y,q)*180/Math.PI;if(this.#c(_.shiftKey))G=Math.round(G/15)*15;if(this.#B=G,this.#P)this.#P.setAttribute("text",`Angle ${Math.round(G)}°`);this.#p(),this.#s()},j=this.#CJ((_)=>{if(this.#z=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#j.removeAttribute("selected"),this.#P)this.#P.removeAttribute("show");if(_)this.#JJ(),this.#g()});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.#q)this.#q.addEventListener("input",(J)=>{J.stopPropagation(),this.#K=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#_/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#_=Math.round(Math.max(0,Math.min(100,Z*100))),this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#p(),this.#s()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#N)this.#N.removeAttribute("show");this.#p(),this.#JJ(),this.#g(),requestAnimationFrame(()=>{this.#K=!1})}),this.#m(this.#$,!0),this.#m(this.#q,!1)}#m(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let j=this.#h;if(!j)return;this.#M=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#Z,O=Q?this.#_:this.#Q,B=Q?this.#Z:this.#J,q=Q?this.#Q:this.#_,Y=X/100*_.width,G=O/100*_.height,k=B/100*_.width,K=q/100*_.height,P=Math.sqrt((k-Y)**2+(K-G)**2),L=Q?this.#G:this.#N;if(L)L.removeAttribute("show"),L.hidePopup?.();let z=(W)=>{let S=j.getBoundingClientRect(),R=X/100*S.width,D=O/100*S.height,V=W.clientX-S.left-R,E=W.clientY-S.top-D,H=Math.atan2(E,V);if(this.#c(W.shiftKey))H=Math.round(H*180/Math.PI/15)*15*Math.PI/180;let $J=R+P*Math.cos(H),jJ=D+P*Math.sin(H),w=Math.max(0,Math.min(100,$J/S.width*100)),p=Math.max(0,Math.min(100,jJ/S.height*100));if(Q)this.#Z=w,this.#Q=p;else this.#J=w,this.#_=p;this.#p(),this.#s()},F=this.#CJ((W)=>{if(this.#M=!1,L)L.removeAttribute("show");if(W)this.#JJ(),this.#g()});window.addEventListener("pointermove",z,{signal:F.signal}),window.addEventListener("pointerup",()=>F.finish(!0),{signal:F.signal}),window.addEventListener("pointercancel",()=>F.finish(!1),{signal:F.signal})})}#fJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#L)return;let $=this.#h;if(!$)return;let j=$.getBoundingClientRect(),_=this.#Z/100*j.width,X=this.#Q/100*j.height,O=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#e(J,this.#w(O))});let Q=(Z)=>{if(N(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#h;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#$J(Z.clientX,Z.clientY);if(this.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();let j=this.#j?.style.pointerEvents,_=this.#j?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#j)this.#j.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let O=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),q=this.#Z/100*B.width,Y=this.#Q/100*B.height,G=Math.atan2(Z.clientY-B.top-Y,Z.clientX-B.left-q)*180/Math.PI,k=Math.round(G);document.body.style.cursor=this.#w(k);let K=(L)=>{let z=$.getBoundingClientRect(),F=this.#Z/100*z.width,W=this.#Q/100*z.height,S=L.clientX-z.left-F,R=L.clientY-z.top-W,D=Math.round(Math.atan2(R,S)*180/Math.PI);if(D!==k)k=D,document.body.style.cursor=this.#w(D);let V=Math.sqrt(S*S+R*R);if(this.#c(L.shiftKey)){let E=this.#Y?5:10;if(this.#Y){let H=V/z.width*100;H=Math.round(H/E)*E,V=H/100*z.width}else V=Math.round(V/E)*E}if(this.#Y)this.#X=Math.max(0,V/z.width*100);else this.#X=Math.max(0,V);if(this.#U)this.#U.setAttribute("text",this.#BJ()),this.#$J(L.clientX,L.clientY);this.#p(),this.#s()},P=this.#CJ((L)=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#j)this.#j.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=O,this.#U)this.#U.removeAttribute("show");if(L)this.#JJ(),this.#g()});window.addEventListener("pointermove",K,{signal:P.signal}),window.addEventListener("pointerup",()=>P.finish(!0),{signal:P.signal}),window.addEventListener("pointercancel",()=>P.finish(!1),{signal:P.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#DJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#CJ(J){this.#RJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#f===Q)this.#f=null,this.#x=null;J(j)};return this.#f=Q,this.#x=$,{signal:Q.signal,finish:$}}#RJ(){this.#x?.(!1),this.#f?.abort(),this.#f=null,this.#x=null}}M("fig-canvas-control",ZJ);class U extends HTMLElement{#Z=[U.#W()];#Q=0;#J=2;#_=240;#X=120;#Y={min:-1,max:1};#B=null;#$=null;#q=null;#j=null;#O=0;#k=null;#G=null;#N=null;#U=null;#P=[];#M=[];#K=[];#L=[];#z=new Set;#S=null;#F=null;#T=null;#R=null;#H=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#W(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.#H===null)this.#H=this.getAttribute("default")??this.getAttribute("value")??JSON.stringify({waves:[U.#W()]});this.#J=this.#y("precision",2),this.#C(this.getAttribute("value")),this.#x(),this.#h(),this.#SJ(),T(this)}disconnectedCallback(){if(this.#_J(),this.#GJ(),this.#S)this.#S.disconnect(),this.#S=null;f(this)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#C(Z),this.isConnected)this.#h();return}if(J==="precision"){if(this.#J=this.#y("precision",2),this.isConnected)this.#g();return}if(J==="aspect-ratio"){if(this.#x(),this.#$)this.#YJ();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#h()}}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.#H??""}get isDefault(){let J=this.#o(this.defaultValue);if(!J)return!1;return JSON.stringify(this.data.waves)===JSON.stringify(J.map((Q)=>this.#D(Q)))}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,this.#m("input"),this.#m("change")}get data(){return{waves:this.#Z.map((J)=>this.#D(J))}}get preset(){let J=this.#I;return U.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}#A(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}#V(){return this.getAttribute("edit")!=="false"}#f(){return this.#A("disabled",!1)}#x(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#C(J){let Q=this.#o(J);if(!Q)return!1;if(this.#Z=Q,!this.#Z.length)this.#Z=[U.#W()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#o(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.#b($))}#b(J={}){return{type:this.#v(J.type),frequency:this.#E(J.frequency,1,0.1,16),amplitude:this.#E(J.amplitude,1,-4,4),phase:this.#E(J.phase,0,-360,360),offset:this.#E(J.offset,0,-4,4)}}#D(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||U.#W()}#v(J){let Q=String(J||"").toLowerCase();return U.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#E(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#c(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#r(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#u(J){return U.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let j=Q-10,_="";for(let X=0;X<=32;X++){let O=X/32,B=U.#i(J,O),q=5+O*j,Y=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${q.toFixed(1)},${Y.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${_}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#i(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(_)}}#h(){this.#_J(),this.#GJ(),this.innerHTML=this.#XJ(),this.#ZJ(),this.#OJ(),this.#YJ(),this.#WJ(),this.#$J(),T(this)}#XJ(){let J=this.#V()&&!this.#f(),Q=J?"":" disabled";return`<div class="propskit-oscillator-svg-container">
|
|
4
|
+
<svg viewBox="0 0 ${this.#_} ${this.#X}" class="propskit-oscillator-svg">
|
|
5
|
+
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#_}" height="${this.#X}"></rect>
|
|
6
6
|
<line class="propskit-oscillator-baseline"></line>
|
|
7
7
|
<path class="propskit-oscillator-path"></path>
|
|
8
8
|
<circle class="propskit-oscillator-playhead"></circle>
|
|
@@ -10,9 +10,9 @@ function K(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(
|
|
|
10
10
|
<foreignObject class="propskit-oscillator-handle propskit-oscillator-frequency-handle" data-handle="frequency" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Frequency"><fig-handle size="small" aria-label="Oscillator frequency handle"></fig-handle></fig-tooltip></div></foreignObject>`:""}
|
|
11
11
|
</svg>
|
|
12
12
|
</div>
|
|
13
|
-
${this.#
|
|
13
|
+
${this.#V()?this.#UJ(Q):""}`}#UJ(J){return`<div class="propskit-oscillator-waves">
|
|
14
14
|
${this.#Z.map((Q,Z)=>this.#BJ(Q,Z,J)).join("")}
|
|
15
|
-
</div>`}#BJ(J,Q,Z){let $=Z||this.#Z.length<=1?" disabled":"",j=Q===this.#Q?" data-active":"",_=
|
|
15
|
+
</div>`}#BJ(J,Q,Z){let $=Z||this.#Z.length<=1?" disabled":"",j=Q===this.#Q?" data-active":"",_=U.#u(J.type);return`<fig-group class="propskit-oscillator-wave" collapsible borderless compact="true"${this.#z.has(Q)?' open="true"':' open="false"'} data-wave-index="${Q}">
|
|
16
16
|
<fig-header borderless>
|
|
17
17
|
<h3>${_}</h3>
|
|
18
18
|
<fig-tooltip text="Remove form">
|
|
@@ -26,23 +26,23 @@ function K(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(
|
|
|
26
26
|
${this.#l(Q,"phase","Phase",-360,360,1,"°")}
|
|
27
27
|
${this.#l(Q,"offset","Offset",-4,4,0.1,"")}
|
|
28
28
|
</div>
|
|
29
|
-
</fig-group>`}#QJ(J,Q){let Z=
|
|
30
|
-
${
|
|
29
|
+
</fig-group>`}#QJ(J,Q){let Z=U.TYPES.map((j)=>{return`<fig-menu-item value="${j.value}">
|
|
30
|
+
${U.waveIcon(j.value,24)}
|
|
31
31
|
<span>${j.name}</span>
|
|
32
|
-
</fig-menu-item>`}).join("");return`<fig-menu class="propskit-oscillator-add-type" position="bottom right"${` data-wave-index="${
|
|
32
|
+
</fig-menu-item>`}).join("");return`<fig-menu class="propskit-oscillator-add-type" position="bottom right"${` data-wave-index="${U.#r(String(Q))}"`}${J}>
|
|
33
33
|
<fig-tooltip text="Add form">
|
|
34
34
|
<fig-button class="propskit-oscillator-add-type-button" variant="ghost" icon fig-menu-trigger aria-label="Add form"><fig-icon name="plus"></fig-icon></fig-button>
|
|
35
35
|
</fig-tooltip>
|
|
36
36
|
${Z}
|
|
37
|
-
</fig-menu>`}#l(J,Q,Z,$,j,_,X){let O=this.#H()?" disabled":"",B=Q==="amplitude"||Q==="offset"?' type="delta" default="0"':"",q=X?` units="${P.#r(X)}"`:"",Y=this.#Z[J]||P.#T();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(Y[Q])}" min="${$}" max="${j}" step="${_}" precision="${this.#J}" elastic="false"${B}${q}${O}></propskit-slider>`}#ZJ(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#B=this.querySelector(".propskit-oscillator-path"),this.#q=this.querySelector(".propskit-oscillator-playhead"),this.#k=this.querySelector(".propskit-oscillator-baseline"),this.#G=this.querySelector(".propskit-oscillator-bounds"),this.#N=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#M=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#P=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#S=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#K=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#LJ(J){let Q=new Set;for(let Z of this.#z)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#z=Q}#qJ(J){let Q=new Set;for(let Z of this.#z)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#z=Q}#SJ(){if(this.#L||!window.ResizeObserver)return;this.#L=new ResizeObserver(()=>{if(this.#OJ())this.#YJ()}),this.#L.observe(this)}#OJ(){if(!this.#$)return!1;let J=this.#$.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#_||Z!==this.#j;return this.#_=Q,this.#j=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#zJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#a(Z/Q)));return{min:-J,max:J}}#d(J){let{min:Q,max:Z}=this.#O;return this.#j-(J-Q)/(Z-Q)*this.#j}#t(J){let{min:Q,max:Z}=this.#O;return Q+(1-J/this.#j)*(Z-Q)}#a(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,j=P.#i(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#YJ(){if(!this.#$||!this.#B)return;if(this.#OJ(),this.#O=this.#zJ(),this.#G)this.#G.setAttribute("width",this.#_),this.#G.setAttribute("height",this.#j);let J=Math.max(...this.#Z.map((_)=>_.frequency)),Z=this.#Z.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,O=X*this.#_,B=this.#d(this.#a(X));$+=`${_===0?"M":"L"}${O.toFixed(1)},${B.toFixed(1)}`}this.#B.setAttribute("d",$);let j=this.#d(0);this.#k?.setAttribute("x1","0"),this.#k?.setAttribute("y1",j),this.#k?.setAttribute("x2",this.#_),this.#k?.setAttribute("y2",j),this.#KJ()}#$J(){if(this.#Y||!this.#q)return;let J=(Q)=>{if(!this.isConnected||!this.#q){this.#Y=0;return}this.#TJ(Q%1000/1000),this.#Y=requestAnimationFrame(J)};this.#Y=requestAnimationFrame(J)}#GJ(){if(!this.#Y)return;cancelAnimationFrame(this.#Y),this.#Y=0}#TJ(J){if(!this.#q)return;let Q=J*this.#_,Z=this.#d(this.#a(J));this.#q.setAttribute("cx",Q.toFixed(1)),this.#q.setAttribute("cy",Z.toFixed(1))}#KJ(){let Q=this.#I,Z=this.#FJ(),$=Math.max(8,Math.min(this.#_-8,this.#_/Q.frequency)),j=this.#d(this.#a(Z/this.#_)),_=this.#d(this.#a($/this.#_));this.#kJ(this.#N,Z,j,8),this.#kJ(this.#U,$,_,8)}#FJ(){let J=this.#I,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.#_-8,j*this.#_))}#kJ(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.#R()||this.#H())return;for(let Q of this.#M)Q.addEventListener("change",(Z)=>{if(this.#H())return;let $=this.#w(Q);this.#e($),this.#Z[$].type=this.#v(Z.detail??Z.target?.value),this.#g(),this.#m("input"),this.#m("change")});for(let Q of this.#P)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#E=Q;try{this.#NJ(this.#w(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#E=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#NJ(this.#w(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#S)Q.addEventListener("pointerdown",()=>{this.#e(this.#w(Q))}),Q.addEventListener("focusin",()=>{this.#e(this.#w(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#w(Q);if(Z.detail?.open)this.#z.add($);else this.#z.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.#H())return;let _=this.#w(Q)+1,X=this.#v($.detail?.value??Q.value);this.#Z.splice(_,0,P.#T(X)),this.#qJ(_),this.#Q=_,this.#h(),this.#m("input"),this.#m("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.#H()||this.#Z.length<=1)return;let $=this.#w(Q);this.#Z.splice($,1),this.#LJ($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#h(),this.#m("input"),this.#m("change")});for(let Q of[this.#N,this.#U])this.#n(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#H())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#jJ(Q,"offset")})}#w(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Z.length-1,Math.max(0,Q)):0}#n(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#H())return;$.preventDefault(),$.stopImmediatePropagation(),this.#jJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#H())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#MJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#e(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#HJ(),this.#KJ()}#NJ(J,Q,Z,$){if(this.#H())return;this.#e(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#JJ();return}this.#Z[J]=this.#b({...this.#Z[J],[Q]:j}),this.#g({skipFieldSync:$=="input"}),this.#m($)}#MJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;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.#Z[this.#Q]=this.#b($),this.#g(),this.#m("input"),this.#m("change"),!0}#PJ(J){let Q=this.#$?.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}}#jJ(J,Q){this.#_J(),this.#X=Q,this.#$?.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=(O)=>{if(!this.#X)return;let B=this.#PJ(O),q=this.#I;if(Q==="frequency"){let Y=Math.max(1,Math.min(this.#_,B.x));q.frequency=this.#_/Y}else if(Q==="offset"){let Y=this.#D(B.x/this.#_,0,0,1),G=this.#s(q,Y);q.offset=this.#t(B.y)-this.#p(this.#Q,Y)-G*q.amplitude}else if(Q==="amplitude"){let Y=this.#D(B.x/this.#_,0,0,1),G=this.#s(q,Y),k=this.#t(B.y)-this.#p(this.#Q,Y)-q.offset;q.amplitude=Math.abs(G)<0.001?q.amplitude:k/G}this.#Z[this.#Q]=this.#b(q),this.#g(),this.#m("input")},_=new AbortController,X=(O=!1)=>{if(this.#X=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#W===_)this.#W=null,this.#F=null;if(O)this.#m("change")};this.#W=_,this.#F=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})}#_J(){this.#F?.(!1),this.#W?.abort(),this.#W=null,this.#F=null,this.#X=null,this.#$?.classList.remove("dragging")}#p(J,Q){return this.#Z.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=P.#i($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#s(J,Q){return P.#i(J.type,Q*J.frequency,J.phase)}#g({skipFieldSync:J=!1}={}){if(this.#VJ(),!J)this.#JJ();this.#HJ(),this.#YJ()}#VJ(){for(let J of this.#M){let Q=this.#w(J);J.value=this.#Z[Q]?.type||"sine"}}#JJ(){for(let J of this.#P){if(J===this.#E)continue;let Q=this.#w(J),Z=J.getAttribute("name"),$=this.#c(this.#Z[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#HJ(){for(let J of this.#K)if(this.#w(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#m(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:P.#u(this.#I.type)}}))}}K("propskit-oscillator",P);class b extends HTMLElement{#Z;#Q;#J=null;#_;#j;#O;#X;#$;#B;#q;#Y=null;#k=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.#j=this.#c.bind(this),this.#O=this.#r.bind(this),this.#X=this.#h.bind(this),this.#$=this.#XJ.bind(this),this.#B=this.#x.bind(this),this.#q=this.#i.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.#N("dial",!0),this.showRotations=this.#U(),this.#G(),this.#A(),this.#D(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#u(),this.#R()}#G(){this.#u(),this.#R(),this.innerHTML=this.#P()}#N(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}#U(){if(this.hasAttribute("rotations"))return this.#N("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#N("show-rotations",!1);return!1}#P(){let J=this.#F(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"",$=this.#S(),j=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",_=this.min??this.#T(0),X=this.max??this.#T(360);return`
|
|
37
|
+
</fig-menu>`}#l(J,Q,Z,$,j,_,X){let O=this.#f()?" disabled":"",B=Q==="amplitude"||Q==="offset"?' type="delta" default="0"':"",q=X?` units="${U.#r(X)}"`:"",Y=this.#Z[J]||U.#W();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(Y[Q])}" min="${$}" max="${j}" step="${_}" precision="${this.#J}" elastic="false"${B}${q}${O}></propskit-slider>`}#ZJ(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#q=this.querySelector(".propskit-oscillator-path"),this.#j=this.querySelector(".propskit-oscillator-playhead"),this.#k=this.querySelector(".propskit-oscillator-baseline"),this.#G=this.querySelector(".propskit-oscillator-bounds"),this.#N=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#M=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.#K=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#LJ(J){let Q=new Set;for(let Z of this.#z)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#z=Q}#qJ(J){let Q=new Set;for(let Z of this.#z)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#z=Q}#SJ(){if(this.#S||!window.ResizeObserver)return;this.#S=new ResizeObserver(()=>{if(this.#OJ())this.#YJ()}),this.#S.observe(this)}#OJ(){if(!this.#$)return!1;let J=this.#$.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#_||Z!==this.#X;return this.#_=Q,this.#X=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#zJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#a(Z/Q)));return{min:-J,max:J}}#d(J){let{min:Q,max:Z}=this.#Y;return this.#X-(J-Q)/(Z-Q)*this.#X}#t(J){let{min:Q,max:Z}=this.#Y;return Q+(1-J/this.#X)*(Z-Q)}#a(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,j=U.#i(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#YJ(){if(!this.#$||!this.#q)return;if(this.#OJ(),this.#Y=this.#zJ(),this.#G)this.#G.setAttribute("width",this.#_),this.#G.setAttribute("height",this.#X);let J=Math.max(...this.#Z.map((_)=>_.frequency)),Z=this.#Z.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,O=X*this.#_,B=this.#d(this.#a(X));$+=`${_===0?"M":"L"}${O.toFixed(1)},${B.toFixed(1)}`}this.#q.setAttribute("d",$);let j=this.#d(0);this.#k?.setAttribute("x1","0"),this.#k?.setAttribute("y1",j),this.#k?.setAttribute("x2",this.#_),this.#k?.setAttribute("y2",j),this.#KJ()}#$J(){if(this.#O||!this.#j)return;let J=(Q)=>{if(!this.isConnected||!this.#j){this.#O=0;return}this.#TJ(Q%1000/1000),this.#O=requestAnimationFrame(J)};this.#O=requestAnimationFrame(J)}#GJ(){if(!this.#O)return;cancelAnimationFrame(this.#O),this.#O=0}#TJ(J){if(!this.#j)return;let Q=J*this.#_,Z=this.#d(this.#a(J));this.#j.setAttribute("cx",Q.toFixed(1)),this.#j.setAttribute("cy",Z.toFixed(1))}#KJ(){let Q=this.#I,Z=this.#FJ(),$=Math.max(8,Math.min(this.#_-8,this.#_/Q.frequency)),j=this.#d(this.#a(Z/this.#_)),_=this.#d(this.#a($/this.#_));this.#kJ(this.#N,Z,j,8),this.#kJ(this.#U,$,_,8)}#FJ(){let J=this.#I,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.#_-8,j*this.#_))}#kJ(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.#V()||this.#f())return;for(let Q of this.#M)Q.addEventListener("change",(Z)=>{if(this.#f())return;let $=this.#w(Q);this.#e($),this.#Z[$].type=this.#v(Z.detail??Z.target?.value),this.#g(),this.#m("input"),this.#m("change")});for(let Q of this.#P)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#F=Q;try{this.#NJ(this.#w(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#F=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#NJ(this.#w(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#L)Q.addEventListener("pointerdown",()=>{this.#e(this.#w(Q))}),Q.addEventListener("focusin",()=>{this.#e(this.#w(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#w(Q);if(Z.detail?.open)this.#z.add($);else this.#z.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.#w(Q)+1,X=this.#v($.detail?.value??Q.value);this.#Z.splice(_,0,U.#W(X)),this.#qJ(_),this.#Q=_,this.#h(),this.#m("input"),this.#m("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.#Z.length<=1)return;let $=this.#w(Q);this.#Z.splice($,1),this.#LJ($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#h(),this.#m("input"),this.#m("change")});for(let Q of[this.#N,this.#U])this.#n(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.#jJ(Q,"offset")})}#w(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Z.length-1,Math.max(0,Q)):0}#n(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.#jJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#f())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#MJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#e(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#HJ(),this.#KJ()}#NJ(J,Q,Z,$){if(this.#f())return;this.#e(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#JJ();return}this.#Z[J]=this.#b({...this.#Z[J],[Q]:j}),this.#g({skipFieldSync:$=="input"}),this.#m($)}#MJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;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.#Z[this.#Q]=this.#b($),this.#g(),this.#m("input"),this.#m("change"),!0}#PJ(J){let Q=this.#$?.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}}#jJ(J,Q){this.#_J(),this.#B=Q,this.#$?.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=(O)=>{if(!this.#B)return;let B=this.#PJ(O),q=this.#I;if(Q==="frequency"){let Y=Math.max(1,Math.min(this.#_,B.x));q.frequency=this.#_/Y}else if(Q==="offset"){let Y=this.#E(B.x/this.#_,0,0,1),G=this.#s(q,Y);q.offset=this.#t(B.y)-this.#p(this.#Q,Y)-G*q.amplitude}else if(Q==="amplitude"){let Y=this.#E(B.x/this.#_,0,0,1),G=this.#s(q,Y),k=this.#t(B.y)-this.#p(this.#Q,Y)-q.offset;q.amplitude=Math.abs(G)<0.001?q.amplitude:k/G}this.#Z[this.#Q]=this.#b(q),this.#g(),this.#m("input")},_=new AbortController,X=(O=!1)=>{if(this.#B=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#T===_)this.#T=null,this.#R=null;if(O)this.#m("change")};this.#T=_,this.#R=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})}#_J(){this.#R?.(!1),this.#T?.abort(),this.#T=null,this.#R=null,this.#B=null,this.#$?.classList.remove("dragging")}#p(J,Q){return this.#Z.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=U.#i($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#s(J,Q){return U.#i(J.type,Q*J.frequency,J.phase)}#g({skipFieldSync:J=!1}={}){if(this.#VJ(),!J)this.#JJ();this.#HJ(),this.#YJ()}#VJ(){for(let J of this.#M){let Q=this.#w(J);J.value=this.#Z[Q]?.type||"sine"}}#JJ(){for(let J of this.#P){if(J===this.#F)continue;let Q=this.#w(J),Z=J.getAttribute("name"),$=this.#c(this.#Z[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#HJ(){for(let J of this.#K)if(this.#w(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#m(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:U.#u(this.#I.type)}}))}}M("propskit-oscillator",U);class y extends HTMLElement{#Z;#Q;#J=null;#_;#X;#Y;#B;#$;#q;#j;#O=null;#k=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.#f.bind(this),this.#X=this.#c.bind(this),this.#Y=this.#r.bind(this),this.#B=this.#h.bind(this),this.#$=this.#XJ.bind(this),this.#q=this.#x.bind(this),this.#j=this.#i.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.#N("dial",!0),this.showRotations=this.#U(),this.#G(),this.#A(),this.#E(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#u(),this.#V()}#G(){this.#u(),this.#V(),this.innerHTML=this.#P()}#N(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}#U(){if(this.hasAttribute("rotations"))return this.#N("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#N("show-rotations",!1);return!1}#P(){let J=this.#R(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"",$=this.#L(),j=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",_=this.min??this.#W(0),X=this.max??this.#W(360);return`
|
|
38
38
|
${this.dial?`<div class="fig-input-angle-plane"
|
|
39
39
|
role="slider"
|
|
40
40
|
tabindex="${$?-1:0}"
|
|
41
|
-
aria-label="${
|
|
41
|
+
aria-label="${y.#K(j)}"
|
|
42
42
|
aria-valuemin="${_}"
|
|
43
43
|
aria-valuemax="${X}"
|
|
44
44
|
aria-valuenow="${this.angle}"
|
|
45
|
-
aria-valuetext="${
|
|
45
|
+
aria-valuetext="${y.#K(`${this.angle.toFixed(this.precision)}${this.units}`)}"
|
|
46
46
|
${$?'aria-disabled="true"':""}>
|
|
47
47
|
<div class="fig-input-angle-handle"></div>
|
|
48
48
|
</div>`:""}
|
|
@@ -53,8 +53,8 @@ function K(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(
|
|
|
53
53
|
${Q}
|
|
54
54
|
${Z}
|
|
55
55
|
units="${this.units}"
|
|
56
|
-
aria-label="${
|
|
56
|
+
aria-label="${y.#K(j)}"
|
|
57
57
|
${$?"disabled":""}>
|
|
58
58
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
59
59
|
</fig-input-number>`:""}
|
|
60
|
-
`}#M(){let J=Math.abs(this.#V(this.angle));return Math.floor(J/360)}static#K(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#S(){return U(this,"disabled")}#z(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.#z(J);if(this.angle=Z,this.#C(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#D(),this.angleInput)this.angleInput.value=Z.toFixed(this.precision);this.#E(),this.#W()}#E(){if(!this.plane)return;this.plane.setAttribute("aria-valuenow",String(this.angle)),this.plane.setAttribute("aria-valuetext",`${this.angle.toFixed(this.precision)}${this.units}`)}#W(){if(!this.rotationSpan)return;let J=this.#M();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#F(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#V(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#T(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#y(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 $}}#A(){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.#W(),this.plane?.addEventListener("mousedown",this.#j),this.plane?.addEventListener("touchstart",this.#O),this.plane?.addEventListener("keydown",this.#q),window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#B),this.angleInput.addEventListener("change",this.#B);this.addEventListener("change",this.#_,!0)}#R(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#O),this.plane?.removeEventListener("keydown",this.#q),window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#B),this.angleInput.removeEventListener("change",this.#B);this.removeEventListener("change",this.#_,!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.#y($,j,this.units);J.target.value=String(_)}}}#x(J){if(J.stopPropagation(),this.#S())return;if(this.#L(Number(J.target.value)),J.type==="change")this.#v();else this.#I()}#C(){let Q=this.#V(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#o(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#b(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}#f(J){let Z=(this.#b(J)%360+360)%360;if(Z=this.#o(Z),this.min!==null||this.max!==null)this.angle=this.#z(this.#T(Z));else if(this.#J===null){this.#J=Z;let _=(this.#V(this.angle)%360+360)%360,X=Z-_;if(X>180)X-=360;if(X<-180)X+=360;this.angle=this.#z(this.angle+this.#T(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#z(this.angle+this.#T(j)),this.#J=Z}if(this.#C(),this.setAttribute("value",String(this.angle)),this.#D(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#W(),this.#E(),this.#I()}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#v(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#D(){if(this.handle){let Q=this.#V(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.#S()||J.button!==0)return;this.#u(),this.isDragging=!0,this.#J=null,this.#f(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#f(j)},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#Y===Z)this.#Y=null,this.#k=null;if(j)this.#v()};this.#Y=Z,this.#k=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#r(J){if(this.#S())return;J.preventDefault(),this.#u(),this.isDragging=!0,this.#J=null,this.#f(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#f(j.touches[0])},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#Y===Z)this.#Y=null,this.#k=null;if(j)this.#v()};this.#Y=Z,this.#k=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#u(){this.#k?.(!1),this.#Y?.abort(),this.#Y=null,this.#k=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#i(J){if(this.#S())return;let Q=this.#F()*(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.#T(0);else if(J.key==="End")Z=this.max??this.#T(360);else return;J.preventDefault(),J.stopPropagation(),this.#L(Z),this.#I(),this.#v()}#h(J){if(J.key==="Shift")this.isShiftHeld=!0}#XJ(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.#Z}get opposite(){return this.#Q}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.#G(),this.#A(),this.#D()}break;case"dial":if(this.dial=this.#N("dial",!0),this.isConnected)this.#G(),this.#A(),this.#D();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#G(),this.#A(),this.#D();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#G(),this.#A(),this.#D();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#G(),this.#A(),this.#D();break;case"disabled":if(this.#u(),this.isConnected)this.#G(),this.#A(),this.#D();break;case"aria-label":case"name":if(this.isConnected)this.#G(),this.#A(),this.#D();break;case"rotations":case"show-rotations":if(this.showRotations=this.#U(),this.isConnected)this.#G(),this.#A(),this.#D();break}}}K("fig-input-angle",b);class H 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-joystick","fig-canvas-control","propskit-number","propskit-slider","propskit-oscillator"];#J=null;#_=new Map;#j=null;#O=null;#X=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.#z(),this.#k(),this.#J=new MutationObserver(()=>this.#k()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#f(),this.#I(),this.#x(),this.#X?.remove(),this.#X=null}attributeChangedCallback(){if(this.isConnected){if(this.#$)this.#I();this.#k()}}get#$(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#B(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#q(){return(this.getAttribute("handle")||"").trim()}#Y(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#k(){let J=this.#Y(),Q=new Set(J);for(let[Z,$]of this.#_)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#S($),this.#_.delete(Z);if(this.#U(J),this.#G(J),this.#$||J.length<2){this.#f();return}for(let Z of J){let $=this.#M(Z),j=this.#_.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#_.delete(Z);if(!$)continue;this.#K(Z,$)}this.#P(J),this.#N(J)}#G(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")}#N(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","")}#U(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.#q)return;for(let Q of J){let Z=Q.querySelector(this.#q);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#M(J){if(this.#q)return J.querySelector(this.#q);return J}#K(J,Q){let Z=(B)=>{if(this.#$||this.#Y().length<2)return;if(B.button!==0)return;if(!this.#q&&this.#E(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 O=(B)=>{if(this.#$)return;let q=this.#B==="horizontal",Y=q?"ArrowLeft":"ArrowUp",G=q?"ArrowRight":"ArrowDown";if(B.key!==Y&&B.key!==G&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let k=this.#Y(),M=k.indexOf(J),N=M;if(B.key===Y)N=Math.max(0,M-1);else if(B.key===G)N=Math.min(k.length-1,M+1);else if(B.key==="Home")N=0;else if(B.key==="End")N=k.length-1;if(N===M){this.#L(`${X}, position ${M+1} of ${k.length}`);return}this.#o(J,N),this.#k(),this.#M(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:M,newIndex:N,item:J}})),this.#L(`${X}, position ${N+1} of ${k.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",O),this.#_.set(J,{target:Q,onPointerDown:Z,onKeyDown:O,originalTabIndex:$,originalAriaLabel:j,originalRole:_})}#S(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)}#z(){if(this.#X?.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.#X=J,document.body.appendChild(J)}#L(J){if(!this.#X)return;this.#X.textContent="",requestAnimationFrame(()=>{if(this.#X)this.#X.textContent=J})}#E(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of H.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#W="fig-reorder-dragging";static#F(J){document.body.classList.toggle(H.#W,J)}#V(J,Q,Z){this.#I();let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#Y().indexOf(Q),targetIndex:this.#Y().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<H.#Z*H.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging"),H.#F(!0);try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let O=this.#B==="horizontal"?j.clientX:j.clientY,B=this.#T(O);$.targetIndex=B,this.#H(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#b($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#b($,j.type==="pointercancel")},this.#j=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#T(J){let Q=this.#Y(),Z=this.#B==="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.#Y(),$=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}#A(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-$}}#R(){if(this.#O)return this.#O;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#B),document.body.appendChild(J),this.#O=J,J}#H(J,Q){let Z=this.#Y();if(!this.#y(Q,J)){this.#x();return}let $=this.#A(Z);if(!$){this.#x();return}let j=this.#R();if(j.setAttribute("data-axis",this.#B),this.#B==="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"}#x(){this.#O?.remove(),this.#O=null}#C(J,Q){let Z=this.#Y(),$=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)}#o(J,Q){let $=this.#Y().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#b(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:O}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",O),j){if(!Q){this.#C(Z,J.targetIndex);let B=this.#Y().indexOf(Z);if(B!==-1&&B!==$){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}));let q=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#L(`${q}, position ${B+1} of ${this.#Y().length}`)}}}if(Z.classList.remove("dragging"),H.#F(!1),this.#x(),this.#j===J)this.#j=null}#f(){for(let[,J]of this.#_)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#S(J);this.#_.clear()}#I(){if(!this.#j)return;this.#b(this.#j,!0)}}K("fig-reorder",H);
|
|
60
|
+
`}#M(){let J=Math.abs(this.#H(this.angle));return Math.floor(J/360)}static#K(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#L(){return N(this,"disabled")}#z(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}#S(J,{reflect:Q=!0}={}){let Z=this.#z(J);if(this.angle=Z,this.#C(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#E(),this.angleInput)this.angleInput.value=Z.toFixed(this.precision);this.#F(),this.#T()}#F(){if(!this.plane)return;this.plane.setAttribute("aria-valuenow",String(this.angle)),this.plane.setAttribute("aria-valuetext",`${this.angle.toFixed(this.precision)}${this.units}`)}#T(){if(!this.rotationSpan)return;let J=this.#M();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#R(){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}}#W(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#y(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 $}}#A(){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.#T(),this.plane?.addEventListener("mousedown",this.#X),this.plane?.addEventListener("touchstart",this.#Y),this.plane?.addEventListener("keydown",this.#j),window.addEventListener("keydown",this.#B),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q),this.angleInput.addEventListener("change",this.#q);this.addEventListener("change",this.#_,!0)}#V(){if(this.plane?.removeEventListener("mousedown",this.#X),this.plane?.removeEventListener("touchstart",this.#Y),this.plane?.removeEventListener("keydown",this.#j),window.removeEventListener("keydown",this.#B),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q),this.angleInput.removeEventListener("change",this.#q);this.removeEventListener("change",this.#_,!0)}#f(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.#y($,j,this.units);J.target.value=String(_)}}}#x(J){if(J.stopPropagation(),this.#L())return;if(this.#S(Number(J.target.value)),J.type==="change")this.#v();else this.#I()}#C(){let Q=this.#H(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#o(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#b(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}#D(J){let Z=(this.#b(J)%360+360)%360;if(Z=this.#o(Z),this.min!==null||this.max!==null)this.angle=this.#z(this.#W(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.#z(this.angle+this.#W(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#z(this.angle+this.#W(j)),this.#J=Z}if(this.#C(),this.setAttribute("value",String(this.angle)),this.#E(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#T(),this.#F(),this.#I()}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#v(){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.#L()||J.button!==0)return;this.#u(),this.isDragging=!0,this.#J=null,this.#D(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#D(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.#k=null;if(j)this.#v()};this.#O=Z,this.#k=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#r(J){if(this.#L())return;J.preventDefault(),this.#u(),this.isDragging=!0,this.#J=null,this.#D(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#D(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.#k=null;if(j)this.#v()};this.#O=Z,this.#k=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#u(){this.#k?.(!1),this.#O?.abort(),this.#O=null,this.#k=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#i(J){if(this.#L())return;let Q=this.#R()*(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.#W(0);else if(J.key==="End")Z=this.max??this.#W(360);else return;J.preventDefault(),J.stopPropagation(),this.#S(Z),this.#I(),this.#v()}#h(J){if(J.key==="Shift")this.isShiftHeld=!0}#XJ(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.#Z}get opposite(){return this.#Q}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}this.#S(Number(J))}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;if(Z!==null)this.#S(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.#G(),this.#A(),this.#E()}break;case"dial":if(this.dial=this.#N("dial",!0),this.isConnected)this.#G(),this.#A(),this.#E();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#G(),this.#A(),this.#E();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#S(this.angle),this.isConnected)this.#G(),this.#A(),this.#E();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#S(this.angle),this.isConnected)this.#G(),this.#A(),this.#E();break;case"disabled":if(this.#u(),this.isConnected)this.#G(),this.#A(),this.#E();break;case"aria-label":case"name":if(this.isConnected)this.#G(),this.#A(),this.#E();break;case"rotations":case"show-rotations":if(this.showRotations=this.#U(),this.isConnected)this.#G(),this.#A(),this.#E();break}}}M("fig-input-angle",y);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-joystick","fig-canvas-control","propskit-color-point","propskit-number","propskit-point-point","propskit-point-radius","propskit-point-radius-angle","propskit-position","propskit-slider","propskit-oscillator"];#J=null;#_=new Map;#X=null;#Y=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.#z(),this.#k(),this.#J=new MutationObserver(()=>this.#k()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#D(),this.#I(),this.#x(),this.#B?.remove(),this.#B=null}attributeChangedCallback(){if(this.isConnected){if(this.#$)this.#I();this.#k()}}get#$(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#q(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#j(){return(this.getAttribute("handle")||"").trim()}#O(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#k(){let J=this.#O(),Q=new Set(J);for(let[Z,$]of this.#_)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#L($),this.#_.delete(Z);if(this.#U(J),this.#G(J),this.#$||J.length<2){this.#D();return}for(let Z of J){let $=this.#M(Z),j=this.#_.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#_.delete(Z);if(!$)continue;this.#K(Z,$)}this.#P(J),this.#N(J)}#G(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")}#N(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","")}#U(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.#j)return;for(let Q of J){let Z=Q.querySelector(this.#j);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#M(J){if(this.#j)return J.querySelector(this.#j);return J}#K(J,Q){let Z=(B)=>{if(this.#$||this.#O().length<2)return;if(B.button!==0)return;if(!this.#j&&this.#F(B.target,J))return;this.#H(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 O=(B)=>{if(this.#$)return;let q=this.#q==="horizontal",Y=q?"ArrowLeft":"ArrowUp",G=q?"ArrowRight":"ArrowDown";if(B.key!==Y&&B.key!==G&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let k=this.#O(),K=k.indexOf(J),P=K;if(B.key===Y)P=Math.max(0,K-1);else if(B.key===G)P=Math.min(k.length-1,K+1);else if(B.key==="Home")P=0;else if(B.key==="End")P=k.length-1;if(P===K){this.#S(`${X}, position ${K+1} of ${k.length}`);return}this.#o(J,P),this.#k(),this.#M(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:K,newIndex:P,item:J}})),this.#S(`${X}, position ${P+1} of ${k.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",O),this.#_.set(J,{target:Q,onPointerDown:Z,onKeyDown:O,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)}#z(){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)}#S(J){if(!this.#B)return;this.#B.textContent="",requestAnimationFrame(()=>{if(this.#B)this.#B.textContent=J})}#F(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of C.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#T="fig-reorder-dragging";static#R(J){document.body.classList.toggle(C.#T,J)}#H(J,Q,Z){this.#I();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<C.#Z*C.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging"),C.#R(!0);try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let O=this.#q==="horizontal"?j.clientX:j.clientY,B=this.#W(O);$.targetIndex=B,this.#f(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#b($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#b($,j.type==="pointercancel")},this.#X=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#W(J){let Q=this.#O(),Z=this.#q==="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}#A(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-$}}#V(){if(this.#Y)return this.#Y;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#q),document.body.appendChild(J),this.#Y=J,J}#f(J,Q){let Z=this.#O();if(!this.#y(Q,J)){this.#x();return}let $=this.#A(Z);if(!$){this.#x();return}let j=this.#V();if(j.setAttribute("data-axis",this.#q),this.#q==="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"}#x(){this.#Y?.remove(),this.#Y=null}#C(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)}#o(J,Q){let $=this.#O().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#b(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:O}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",O),j){if(!Q){this.#C(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 q=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#S(`${q}, position ${B+1} of ${this.#O().length}`)}}}if(Z.classList.remove("dragging"),C.#R(!1),this.#x(),this.#X===J)this.#X=null}#D(){for(let[,J]of this.#_)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#L(J);this.#_.clear()}#I(){if(!this.#X)return;this.#b(this.#X,!0)}}M("fig-reorder",C);
|