@rogieking/figui3 6.27.0 → 6.28.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 +1 -1
- package/dist/fig-lab.js +3 -3
- package/dist/fig.js +21 -21
- package/fig-lab.js +13 -1
- package/fig.js +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -372,7 +372,7 @@ Composes a `<fig-field>` and `<fig-select>` into a full-surface property control
|
|
|
372
372
|
|
|
373
373
|
**Attributes:** `label`, `value`, `default`, `options`, `disabled`, `size`
|
|
374
374
|
|
|
375
|
-
**Events:** `input`, `change` — forwarded from the inner select.
|
|
375
|
+
**Events:** `input`, `change`, `optionhover` — forwarded from the inner select. `optionhover` fires once when the pointer enters an enabled option, with the option value in `event.detail`, without changing the selection.
|
|
376
376
|
|
|
377
377
|
Right-click and choose **Reset**, or call `resetToDefault()`, to restore `default` or the initial selection.
|
|
378
378
|
|
package/dist/fig-lab.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function S(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function ZJ(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 h=new WeakMap;function C(J){let Q=h.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 G=Q?.point;if(G)Z.showAt?.(G.x,G.y)};Q={menu:Z,point:null,clearPendingOpen:_,handleContextMenu:(G)=>{if(U(J,"disabled")||G.target?.closest?.("fig-menu"))return;G.preventDefault(),G.stopPropagation(),G.stopImmediatePropagation?.(),Q.point={x:G.clientX,y:G.clientY},_(),window.addEventListener("pointerup",X,{once:!0,capture:!0}),window.addEventListener("pointercancel",X,{once:!0,capture:!0}),j=window.setTimeout(X,180)},handleChange:(G)=>{if(G.stopPropagation(),G.detail?.value==="reset-default")J.resetToDefault?.()}},h.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 E(J){let Q=h.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 $J(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,Y]=j.map((G)=>{let k=G/255;return k<=0.04045?k/12.92:((k+0.055)/1.055)**2.4});return 0.2126*_+0.7152*X+0.0722*Y<=0.179?"light":"dark"}var u=0;function jJ(J="fig-lab"){return u+=1,`${J}-${u}`}class s extends HTMLElement{}S("fig-ai-prompt",s);class o extends HTMLElement{}S("fig-chat-message",o);class r extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=null;#$=null;#Y=this.#K.bind(this);#B=!1;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#P(),this.#q(),this.#M(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),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.#P();if(Z)this.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#Y),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#P()}#G(){this.#B=U(this,"checked");let Q=Array.from(this.childNodes).filter((Y)=>Y.nodeType!==Node.TEXT_NODE||Boolean(Y.textContent?.trim())).find((Y)=>Y.nodeType===Node.ELEMENT_NODE&&Y.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.#X=Boolean(Q),this.replaceChildren(Z)}#P(){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.#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")}#N(){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-"))}#q(){if(!this.#J)return;let J=this.#N(),Q=new Set(J);for(let Z of this.#k)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.#k=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#B}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)}}S("propskit-switch",r);class l extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=null;#$=null;#Y=this.#z.bind(this);#B=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#P(),this.#q(),this.#M(),this.#B===null)this.#B=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),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.#P();if(Z)this.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#Y),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#P()}#G(){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.#X=Boolean(Q),this.replaceChildren(Z)}#P(){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("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#N(){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-"))}#q(){if(!this.#J)return;let J=this.#N(),Q=new Set(J);for(let Z of this.#k)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.#k=Q}#M(){if(!this.#J)return;this.#_??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#O(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}))}#z(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)}#S(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.#B??""}get defaultValue(){return String(this.#L())}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#S(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)}}S("propskit-color",l);class d extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=null;#$=null;#Y=this.#f.bind(this);#B=this.#L.bind(this);#G=!1;#P=null;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#N();if(this.#q(),this.#U(),this.#O(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#B,!0),this.addEventListener("pointerdown",this.#B,!0),C(this),!this.#j)this.#j=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.#q();if(Z)this.#U()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#K(),this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#B,!0),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#q();return}if(J==="options"||J==="value")this.#U()}#N(){this.#P=this.getAttribute("value")??"";let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label"),$=document.createElement("fig-select");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#X=Boolean(J),this.replaceChildren(Q)}#q(){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","")}#M(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#M().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.#k)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#k=Q}#O(){if(!this.#J)return;this.#_??=this.#z.bind(this,"input"),this.#$??=this.#z.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#K(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#z(J,Q){if(Q.target!==this.#J)return;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}))}#S(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#L(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select")){this.#G=!1;return}this.#G=this.#S()}#f(J){if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select")){this.#G=!1;return}if(!this.#J||U(this.#J,"disabled")){this.#G=!1;return}if(this.#J.focus(),this.#G||this.#S()){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.#P??""}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)}}S("propskit-select",d);class i extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=null;#$=null;#Y=this.#K.bind(this);#B=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#P(),this.#q(),this.#M(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),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.#P();if(Z)this.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#Y),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#P()}#G(){this.#B=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.#X=Boolean(Q),this.replaceChildren(Z)}#P(){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("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#N(){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-"))}#q(){if(!this.#J)return;let J=this.#N(),Q=new Set(J);for(let Z of this.#k)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#k=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#B??""}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)}}S("propskit-text",i);class a extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=null;#$=null;#Y=this.#K.bind(this);#B=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#P(),this.#q(),this.#M(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),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.#P();if(Z)this.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#Y),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#P()}#G(){this.#B=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.#X=Boolean(Q),this.replaceChildren(Z);for(let _ of J)if(_!==Q)j.appendChild(_)}#P(){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.#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")}#N(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#q(){if(!this.#J)return;let J=this.#N(),Q=new Set(J);for(let Z of this.#k)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#k=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#B??"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)}}S("propskit-number",a);class b extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","propskit-oscillator"].join(",");#Q=null;#J=null;#X=null;#j=null;#k=0;#_=()=>this.#B();connectedCallback(){this.#W(),this.#$(),requestAnimationFrame(()=>{this.#K()})}disconnectedCallback(){if(this.#Y(),this.#k)cancelAnimationFrame(this.#k),this.#k=0;this.#Q?.removeEventListener("click",this.#P),this.#Q?.removeEventListener("keydown",this.#N),this.#X?.querySelector("fig-button")?.removeEventListener("click",this.#q)}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.#S()}#$(){if(this.removeEventListener("input",this.#_,!0),this.removeEventListener("change",this.#_,!0),this.addEventListener("input",this.#_,!0),this.addEventListener("change",this.#_,!0),!this.#j)this.#j=new MutationObserver(()=>{this.#B()});this.#j.disconnect(),this.#j.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","checked","default"]})}#Y(){this.removeEventListener("input",this.#_,!0),this.removeEventListener("change",this.#_,!0),this.#j?.disconnect()}#B(){if(this.#k)return;this.#k=requestAnimationFrame(()=>{this.#k=0,this.#K()})}#G(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#P=(J)=>{if(this.#G(J.target))return;J.stopPropagation(),this.open=!this.open};#N=(J)=>{if(this.#G(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#q=(J)=>{J.preventDefault(),J.stopPropagation(),this.#S()};#M(){return[...this.querySelectorAll(b.#Z)].filter((J)=>J.closest("propskit-group")===this&&!J.parentElement?.closest(b.#Z))}#U(J){return J.isDefault===!1}#O(){for(let J of this.#M())if(this.#U(J))return!0;return!1}#K(){if(this.#O())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#L()}#z(J){if(typeof J.resetToDefault==="function")J.resetToDefault()}#S(){for(let J of this.#M())this.#z(J);this.#K(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#L(){if(!this.showReset){this.#X?.setAttribute("hidden","");return}this.#f(),this.#X?.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.#q)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#q),Q?.addEventListener("click",this.#q)}this.#X=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=jJ("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.#P),this.#Q.addEventListener("click",this.#P),this.#Q.removeEventListener("keydown",this.#N),this.#Q.addEventListener("keydown",this.#N),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}S("propskit-group",b);class n extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#k=new Set;#_=0;#$=0;#Y=null;#B=null;#G=0;#P=null;#N=null;#q=!1;#M=0;#U=null;#O=0;#K=null;#z=null;#S=null;#L=this.#_J.bind(this);#f=this.#XJ.bind(this);#W=this.#$J.bind(this);#R=this.#h.bind(this);#V=this.#r.bind(this);#T=this.#MJ.bind(this);#p=this.#x.bind(this);#D=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.#b(),this.#A(),this.#KJ(),this.#u(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#V),this.addEventListener("contextmenu",this.#V),this.removeEventListener("click",this.#p,!0),this.addEventListener("click",this.#p,!0),this.#B?.removeEventListener("change",this.#T),this.#B?.addEventListener("change",this.#T),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName==="value"){this.#y();continue}if($.attributeName==="color"){Z=!0;continue}if($.attributeName&&this.#D.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#b();if(Z)this.#A(),this.#u()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#_)cancelAnimationFrame(this.#_),this.#_=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#JJ(),this.#e(),this.#QJ(),this.#o(),this.#PJ(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#V),this.removeEventListener("click",this.#p,!0),this.#B?.removeEventListener("change",this.#T)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#b()}#E(){this.#N=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.#C()){let X=this.getAttribute(_);j.setAttribute(_,X??"")}Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#X=Boolean(Q),this.replaceChildren(Z),this.#H();for(let _ of J){if(_===Q)continue;this.#J.appendChild(_)}}#H(){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.#T),this.#B=J,this.appendChild(J)}#b(){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.#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")}#A(){if(!this.#J)return;let J=this.#C(),Q=new Set(J.filter(($)=>$!=="text"&&$!=="value"));for(let $ of this.#k)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.#d(Z),this.#k=Q,this.#y(),this.#I()}#d(J){let Q=this.#J?.querySelector("fig-input-number");if(!Q)return;if(J!=="opacity"||!this.hasAttribute("color")){Q.removeAttribute("theme");return}let Z=$J(this.#J,this.getAttribute("color"));if(Z)Q.setAttribute("theme",Z);else Q.removeAttribute("theme")}#y(){if(!this.#J)return;let J=this.getAttribute("value")??"";if(String(this.#J.value)!==J)this.#J.value=J}#C(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#D.has(Q))}#I(){if(this.#_)cancelAnimationFrame(this.#_);this.#_=requestAnimationFrame(()=>{this.#_=0,this.#NJ(),this.#F()})}#u(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#F()})}#F(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#Y)this.#c(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")}#x(J){if(U(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.#i()}#i(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!U(this,"disabled"))this.focus()})})}#c(J){if(this.#o(),this.#Y=J,!this.#Y)return;this.#Y.addEventListener("dblclick",this.#R,{capture:!0})}#o(){if(!this.#Y)return;this.#Y.removeEventListener("dblclick",this.#R,{capture:!0}),this.#Y=null}#h(J){J.preventDefault(),J.stopImmediatePropagation(),this.#n()}#_J(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.#Y;if(!Q)return;this.#e(),this.#QJ(),this.#Y=Q,this.#q=!0,this.#K=J.pointerId,this.#M=this.#OJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#O=$.width,window.addEventListener("pointermove",this.#f,{passive:!0}),window.addEventListener("pointerup",this.#W,{once:!0}),window.addEventListener("pointercancel",this.#W,{once:!0}),window.addEventListener("blur",this.#W,{once:!0})}#XJ(J){if(!this.#q)return;if(J.pointerId!==this.#K)return;if(J.buttons===0){this.#$J(J);return}this.#jJ(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.#e(),this.#QJ(),Q)this.#i()}#e(){window.removeEventListener("pointermove",this.#f),window.removeEventListener("pointerup",this.#W),window.removeEventListener("pointercancel",this.#W),window.removeEventListener("blur",this.#W),this.#q=!1,this.#K=null}#r(J){if(U(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#JJ(),this.#BJ(J.clientX,J.clientY)}#BJ(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.#B?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#MJ(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#n()}#JJ(){if(this.#G)clearTimeout(this.#G),this.#G=0;this.#P=null}#OJ(){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}#jJ(J){let Q=this.#U;if(!Q||!this.#M){this.#QJ();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#l();return}let $=Math.max(-this.#M,Math.min(this.#M,Z*0.5)),j=Math.abs($),_=this.#O?(this.#O+j)/this.#O: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")}#QJ(){this.#l(),this.#M=0,this.#U=null,this.#O=0,this.#K=null}#l(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#YJ(J){let Q=this.#Y;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),Y=j+(_-j)*$;if(!X)return String(Y);let B=Math.round((Y-j)/X)*X+j,G=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(G)))}#s(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.#N??this.#Y?.min??"0"}#n(){this.#JJ(),this.#ZJ(this.#s(),"input"),this.#ZJ(this.#s(),"change")}#ZJ(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}))}#NJ(){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??"")}#KJ(){if(!this.#J)return;if(!this.#z)this.#z=this.#qJ.bind(this,"input");if(!this.#S)this.#S=this.#qJ.bind(this,"change");this.#J.addEventListener("input",this.#z),this.#J.addEventListener("change",this.#S)}#PJ(){if(!this.#J)return;if(this.#z)this.#J.removeEventListener("input",this.#z);if(this.#S)this.#J.removeEventListener("change",this.#S)}#qJ(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#QJ();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.#F();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.#s()}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){this.#n()}}S("propskit-slider",n);class t extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#X=75;#j=0;#k=!1;#_=0;#$=null;#Y=null;#B=null;#G=null;#P=null;#N=null;#q=null;#M=null;#U=null;#O=!1;#K=!1;#z=!1;#S=!1;#L=null;#f="";#W="";#R=null;#V=null;#T=null;#p="";#D="";#E=null;#H=null;#b=null;get#A(){return this.getAttribute("type")||"point"}get#d(){return this.#A==="point-radius"||this.#A==="point-radius-angle"}get#y(){return this.#A==="point-radius-angle"}get#C(){return this.#A==="point-point"}get#I(){return this.#A==="point-radius-angle"||this.#A==="point-point"}get#u(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#F(){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"}#x(J){let Q=this.#F;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#i(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#c(){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.#X)}%`}get#o(){return this.getAttribute("drag-surface")||"parent"}get#h(){let J=this.#o;if(J==="parent")return this.parentElement;return this.closest(J)}get#_J(){let J=this.#o;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#XJ(J){if(this.#k)return this.#j/100*J;return this.#j}#$J(){if(this.#k)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}connectedCallback(){this.#e(),this.#r()}disconnectedCallback(){this.#LJ(),this.#DJ(),this.#JJ(),this.#l(),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.#O&&!this.#K&&!this.#z&&!this.#S)if(this.#e(),this.#$)this.#m();else this.#r();if(J==="type")this.#LJ(),this.#e(),this.#r();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#LJ(),this.#r();if(J==="tooltips")this.#r();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#Y)this.#Y.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#N)this.#N.setAttribute("text",this.#i);if(this.#q)this.#q.setAttribute("text",this.#c)}}#e(){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.#k=!0,this.#j=parseFloat(Z);else this.#k=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#_=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#X=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#A==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#d)J.radius=this.#k?`${this.#j}%`:this.#j;if(this.#y)J.angle=this.#_;if(this.#C)J.x2=this.#J,J.y2=this.#X;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#r(){this.#LJ(),this.innerHTML="",this.#$=null,this.#Y=null,this.#B=null,this.#G=null,this.#P=null,this.#N=null,this.#q=null,this.#M=null,this.#U=null;let J=U(this,"disabled"),Q=this.#A,Z=this.#u,$=this.#_J,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.#F),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.#C)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#$=j,this.#d)this.#KJ();if(this.#I)this.#PJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#i),_.appendChild(j),this.appendChild(_),this.#N=_}else this.appendChild(j);if(this.#y)this.#SJ(J,Z,$);if(this.#C)this.#HJ(J,Z,$);this.#BJ(this.#$),this.#BJ(this.#B),this.#BJ(this.#Y),this.#RJ(),this.#n(),requestAnimationFrame(()=>this.#m())}#BJ(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#QJ(Q,J);else this.#MJ(Q)},{capture:!0})}#MJ(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.#f=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.#R)this.#R=(Q)=>{if(Q?.pointerId!==void 0&&this.#L!==null&&Q.pointerId!==this.#L)return;if(Q?.type==="blur")this.#JJ();else requestAnimationFrame(()=>this.#JJ())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#JJ(){if(this.#L===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#f)document.body.style.setProperty("cursor",this.#f,this.#W);else document.body.style.removeProperty("cursor");if(this.#L=null,this.#f="",this.#W="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#OJ(J){if(!J)return 0;if(J===this.#B)return this.#_;if(!this.#C)return 0;let Q=this.#TJ();return J===this.#$?Q+180:Q}#jJ(){if(this.#V===null)return;let J=this.#zJ(this.#OJ(this.#T));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#QJ(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.#p=document.body.style.getPropertyValue("cursor"),this.#D=document.body.style.getPropertyPriority("cursor");if(this.#V=J?.pointerId??-1,this.#T=Q,document.body.classList.add("fig-lab-rotate-active"),this.#jJ(),!this.#E)this.#E=(Z)=>{if(Z?.pointerId!==void 0&&this.#V!==null&&Z.pointerId!==this.#V)return;if(Z?.type==="blur")this.#l();else requestAnimationFrame(()=>this.#l())};window.addEventListener("pointerup",this.#E),window.addEventListener("pointercancel",this.#E),window.addEventListener("blur",this.#E)}#l(){if(this.#V===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#p)document.body.style.setProperty("cursor",this.#p,this.#D);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#T=null,this.#p="",this.#D="",this.#E)window.removeEventListener("pointerup",this.#E),window.removeEventListener("pointercancel",this.#E),window.removeEventListener("blur",this.#E)}#YJ(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?.()},Y=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",Y)}#s(){return this.#O||this.#K||this.#z||this.#S}#n(){if(this.#$)this.#YJ(this.#$,()=>this.#N,()=>this.#i,()=>this.#s()||!!this.#$?.querySelector("fig-color-tip"));if(this.#B)this.#YJ(this.#B,()=>this.#U,()=>`Angle ${Math.round(this.#_)}°`,()=>this.#s());if(this.#Y)this.#YJ(this.#Y,()=>this.#q,()=>this.#c,()=>this.#s());if(this.#G){let J=this.#G.querySelector(".fig-canvas-control-radius-hit");this.#NJ(J||this.#G)}if(this.#A==="color"&&this.#$&&this.#N)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#N?.removeAttribute("show"),this.#N?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#ZJ(J,Q){let Z=this.#M;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?.()}#NJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#M;if(!Z)return;Z.setAttribute("text",this.#$J()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#z)return;this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#z)return;let Q=this.#M;if(!Q)return;Q.removeAttribute("show")})}#KJ(){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.#G=Q,this.#u){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#$J()),_.appendChild(Q),this.appendChild(_),this.#M=_}else this.appendChild(Q);this.#fJ(Z)}#PJ(){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.#C){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.#qJ(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.#P=Q,this.appendChild(Q)}#qJ(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,Y=this.#J,B=this.#X;this.#O=!0,this.#K=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let G=(N)=>{let P=Z.getBoundingClientRect(),O=P.width>0?(N.clientX-$)/P.width*100:0,q=P.height>0?(N.clientY-j)/P.height*100:0,K=-Math.min(_,Y),z=100-Math.max(_,Y),T=-Math.min(X,B),F=100-Math.max(X,B),L=Math.max(K,Math.min(z,O)),W=Math.max(T,Math.min(F,q));this.#Z=_+L,this.#Q=X+W,this.#J=Y+L,this.#X=B+W,this.#m(),this.#a()},k=this.#VJ((N)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#O=!1,this.#K=!1,N)this.#t(),this.#v()});window.addEventListener("pointermove",G,{signal:k.signal}),window.addEventListener("pointerup",()=>k.finish(!0),{signal:k.signal}),window.addEventListener("pointercancel",()=>k.finish(!1),{signal:k.signal})})}#SJ(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.#B=$,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.#_)}°`),j.appendChild($),this.appendChild(j),this.#U=j}else this.appendChild($)}#HJ(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.#F),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#X}%`),J)$.setAttribute("disabled","");if(this.#Y=$,Q){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#c),j.appendChild($),this.appendChild(j),this.#q=j}else this.appendChild($)}#g(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`}#zJ(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`}#GJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#UJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#GJ(Z,this.#zJ(Q)),this.#T===J)this.#jJ()}#CJ(){if(!this.#B||!this.#y)return;this.#UJ(this.#B,this.#_)}#TJ(){return Math.atan2(this.#X-this.#Q,this.#J-this.#Z)*180/Math.PI}#FJ(){if(!this.#C)return;let J=this.#TJ();this.#$?.style.removeProperty("cursor"),this.#Y?.style.removeProperty("cursor"),this.#UJ(this.#$,J+180),this.#UJ(this.#Y,J)}#kJ(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`}#m(){let J=this.#h;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#kJ(this.#$,this.#Z,this.#Q,Q),this.#G){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#XJ(Q.width),_=this.#G,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 Y=_.querySelectorAll("circle");for(let B of Y)B.setAttribute("cx",String(j)),B.setAttribute("cy",String(j)),B.setAttribute("r",String(Math.max(j-1,0)))}if(this.#P&&this.#I){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j,_;if(this.#C)j=this.#J/100*Q.width,_=this.#X/100*Q.height;else{let B=this.#XJ(Q.width),G=this.#_*Math.PI/180;j=Z+B*Math.cos(G),_=$+B*Math.sin(G)}let X=this.#P;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 Y=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of Y)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#B&&this.#y){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#XJ(Q.width),_=this.#_*Math.PI/180,X=Z+j*Math.cos(_),Y=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,G=Q.height>0?Y/Q.height*100:0;this.#kJ(this.#B,B,G,Q)}if(this.#Y&&this.#C)this.#kJ(this.#Y,this.#J,this.#X,Q);this.#CJ(),this.#FJ()}#a(J=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:J}))}#v(J=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:J}))}#WJ(J){return{...this.value,...ZJ(J.color,J.alpha,J.opacity)}}#t(){this.setAttribute("value",JSON.stringify(this.value))}#RJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#a(this.#WJ(J.detail));return}this.#O=!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.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#m(),this.#a()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#v(this.#WJ(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.#N)this.#N.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#O=!1})}),this.#B)this.#B.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#h;if(!Q)return;this.#S=!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,Y=this.#B.offsetWidth/2,B=this.#B.offsetHeight/2,G=_+Y-$,k=X+B-j,N=Math.atan2(k,G)*180/Math.PI;if(this.#x(J.detail?.shiftKey))N=Math.round(N/15)*15;this.#_=N;let P=Math.sqrt(G*G+k*k);if(this.#x(J.detail?.shiftKey)){let O=this.#k?5:10;if(this.#k){let q=P/Z.width*100;q=Math.round(q/O)*O,P=q/100*Z.width}else P=Math.round(P/O)*O}if(this.#k)this.#j=Math.max(0,P/Z.width*100);else this.#j=Math.max(0,P);if(this.#U)this.#U.setAttribute("text",`Angle ${Math.round(this.#_)}°`),this.#U.setAttribute("show","true"),this.#U.showPopup?.();this.#m(),this.#a()}),this.#B.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#U)this.#U.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#S=!1})}),this.#B.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#h;if(!Z)return;if(this.#S=!0,this.classList.add("fig-canvas-control-ring-active"),this.#B.setAttribute("selected",""),this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),Y=this.#Z/100*X.width,B=this.#Q/100*X.height,G=_.clientX-X.left-Y,k=_.clientY-X.top-B,N=Math.atan2(k,G)*180/Math.PI;if(this.#x(_.shiftKey))N=Math.round(N/15)*15;if(this.#_=N,this.#U)this.#U.setAttribute("text",`Angle ${Math.round(N)}°`);this.#m(),this.#a()},j=this.#VJ((_)=>{if(this.#S=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#B.removeAttribute("selected"),this.#U)this.#U.removeAttribute("show");if(_)this.#t(),this.#v()});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.#Y)this.#Y.addEventListener("input",(J)=>{J.stopPropagation(),this.#K=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#X/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#X=Math.round(Math.max(0,Math.min(100,Z*100))),this.#q)this.#q.removeAttribute("show"),this.#q.hidePopup?.();this.#m(),this.#a()}),this.#Y.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)this.#q.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#K=!1})}),this.#w(this.#$,!0),this.#w(this.#Y,!1)}#w(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.#O=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#Z,Y=Q?this.#X:this.#Q,B=Q?this.#Z:this.#J,G=Q?this.#Q:this.#X,k=X/100*_.width,N=Y/100*_.height,P=B/100*_.width,O=G/100*_.height,q=Math.sqrt((P-k)**2+(O-N)**2),K=Q?this.#N:this.#q;if(K)K.removeAttribute("show"),K.hidePopup?.();let z=(F)=>{let L=j.getBoundingClientRect(),W=X/100*L.width,f=Y/100*L.height,R=F.clientX-L.left-W,D=F.clientY-L.top-f,V=Math.atan2(D,R);if(this.#x(F.shiftKey))V=Math.round(V*180/Math.PI/15)*15*Math.PI/180;let JJ=W+q*Math.cos(V),QJ=f+q*Math.sin(V),g=Math.max(0,Math.min(100,JJ/L.width*100)),m=Math.max(0,Math.min(100,QJ/L.height*100));if(Q)this.#Z=g,this.#Q=m;else this.#J=g,this.#X=m;this.#m(),this.#a()},T=this.#VJ((F)=>{if(this.#O=!1,K)K.removeAttribute("show");if(F)this.#t(),this.#v()});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.#z)return;let $=this.#h;if(!$)return;let j=$.getBoundingClientRect(),_=this.#Z/100*j.width,X=this.#Q/100*j.height,Y=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#GJ(J,this.#g(Y))});let Q=(Z)=>{if(U(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#z=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#h;if(!$)return;if(this.#M)this.#M.setAttribute("show","true"),this.#M.showPopup?.(),this.#ZJ(Z.clientX,Z.clientY);if(this.#U)this.#U.removeAttribute("show"),this.#U.hidePopup?.();let j=this.#B?.style.pointerEvents,_=this.#B?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#B)this.#B.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let Y=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),G=this.#Z/100*B.width,k=this.#Q/100*B.height,N=Math.atan2(Z.clientY-B.top-k,Z.clientX-B.left-G)*180/Math.PI,P=Math.round(N);document.body.style.cursor=this.#g(P);let O=(K)=>{let z=$.getBoundingClientRect(),T=this.#Z/100*z.width,F=this.#Q/100*z.height,L=K.clientX-z.left-T,W=K.clientY-z.top-F,f=Math.round(Math.atan2(W,L)*180/Math.PI);if(f!==P)P=f,document.body.style.cursor=this.#g(f);let R=Math.sqrt(L*L+W*W);if(this.#x(K.shiftKey)){let D=this.#k?5:10;if(this.#k){let V=R/z.width*100;V=Math.round(V/D)*D,R=V/100*z.width}else R=Math.round(R/D)*D}if(this.#k)this.#j=Math.max(0,R/z.width*100);else this.#j=Math.max(0,R);if(this.#M)this.#M.setAttribute("text",this.#$J()),this.#ZJ(K.clientX,K.clientY);this.#m(),this.#a()},q=this.#VJ((K)=>{if(this.#z=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#B)this.#B.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=Y,this.#M)this.#M.removeAttribute("show");if(K)this.#t(),this.#v()});window.addEventListener("pointermove",O,{signal:q.signal}),window.addEventListener("pointerup",()=>q.finish(!0),{signal:q.signal}),window.addEventListener("pointercancel",()=>q.finish(!1),{signal:q.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#DJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#VJ(J){this.#LJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#H===Q)this.#H=null,this.#b=null;J(j)};return this.#H=Q,this.#b=$,{signal:Q.signal,finish:$}}#LJ(){this.#b?.(!1),this.#H?.abort(),this.#H=null,this.#b=null}}S("fig-canvas-control",t);class M extends HTMLElement{#Z=[M.#T()];#Q=0;#J=2;#X=240;#j=120;#k={min:-1,max:1};#_=null;#$=null;#Y=null;#B=null;#G=0;#P=null;#N=null;#q=null;#M=null;#U=[];#O=[];#K=[];#z=[];#S=new Set;#L=null;#f=null;#W=null;#R=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:[M.#T()]});this.#J=this.#p("precision",2),this.#A(this.getAttribute("value")),this.#b(),this.#h(),this.#OJ(),C(this)}disconnectedCallback(){if(this.#kJ(),this.#NJ(),this.#L)this.#L.disconnect(),this.#L=null;E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#A(Z),this.isConnected)this.#h();return}if(J==="precision"){if(this.#J=this.#p("precision",2),this.isConnected)this.#v();return}if(J==="aspect-ratio"){if(this.#b(),this.#$)this.#n();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.#d(this.defaultValue);if(!J)return!1;return JSON.stringify(this.data.waves)===JSON.stringify(J.map((Q)=>this.#C(Q)))}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,this.#w("input"),this.#w("change")}get data(){return{waves:this.#Z.map((J)=>this.#C(J))}}get preset(){let J=this.#I;return M.TYPES.find((Q)=>Q.value===J.type)?.name}#p(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#D(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}#E(){return this.getAttribute("edit")!=="false"}#H(){return this.#D("disabled",!1)}#b(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#A(J){let Q=this.#d(J);if(!Q)return!1;if(this.#Z=Q,!this.#Z.length)this.#Z=[M.#T()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#d(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.#y($))}#y(J={}){return{type:this.#u(J.type),frequency:this.#F(J.frequency,1,0.1,16),amplitude:this.#F(J.amplitude,1,-4,4),phase:this.#F(J.phase,0,-360,360),offset:this.#F(J.offset,0,-4,4)}}#C(J){return{type:J.type,frequency:this.#x(J.frequency),amplitude:this.#x(J.amplitude),phase:this.#x(J.phase),offset:this.#x(J.offset)}}get#I(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||M.#T()}#u(J){let Q=String(J||"").toLowerCase();return M.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#F(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#x(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#i(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#c(J){return M.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 Y=X/32,B=M.#o(J,Y),G=5+Y*j,k=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${G.toFixed(1)},${k.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#o(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.#kJ(),this.#NJ(),this.innerHTML=this.#_J(),this.#BJ(),this.#jJ(),this.#n(),this.#HJ(),this.#ZJ(),C(this)}#_J(){let J=this.#E()&&!this.#H(),Q=J?"":" disabled";return`<div class="propskit-oscillator-svg-container">
|
|
1
|
+
function S(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function ZJ(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 h=new WeakMap;function C(J){let Q=h.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 G=Q?.point;if(G)Z.showAt?.(G.x,G.y)};Q={menu:Z,point:null,clearPendingOpen:_,handleContextMenu:(G)=>{if(U(J,"disabled")||G.target?.closest?.("fig-menu"))return;G.preventDefault(),G.stopPropagation(),G.stopImmediatePropagation?.(),Q.point={x:G.clientX,y:G.clientY},_(),window.addEventListener("pointerup",X,{once:!0,capture:!0}),window.addEventListener("pointercancel",X,{once:!0,capture:!0}),j=window.setTimeout(X,180)},handleChange:(G)=>{if(G.stopPropagation(),G.detail?.value==="reset-default")J.resetToDefault?.()}},h.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 E(J){let Q=h.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 $J(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,Y]=j.map((G)=>{let k=G/255;return k<=0.04045?k/12.92:((k+0.055)/1.055)**2.4});return 0.2126*_+0.7152*X+0.0722*Y<=0.179?"light":"dark"}var u=0;function jJ(J="fig-lab"){return u+=1,`${J}-${u}`}class s extends HTMLElement{}S("fig-ai-prompt",s);class o extends HTMLElement{}S("fig-chat-message",o);class r extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=null;#$=null;#B=this.#K.bind(this);#Y=!1;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#k(),this.#q(),this.#M(),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.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#B),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#G(){this.#Y=U(this,"checked");let Q=Array.from(this.childNodes).filter((Y)=>Y.nodeType!==Node.TEXT_NODE||Boolean(Y.textContent?.trim())).find((Y)=>Y.nodeType===Node.ELEMENT_NODE&&Y.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.#X=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.#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")}#P(){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-"))}#q(){if(!this.#J)return;let J=this.#P(),Q=new Set(J);for(let Z of this.#N)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.#N=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#Y}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)}}S("propskit-switch",r);class l extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=null;#$=null;#B=this.#z.bind(this);#Y=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#k(),this.#q(),this.#M(),this.#Y===null)this.#Y=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.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#B),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#G(){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.#X=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.#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("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#P(){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-"))}#q(){if(!this.#J)return;let J=this.#P(),Q=new Set(J);for(let Z of this.#N)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.#N=Q}#M(){if(!this.#J)return;this.#_??=this.#K.bind(this,"input"),this.#$??=this.#K.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#O(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}))}#z(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)}#S(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.#Y??""}get defaultValue(){return String(this.#L())}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){let J=this.defaultValue;this.setAttribute("value",J),this.#S(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)}}S("propskit-color",l);class d extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=null;#$=null;#B=null;#Y=this.#T.bind(this);#G=this.#f.bind(this);#k=!1;#P=null;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#q();if(this.#M(),this.#O(),this.#K(),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#G,!0),this.addEventListener("pointerdown",this.#G,!0),C(this),!this.#j)this.#j=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.#M();if(Z)this.#O()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#z(),this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#G,!0),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#M();return}if(J==="options"||J==="value")this.#O()}#q(){this.#P=this.getAttribute("value")??"";let J=this.querySelector(":scope > label"),Q=document.createElement("fig-field"),Z=J||document.createElement("label"),$=document.createElement("fig-select");$.setAttribute("full",""),Q.append(Z,$),this.#Z=Q,this.#Q=Z,this.#J=$,this.#X=Boolean(J),this.replaceChildren(Q)}#M(){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","")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#O(){if(!this.#J)return;let J=this.#U().sort((Z,$)=>{if(Z==="options")return-1;if($==="options")return 1;if(Z==="value")return 1;if($==="value")return-1;return 0}),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#K(){if(!this.#J)return;this.#_??=this.#S.bind(this,"input"),this.#$??=this.#S.bind(this,"change"),this.#B??=this.#S.bind(this,"optionhover"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$),this.#J.addEventListener("optionhover",this.#B)}#z(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$);if(this.#B)this.#J.removeEventListener("optionhover",this.#B)}#S(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}))}#L(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#f(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-menu"))return;if(J.target.closest("fig-select")){this.#k=!1;return}this.#k=this.#L()}#T(J){if(J.target instanceof Element&&J.target.closest("fig-menu"))return;if(J.target instanceof Element&&J.target.closest("fig-select")){this.#k=!1;return}if(!this.#J||U(this.#J,"disabled")){this.#k=!1;return}if(this.#J.focus(),this.#k||this.#L()){this.#k=!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.#P??""}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)}}S("propskit-select",d);class i extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=null;#$=null;#B=this.#K.bind(this);#Y=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#k(),this.#q(),this.#M(),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.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#B),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#k()}#G(){this.#Y=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.#X=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.#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("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#P(){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-"))}#q(){if(!this.#J)return;let J=this.#P(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#Y??""}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)}}S("propskit-text",i);class a extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=null;#$=null;#B=this.#K.bind(this);#Y=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#k(),this.#q(),this.#M(),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.#q()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#U(),this.removeEventListener("click",this.#B),E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#k()}#G(){this.#Y=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.#X=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.#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")}#P(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","default"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#q(){if(!this.#J)return;let J=this.#P(),Q=new Set(J);for(let Z of this.#N)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#N=Q}#M(){if(!this.#J)return;this.#_??=this.#O.bind(this,"input"),this.#$??=this.#O.bind(this,"change"),this.#J.addEventListener("input",this.#_),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#_)this.#J.removeEventListener("input",this.#_);if(this.#$)this.#J.removeEventListener("change",this.#$)}#O(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.#Y??"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)}}S("propskit-number",a);class b extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","propskit-oscillator"].join(",");#Q=null;#J=null;#X=null;#j=null;#N=0;#_=()=>this.#Y();connectedCallback(){this.#T(),this.#$(),requestAnimationFrame(()=>{this.#K()})}disconnectedCallback(){if(this.#B(),this.#N)cancelAnimationFrame(this.#N),this.#N=0;this.#Q?.removeEventListener("click",this.#k),this.#Q?.removeEventListener("keydown",this.#P),this.#X?.querySelector("fig-button")?.removeEventListener("click",this.#q)}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.#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.#S()}#$(){if(this.removeEventListener("input",this.#_,!0),this.removeEventListener("change",this.#_,!0),this.addEventListener("input",this.#_,!0),this.addEventListener("change",this.#_,!0),!this.#j)this.#j=new MutationObserver(()=>{this.#Y()});this.#j.disconnect(),this.#j.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","checked","default"]})}#B(){this.removeEventListener("input",this.#_,!0),this.removeEventListener("change",this.#_,!0),this.#j?.disconnect()}#Y(){if(this.#N)return;this.#N=requestAnimationFrame(()=>{this.#N=0,this.#K()})}#G(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#k=(J)=>{if(this.#G(J.target))return;J.stopPropagation(),this.open=!this.open};#P=(J)=>{if(this.#G(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#q=(J)=>{J.preventDefault(),J.stopPropagation(),this.#S()};#M(){return[...this.querySelectorAll(b.#Z)].filter((J)=>J.closest("propskit-group")===this&&!J.parentElement?.closest(b.#Z))}#U(J){return J.isDefault===!1}#O(){for(let J of this.#M())if(this.#U(J))return!0;return!1}#K(){if(this.#O())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#L()}#z(J){if(typeof J.resetToDefault==="function")J.resetToDefault()}#S(){for(let J of this.#M())this.#z(J);this.#K(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#L(){if(!this.showReset){this.#X?.setAttribute("hidden","");return}this.#f(),this.#X?.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.#q)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#q),Q?.addEventListener("click",this.#q)}this.#X=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=jJ("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.#P),this.#Q.addEventListener("keydown",this.#P),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}S("propskit-group",b);class n extends HTMLElement{#Z=null;#Q=null;#J=null;#X=!1;#j=null;#N=new Set;#_=0;#$=0;#B=null;#Y=null;#G=0;#k=null;#P=null;#q=!1;#M=0;#U=null;#O=0;#K=null;#z=null;#S=null;#L=this.#_J.bind(this);#f=this.#XJ.bind(this);#T=this.#$J.bind(this);#R=this.#h.bind(this);#V=this.#r.bind(this);#F=this.#MJ.bind(this);#p=this.#x.bind(this);#D=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.#b(),this.#A(),this.#KJ(),this.#u(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#V),this.addEventListener("contextmenu",this.#V),this.removeEventListener("click",this.#p,!0),this.addEventListener("click",this.#p,!0),this.#Y?.removeEventListener("change",this.#F),this.#Y?.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.#y();continue}if($.attributeName==="color"){Z=!0;continue}if($.attributeName&&this.#D.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#b();if(Z)this.#A(),this.#u()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#_)cancelAnimationFrame(this.#_),this.#_=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#JJ(),this.#e(),this.#QJ(),this.#o(),this.#PJ(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#V),this.removeEventListener("click",this.#p,!0),this.#Y?.removeEventListener("change",this.#F)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#b()}#E(){this.#P=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.#C()){let X=this.getAttribute(_);j.setAttribute(_,X??"")}Z.append($,j),this.#Z=Z,this.#Q=$,this.#J=j,this.#X=Boolean(Q),this.replaceChildren(Z),this.#H();for(let _ of J){if(_===Q)continue;this.#J.appendChild(_)}}#H(){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.#Y=J,this.appendChild(J)}#b(){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.#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")}#A(){if(!this.#J)return;let J=this.#C(),Q=new Set(J.filter(($)=>$!=="text"&&$!=="value"));for(let $ of this.#N)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.#d(Z),this.#N=Q,this.#y(),this.#I()}#d(J){let Q=this.#J?.querySelector("fig-input-number");if(!Q)return;if(J!=="opacity"||!this.hasAttribute("color")){Q.removeAttribute("theme");return}let Z=$J(this.#J,this.getAttribute("color"));if(Z)Q.setAttribute("theme",Z);else Q.removeAttribute("theme")}#y(){if(!this.#J)return;let J=this.getAttribute("value")??"";if(String(this.#J.value)!==J)this.#J.value=J}#C(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#D.has(Q))}#I(){if(this.#_)cancelAnimationFrame(this.#_);this.#_=requestAnimationFrame(()=>{this.#_=0,this.#NJ(),this.#W()})}#u(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#W()})}#W(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#B)this.#c(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")}#x(J){if(U(this,"disabled"))return;if(J.target instanceof Element&&J.target.closest("fig-input-number, fig-menu"))return;this.#i()}#i(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this.isConnected&&!U(this,"disabled"))this.focus()})})}#c(J){if(this.#o(),this.#B=J,!this.#B)return;this.#B.addEventListener("dblclick",this.#R,{capture:!0})}#o(){if(!this.#B)return;this.#B.removeEventListener("dblclick",this.#R,{capture:!0}),this.#B=null}#h(J){J.preventDefault(),J.stopImmediatePropagation(),this.#n()}#_J(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.#e(),this.#QJ(),this.#B=Q,this.#q=!0,this.#K=J.pointerId,this.#M=this.#OJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#O=$.width,window.addEventListener("pointermove",this.#f,{passive:!0}),window.addEventListener("pointerup",this.#T,{once:!0}),window.addEventListener("pointercancel",this.#T,{once:!0}),window.addEventListener("blur",this.#T,{once:!0})}#XJ(J){if(!this.#q)return;if(J.pointerId!==this.#K)return;if(J.buttons===0){this.#$J(J);return}this.#jJ(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.#e(),this.#QJ(),Q)this.#i()}#e(){window.removeEventListener("pointermove",this.#f),window.removeEventListener("pointerup",this.#T),window.removeEventListener("pointercancel",this.#T),window.removeEventListener("blur",this.#T),this.#q=!1,this.#K=null}#r(J){if(U(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#JJ(),this.#BJ(J.clientX,J.clientY)}#BJ(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.#Y?.showAt?.(J,Q)})};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",j,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#MJ(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#n()}#JJ(){if(this.#G)clearTimeout(this.#G),this.#G=0;this.#k=null}#OJ(){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}#jJ(J){let Q=this.#U;if(!Q||!this.#M){this.#QJ();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#l();return}let $=Math.max(-this.#M,Math.min(this.#M,Z*0.5)),j=Math.abs($),_=this.#O?(this.#O+j)/this.#O: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")}#QJ(){this.#l(),this.#M=0,this.#U=null,this.#O=0,this.#K=null}#l(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#YJ(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),Y=j+(_-j)*$;if(!X)return String(Y);let B=Math.round((Y-j)/X)*X+j,G=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(G)))}#s(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.#P??this.#B?.min??"0"}#n(){this.#JJ(),this.#ZJ(this.#s(),"input"),this.#ZJ(this.#s(),"change")}#ZJ(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}))}#NJ(){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??"")}#KJ(){if(!this.#J)return;if(!this.#z)this.#z=this.#qJ.bind(this,"input");if(!this.#S)this.#S=this.#qJ.bind(this,"change");this.#J.addEventListener("input",this.#z),this.#J.addEventListener("change",this.#S)}#PJ(){if(!this.#J)return;if(this.#z)this.#J.removeEventListener("input",this.#z);if(this.#S)this.#J.removeEventListener("change",this.#S)}#qJ(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#QJ();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.#W();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.#s()}get isDefault(){return I(this.value,this.defaultValue)}resetToDefault(){this.#n()}}S("propskit-slider",n);class t extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#X=75;#j=0;#N=!1;#_=0;#$=null;#B=null;#Y=null;#G=null;#k=null;#P=null;#q=null;#M=null;#U=null;#O=!1;#K=!1;#z=!1;#S=!1;#L=null;#f="";#T="";#R=null;#V=null;#F=null;#p="";#D="";#E=null;#H=null;#b=null;get#A(){return this.getAttribute("type")||"point"}get#d(){return this.#A==="point-radius"||this.#A==="point-radius-angle"}get#y(){return this.#A==="point-radius-angle"}get#C(){return this.#A==="point-point"}get#I(){return this.#A==="point-radius-angle"||this.#A==="point-point"}get#u(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#W(){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"}#x(J){let Q=this.#W;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#i(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#c(){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.#X)}%`}get#o(){return this.getAttribute("drag-surface")||"parent"}get#h(){let J=this.#o;if(J==="parent")return this.parentElement;return this.closest(J)}get#_J(){let J=this.#o;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#XJ(J){if(this.#N)return this.#j/100*J;return this.#j}#$J(){if(this.#N)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}connectedCallback(){this.#e(),this.#r()}disconnectedCallback(){this.#LJ(),this.#DJ(),this.#JJ(),this.#l(),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.#O&&!this.#K&&!this.#z&&!this.#S)if(this.#e(),this.#$)this.#m();else this.#r();if(J==="type")this.#LJ(),this.#e(),this.#r();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#LJ(),this.#r();if(J==="tooltips")this.#r();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.#P)this.#P.setAttribute("text",this.#i);if(this.#q)this.#q.setAttribute("text",this.#c)}}#e(){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.#N=!0,this.#j=parseFloat(Z);else this.#N=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#_=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#X=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#A==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#d)J.radius=this.#N?`${this.#j}%`:this.#j;if(this.#y)J.angle=this.#_;if(this.#C)J.x2=this.#J,J.y2=this.#X;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#r(){this.#LJ(),this.innerHTML="",this.#$=null,this.#B=null,this.#Y=null,this.#G=null,this.#k=null,this.#P=null,this.#q=null,this.#M=null,this.#U=null;let J=U(this,"disabled"),Q=this.#A,Z=this.#u,$=this.#_J,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.#W),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.#C)j.setAttribute("hit-area","12 circle"),j.setAttribute("hit-area-mode","delegate");if(this.#$=j,this.#d)this.#KJ();if(this.#I)this.#PJ();if(Z){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#i),_.appendChild(j),this.appendChild(_),this.#P=_}else this.appendChild(j);if(this.#y)this.#SJ(J,Z,$);if(this.#C)this.#HJ(J,Z,$);this.#BJ(this.#$),this.#BJ(this.#Y),this.#BJ(this.#B),this.#RJ(),this.#n(),requestAnimationFrame(()=>this.#m())}#BJ(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#QJ(Q,J);else this.#MJ(Q)},{capture:!0})}#MJ(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.#f=document.body.style.getPropertyValue("cursor"),this.#T=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.#R)this.#R=(Q)=>{if(Q?.pointerId!==void 0&&this.#L!==null&&Q.pointerId!==this.#L)return;if(Q?.type==="blur")this.#JJ();else requestAnimationFrame(()=>this.#JJ())};window.addEventListener("pointerup",this.#R),window.addEventListener("pointercancel",this.#R),window.addEventListener("blur",this.#R)}#JJ(){if(this.#L===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.#L=null,this.#f="",this.#T="",this.#R)window.removeEventListener("pointerup",this.#R),window.removeEventListener("pointercancel",this.#R),window.removeEventListener("blur",this.#R)}#OJ(J){if(!J)return 0;if(J===this.#Y)return this.#_;if(!this.#C)return 0;let Q=this.#TJ();return J===this.#$?Q+180:Q}#jJ(){if(this.#V===null)return;let J=this.#zJ(this.#OJ(this.#F));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#QJ(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.#p=document.body.style.getPropertyValue("cursor"),this.#D=document.body.style.getPropertyPriority("cursor");if(this.#V=J?.pointerId??-1,this.#F=Q,document.body.classList.add("fig-lab-rotate-active"),this.#jJ(),!this.#E)this.#E=(Z)=>{if(Z?.pointerId!==void 0&&this.#V!==null&&Z.pointerId!==this.#V)return;if(Z?.type==="blur")this.#l();else requestAnimationFrame(()=>this.#l())};window.addEventListener("pointerup",this.#E),window.addEventListener("pointercancel",this.#E),window.addEventListener("blur",this.#E)}#l(){if(this.#V===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#p)document.body.style.setProperty("cursor",this.#p,this.#D);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#F=null,this.#p="",this.#D="",this.#E)window.removeEventListener("pointerup",this.#E),window.removeEventListener("pointercancel",this.#E),window.removeEventListener("blur",this.#E)}#YJ(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?.()},Y=()=>{_()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",Y)}#s(){return this.#O||this.#K||this.#z||this.#S}#n(){if(this.#$)this.#YJ(this.#$,()=>this.#P,()=>this.#i,()=>this.#s()||!!this.#$?.querySelector("fig-color-tip"));if(this.#Y)this.#YJ(this.#Y,()=>this.#U,()=>`Angle ${Math.round(this.#_)}°`,()=>this.#s());if(this.#B)this.#YJ(this.#B,()=>this.#q,()=>this.#c,()=>this.#s());if(this.#G){let J=this.#G.querySelector(".fig-canvas-control-radius-hit");this.#NJ(J||this.#G)}if(this.#A==="color"&&this.#$&&this.#P)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#P?.removeAttribute("show"),this.#P?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#ZJ(J,Q){let Z=this.#M;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?.()}#NJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#M;if(!Z)return;Z.setAttribute("text",this.#$J()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#z)return;this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#z)return;let Q=this.#M;if(!Q)return;Q.removeAttribute("show")})}#KJ(){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.#G=Q,this.#u){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#$J()),_.appendChild(Q),this.appendChild(_),this.#M=_}else this.appendChild(Q);this.#fJ(Z)}#PJ(){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.#C){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.#qJ(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)}#qJ(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,Y=this.#J,B=this.#X;this.#O=!0,this.#K=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let G=(N)=>{let P=Z.getBoundingClientRect(),O=P.width>0?(N.clientX-$)/P.width*100:0,q=P.height>0?(N.clientY-j)/P.height*100:0,K=-Math.min(_,Y),z=100-Math.max(_,Y),T=-Math.min(X,B),F=100-Math.max(X,B),L=Math.max(K,Math.min(z,O)),W=Math.max(T,Math.min(F,q));this.#Z=_+L,this.#Q=X+W,this.#J=Y+L,this.#X=B+W,this.#m(),this.#a()},k=this.#VJ((N)=>{if(document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#O=!1,this.#K=!1,N)this.#t(),this.#v()});window.addEventListener("pointermove",G,{signal:k.signal}),window.addEventListener("pointerup",()=>k.finish(!0),{signal:k.signal}),window.addEventListener("pointercancel",()=>k.finish(!1),{signal:k.signal})})}#SJ(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.#Y=$,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.#_)}°`),j.appendChild($),this.appendChild(j),this.#U=j}else this.appendChild($)}#HJ(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.#W),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#X}%`),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.#c),j.appendChild($),this.appendChild(j),this.#q=j}else this.appendChild($)}#g(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`}#zJ(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`}#GJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#UJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#GJ(Z,this.#zJ(Q)),this.#F===J)this.#jJ()}#CJ(){if(!this.#Y||!this.#y)return;this.#UJ(this.#Y,this.#_)}#TJ(){return Math.atan2(this.#X-this.#Q,this.#J-this.#Z)*180/Math.PI}#FJ(){if(!this.#C)return;let J=this.#TJ();this.#$?.style.removeProperty("cursor"),this.#B?.style.removeProperty("cursor"),this.#UJ(this.#$,J+180),this.#UJ(this.#B,J)}#kJ(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`}#m(){let J=this.#h;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#kJ(this.#$,this.#Z,this.#Q,Q),this.#G){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#XJ(Q.width),_=this.#G,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 Y=_.querySelectorAll("circle");for(let B of Y)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.#C)j=this.#J/100*Q.width,_=this.#X/100*Q.height;else{let B=this.#XJ(Q.width),G=this.#_*Math.PI/180;j=Z+B*Math.cos(G),_=$+B*Math.sin(G)}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 Y=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo, .fig-canvas-control-angle-line-hit");for(let B of Y)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(j)),B.setAttribute("y2",String(_))}if(this.#Y&&this.#y){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,j=this.#XJ(Q.width),_=this.#_*Math.PI/180,X=Z+j*Math.cos(_),Y=$+j*Math.sin(_),B=Q.width>0?X/Q.width*100:0,G=Q.height>0?Y/Q.height*100:0;this.#kJ(this.#Y,B,G,Q)}if(this.#B&&this.#C)this.#kJ(this.#B,this.#J,this.#X,Q);this.#CJ(),this.#FJ()}#a(J=this.value){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:J}))}#v(J=this.value){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:J}))}#WJ(J){return{...this.value,...ZJ(J.color,J.alpha,J.opacity)}}#t(){this.setAttribute("value",JSON.stringify(this.value))}#RJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#a(this.#WJ(J.detail));return}this.#O=!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.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();this.#m(),this.#a()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",this.#$.getAttribute("color")||J.detail.color),this.#v(this.#WJ(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.#P)this.#P.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#O=!1})}),this.#Y)this.#Y.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#h;if(!Q)return;this.#S=!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,Y=this.#Y.offsetWidth/2,B=this.#Y.offsetHeight/2,G=_+Y-$,k=X+B-j,N=Math.atan2(k,G)*180/Math.PI;if(this.#x(J.detail?.shiftKey))N=Math.round(N/15)*15;this.#_=N;let P=Math.sqrt(G*G+k*k);if(this.#x(J.detail?.shiftKey)){let O=this.#N?5:10;if(this.#N){let q=P/Z.width*100;q=Math.round(q/O)*O,P=q/100*Z.width}else P=Math.round(P/O)*O}if(this.#N)this.#j=Math.max(0,P/Z.width*100);else this.#j=Math.max(0,P);if(this.#U)this.#U.setAttribute("text",`Angle ${Math.round(this.#_)}°`),this.#U.setAttribute("show","true"),this.#U.showPopup?.();this.#m(),this.#a()}),this.#Y.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#U)this.#U.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#S=!1})}),this.#Y.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#h;if(!Z)return;if(this.#S=!0,this.classList.add("fig-canvas-control-ring-active"),this.#Y.setAttribute("selected",""),this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.();let $=(_)=>{let X=Z.getBoundingClientRect(),Y=this.#Z/100*X.width,B=this.#Q/100*X.height,G=_.clientX-X.left-Y,k=_.clientY-X.top-B,N=Math.atan2(k,G)*180/Math.PI;if(this.#x(_.shiftKey))N=Math.round(N/15)*15;if(this.#_=N,this.#U)this.#U.setAttribute("text",`Angle ${Math.round(N)}°`);this.#m(),this.#a()},j=this.#VJ((_)=>{if(this.#S=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#Y.removeAttribute("selected"),this.#U)this.#U.removeAttribute("show");if(_)this.#t(),this.#v()});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.#X/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#X=Math.round(Math.max(0,Math.min(100,Z*100))),this.#q)this.#q.removeAttribute("show"),this.#q.hidePopup?.();this.#m(),this.#a()}),this.#B.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)this.#q.removeAttribute("show");this.#m(),this.#t(),this.#v(),requestAnimationFrame(()=>{this.#K=!1})}),this.#w(this.#$,!0),this.#w(this.#B,!1)}#w(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.#O=!0;let _=j.getBoundingClientRect(),X=Q?this.#J:this.#Z,Y=Q?this.#X:this.#Q,B=Q?this.#Z:this.#J,G=Q?this.#Q:this.#X,k=X/100*_.width,N=Y/100*_.height,P=B/100*_.width,O=G/100*_.height,q=Math.sqrt((P-k)**2+(O-N)**2),K=Q?this.#P:this.#q;if(K)K.removeAttribute("show"),K.hidePopup?.();let z=(F)=>{let L=j.getBoundingClientRect(),W=X/100*L.width,f=Y/100*L.height,R=F.clientX-L.left-W,D=F.clientY-L.top-f,V=Math.atan2(D,R);if(this.#x(F.shiftKey))V=Math.round(V*180/Math.PI/15)*15*Math.PI/180;let JJ=W+q*Math.cos(V),QJ=f+q*Math.sin(V),g=Math.max(0,Math.min(100,JJ/L.width*100)),m=Math.max(0,Math.min(100,QJ/L.height*100));if(Q)this.#Z=g,this.#Q=m;else this.#J=g,this.#X=m;this.#m(),this.#a()},T=this.#VJ((F)=>{if(this.#O=!1,K)K.removeAttribute("show");if(F)this.#t(),this.#v()});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.#z)return;let $=this.#h;if(!$)return;let j=$.getBoundingClientRect(),_=this.#Z/100*j.width,X=this.#Q/100*j.height,Y=Math.atan2(Z.clientY-j.top-X,Z.clientX-j.left-_)*180/Math.PI;this.#GJ(J,this.#g(Y))});let Q=(Z)=>{if(U(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#z=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#h;if(!$)return;if(this.#M)this.#M.setAttribute("show","true"),this.#M.showPopup?.(),this.#ZJ(Z.clientX,Z.clientY);if(this.#U)this.#U.removeAttribute("show"),this.#U.hidePopup?.();let j=this.#Y?.style.pointerEvents,_=this.#Y?.querySelector(".fig-handle-hit-area"),X=_?.style.pointerEvents;if(this.#Y)this.#Y.style.pointerEvents="none";if(_)_.style.pointerEvents="none";let Y=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),G=this.#Z/100*B.width,k=this.#Q/100*B.height,N=Math.atan2(Z.clientY-B.top-k,Z.clientX-B.left-G)*180/Math.PI,P=Math.round(N);document.body.style.cursor=this.#g(P);let O=(K)=>{let z=$.getBoundingClientRect(),T=this.#Z/100*z.width,F=this.#Q/100*z.height,L=K.clientX-z.left-T,W=K.clientY-z.top-F,f=Math.round(Math.atan2(W,L)*180/Math.PI);if(f!==P)P=f,document.body.style.cursor=this.#g(f);let R=Math.sqrt(L*L+W*W);if(this.#x(K.shiftKey)){let D=this.#N?5:10;if(this.#N){let V=R/z.width*100;V=Math.round(V/D)*D,R=V/100*z.width}else R=Math.round(R/D)*D}if(this.#N)this.#j=Math.max(0,R/z.width*100);else this.#j=Math.max(0,R);if(this.#M)this.#M.setAttribute("text",this.#$J()),this.#ZJ(K.clientX,K.clientY);this.#m(),this.#a()},q=this.#VJ((K)=>{if(this.#z=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#Y)this.#Y.style.pointerEvents=j??"";if(_)_.style.pointerEvents=X??"";if(document.body.style.cursor=Y,this.#M)this.#M.removeAttribute("show");if(K)this.#t(),this.#v()});window.addEventListener("pointermove",O,{signal:q.signal}),window.addEventListener("pointerup",()=>q.finish(!0),{signal:q.signal}),window.addEventListener("pointercancel",()=>q.finish(!1),{signal:q.signal})};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#DJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}#VJ(J){this.#LJ();let Q=new AbortController,Z=!1,$=(j=!1)=>{if(Z)return;if(Z=!0,Q.abort(),this.#H===Q)this.#H=null,this.#b=null;J(j)};return this.#H=Q,this.#b=$,{signal:Q.signal,finish:$}}#LJ(){this.#b?.(!1),this.#H?.abort(),this.#H=null,this.#b=null}}S("fig-canvas-control",t);class M extends HTMLElement{#Z=[M.#F()];#Q=0;#J=2;#X=240;#j=120;#N={min:-1,max:1};#_=null;#$=null;#B=null;#Y=null;#G=0;#k=null;#P=null;#q=null;#M=null;#U=[];#O=[];#K=[];#z=[];#S=new Set;#L=null;#f=null;#T=null;#R=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#F(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:[M.#F()]});this.#J=this.#p("precision",2),this.#A(this.getAttribute("value")),this.#b(),this.#h(),this.#OJ(),C(this)}disconnectedCallback(){if(this.#kJ(),this.#NJ(),this.#L)this.#L.disconnect(),this.#L=null;E(this)}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#A(Z),this.isConnected)this.#h();return}if(J==="precision"){if(this.#J=this.#p("precision",2),this.isConnected)this.#v();return}if(J==="aspect-ratio"){if(this.#b(),this.#$)this.#n();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.#d(this.defaultValue);if(!J)return!1;return JSON.stringify(this.data.waves)===JSON.stringify(J.map((Q)=>this.#C(Q)))}resetToDefault(){let J=this.defaultValue;if(!J)return;this.value=J,this.#w("input"),this.#w("change")}get data(){return{waves:this.#Z.map((J)=>this.#C(J))}}get preset(){let J=this.#I;return M.TYPES.find((Q)=>Q.value===J.type)?.name}#p(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#D(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}#E(){return this.getAttribute("edit")!=="false"}#H(){return this.#D("disabled",!1)}#b(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#A(J){let Q=this.#d(J);if(!Q)return!1;if(this.#Z=Q,!this.#Z.length)this.#Z=[M.#F()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#d(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.#y($))}#y(J={}){return{type:this.#u(J.type),frequency:this.#W(J.frequency,1,0.1,16),amplitude:this.#W(J.amplitude,1,-4,4),phase:this.#W(J.phase,0,-360,360),offset:this.#W(J.offset,0,-4,4)}}#C(J){return{type:J.type,frequency:this.#x(J.frequency),amplitude:this.#x(J.amplitude),phase:this.#x(J.phase),offset:this.#x(J.offset)}}get#I(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||M.#F()}#u(J){let Q=String(J||"").toLowerCase();return M.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#W(J,Q,Z,$){let j=Number.parseFloat(J);if(!Number.isFinite(j))return Q;return Math.min($,Math.max(Z,j))}#x(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#i(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#c(J){return M.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 Y=X/32,B=M.#o(J,Y),G=5+Y*j,k=5+(1-(B+1)/2)*j;_+=`${X===0?"M":"L"}${G.toFixed(1)},${k.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#o(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.#kJ(),this.#NJ(),this.innerHTML=this.#_J(),this.#BJ(),this.#jJ(),this.#n(),this.#HJ(),this.#ZJ(),C(this)}#_J(){let J=this.#E()&&!this.#H(),Q=J?"":" disabled";return`<div class="propskit-oscillator-svg-container">
|
|
2
2
|
<svg viewBox="0 0 ${this.#X} ${this.#j}" class="propskit-oscillator-svg">
|
|
3
3
|
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#X}" height="${this.#j}"></rect>
|
|
4
4
|
<line class="propskit-oscillator-baseline"></line>
|
|
@@ -32,7 +32,7 @@ function S(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(
|
|
|
32
32
|
<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>
|
|
33
33
|
</fig-tooltip>
|
|
34
34
|
${Z}
|
|
35
|
-
</fig-menu>`}#r(J,Q,Z,$,j,_,X){let Y=this.#H()?" disabled":"",B=Q==="amplitude"||Q==="offset"?' type="delta" default="0"':"",G=X?` units="${M.#i(X)}"`:"",k=this.#Z[J]||M.#T();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#x(k[Q])}" min="${$}" max="${j}" step="${_}" precision="${this.#J}" elastic="false"${B}${G}${Y}></propskit-slider>`}#BJ(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#Y=this.querySelector(".propskit-oscillator-path"),this.#B=this.querySelector(".propskit-oscillator-playhead"),this.#P=this.querySelector(".propskit-oscillator-baseline"),this.#N=this.querySelector(".propskit-oscillator-bounds"),this.#q=this.querySelector('[data-handle="amplitude"]'),this.#M=this.querySelector('[data-handle="frequency"]'),this.#O=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#U=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#z=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#K=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#MJ(J){let Q=new Set;for(let Z of this.#S)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#S=Q}#JJ(J){let Q=new Set;for(let Z of this.#S)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#S=Q}#OJ(){if(this.#L||!window.ResizeObserver)return;this.#L=new ResizeObserver(()=>{if(this.#jJ())this.#n()}),this.#L.observe(this)}#jJ(){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.#X||Z!==this.#j;return this.#X=Q,this.#j=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#QJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#s(Z/Q)));return{min:-J,max:J}}#l(J){let{min:Q,max:Z}=this.#k;return this.#j-(J-Q)/(Z-Q)*this.#j}#YJ(J){let{min:Q,max:Z}=this.#k;return Q+(1-J/this.#j)*(Z-Q)}#s(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,j=M.#o(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#n(){if(!this.#$||!this.#Y)return;if(this.#jJ(),this.#k=this.#QJ(),this.#N)this.#N.setAttribute("width",this.#X),this.#N.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,Y=X*this.#X,B=this.#l(this.#s(X));$+=`${_===0?"M":"L"}${Y.toFixed(1)},${B.toFixed(1)}`}this.#Y.setAttribute("d",$);let j=this.#l(0);this.#P?.setAttribute("x1","0"),this.#P?.setAttribute("y1",j),this.#P?.setAttribute("x2",this.#X),this.#P?.setAttribute("y2",j),this.#PJ()}#ZJ(){if(this.#G||!this.#B)return;let J=(Q)=>{if(!this.isConnected||!this.#B){this.#G=0;return}this.#KJ(Q%1000/1000),this.#G=requestAnimationFrame(J)};this.#G=requestAnimationFrame(J)}#NJ(){if(!this.#G)return;cancelAnimationFrame(this.#G),this.#G=0}#KJ(J){if(!this.#B)return;let Q=J*this.#X,Z=this.#l(this.#s(J));this.#B.setAttribute("cx",Q.toFixed(1)),this.#B.setAttribute("cy",Z.toFixed(1))}#PJ(){let Q=this.#I,Z=this.#qJ(),$=Math.max(8,Math.min(this.#X-8,this.#X/Q.frequency)),j=this.#l(this.#s(Z/this.#X)),_=this.#l(this.#s($/this.#X));this.#SJ(this.#q,Z,j,8),this.#SJ(this.#M,$,_,8)}#qJ(){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.#X-8,j*this.#X))}#SJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#HJ(){if(!this.#E()||this.#H())return;for(let Q of this.#O)Q.addEventListener("change",(Z)=>{if(this.#H())return;let $=this.#g(Q);this.#GJ($),this.#Z[$].type=this.#u(Z.detail??Z.target?.value),this.#v(),this.#w("input"),this.#w("change")});for(let Q of this.#U)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#f=Q;try{this.#UJ(this.#g(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#f=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#UJ(this.#g(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#z)Q.addEventListener("pointerdown",()=>{this.#GJ(this.#g(Q))}),Q.addEventListener("focusin",()=>{this.#GJ(this.#g(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#g(Q);if(Z.detail?.open)this.#S.add($);else this.#S.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.#g(Q)+1,X=this.#u($.detail?.value??Q.value);this.#Z.splice(_,0,M.#T(X)),this.#JJ(_),this.#Q=_,this.#h(),this.#w("input"),this.#w("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.#g(Q);this.#Z.splice($,1),this.#MJ($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#h(),this.#w("input"),this.#w("change")});for(let Q of[this.#q,this.#M])this.#zJ(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.#FJ(Q,"offset")})}#g(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}#zJ(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.#FJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#H())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#CJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#GJ(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#RJ(),this.#PJ()}#UJ(J,Q,Z,$){if(this.#H())return;this.#GJ(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#t();return}this.#Z[J]=this.#y({...this.#Z[J],[Q]:j}),this.#v({skipFieldSync:$=="input"}),this.#w($)}#CJ(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.#y($),this.#v(),this.#w("input"),this.#w("change"),!0}#TJ(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}}#FJ(J,Q){this.#kJ(),this.#_=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=(Y)=>{if(!this.#_)return;let B=this.#TJ(Y),G=this.#I;if(Q==="frequency"){let k=Math.max(1,Math.min(this.#X,B.x));G.frequency=this.#X/k}else if(Q==="offset"){let k=this.#F(B.x/this.#X,0,0,1),N=this.#a(G,k);G.offset=this.#YJ(B.y)-this.#m(this.#Q,k)-N*G.amplitude}else if(Q==="amplitude"){let k=this.#F(B.x/this.#X,0,0,1),N=this.#a(G,k),P=this.#YJ(B.y)-this.#m(this.#Q,k)-G.offset;G.amplitude=Math.abs(N)<0.001?G.amplitude:P/N}this.#Z[this.#Q]=this.#y(G),this.#v(),this.#w("input")},_=new AbortController,X=(Y=!1)=>{if(this.#_=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#W===_)this.#W=null,this.#R=null;if(Y)this.#w("change")};this.#W=_,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})}#kJ(){this.#R?.(!1),this.#W?.abort(),this.#W=null,this.#R=null,this.#_=null,this.#$?.classList.remove("dragging")}#m(J,Q){return this.#Z.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=M.#o($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#a(J,Q){return M.#o(J.type,Q*J.frequency,J.phase)}#v({skipFieldSync:J=!1}={}){if(this.#WJ(),!J)this.#t();this.#RJ(),this.#n()}#WJ(){for(let J of this.#O){let Q=this.#g(J);J.value=this.#Z[Q]?.type||"sine"}}#t(){for(let J of this.#U){if(J===this.#f)continue;let Q=this.#g(J),Z=J.getAttribute("name"),$=this.#x(this.#Z[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#RJ(){for(let J of this.#K)if(this.#g(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#w(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:M.#c(this.#I.type)}}))}}S("propskit-oscillator",M);class A extends HTMLElement{#Z;#Q;#J=null;#X;#j;#k;#_;#$;#Y;#B;#G=null;#P=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.#X=this.#H.bind(this),this.#j=this.#x.bind(this),this.#k=this.#i.bind(this),this.#_=this.#h.bind(this),this.#$=this.#_J.bind(this),this.#Y=this.#b.bind(this),this.#B=this.#o.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.#q("dial",!0),this.showRotations=this.#M(),this.#N(),this.#D(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#c(),this.#E()}#N(){this.#c(),this.#E(),this.innerHTML=this.#U()}#q(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}#M(){if(this.hasAttribute("rotations"))return this.#q("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#q("show-rotations",!1);return!1}#U(){let J=this.#R(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"",$=this.#z(),j=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",_=this.min??this.#T(0),X=this.max??this.#T(360);return`
|
|
35
|
+
</fig-menu>`}#r(J,Q,Z,$,j,_,X){let Y=this.#H()?" disabled":"",B=Q==="amplitude"||Q==="offset"?' type="delta" default="0"':"",G=X?` units="${M.#i(X)}"`:"",k=this.#Z[J]||M.#F();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#x(k[Q])}" min="${$}" max="${j}" step="${_}" precision="${this.#J}" elastic="false"${B}${G}${Y}></propskit-slider>`}#BJ(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#B=this.querySelector(".propskit-oscillator-path"),this.#Y=this.querySelector(".propskit-oscillator-playhead"),this.#k=this.querySelector(".propskit-oscillator-baseline"),this.#P=this.querySelector(".propskit-oscillator-bounds"),this.#q=this.querySelector('[data-handle="amplitude"]'),this.#M=this.querySelector('[data-handle="frequency"]'),this.#O=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#U=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#z=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#K=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#MJ(J){let Q=new Set;for(let Z of this.#S)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#S=Q}#JJ(J){let Q=new Set;for(let Z of this.#S)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#S=Q}#OJ(){if(this.#L||!window.ResizeObserver)return;this.#L=new ResizeObserver(()=>{if(this.#jJ())this.#n()}),this.#L.observe(this)}#jJ(){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.#X||Z!==this.#j;return this.#X=Q,this.#j=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#QJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#s(Z/Q)));return{min:-J,max:J}}#l(J){let{min:Q,max:Z}=this.#N;return this.#j-(J-Q)/(Z-Q)*this.#j}#YJ(J){let{min:Q,max:Z}=this.#N;return Q+(1-J/this.#j)*(Z-Q)}#s(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,j=M.#o(Z.type,$,Z.phase);return Q+Z.offset+j*Z.amplitude},0)}#n(){if(!this.#$||!this.#B)return;if(this.#jJ(),this.#N=this.#QJ(),this.#P)this.#P.setAttribute("width",this.#X),this.#P.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,Y=X*this.#X,B=this.#l(this.#s(X));$+=`${_===0?"M":"L"}${Y.toFixed(1)},${B.toFixed(1)}`}this.#B.setAttribute("d",$);let j=this.#l(0);this.#k?.setAttribute("x1","0"),this.#k?.setAttribute("y1",j),this.#k?.setAttribute("x2",this.#X),this.#k?.setAttribute("y2",j),this.#PJ()}#ZJ(){if(this.#G||!this.#Y)return;let J=(Q)=>{if(!this.isConnected||!this.#Y){this.#G=0;return}this.#KJ(Q%1000/1000),this.#G=requestAnimationFrame(J)};this.#G=requestAnimationFrame(J)}#NJ(){if(!this.#G)return;cancelAnimationFrame(this.#G),this.#G=0}#KJ(J){if(!this.#Y)return;let Q=J*this.#X,Z=this.#l(this.#s(J));this.#Y.setAttribute("cx",Q.toFixed(1)),this.#Y.setAttribute("cy",Z.toFixed(1))}#PJ(){let Q=this.#I,Z=this.#qJ(),$=Math.max(8,Math.min(this.#X-8,this.#X/Q.frequency)),j=this.#l(this.#s(Z/this.#X)),_=this.#l(this.#s($/this.#X));this.#SJ(this.#q,Z,j,8),this.#SJ(this.#M,$,_,8)}#qJ(){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.#X-8,j*this.#X))}#SJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#HJ(){if(!this.#E()||this.#H())return;for(let Q of this.#O)Q.addEventListener("change",(Z)=>{if(this.#H())return;let $=this.#g(Q);this.#GJ($),this.#Z[$].type=this.#u(Z.detail??Z.target?.value),this.#v(),this.#w("input"),this.#w("change")});for(let Q of this.#U)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#f=Q;try{this.#UJ(this.#g(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#f=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#UJ(this.#g(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#z)Q.addEventListener("pointerdown",()=>{this.#GJ(this.#g(Q))}),Q.addEventListener("focusin",()=>{this.#GJ(this.#g(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#g(Q);if(Z.detail?.open)this.#S.add($);else this.#S.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.#g(Q)+1,X=this.#u($.detail?.value??Q.value);this.#Z.splice(_,0,M.#F(X)),this.#JJ(_),this.#Q=_,this.#h(),this.#w("input"),this.#w("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.#g(Q);this.#Z.splice($,1),this.#MJ($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#h(),this.#w("input"),this.#w("change")});for(let Q of[this.#q,this.#M])this.#zJ(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.#FJ(Q,"offset")})}#g(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}#zJ(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.#FJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#H())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#CJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#GJ(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#RJ(),this.#PJ()}#UJ(J,Q,Z,$){if(this.#H())return;this.#GJ(J);let j=Number.parseFloat(Z);if(!Number.isFinite(j)){if($==="change")this.#t();return}this.#Z[J]=this.#y({...this.#Z[J],[Q]:j}),this.#v({skipFieldSync:$=="input"}),this.#w($)}#CJ(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.#y($),this.#v(),this.#w("input"),this.#w("change"),!0}#TJ(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}}#FJ(J,Q){this.#kJ(),this.#_=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=(Y)=>{if(!this.#_)return;let B=this.#TJ(Y),G=this.#I;if(Q==="frequency"){let k=Math.max(1,Math.min(this.#X,B.x));G.frequency=this.#X/k}else if(Q==="offset"){let k=this.#W(B.x/this.#X,0,0,1),N=this.#a(G,k);G.offset=this.#YJ(B.y)-this.#m(this.#Q,k)-N*G.amplitude}else if(Q==="amplitude"){let k=this.#W(B.x/this.#X,0,0,1),N=this.#a(G,k),P=this.#YJ(B.y)-this.#m(this.#Q,k)-G.offset;G.amplitude=Math.abs(N)<0.001?G.amplitude:P/N}this.#Z[this.#Q]=this.#y(G),this.#v(),this.#w("input")},_=new AbortController,X=(Y=!1)=>{if(this.#_=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;if(_.abort(),this.#T===_)this.#T=null,this.#R=null;if(Y)this.#w("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})}#kJ(){this.#R?.(!1),this.#T?.abort(),this.#T=null,this.#R=null,this.#_=null,this.#$?.classList.remove("dragging")}#m(J,Q){return this.#Z.reduce((Z,$,j)=>{if(j===J)return Z;let _=Q*$.frequency,X=M.#o($.type,_,$.phase);return Z+$.offset+X*$.amplitude},0)}#a(J,Q){return M.#o(J.type,Q*J.frequency,J.phase)}#v({skipFieldSync:J=!1}={}){if(this.#WJ(),!J)this.#t();this.#RJ(),this.#n()}#WJ(){for(let J of this.#O){let Q=this.#g(J);J.value=this.#Z[Q]?.type||"sine"}}#t(){for(let J of this.#U){if(J===this.#f)continue;let Q=this.#g(J),Z=J.getAttribute("name"),$=this.#x(this.#Z[Q]?.[Z]??0),j=J.querySelector("fig-slider");if(j)j.value=$;else J.setAttribute("value",String($))}}#RJ(){for(let J of this.#K)if(this.#g(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#w(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:M.#c(this.#I.type)}}))}}S("propskit-oscillator",M);class A extends HTMLElement{#Z;#Q;#J=null;#X;#j;#N;#_;#$;#B;#Y;#G=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.#X=this.#H.bind(this),this.#j=this.#x.bind(this),this.#N=this.#i.bind(this),this.#_=this.#h.bind(this),this.#$=this.#_J.bind(this),this.#B=this.#b.bind(this),this.#Y=this.#o.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.#q("dial",!0),this.showRotations=this.#M(),this.#P(),this.#D(),this.#W(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#c(),this.#E()}#P(){this.#c(),this.#E(),this.innerHTML=this.#U()}#q(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}#M(){if(this.hasAttribute("rotations"))return this.#q("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#q("show-rotations",!1);return!1}#U(){let J=this.#R(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"",$=this.#z(),j=this.getAttribute("aria-label")||this.getAttribute("name")||"Angle",_=this.min??this.#F(0),X=this.max??this.#F(360);return`
|
|
36
36
|
${this.dial?`<div class="fig-input-angle-plane"
|
|
37
37
|
role="slider"
|
|
38
38
|
tabindex="${$?-1:0}"
|
|
@@ -55,4 +55,4 @@ function S(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function U(
|
|
|
55
55
|
${$?"disabled":""}>
|
|
56
56
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
57
57
|
</fig-input-number>`:""}
|
|
58
|
-
`}#O(){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,">")}#z(){return U(this,"disabled")}#S(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.#S(J);if(this.angle=Z,this.#A(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#F(),this.angleInput)this.angleInput.value=Z.toFixed(this.precision);this.#f(),this.#W()}#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}`)}#W(){if(!this.rotationSpan)return;let J=this.#O();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}}#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}}#p(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 $}}#D(){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.#k),this.plane?.addEventListener("keydown",this.#B),window.addEventListener("keydown",this.#_),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#Y),this.angleInput.addEventListener("change",this.#Y);this.addEventListener("change",this.#X,!0)}#E(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#k),this.plane?.removeEventListener("keydown",this.#B),window.removeEventListener("keydown",this.#_),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#Y),this.angleInput.removeEventListener("change",this.#Y);this.removeEventListener("change",this.#X,!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.#p($,j,this.units);J.target.value=String(_)}}}#b(J){if(J.stopPropagation(),this.#z())return;if(this.#L(Number(J.target.value)),J.type==="change")this.#u();else this.#I()}#A(){let Q=this.#V(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#d(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#y(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}#C(J){let Z=(this.#y(J)%360+360)%360;if(Z=this.#d(Z),this.min!==null||this.max!==null)this.angle=this.#S(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.#S(this.angle+this.#T(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#S(this.angle+this.#T(j)),this.#J=Z}if(this.#A(),this.setAttribute("value",String(this.angle)),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#W(),this.#f(),this.#I()}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#F(){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)`}}#x(J){if(this.#z()||J.button!==0)return;this.#c(),this.isDragging=!0,this.#J=null,this.#C(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(j)},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#G===Z)this.#G=null,this.#P=null;if(j)this.#u()};this.#G=Z,this.#P=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#i(J){if(this.#z())return;J.preventDefault(),this.#c(),this.isDragging=!0,this.#J=null,this.#C(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(j.touches[0])},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#G===Z)this.#G=null,this.#P=null;if(j)this.#u()};this.#G=Z,this.#P=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#c(){this.#P?.(!1),this.#G?.abort(),this.#G=null,this.#P=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#o(J){if(this.#z())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.#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.#u()}#h(J){if(J.key==="Shift")this.isShiftHeld=!0}#_J(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.#N(),this.#D(),this.#F()}break;case"dial":if(this.dial=this.#q("dial",!0),this.isConnected)this.#N(),this.#D(),this.#F();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#N(),this.#D(),this.#F();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#N(),this.#D(),this.#F();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#N(),this.#D(),this.#F();break;case"disabled":if(this.#c(),this.isConnected)this.#N(),this.#D(),this.#F();break;case"aria-label":case"name":if(this.isConnected)this.#N(),this.#D(),this.#F();break;case"rotations":case"show-rotations":if(this.showRotations=this.#M(),this.isConnected)this.#N(),this.#D(),this.#F();break}}}S("fig-input-angle",A);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;#X=new Map;#j=null;#k=null;#_=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.#S(),this.#P(),this.#J=new MutationObserver(()=>this.#P()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#C(),this.#I(),this.#b(),this.#_?.remove(),this.#_=null}attributeChangedCallback(){if(this.isConnected){if(this.#$)this.#I();this.#P()}}get#$(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#Y(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#B(){return(this.getAttribute("handle")||"").trim()}#G(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#P(){let J=this.#G(),Q=new Set(J);for(let[Z,$]of this.#X)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#z($),this.#X.delete(Z);if(this.#M(J),this.#N(J),this.#$||J.length<2){this.#C();return}for(let Z of J){let $=this.#O(Z),j=this.#X.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#X.delete(Z);if(!$)continue;this.#K(Z,$)}this.#U(J),this.#q(J)}#N(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")}#q(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","")}#M(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>{Z.removeAttribute("data-reorder-handle"),Z.removeAttribute("aria-roledescription")})}#U(J){if(!this.#B)return;for(let Q of J){let Z=Q.querySelector(this.#B);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#O(J){if(this.#B)return J.querySelector(this.#B);return J}#K(J,Q){let Z=(B)=>{if(this.#$||this.#G().length<2)return;if(B.button!==0)return;if(!this.#B&&this.#f(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 Y=(B)=>{if(this.#$)return;let G=this.#Y==="horizontal",k=G?"ArrowLeft":"ArrowUp",N=G?"ArrowRight":"ArrowDown";if(B.key!==k&&B.key!==N&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let P=this.#G(),O=P.indexOf(J),q=O;if(B.key===k)q=Math.max(0,O-1);else if(B.key===N)q=Math.min(P.length-1,O+1);else if(B.key==="Home")q=0;else if(B.key==="End")q=P.length-1;if(q===O){this.#L(`${X}, position ${O+1} of ${P.length}`);return}this.#d(J,q),this.#P(),this.#O(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:O,newIndex:q,item:J}})),this.#L(`${X}, position ${q+1} of ${P.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",Y),this.#X.set(J,{target:Q,onPointerDown:Z,onKeyDown:Y,originalTabIndex:$,originalAriaLabel:j,originalRole:_})}#z(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)}#S(){if(this.#_?.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.#_=J,document.body.appendChild(J)}#L(J){if(!this.#_)return;this.#_.textContent="",requestAnimationFrame(()=>{if(this.#_)this.#_.textContent=J})}#f(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#R(J){document.body.classList.toggle(H.#W,J)}#V(J,Q,Z){this.#I();let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#G().indexOf(Q),targetIndex:this.#G().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.#R(!0);try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let Y=this.#Y==="horizontal"?j.clientX:j.clientY,B=this.#T(Y);$.targetIndex=B,this.#H(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#y($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#y($,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.#G(),Z=this.#Y==="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}#p(J,Q){let Z=this.#G(),$=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}#D(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-$}}#E(){if(this.#k)return this.#k;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#Y),document.body.appendChild(J),this.#k=J,J}#H(J,Q){let Z=this.#G();if(!this.#p(Q,J)){this.#b();return}let $=this.#D(Z);if(!$){this.#b();return}let j=this.#E();if(j.setAttribute("data-axis",this.#Y),this.#Y==="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"}#b(){this.#k?.remove(),this.#k=null}#A(J,Q){let Z=this.#G(),$=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)}#d(J,Q){let $=this.#G().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#y(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:Y}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",Y),j){if(!Q){this.#A(Z,J.targetIndex);let B=this.#G().indexOf(Z);if(B!==-1&&B!==$){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}));let G=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#L(`${G}, position ${B+1} of ${this.#G().length}`)}}}if(Z.classList.remove("dragging"),H.#R(!1),this.#b(),this.#j===J)this.#j=null}#C(){for(let[,J]of this.#X)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#z(J);this.#X.clear()}#I(){if(!this.#j)return;this.#y(this.#j,!0)}}S("fig-reorder",H);var c=new WeakSet,x=new WeakSet,v=new WeakSet;function _J(J){return Array.from(J.querySelectorAll("fig-select-option"))}function w(J,Q,Z=!0){let $=_J(J);if(!$.length)return;let j=Q&&$.includes(Q)?Q:$.find((Y)=>U(Y,"selected"));if(!j||U(j,"disabled"))j=$.find((Y)=>!U(Y,"disabled"))||$[0];if(!j)return;let _=j.value??j.getAttribute("value")??"",X=J.getAttribute("value")??"";J.setAttribute("value",String(_));for(let Y of $){let B=Y===j;Y.toggleAttribute("selected",B),Y.setAttribute("aria-selected",String(B))}if(Z&&X!==String(_))J.dispatchEvent(new CustomEvent("input",{detail:String(_),bubbles:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:String(_),bubbles:!0,composed:!0}))}function p(J){if(c.has(J))return;if(!J.shadowRoot?.querySelector(".fig-select-trigger")){requestAnimationFrame(()=>{if(J.isConnected)p(J)});return}c.add(J),new MutationObserver(($)=>{let j=null,_=!1;for(let X of $){if(X.type!=="attributes"||X.attributeName!=="selected"||X.target.tagName!=="FIG-SELECT-OPTION")continue;if(U(X.target,"selected"))j=X.target;else if(String(X.target.value??"")===(J.getAttribute("value")??""))_=!0}if(j){let X=String(j.value??"");if((J.getAttribute("value")??"")!==X)w(J,j)}else if(_)w(J,null)}).observe(J,{attributes:!0,subtree:!0,attributeFilter:["selected"]})}function XJ(J){if(v.has(J))return;let Q=J.shadowRoot?.querySelector(".fig-select-trigger");if(!Q)return;v.add(J),Q.addEventListener("click",()=>{if(U(J,"disabled"))return;J.open=!J.open}),J.addEventListener("click",(Z)=>{let $=Z.composedPath().find((j)=>j?.tagName==="FIG-SELECT-OPTION");if(!$||!J.contains($)||U($,"disabled"))return;w(J,$),J.open=!1})}function BJ(J){if(J instanceof Element&&J.matches("fig-select"))x.add(J);J.querySelectorAll?.("fig-select").forEach((Q)=>x.add(Q))}function e(J){if(J instanceof Element&&J.matches("fig-select"))p(J);J.querySelectorAll?.("fig-select").forEach((Q)=>p(Q))}e(document);new MutationObserver((J)=>{for(let Q of J){for(let Z of Q.removedNodes)if(Z instanceof Element)BJ(Z);for(let Z of Q.addedNodes){if(!(Z instanceof Element))continue;e(Z);let $=Z.matches("fig-select")?[Z]:[...Z.querySelectorAll("fig-select")];for(let j of $)if(x.has(j))XJ(j)}}}).observe(document.documentElement,{childList:!0,subtree:!0});
|
|
58
|
+
`}#O(){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,">")}#z(){return U(this,"disabled")}#S(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.#S(J);if(this.angle=Z,this.#A(),Q){let $=String(Z);if(this.getAttribute("value")!==$)this.setAttribute("value",$)}if(this.#W(),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.#O();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}}#V(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#F(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#p(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 $}}#D(){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.#j),this.plane?.addEventListener("touchstart",this.#N),this.plane?.addEventListener("keydown",this.#Y),window.addEventListener("keydown",this.#_),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#B),this.angleInput.addEventListener("change",this.#B);this.addEventListener("change",this.#X,!0)}#E(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#N),this.plane?.removeEventListener("keydown",this.#Y),window.removeEventListener("keydown",this.#_),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#B),this.angleInput.removeEventListener("change",this.#B);this.removeEventListener("change",this.#X,!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.#p($,j,this.units);J.target.value=String(_)}}}#b(J){if(J.stopPropagation(),this.#z())return;if(this.#L(Number(J.target.value)),J.type==="change")this.#u();else this.#I()}#A(){let Q=this.#V(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#d(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#y(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}#C(J){let Z=(this.#y(J)%360+360)%360;if(Z=this.#d(Z),this.min!==null||this.max!==null)this.angle=this.#S(this.#F(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.#S(this.angle+this.#F(X))}else{let j=Z-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle=this.#S(this.angle+this.#F(j)),this.#J=Z}if(this.#A(),this.setAttribute("value",String(this.angle)),this.#W(),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}}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#W(){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)`}}#x(J){if(this.#z()||J.button!==0)return;this.#c(),this.isDragging=!0,this.#J=null,this.#C(J);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(j)},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#G===Z)this.#G=null,this.#k=null;if(j)this.#u()};this.#G=Z,this.#k=$,window.addEventListener("mousemove",Q,{signal:Z.signal}),window.addEventListener("mouseup",()=>$(!0),{signal:Z.signal}),window.addEventListener("blur",()=>$(!1),{signal:Z.signal})}#i(J){if(this.#z())return;J.preventDefault(),this.#c(),this.isDragging=!0,this.#J=null,this.#C(J.touches[0]);let Q=(j)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(j.touches[0])},Z=new AbortController,$=(j=!1)=>{if(this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),Z.abort(),this.#G===Z)this.#G=null,this.#k=null;if(j)this.#u()};this.#G=Z,this.#k=$,window.addEventListener("touchmove",Q,{signal:Z.signal}),window.addEventListener("touchend",()=>$(!0),{signal:Z.signal}),window.addEventListener("touchcancel",()=>$(!1),{signal:Z.signal})}#c(){this.#k?.(!1),this.#G?.abort(),this.#G=null,this.#k=null,this.isDragging=!1,this.#J=null,this.plane?.classList.remove("dragging")}#o(J){if(this.#z())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.#F(0);else if(J.key==="End")Z=this.max??this.#F(360);else return;J.preventDefault(),J.stopPropagation(),this.#L(Z),this.#I(),this.#u()}#h(J){if(J.key==="Shift")this.isShiftHeld=!0}#_J(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.#P(),this.#D(),this.#W()}break;case"dial":if(this.dial=this.#q("dial",!0),this.isConnected)this.#P(),this.#D(),this.#W();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#P(),this.#D(),this.#W();break}case"min":if(this.min=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#P(),this.#D(),this.#W();break;case"max":if(this.max=Z!==null?Number(Z):null,this.#L(this.angle),this.isConnected)this.#P(),this.#D(),this.#W();break;case"disabled":if(this.#c(),this.isConnected)this.#P(),this.#D(),this.#W();break;case"aria-label":case"name":if(this.isConnected)this.#P(),this.#D(),this.#W();break;case"rotations":case"show-rotations":if(this.showRotations=this.#M(),this.isConnected)this.#P(),this.#D(),this.#W();break}}}S("fig-input-angle",A);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;#X=new Map;#j=null;#N=null;#_=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.#S(),this.#k(),this.#J=new MutationObserver(()=>this.#k()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#C(),this.#I(),this.#b(),this.#_?.remove(),this.#_=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#Y(){return(this.getAttribute("handle")||"").trim()}#G(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE&&!J.hasAttribute("data-reorder-live"))}#k(){let J=this.#G(),Q=new Set(J);for(let[Z,$]of this.#X)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),$.target.removeEventListener("keydown",$.onKeyDown),this.#z($),this.#X.delete(Z);if(this.#M(J),this.#P(J),this.#$||J.length<2){this.#C();return}for(let Z of J){let $=this.#O(Z),j=this.#X.get(Z);if(j&&j.target===$)continue;if(j)j.target.removeEventListener("pointerdown",j.onPointerDown,!0),this.#X.delete(Z);if(!$)continue;this.#K(Z,$)}this.#U(J),this.#q(J)}#P(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")}#q(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","")}#M(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>{Z.removeAttribute("data-reorder-handle"),Z.removeAttribute("aria-roledescription")})}#U(J){if(!this.#Y)return;for(let Q of J){let Z=Q.querySelector(this.#Y);if(Z)Z.setAttribute("data-reorder-handle",""),Z.setAttribute("aria-roledescription","reorder handle")}}#O(J){if(this.#Y)return J.querySelector(this.#Y);return J}#K(J,Q){let Z=(B)=>{if(this.#$||this.#G().length<2)return;if(B.button!==0)return;if(!this.#Y&&this.#f(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 Y=(B)=>{if(this.#$)return;let G=this.#B==="horizontal",k=G?"ArrowLeft":"ArrowUp",N=G?"ArrowRight":"ArrowDown";if(B.key!==k&&B.key!==N&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault(),B.stopPropagation();let P=this.#G(),O=P.indexOf(J),q=O;if(B.key===k)q=Math.max(0,O-1);else if(B.key===N)q=Math.min(P.length-1,O+1);else if(B.key==="Home")q=0;else if(B.key==="End")q=P.length-1;if(q===O){this.#L(`${X}, position ${O+1} of ${P.length}`);return}this.#d(J,q),this.#k(),this.#O(J)?.focus(),this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:O,newIndex:q,item:J}})),this.#L(`${X}, position ${q+1} of ${P.length}`)};Q.addEventListener("pointerdown",Z,!0),Q.addEventListener("keydown",Y),this.#X.set(J,{target:Q,onPointerDown:Z,onKeyDown:Y,originalTabIndex:$,originalAriaLabel:j,originalRole:_})}#z(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)}#S(){if(this.#_?.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.#_=J,document.body.appendChild(J)}#L(J){if(!this.#_)return;this.#_.textContent="",requestAnimationFrame(()=>{if(this.#_)this.#_.textContent=J})}#f(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#T="fig-reorder-dragging";static#R(J){document.body.classList.toggle(H.#T,J)}#V(J,Q,Z){this.#I();let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#G().indexOf(Q),targetIndex:this.#G().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.#R(!0);try{Z.setPointerCapture($.pointerId)}catch{}}j.preventDefault();let Y=this.#B==="horizontal"?j.clientX:j.clientY,B=this.#F(Y);$.targetIndex=B,this.#H(B,Q)},$.onKeyDown=(j)=>{if(j.key!=="Escape"||!$.active)return;j.preventDefault(),this.#y($,!0)},$.onUp=(j)=>{if(j.pointerId!==$.pointerId)return;this.#y($,j.type==="pointercancel")},this.#j=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#F(J){let Q=this.#G(),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}#p(J,Q){let Z=this.#G(),$=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}#D(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-$}}#E(){if(this.#N)return this.#N;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#B),document.body.appendChild(J),this.#N=J,J}#H(J,Q){let Z=this.#G();if(!this.#p(Q,J)){this.#b();return}let $=this.#D(Z);if(!$){this.#b();return}let j=this.#E();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"}#b(){this.#N?.remove(),this.#N=null}#A(J,Q){let Z=this.#G(),$=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)}#d(J,Q){let $=this.#G().filter((j)=>j!==J)[Q]??null;if($)this.insertBefore(J,$);else this.appendChild(J)}#y(J,Q){let{item:Z,oldIndex:$,active:j,onMove:_,onUp:X,onKeyDown:Y}=J;if(window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",Y),j){if(!Q){this.#A(Z,J.targetIndex);let B=this.#G().indexOf(Z);if(B!==-1&&B!==$){this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}));let G=Z.getAttribute("aria-label")||Z.textContent?.trim().replace(/\s+/g," ").slice(0,80)||"item";this.#L(`${G}, position ${B+1} of ${this.#G().length}`)}}}if(Z.classList.remove("dragging"),H.#R(!1),this.#b(),this.#j===J)this.#j=null}#C(){for(let[,J]of this.#X)J.target.removeEventListener("pointerdown",J.onPointerDown,!0),J.target.removeEventListener("keydown",J.onKeyDown),this.#z(J);this.#X.clear()}#I(){if(!this.#j)return;this.#y(this.#j,!0)}}S("fig-reorder",H);var c=new WeakSet,x=new WeakSet,v=new WeakSet;function _J(J){return Array.from(J.querySelectorAll("fig-select-option"))}function w(J,Q,Z=!0){let $=_J(J);if(!$.length)return;let j=Q&&$.includes(Q)?Q:$.find((Y)=>U(Y,"selected"));if(!j||U(j,"disabled"))j=$.find((Y)=>!U(Y,"disabled"))||$[0];if(!j)return;let _=j.value??j.getAttribute("value")??"",X=J.getAttribute("value")??"";J.setAttribute("value",String(_));for(let Y of $){let B=Y===j;Y.toggleAttribute("selected",B),Y.setAttribute("aria-selected",String(B))}if(Z&&X!==String(_))J.dispatchEvent(new CustomEvent("input",{detail:String(_),bubbles:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:String(_),bubbles:!0,composed:!0}))}function p(J){if(c.has(J))return;if(!J.shadowRoot?.querySelector(".fig-select-trigger")){requestAnimationFrame(()=>{if(J.isConnected)p(J)});return}c.add(J),new MutationObserver(($)=>{let j=null,_=!1;for(let X of $){if(X.type!=="attributes"||X.attributeName!=="selected"||X.target.tagName!=="FIG-SELECT-OPTION")continue;if(U(X.target,"selected"))j=X.target;else if(String(X.target.value??"")===(J.getAttribute("value")??""))_=!0}if(j){let X=String(j.value??"");if((J.getAttribute("value")??"")!==X)w(J,j)}else if(_)w(J,null)}).observe(J,{attributes:!0,subtree:!0,attributeFilter:["selected"]})}function XJ(J){if(v.has(J))return;let Q=J.shadowRoot?.querySelector(".fig-select-trigger");if(!Q)return;v.add(J),Q.addEventListener("click",()=>{if(U(J,"disabled"))return;J.open=!J.open}),J.addEventListener("click",(Z)=>{let $=Z.composedPath().find((j)=>j?.tagName==="FIG-SELECT-OPTION");if(!$||!J.contains($)||U($,"disabled"))return;w(J,$),J.open=!1})}function BJ(J){if(J instanceof Element&&J.matches("fig-select"))x.add(J);J.querySelectorAll?.("fig-select").forEach((Q)=>x.add(Q))}function e(J){if(J instanceof Element&&J.matches("fig-select"))p(J);J.querySelectorAll?.("fig-select").forEach((Q)=>p(Q))}e(document);new MutationObserver((J)=>{for(let Q of J){for(let Z of Q.removedNodes)if(Z instanceof Element)BJ(Z);for(let Z of Q.addedNodes){if(!(Z instanceof Element))continue;e(Z);let $=Z.matches("fig-select")?[Z]:[...Z.querySelectorAll("fig-select")];for(let j of $)if(x.has(j))XJ(j)}}}).observe(document.documentElement,{childList:!0,subtree:!0});
|