@rogieking/figui3 6.20.2 → 6.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -1
- package/components.css +63 -2
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-editor.js +115 -98
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +16 -16
- package/dist/fig.css +1 -1
- package/dist/fig.js +60 -43
- package/dist/propskit.css +1 -0
- package/dist/propskit.js +1 -0
- package/fig-editor.css +157 -17
- package/fig-editor.js +464 -188
- package/fig-lab.css +51 -42
- package/fig-lab.js +145 -23
- package/fig.js +577 -68
- package/package.json +33 -4
- package/propskit-core.js +556 -0
- package/propskit.d.ts +98 -0
- package/propskit.js +15 -0
package/dist/fig-lab.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=null;#$=null;#q=this.#L.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#X();if(this.#B(),this.#U(),this.#k(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#K(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#X(){let Q=Array.from(this.childNodes).filter((X)=>X.nodeType!==Node.TEXT_NODE||Boolean(X.textContent?.trim())).find((X)=>X.nodeType===Node.ELEMENT_NODE&&X.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-segmented-control"),j=document.createElement("fig-segment"),G=document.createElement("fig-segment");_.setAttribute("sizing","equal"),j.setAttribute("value","off"),j.textContent="Off",G.setAttribute("value","on"),G.textContent="On",_.append(j,G),Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#z(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","checked","value"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#z(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",Y(this,"checked")?"on":"off"),this.#Y=Q}#k(){if(!this.#J)return;this.#G??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#K(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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}))}#L(J){if(J.target instanceof Element&&J.target.closest("fig-segmented-control"))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":Y(this,"checked")}set checked(J){this.toggleAttribute("checked",Boolean(J))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){this.setAttribute("value",J??"")}focus(J){(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}customElements.define("propskit-switch",y);class b extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=null;#$=null;#q=this.#W.bind(this);#X=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#B();if(this.#z(),this.#k(),this.#K(),this.#X===null)this.#X=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#z();if(Z)this.#k()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#N(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#z()}#B(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-color");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#z(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#U(){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-"))}#k(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J){let $=this.getAttribute(Z)??"";if(Z==="value"&&this.#J.getAttribute("value")===$)continue;this.#J.setAttribute(Z,$)}this.#J.setAttribute("text","true"),this.#Y=Q}#K(){if(!this.#J)return;this.#G??=this.#D.bind(this,"input"),this.#$??=this.#D.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#L(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")??""}#D(J,Q){Q.stopImmediatePropagation();let Z=this.#L(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}))}#W(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))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)}#M(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#T(){return this.getAttribute("default")??this.#X??""}resetToDefault(){let J=String(this.#T());this.setAttribute("value",J),this.#M(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)}}customElements.define("propskit-color",b);class x extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=null;#$=null;#q=this.#T.bind(this);#X=this.#M.bind(this);#B=!1;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#z();if(this.#U(),this.#K(),this.#N(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#X,!0),this.addEventListener("pointerdown",this.#X,!0),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let _=$.attributeName;if(_==="label"||_==="direction"||_==="aria-label")Q=!0;else Z=!0}if(Q)this.#U();if(Z)this.#K()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#L(),this.removeEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#X,!0)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#U();return}if(J==="options"||J==="value")this.#K()}#z(){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.#j=Boolean(J),this.replaceChildren(Q)}#U(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#k(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#k().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.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#N(){if(!this.#J)return;this.#G??=this.#D.bind(this,"input"),this.#$??=this.#D.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#L(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#D(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}))}#W(){if(!this.#J)return!1;if(this.#J.open)return!0;let J=this.#J.shadowRoot?.querySelector('dialog[is="fig-popup"]');return Boolean(J?.open||J?.matches?.(":open"))}#M(J){if(!(J.target instanceof Element))return;if(J.target.closest("fig-select")){this.#B=!1;return}this.#B=this.#W()}#T(J){if(J.target instanceof Element&&J.target.closest("fig-select")){this.#B=!1;return}if(!this.#J||Y(this.#J,"disabled")){this.#B=!1;return}if(this.#J.focus(),this.#B||this.#W()){this.#B=!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))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-select",x);class w extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=null;#$=null;#q=this.#L.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#X();if(this.#B(),this.#U(),this.#k(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#K(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#B()}#X(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-text");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#z(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","multiline","resizable"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#z(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#k(){if(!this.#J)return;this.#G??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#K(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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}))}#L(J){if(J.target instanceof Element&&J.target.closest("fig-input-text"))return;this.focus()}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))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-text",w);class h extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=null;#$=null;#q=this.#L.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#X();if(this.#B(),this.#U(),this.#k(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#K(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#X(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-number");Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#B(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#z(){let J=new Set(["label","direction","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#U(){if(!this.#J)return;let J=this.#z(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#k(){if(!this.#J)return;this.#G??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#$)}#K(){if(!this.#J)return;if(this.#G)this.#J.removeEventListener("input",this.#G);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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}))}#L(J){if(J.target instanceof Element&&J.target.closest("fig-input-number"))return;this.focus()}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J==="")this.removeAttribute("value");else this.setAttribute("value",String(J))}focus(J){this.#J?.focus(J)}}customElements.define("propskit-number",h);class I extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text"].join(",");#Q=null;#J=null;#j=null;#_=new WeakMap;#Y=null;#G=0;#$=()=>this.#B();connectedCallback(){this.#A(),this.#q(),requestAnimationFrame(()=>{this.#D(),this.#T()})}disconnectedCallback(){if(this.#X(),this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(this.#Q)this.#Q.removeEventListener("click",this.#U),this.#Q.removeEventListener("keydown",this.#k);this.#j?.querySelector("fig-button")?.removeEventListener("click",this.#K)}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.#H(),this.#T();return}this.#A()}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.#R()}#q(){if(this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.addEventListener("input",this.#$,!0),this.addEventListener("change",this.#$,!0),!this.#Y)this.#Y=new MutationObserver(()=>{this.#D(),this.#B()});this.#Y.disconnect(),this.#Y.observe(this,{childList:!0,subtree:!0})}#X(){this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.#Y?.disconnect()}#B(){if(this.#G)return;this.#G=requestAnimationFrame(()=>{this.#G=0,this.#D(),this.#T()})}#z(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#U=(J)=>{if(this.#z(J.target))return;J.stopPropagation(),this.open=!this.open};#k=(J)=>{if(this.#z(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#K=(J)=>{J.preventDefault(),J.stopPropagation(),this.#R()};#N(){return[...this.querySelectorAll(I.#Z)].filter((J)=>J.closest("propskit-group")===this)}#L(J){if(J.localName==="propskit-switch")return{kind:"checked",value:Boolean(J.checked)};if("value"in J)return{kind:"value",value:J.value};return{kind:"value",value:J.getAttribute("value")??""}}#D(){for(let J of this.#N()){if(this.#_.has(J))continue;if(J.hasAttribute("default")){if(J.localName==="propskit-switch"){this.#_.set(J,{kind:"checked",value:Y(J,"default")});continue}this.#_.set(J,{kind:"value",value:J.getAttribute("default")??""});continue}this.#_.set(J,this.#L(J))}}#W(J){let Q=this.#_.get(J);if(!Q)return!1;let Z=this.#L(J);if(Q.kind==="checked")return Boolean(Z.value)!==Boolean(Q.value);return String(Z.value??"")!==String(Q.value??"")}#M(){for(let J of this.#N())if(this.#W(J))return!0;return!1}#T(){if(this.#M())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#H()}#O(J){let Q=this.#_.get(J);if(!Q)return;if(Q.kind==="checked"){J.checked=Q.value;let $={checked:Boolean(Q.value),value:J.getAttribute("value")??""};J.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,cancelable:!0,composed:!0}));return}if(typeof J.resetToDefault==="function"){let $=J.getAttribute("default");if(J.setAttribute("default",String(Q.value??"")),J.resetToDefault(),$===null)J.removeAttribute("default");else J.setAttribute("default",$);return}J.value=Q.value;let Z=J.getAttribute?.("value")??("value"in J?J.value:Q.value);J.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#R(){this.#D();for(let J of this.#N())this.#O(J);this.#T(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#H(){if(!this.showReset){this.#j?.setAttribute("hidden","");return}this.#V(),this.#j?.removeAttribute("hidden")}#V(){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.#K)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#K),Q?.addEventListener("click",this.#K)}this.#j=J}#A(){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=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector("h3");if(!$)$=document.createElement("h3"),this.#Q.prepend($);if(!$.id)$.id=v("propskit-group");if(this.#Q.dataset.generated){let _=$.querySelector(".propskit-group-chevron");if($.textContent=Q,_)$.prepend(_)}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 _=document.createElement("fig-icon");_.setAttribute("name","chevron"),_.setAttribute("size","small"),_.className="propskit-group-chevron",$.prepend(_)}if(this.#J=$.querySelector(".propskit-group-chevron"),this.#H(),this.#Q.removeEventListener("click",this.#U),this.#Q.addEventListener("click",this.#U),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#k),this.#Q.addEventListener("keydown",this.#k),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}customElements.define("propskit-group",I);class g extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#G=0;#$=0;#q=null;#X=null;#B=0;#z=null;#U=!1;#k=0;#K=null;#N=0;#L=null;#D=null;#W=null;#M=this.#l.bind(this);#T=this.#g.bind(this);#O=this.#x.bind(this);#R=this.#v.bind(this);#H=this.#GJ.bind(this);#V=this.#i.bind(this);#A=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.#P();if(this.#S(),this.#F(),this.#qJ(),this.#C(),this.removeEventListener("pointerdown",this.#M,{capture:!0}),this.addEventListener("pointerdown",this.#M,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#H),this.addEventListener("contextmenu",this.#H),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#A.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#S();if(Z)this.#F(),this.#C()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#_?.disconnect(),this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#o(),this.#w(),this.#y(),this.#d(),this.#BJ(),this.removeEventListener("pointerdown",this.#M,{capture:!0}),this.removeEventListener("contextmenu",this.#H),this.#X?.removeEventListener("change",this.#V)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#S()}#P(){let J=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-slider");_.setAttribute("text","true");for(let j of this.#h()){let G=this.getAttribute(j);_.setAttribute(j,G??"")}Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#b();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#b(){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 to default",J.appendChild(Q),J.addEventListener("change",this.#V),this.#X=J,this.appendChild(J)}#S(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#F(){if(!this.#J)return;let J=this.#h(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#Y)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J){if($==="text")continue;let _=this.getAttribute($);this.#J.setAttribute($,_??"")}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","light-dark(#444444, #e6e6e6)");else this.#J.style.removeProperty("--color");this.#Y=Q,this.#E()}#h(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#A.has(Q))}#E(){if(this.#G)cancelAnimationFrame(this.#G);this.#G=requestAnimationFrame(()=>{this.#G=0,this.#JJ(),this.#I()})}#C(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#I()})}#I(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#q)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#d(),this.#q=J,!this.#q)return;this.#q.addEventListener("dblclick",this.#R,{capture:!0})}#d(){if(!this.#q)return;this.#q.removeEventListener("dblclick",this.#R,{capture:!0}),this.#q=null}#v(J){J.preventDefault(),J.stopImmediatePropagation(),this.#_J()}#l(J){if(J.button!==0||Y(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#q;if(!Q)return;this.#w(),this.#y(),this.#q=Q,this.#U=!0,this.#L=J.pointerId,this.#k=this.#u();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#K={left:Z.left,right:Z.right,width:Z.width},this.#N=$.width,window.addEventListener("pointermove",this.#T,{passive:!0}),window.addEventListener("pointerup",this.#O,{once:!0}),window.addEventListener("pointercancel",this.#O,{once:!0}),window.addEventListener("blur",this.#O,{once:!0})}#g(J){if(!this.#U)return;if(J.pointerId!==this.#L)return;if(J.buttons===0){this.#x(J);return}this.#n(J.clientX)}#x(J){if(J?.pointerId!==void 0&&this.#L!==null&&J.pointerId!==this.#L)return;this.#w(),this.#y()}#w(){window.removeEventListener("pointermove",this.#T),window.removeEventListener("pointerup",this.#O),window.removeEventListener("pointercancel",this.#O),window.removeEventListener("blur",this.#O),this.#U=!1,this.#L=null}#GJ(J){if(Y(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#o(),this.#QJ(J.clientX,J.clientY)}#QJ(J,Q){let Z=!1,$=0,_=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0),requestAnimationFrame(()=>{this.#X?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#i(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#_J()}#o(){if(this.#B)clearTimeout(this.#B),this.#B=0;this.#z=null}#u(){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}#n(J){let Q=this.#K;if(!Q||!this.#k){this.#y();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#r();return}let $=Math.max(-this.#k,Math.min(this.#k,Z*0.5)),_=Math.abs($),j=this.#N?(this.#N+_)/this.#N:1;this.dataset.elasticDragging="true",this.style.setProperty("--propskit-slider-elastic-size",`${_}px`),this.style.setProperty("--propskit-slider-elastic-scale",`${j}`),this.style.setProperty("--propskit-slider-elastic-origin",$<0?"right center":"left center")}#y(){this.#r(),this.#k=0,this.#K=null,this.#N=0,this.#L=null}#r(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#XJ(J){let Q=this.#q;if(!Q)return this.#J?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,_=Number(Q.min||0),j=Number(Q.max||100),G=Q.step==="any"?0:Number(Q.step||1),X=_+(j-_)*$;if(!G)return String(X);let q=Math.round((X-_)/G)*G+_,B=Math.max(0,`${G}`.split(".")[1]?.length||0);return String(Number(q.toFixed(B)))}#s(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#q?.min??"0"}#_J(){this.#o(),this.#a(this.#s(),"input"),this.#a(this.#s(),"change")}#a(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#JJ(){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??"")}#qJ(){if(!this.#J)return;if(!this.#D)this.#D=this.#ZJ.bind(this,"input");if(!this.#W)this.#W=this.#ZJ.bind(this,"change");this.#J.addEventListener("input",this.#D),this.#J.addEventListener("change",this.#W)}#BJ(){if(!this.#J)return;if(this.#D)this.#J.removeEventListener("input",this.#D);if(this.#W)this.#J.removeEventListener("change",this.#W)}#ZJ(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#y();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector('input[type="range"]')?.focus(J)}resetToDefault(){this.#_J()}}customElements.define("propskit-slider",g);class m extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#j=75;#_=0;#Y=!1;#G=0;#$=null;#q=null;#X=null;#B=null;#z=null;#U=null;#k=null;#K=null;#N=null;#L=!1;#D=!1;#W=!1;#M=!1;#T=null;#O="";#R="";#H=null;#V=null;#A=null;#P="";#b="";#S=null;get#F(){return this.getAttribute("type")||"point"}get#h(){return this.#F==="point-radius"||this.#F==="point-radius-angle"}get#E(){return this.#F==="point-radius-angle"}get#C(){return this.#F==="point-point"}get#I(){return this.#F==="point-radius-angle"||this.#F==="point-point"}get#c(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#d(){let J=this.getAttribute("snapping");if(J===null)return"false";let Q=J.trim().toLowerCase();if(Q==="modifier")return"modifier";if(Q===""||Q==="true")return"true";return"false"}#v(J){let Q=this.#d;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#l(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#g(){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.#j)}%`}get#x(){return this.getAttribute("drag-surface")||"parent"}get#w(){let J=this.#x;if(J==="parent")return this.parentElement;return this.closest(J)}get#GJ(){let J=this.#x;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#QJ(J){if(this.#Y)return this.#_/100*J;return this.#_}#i(){if(this.#Y)return`Radius ${Math.round(this.#_)}%`;return`Radius ${Math.round(this.#_)}`}connectedCallback(){this.#o(),this.#u()}disconnectedCallback(){this.#SJ(),this.#r(),this.#a(),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.#L&&!this.#D&&!this.#W&&!this.#M)if(this.#o(),this.#$)this.#m();else this.#u();if(J==="type")this.#o(),this.#u();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#u();if(J==="tooltips")this.#u();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#q)this.#q.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#U)this.#U.setAttribute("text",this.#l);if(this.#k)this.#k.setAttribute("text",this.#g)}}#o(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#Y=!0,this.#_=parseFloat(Z);else this.#Y=!1,this.#_=parseFloat(Z);if(!Number.isFinite(this.#_))this.#_=0}if(typeof Q.angle==="number")this.#G=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#F==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#h)J.radius=this.#Y?`${this.#_}%`:this.#_;if(this.#E)J.angle=this.#G;if(this.#C)J.x2=this.#J,J.y2=this.#j;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#u(){this.innerHTML="",this.#$=null,this.#q=null,this.#X=null,this.#B=null,this.#z=null,this.#U=null,this.#k=null,this.#K=null,this.#N=null;let J=Y(this,"disabled"),Q=this.#F,Z=this.#c,$=this.#GJ,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#d),_.setAttribute("value",`${this.#Z}% ${this.#Q}%`),J)_.setAttribute("disabled","");if(Q==="color"){_.setAttribute("type","color");let j=this.getAttribute("color");if(j)_.setAttribute("color",j)}else _.setAttribute("type","canvas");if(this.#C)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#h)this.#DJ();if(this.#I)this.#kJ();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#l),j.appendChild(_),this.appendChild(j),this.#U=j}else this.appendChild(_);if(this.#E)this.#p(J,Z,$);if(this.#C)this.#WJ(J,Z,$);this.#n(this.#$),this.#n(this.#X),this.#n(this.#q),this.#HJ(),this.#BJ(),requestAnimationFrame(()=>this.#m())}#n(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#_J(Q,J);else this.#y(Q)},{capture:!0})}#y(J){if(Y(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#T===null)this.#O=document.body.style.getPropertyValue("cursor"),this.#R=document.body.style.getPropertyPriority("cursor");if(this.#T=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#H)this.#H=(Q)=>{if(Q?.pointerId!==void 0&&this.#T!==null&&Q.pointerId!==this.#T)return;if(Q?.type==="blur")this.#r();else requestAnimationFrame(()=>this.#r())};window.addEventListener("pointerup",this.#H),window.addEventListener("pointercancel",this.#H),window.addEventListener("blur",this.#H)}#r(){if(this.#T===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#O)document.body.style.setProperty("cursor",this.#O,this.#R);else document.body.style.removeProperty("cursor");if(this.#T=null,this.#O="",this.#R="",this.#H)window.removeEventListener("pointerup",this.#H),window.removeEventListener("pointercancel",this.#H),window.removeEventListener("blur",this.#H)}#XJ(J){if(!J)return 0;if(J===this.#X)return this.#G;if(!this.#C)return 0;let Q=this.#KJ();return J===this.#$?Q+180:Q}#s(){if(this.#V===null)return;let J=this.#YJ(this.#XJ(this.#A));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#_J(J,Q){if(Y(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.#b=document.body.style.getPropertyPriority("cursor");if(this.#V=J?.pointerId??-1,this.#A=Q,document.body.classList.add("fig-lab-rotate-active"),this.#s(),!this.#S)this.#S=(Z)=>{if(Z?.pointerId!==void 0&&this.#V!==null&&Z.pointerId!==this.#V)return;if(Z?.type==="blur")this.#a();else requestAnimationFrame(()=>this.#a())};window.addEventListener("pointerup",this.#S),window.addEventListener("pointercancel",this.#S),window.addEventListener("blur",this.#S)}#a(){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.#b);else document.body.style.removeProperty("cursor");if(this.#V=null,this.#A=null,this.#P="",this.#b="",this.#S)window.removeEventListener("pointerup",this.#S),window.removeEventListener("pointercancel",this.#S),window.removeEventListener("blur",this.#S)}#JJ(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let q=Q();if(!q)return;q.removeAttribute("show"),q.hidePopup?.()},G=()=>{if(_()){j();return}let q=Q();if(!q)return;if(Z)q.setAttribute("text",Z());q.setAttribute("show","true"),q.showPopup?.()},X=()=>{j()};J.addEventListener("pointerenter",G),J.addEventListener("pointerleave",X)}#qJ(){return this.#L||this.#D||this.#W||this.#M}#BJ(){if(this.#$)this.#JJ(this.#$,()=>this.#U,()=>this.#l,()=>this.#qJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#X)this.#JJ(this.#X,()=>this.#N,()=>`Angle ${Math.round(this.#G)}°`,()=>this.#qJ());if(this.#q)this.#JJ(this.#q,()=>this.#k,()=>this.#g,()=>this.#qJ());if(this.#B){let J=this.#B.querySelector(".fig-canvas-control-radius-hit");this.#UJ(J||this.#B)}if(this.#F==="color"&&this.#$&&this.#U)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#U?.removeAttribute("show"),this.#U?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#ZJ(J,Q){let Z=this.#K;if(!Z?.popup)return;let $=Q-8;Z.popup.anchor={getBoundingClientRect:()=>({left:J,top:$,right:J,bottom:$,width:0,height:0,x:J,y:$})},Z.popup.queueReposition?.()}#UJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#K;if(!Z)return;Z.setAttribute("text",this.#i()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#W)return;this.#ZJ(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#W)return;let Q=this.#K;if(!Q)return;Q.removeAttribute("show")})}#DJ(){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 _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#B=Q,this.#c){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#i()),j.appendChild(Q),this.appendChild(j),this.#K=j}else this.appendChild(Q);this.#PJ(Z)}#kJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#C){let _=document.createElementNS("http://www.w3.org/2000/svg","line");_.classList.add("fig-canvas-control-angle-line-hit"),_.setAttribute("stroke","transparent"),_.setAttribute("stroke-width","12"),_.setAttribute("stroke-linecap","round"),_.style.pointerEvents="stroke",Q.appendChild(_),this.#FJ(_)}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.#z=Q,this.appendChild(Q)}#FJ(J){J.addEventListener("pointerdown",(Q)=>{if(Y(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#w;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,G=this.#Z,X=this.#Q,q=this.#J,B=this.#j;this.#L=!0,this.#D=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let N=(U)=>{let L=Z.getBoundingClientRect(),D=L.width>0?(U.clientX-_)/L.width*100:0,k=L.height>0?(U.clientY-j)/L.height*100:0,z=-Math.min(G,q),P=100-Math.max(G,q),W=-Math.min(X,B),F=100-Math.max(X,B),T=Math.max(z,Math.min(P,D)),H=Math.max(W,Math.min(F,k));this.#Z=G+T,this.#Q=X+H,this.#J=q+T,this.#j=B+H,this.#m(),this.#t()},K=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#f(),this.#e(),window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",K),requestAnimationFrame(()=>{this.#L=!1,this.#D=!1})};window.addEventListener("pointermove",N),window.addEventListener("pointerup",K)})}#p(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.#X=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#G)}°`),_.appendChild($),this.appendChild(_),this.#N=_}else this.appendChild($)}#WJ(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("drag-snapping",this.#d),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#q=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#g),_.appendChild($),this.appendChild(_),this.#k=_}else this.appendChild($)}#jJ(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`}#YJ(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`}#LJ(J,Q){if(!J)return;J.style.setProperty("cursor",Q,"important")}#NJ(J,Q){if(!J)return;let Z=J.querySelector(".fig-handle-hit-area");if(!Z)return;if(Z.setAttribute("data-cursor","rotate"),this.#LJ(Z,this.#YJ(Q)),this.#A===J)this.#s()}#MJ(){if(!this.#X||!this.#E)return;this.#NJ(this.#X,this.#G)}#KJ(){return Math.atan2(this.#j-this.#Q,this.#J-this.#Z)*180/Math.PI}#zJ(){if(!this.#C)return;let J=this.#KJ();this.#$?.style.removeProperty("cursor"),this.#q?.style.removeProperty("cursor"),this.#NJ(this.#$,J+180),this.#NJ(this.#q,J)}#$J(J,Q,Z,$){J.style.setProperty("--fig-handle-position-translate","-50% -50%"),J.style.left=`${Q/100*$.width}px`,J.style.top=`${Z/100*$.height}px`}#m(){let J=this.#w;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#$J(this.#$,this.#Z,this.#Q,Q),this.#B){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#QJ(Q.width),j=this.#B,G=Math.max(_*2,1);j.style.position="absolute",j.style.width=`${G}px`,j.style.height=`${G}px`,j.style.left=`${Z-_}px`,j.style.top=`${$-_}px`,j.setAttribute("viewBox",`0 0 ${G} ${G}`);let X=j.querySelectorAll("circle");for(let q of X)q.setAttribute("cx",String(_)),q.setAttribute("cy",String(_)),q.setAttribute("r",String(Math.max(_-1,0)))}if(this.#z&&this.#I){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_,j;if(this.#C)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let q=this.#QJ(Q.width),B=this.#G*Math.PI/180;_=Z+q*Math.cos(B),j=$+q*Math.sin(B)}let G=this.#z;G.style.width=`${Q.width}px`,G.style.height=`${Q.height}px`,G.style.left="0",G.style.top="0",G.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let X=G.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let q of X)q.setAttribute("x1",String(Z)),q.setAttribute("y1",String($)),q.setAttribute("x2",String(_)),q.setAttribute("y2",String(j))}if(this.#X&&this.#E){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#QJ(Q.width),j=this.#G*Math.PI/180,G=Z+_*Math.cos(j),X=$+_*Math.sin(j),q=Q.width>0?G/Q.width*100:0,B=Q.height>0?X/Q.height*100:0;this.#$J(this.#X,q,B,Q)}if(this.#q&&this.#C)this.#$J(this.#q,this.#J,this.#j,Q);this.#MJ(),this.#zJ()}#t(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#e(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#f(){this.setAttribute("value",JSON.stringify(this.value))}#HJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#t();return}this.#L=!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.#U)this.#U.removeAttribute("show"),this.#U.hidePopup?.();this.#m(),this.#t()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#e();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.#U)this.#U.removeAttribute("show");this.#m(),this.#f(),this.#e(),requestAnimationFrame(()=>{this.#L=!1})}),this.#X)this.#X.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#w;if(!Q)return;this.#M=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,_=this.#Q/100*Z.height,j=J.detail?.x??0,G=J.detail?.y??0,X=this.#X.offsetWidth/2,q=this.#X.offsetHeight/2,B=j+X-$,N=G+q-_,K=Math.atan2(N,B)*180/Math.PI;if(this.#v(J.detail?.shiftKey))K=Math.round(K/15)*15;this.#G=K;let U=Math.sqrt(B*B+N*N);if(this.#v(J.detail?.shiftKey)){let L=this.#Y?5:10;if(this.#Y){let D=U/Z.width*100;D=Math.round(D/L)*L,U=D/100*Z.width}else U=Math.round(U/L)*L}if(this.#Y)this.#_=Math.max(0,U/Z.width*100);else this.#_=Math.max(0,U);if(this.#N)this.#N.setAttribute("text",`Angle ${Math.round(this.#G)}°`),this.#N.setAttribute("show","true"),this.#N.showPopup?.();this.#m(),this.#t()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#N)this.#N.removeAttribute("show");this.#m(),this.#f(),this.#e(),requestAnimationFrame(()=>{this.#M=!1})}),this.#X.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#w;if(!Z)return;if(this.#M=!0,this.classList.add("fig-canvas-control-ring-active"),this.#X.setAttribute("selected",""),this.#N)this.#N.setAttribute("show","true"),this.#N.showPopup?.();let $=(j)=>{let G=Z.getBoundingClientRect(),X=this.#Z/100*G.width,q=this.#Q/100*G.height,B=j.clientX-G.left-X,N=j.clientY-G.top-q,K=Math.atan2(N,B)*180/Math.PI;if(this.#v(j.shiftKey))K=Math.round(K/15)*15;if(this.#G=K,this.#N)this.#N.setAttribute("text",`Angle ${Math.round(K)}°`);this.#m(),this.#t()},_=()=>{if(this.#M=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#X.removeAttribute("selected"),this.#N)this.#N.removeAttribute("show");this.#f(),this.#e(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#q)this.#q.addEventListener("input",(J)=>{J.stopPropagation(),this.#D=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#j/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#j=Math.round(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show"),this.#k.hidePopup?.();this.#m(),this.#t()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#k)this.#k.removeAttribute("show");this.#m(),this.#f(),this.#e(),requestAnimationFrame(()=>{this.#D=!1})}),this.#TJ(this.#$,!0),this.#TJ(this.#q,!1)}#TJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#w;if(!_)return;this.#L=!0;let j=_.getBoundingClientRect(),G=Q?this.#J:this.#Z,X=Q?this.#j:this.#Q,q=Q?this.#Z:this.#J,B=Q?this.#Q:this.#j,N=G/100*j.width,K=X/100*j.height,U=q/100*j.width,L=B/100*j.height,D=Math.sqrt((U-N)**2+(L-K)**2),k=Q?this.#U:this.#k;if(k)k.removeAttribute("show"),k.hidePopup?.();let z=(W)=>{let F=_.getBoundingClientRect(),T=G/100*F.width,H=X/100*F.height,S=W.clientX-F.left-T,R=W.clientY-F.top-H,C=Math.atan2(R,S);if(this.#v(W.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let p=T+D*Math.cos(C),d=H+D*Math.sin(C),V=Math.max(0,Math.min(100,p/F.width*100)),A=Math.max(0,Math.min(100,d/F.height*100));if(Q)this.#Z=V,this.#Q=A;else this.#J=V,this.#j=A;this.#m(),this.#t()},P=()=>{if(this.#L=!1,k)k.removeAttribute("show");this.#f(),this.#e(),window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",P)};window.addEventListener("pointermove",z),window.addEventListener("pointerup",P)})}#PJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#W)return;let $=this.#w;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Z/100*_.width,G=this.#Q/100*_.height,X=Math.atan2(Z.clientY-_.top-G,Z.clientX-_.left-j)*180/Math.PI;this.#LJ(J,this.#jJ(X))});let Q=(Z)=>{if(Y(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#W=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#w;if(!$)return;if(this.#K)this.#K.setAttribute("show","true"),this.#K.showPopup?.(),this.#ZJ(Z.clientX,Z.clientY);if(this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();let _=this.#X?.style.pointerEvents,j=this.#X?.querySelector(".fig-handle-hit-area"),G=j?.style.pointerEvents;if(this.#X)this.#X.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let X=document.body.style.cursor;J.style.pointerEvents="none";let q=$.getBoundingClientRect(),B=this.#Z/100*q.width,N=this.#Q/100*q.height,K=Math.atan2(Z.clientY-q.top-N,Z.clientX-q.left-B)*180/Math.PI,U=Math.round(K);document.body.style.cursor=this.#jJ(U);let L=(k)=>{let z=$.getBoundingClientRect(),P=this.#Z/100*z.width,W=this.#Q/100*z.height,F=k.clientX-z.left-P,T=k.clientY-z.top-W,H=Math.round(Math.atan2(T,F)*180/Math.PI);if(H!==U)U=H,document.body.style.cursor=this.#jJ(H);let S=Math.sqrt(F*F+T*T);if(this.#v(k.shiftKey)){let R=this.#Y?5:10;if(this.#Y){let C=S/z.width*100;C=Math.round(C/R)*R,S=C/100*z.width}else S=Math.round(S/R)*R}if(this.#Y)this.#_=Math.max(0,S/z.width*100);else this.#_=Math.max(0,S);if(this.#K)this.#K.setAttribute("text",this.#i()),this.#ZJ(k.clientX,k.clientY);this.#m(),this.#t()},D=()=>{if(this.#W=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#X)this.#X.style.pointerEvents=_??"";if(j)j.style.pointerEvents=G??"";if(document.body.style.cursor=X,this.#K)this.#K.removeAttribute("show");this.#f(),this.#e(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",D)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",D)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#SJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",m);class M extends HTMLElement{#Z=[M.#R()];#Q=0;#J=2;#j=240;#_=120;#Y={min:-1,max:1};#G=null;#$=null;#q=null;#X=null;#B=0;#z=null;#U=null;#k=null;#K=null;#N=[];#L=[];#D=[];#W=[];#M=new Set;#T=null;#O=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#R(J="sine"){return{type:J,frequency:1,amplitude:1,phase:0,offset:0}}static get observedAttributes(){return["value","precision","aspect-ratio","edit","disabled"]}connectedCallback(){this.#J=this.#H("precision",2),this.#S(this.getAttribute("value")),this.#b(),this.#g(),this.#y()}disconnectedCallback(){if(this.#G=null,this.#BJ(),this.#T)this.#T.disconnect(),this.#T=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#S(Z),this.isConnected)this.#g();return}if(J==="precision"){if(this.#J=this.#H("precision",2),this.isConnected)this.#$J();return}if(J==="aspect-ratio"){if(this.#b(),this.#$)this.#JJ();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#g()}}get value(){return JSON.stringify(this.data)}set value(J){this.setAttribute("value",typeof J==="object"&&J!==null?JSON.stringify(J):J)}get data(){return{waves:this.#Z.map((J)=>this.#h(J))}}get preset(){let J=this.#E;return M.TYPES.find((Q)=>Q.value===J.type)?.name}#H(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#V(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}#A(){return this.getAttribute("edit")!=="false"}#P(){return this.#V("disabled",!1)}#b(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#S(J){if(!J)return!1;let Q=null;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}else if(typeof J==="object")Q=J;if(!Q)return!1;let Z=Array.isArray(Q)?Q:Array.isArray(Q.waves)?Q.waves:[Q];if(this.#Z=Z.map(($)=>this.#F($)),!this.#Z.length)this.#Z=[M.#R()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#F(J={}){return{type:this.#C(J.type),frequency:this.#I(J.frequency,1,0.1,16),amplitude:this.#I(J.amplitude,1,-4,4),phase:this.#I(J.phase,0,-360,360),offset:this.#I(J.offset,0,-4,4)}}#h(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#E(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||M.#R()}#C(J){let Q=String(J||"").toLowerCase();return M.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#I(J,Q,Z,$){let _=Number.parseFloat(J);if(!Number.isFinite(_))return Q;return Math.min($,Math.max(Z,_))}#c(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#d(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#v(J){return M.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let _=Q-10,j="";for(let G=0;G<=32;G++){let X=G/32,q=M.#l(J,X),B=5+X*_,N=5+(1-(q+1)/2)*_;j+=`${G===0?"M":"L"}${B.toFixed(1)},${N.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#l(J,Q,Z=0){let $=Q+Z/360,_=$-Math.floor($),j=$*Math.PI*2;switch(J){case"square":return Math.sin(j)>=0?1:-1;case"sawtooth":return _*2-1;case"triangle":return 1-Math.abs(_*4-2);default:return Math.sin(j)}}#g(){this.#BJ(),this.innerHTML=this.#x(),this.#o(),this.#r(),this.#JJ(),this.#FJ(),this.#qJ()}#x(){let J=this.#P()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
1
|
+
function F(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class b extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#K()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#G(){let Q=Array.from(this.childNodes).filter((G)=>G.nodeType!==Node.TEXT_NODE||Boolean(G.textContent?.trim())).find((G)=>G.nodeType===Node.ELEMENT_NODE&&G.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-segmented-control"),j=document.createElement("fig-segment"),X=document.createElement("fig-segment");_.setAttribute("sizing","equal"),j.setAttribute("value","off"),j.textContent="Off",X.setAttribute("value","on"),X.textContent="On",_.append(j,X),Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#D(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id","checked","value"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",Y(this,"checked")?"on":"off"),this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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"))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":Y(this,"checked")}set checked(J){this.toggleAttribute("checked",Boolean(J))}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){this.setAttribute("value",J??"")}focus(J){(this.#J?.querySelector("fig-segment[selected]")||this.#J?.querySelector("fig-segment"))?.focus(J)}}F("propskit-switch",b);class w extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#H.bind(this);#G=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#B();if(this.#D(),this.#M(),this.#U(),this.#G===null)this.#G=this.getAttribute("default")??this.getAttribute("value")??"";if(this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#D();if(Z)this.#M()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#N(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#D()}#B(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-color");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#D(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Color")}#K(){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-"))}#M(){if(!this.#J)return;let J=this.#K(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J){let $=this.getAttribute(Z)??"";if(Z==="value"&&this.#J.getAttribute("value")===$)continue;this.#J.setAttribute(Z,$)}this.#J.setAttribute("text","true"),this.#Y=Q}#U(){if(!this.#J)return;this.#X??=this.#W.bind(this,"input"),this.#$??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#k(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")??""}#W(J,Q){Q.stopImmediatePropagation();let Z=this.#k(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}))}#H(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))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)}#L(J){if(!this.#J)return;if(this.#J.getAttribute("value")===J)this.#J.removeAttribute("value");this.#J.setAttribute("value",J)}#T(){return this.getAttribute("default")??this.#G??""}resetToDefault(){let J=String(this.#T());this.setAttribute("value",J),this.#L(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)}}F("propskit-color",w);class x extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#T.bind(this);#G=this.#L.bind(this);#B=!1;static get observedAttributes(){return["label","direction","aria-label","options","value"]}connectedCallback(){if(!this.#Z)this.#D();if(this.#K(),this.#U(),this.#N(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#G,!0),this.addEventListener("pointerdown",this.#G,!0),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;let _=$.attributeName;if(_==="label"||_==="direction"||_==="aria-label")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#U()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#k(),this.removeEventListener("click",this.#q),this.removeEventListener("pointerdown",this.#G,!0)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label"){this.#K();return}if(J==="options"||J==="value")this.#U()}#D(){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.#j=Boolean(J),this.replaceChildren(Q)}#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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Select"),this.#J.setAttribute("full","")}#M(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","full"]);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.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#N(){if(!this.#J)return;this.#X??=this.#W.bind(this,"input"),this.#$??=this.#W.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#k(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#W(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}))}#H(){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-select")){this.#B=!1;return}this.#B=this.#H()}#T(J){if(J.target instanceof Element&&J.target.closest("fig-select")){this.#B=!1;return}if(!this.#J||Y(this.#J,"disabled")){this.#B=!1;return}if(this.#J.focus(),this.#B||this.#H()){this.#B=!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))}focus(J){this.#J?.focus(J)}}F("propskit-select",x);class h extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#K()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction"||J==="aria-label")this.#B()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-text");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#B(){if(!this.#Z||!this.#Q||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Q.remove();else{if(!this.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Q.textContent?.trim()||"Text")}#D(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","multiline","resizable"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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"))return;this.focus()}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))}focus(J){this.#J?.focus(J)}}F("propskit-text",h);class g extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=null;#$=null;#q=this.#k.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Z)this.#G();if(this.#B(),this.#K(),this.#M(),this.removeEventListener("click",this.#q),this.addEventListener("click",this.#q),!this.#_)this.#_=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.#B();if(Z)this.#K()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){this.#_?.disconnect(),this.#U(),this.removeEventListener("click",this.#q)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#B()}#G(){let J=Array.from(this.childNodes).filter((j)=>j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-input-number");Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#B(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#D(){let J=new Set(["label","direction","size","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#K(){if(!this.#J)return;let J=this.#D(),Q=new Set(J);for(let Z of this.#Y)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#Y=Q}#M(){if(!this.#J)return;this.#X??=this.#N.bind(this,"input"),this.#$??=this.#N.bind(this,"change"),this.#J.addEventListener("input",this.#X),this.#J.addEventListener("change",this.#$)}#U(){if(!this.#J)return;if(this.#X)this.#J.removeEventListener("input",this.#X);if(this.#$)this.#J.removeEventListener("change",this.#$)}#N(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"))return;this.focus()}get value(){return this.#J?.value??this.getAttribute("value")??""}set value(J){if(J===null||J===void 0||J==="")this.removeAttribute("value");else this.setAttribute("value",String(J))}focus(J){this.#J?.focus(J)}}F("propskit-number",g);class A extends HTMLElement{static observedAttributes=["name","open","show-reset"];static#Z=["propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text"].join(",");#Q=null;#J=null;#j=null;#_=new WeakMap;#Y=null;#X=0;#$=()=>this.#B();connectedCallback(){this.#f(),this.#q(),requestAnimationFrame(()=>{this.#W(),this.#T()})}disconnectedCallback(){if(this.#G(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#Q)this.#Q.removeEventListener("click",this.#K),this.#Q.removeEventListener("keydown",this.#M);this.#j?.querySelector("fig-button")?.removeEventListener("click",this.#U)}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.#O(),this.#T();return}this.#f()}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()}#q(){if(this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.addEventListener("input",this.#$,!0),this.addEventListener("change",this.#$,!0),!this.#Y)this.#Y=new MutationObserver(()=>{this.#W(),this.#B()});this.#Y.disconnect(),this.#Y.observe(this,{childList:!0,subtree:!0})}#G(){this.removeEventListener("input",this.#$,!0),this.removeEventListener("change",this.#$,!0),this.#Y?.disconnect()}#B(){if(this.#X)return;this.#X=requestAnimationFrame(()=>{this.#X=0,this.#W(),this.#T()})}#D(J){return J instanceof Element&&Boolean(J.closest(".propskit-group-reset, .propskit-group-reset-tooltip"))}#K=(J)=>{if(this.#D(J.target))return;J.stopPropagation(),this.open=!this.open};#M=(J)=>{if(this.#D(J.target))return;if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),this.open=!this.open};#U=(J)=>{J.preventDefault(),J.stopPropagation(),this.#S()};#N(){return[...this.querySelectorAll(A.#Z)].filter((J)=>J.closest("propskit-group")===this)}#k(J){if(J.localName==="propskit-switch")return{kind:"checked",value:Boolean(J.checked)};if("value"in J)return{kind:"value",value:J.value};return{kind:"value",value:J.getAttribute("value")??""}}#W(){for(let J of this.#N()){if(this.#_.has(J))continue;if(J.hasAttribute("default")){if(J.localName==="propskit-switch"){this.#_.set(J,{kind:"checked",value:Y(J,"default")});continue}this.#_.set(J,{kind:"value",value:J.getAttribute("default")??""});continue}this.#_.set(J,this.#k(J))}}#H(J){let Q=this.#_.get(J);if(!Q)return!1;let Z=this.#k(J);if(Q.kind==="checked")return Boolean(Z.value)!==Boolean(Q.value);return String(Z.value??"")!==String(Q.value??"")}#L(){for(let J of this.#N())if(this.#H(J))return!0;return!1}#T(){if(this.#L())this.setAttribute("data-dirty","");else this.removeAttribute("data-dirty");this.#O()}#P(J){let Q=this.#_.get(J);if(!Q)return;if(Q.kind==="checked"){J.checked=Q.value;let $={checked:Boolean(Q.value),value:J.getAttribute("value")??""};J.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,cancelable:!0,composed:!0}));return}if(typeof J.resetToDefault==="function"){let $=J.getAttribute("default");if(J.setAttribute("default",String(Q.value??"")),J.resetToDefault(),$===null)J.removeAttribute("default");else J.setAttribute("default",$);return}J.value=Q.value;let Z=J.getAttribute?.("value")??("value"in J?J.value:Q.value);J.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,cancelable:!0,composed:!0})),J.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}#S(){this.#W();for(let J of this.#N())this.#P(J);this.#T(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0}))}#O(){if(!this.showReset){this.#j?.setAttribute("hidden","");return}this.#R(),this.#j?.removeAttribute("hidden")}#R(){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.#U)}else{let Q=J.querySelector("fig-button");Q?.removeEventListener("click",this.#U),Q?.addEventListener("click",this.#U)}this.#j=J}#f(){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=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let $=this.#Q.querySelector("h3");if(!$)$=document.createElement("h3"),this.#Q.prepend($);if(!$.id)$.id=u("propskit-group");if(this.#Q.dataset.generated){let _=$.querySelector(".propskit-group-chevron");if($.textContent=Q,_)$.prepend(_)}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 _=document.createElement("fig-icon");_.setAttribute("name","chevron"),_.setAttribute("size","small"),_.className="propskit-group-chevron",$.prepend(_)}if(this.#J=$.querySelector(".propskit-group-chevron"),this.#O(),this.#Q.removeEventListener("click",this.#K),this.#Q.addEventListener("click",this.#K),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#M),this.#Q.addEventListener("keydown",this.#M),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}}F("propskit-group",A);class m extends HTMLElement{#Z=null;#Q=null;#J=null;#j=!1;#_=null;#Y=new Set;#X=0;#$=0;#q=null;#G=null;#B=0;#D=null;#K=!1;#M=0;#U=null;#N=0;#k=null;#W=null;#H=null;#L=this.#o.bind(this);#T=this.#u.bind(this);#P=this.#jJ.bind(this);#S=this.#i.bind(this);#O=this.#s.bind(this);#R=this.#r.bind(this);#f=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.#z();if(this.#C(),this.#F(),this.#JJ(),this.#A(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#O),this.addEventListener("contextmenu",this.#O),!this.#_)this.#_=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#f.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#C();if(Z)this.#F(),this.#A()});this.#_.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#_?.disconnect(),this.#X)cancelAnimationFrame(this.#X),this.#X=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#a(),this.#I(),this.#y(),this.#l(),this.#c(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#O),this.#G?.removeEventListener("change",this.#R)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Z)return;if(J==="label"||J==="direction")this.#C()}#z(){let J=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),Q=J.find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.matches("label")),Z=document.createElement("fig-field"),$=Q||document.createElement("label"),_=document.createElement("fig-slider");_.setAttribute("text","true");for(let j of this.#x()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Z=Z,this.#Q=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#b();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#b(){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 to default",J.appendChild(Q),J.addEventListener("change",this.#R),this.#G=J,this.appendChild(J)}#C(){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.#j)this.#Q.textContent=J?Q??"":"Label";if(this.#Q.parentElement!==this.#Z)this.#Z.prepend(this.#Q)}this.#Z.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#F(){if(!this.#J)return;let J=this.#x(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#Y)if(!Q.has($))this.#J.removeAttribute($);for(let $ of J){if($==="text")continue;let _=this.getAttribute($);this.#J.setAttribute($,_??"")}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","light-dark(#444444, #e6e6e6)");else this.#J.style.removeProperty("--color");this.#Y=Q,this.#E()}#x(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#f.has(Q))}#E(){if(this.#X)cancelAnimationFrame(this.#X);this.#X=requestAnimationFrame(()=>{this.#X=0,this.#m(),this.#w()})}#A(){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.#q)this.#g(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#g(J){if(this.#l(),this.#q=J,!this.#q)return;this.#q.addEventListener("dblclick",this.#S,{capture:!0})}#l(){if(!this.#q)return;this.#q.removeEventListener("dblclick",this.#S,{capture:!0}),this.#q=null}#i(J){J.preventDefault(),J.stopImmediatePropagation(),this.#_J()}#o(J){if(J.button!==0||Y(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#q;if(!Q)return;this.#I(),this.#y(),this.#q=Q,this.#K=!0,this.#k=J.pointerId,this.#M=this.#e();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#U={left:Z.left,right:Z.right,width:Z.width},this.#N=$.width,window.addEventListener("pointermove",this.#T,{passive:!0}),window.addEventListener("pointerup",this.#P,{once:!0}),window.addEventListener("pointercancel",this.#P,{once:!0}),window.addEventListener("blur",this.#P,{once:!0})}#u(J){if(!this.#K)return;if(J.pointerId!==this.#k)return;if(J.buttons===0){this.#jJ(J);return}this.#$J(J.clientX)}#jJ(J){if(J?.pointerId!==void 0&&this.#k!==null&&J.pointerId!==this.#k)return;this.#I(),this.#y()}#I(){window.removeEventListener("pointermove",this.#T),window.removeEventListener("pointerup",this.#P),window.removeEventListener("pointercancel",this.#P),window.removeEventListener("blur",this.#P),this.#K=!1,this.#k=null}#s(J){if(Y(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#a(),this.#XJ(J.clientX,J.clientY)}#XJ(J,Q){let Z=!1,$=0,_=()=>{if(Z)return;Z=!0,window.clearTimeout($),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0),requestAnimationFrame(()=>{this.#G?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#r(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#_J()}#a(){if(this.#B)clearTimeout(this.#B),this.#B=0;this.#D=null}#e(){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}#$J(J){let Q=this.#U;if(!Q||!this.#M){this.#y();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#n();return}let $=Math.max(-this.#M,Math.min(this.#M,Z*0.5)),_=Math.abs($),j=this.#N?(this.#N+_)/this.#N:1;this.dataset.elasticDragging="true",this.style.setProperty("--propskit-slider-elastic-size",`${_}px`),this.style.setProperty("--propskit-slider-elastic-scale",`${j}`),this.style.setProperty("--propskit-slider-elastic-origin",$<0?"right center":"left center")}#y(){this.#n(),this.#M=0,this.#U=null,this.#N=0,this.#k=null}#n(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#YJ(J){let Q=this.#q;if(!Q)return this.#J?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,_=Number(Q.min||0),j=Number(Q.max||100),X=Q.step==="any"?0:Number(Q.step||1),G=_+(j-_)*$;if(!X)return String(G);let q=Math.round((G-_)/X)*X+_,B=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(q.toFixed(B)))}#p(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#q?.min??"0"}#_J(){this.#a(),this.#h(this.#p(),"input"),this.#h(this.#p(),"change")}#h(J,Q){if(!this.#J||J===null||J===void 0)return;this.#J.value=J,this.dispatchEvent(new CustomEvent(Q,{detail:this.#J.value,bubbles:!0,cancelable:!0,composed:!0}))}#m(){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??"")}#JJ(){if(!this.#J)return;if(!this.#W)this.#W=this.#t.bind(this,"input");if(!this.#H)this.#H=this.#t.bind(this,"change");this.#J.addEventListener("input",this.#W),this.#J.addEventListener("change",this.#H)}#c(){if(!this.#J)return;if(this.#W)this.#J.removeEventListener("input",this.#W);if(this.#H)this.#J.removeEventListener("change",this.#H)}#t(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#y();let Z=Q instanceof CustomEvent&&Q.detail!==void 0?Q.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(J,{detail:Z,bubbles:!0,cancelable:!0,composed:!0}))}focus(J){this.#J?.querySelector('input[type="range"]')?.focus(J)}resetToDefault(){this.#_J()}}F("propskit-slider",m);class c extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Z=50;#Q=50;#J=75;#j=75;#_=0;#Y=!1;#X=0;#$=null;#q=null;#G=null;#B=null;#D=null;#K=null;#M=null;#U=null;#N=null;#k=!1;#W=!1;#H=!1;#L=!1;#T=null;#P="";#S="";#O=null;#R=null;#f=null;#z="";#b="";#C=null;get#F(){return this.getAttribute("type")||"point"}get#x(){return this.#F==="point-radius"||this.#F==="point-radius-angle"}get#E(){return this.#F==="point-radius-angle"}get#A(){return this.#F==="point-point"}get#w(){return this.#F==="point-radius-angle"||this.#F==="point-point"}get#g(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#l(){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"}#i(J){let Q=this.#l;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#o(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Z)}%, ${Math.round(this.#Q)}%`}get#u(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#j)}%`}get#jJ(){return this.getAttribute("drag-surface")||"parent"}get#I(){let J=this.#jJ;if(J==="parent")return this.parentElement;return this.closest(J)}get#s(){let J=this.#jJ;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.#Y)return this.#_/100*J;return this.#_}#r(){if(this.#Y)return`Radius ${Math.round(this.#_)}%`;return`Radius ${Math.round(this.#_)}`}connectedCallback(){this.#a(),this.#e()}disconnectedCallback(){this.#OJ(),this.#n(),this.#h(),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.#k&&!this.#W&&!this.#H&&!this.#L)if(this.#a(),this.#$)this.#v();else this.#e();if(J==="type")this.#a(),this.#e();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#e();if(J==="tooltips")this.#e();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#q)this.#q.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#K)this.#K.setAttribute("text",this.#o);if(this.#M)this.#M.setAttribute("text",this.#u)}}#a(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Z=Q.x;if(typeof Q.y==="number")this.#Q=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#Y=!0,this.#_=parseFloat(Z);else this.#Y=!1,this.#_=parseFloat(Z);if(!Number.isFinite(this.#_))this.#_=0}if(typeof Q.angle==="number")this.#X=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Z,y:this.#Q};if(this.#F==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#x)J.radius=this.#Y?`${this.#_}%`:this.#_;if(this.#E)J.angle=this.#X;if(this.#A)J.x2=this.#J,J.y2=this.#j;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#e(){this.innerHTML="",this.#$=null,this.#q=null,this.#G=null,this.#B=null,this.#D=null,this.#K=null,this.#M=null,this.#U=null,this.#N=null;let J=Y(this,"disabled"),Q=this.#F,Z=this.#g,$=this.#s,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#l),_.setAttribute("value",`${this.#Z}% ${this.#Q}%`),J)_.setAttribute("disabled","");if(Q==="color"){_.setAttribute("type","color");let j=this.getAttribute("color");if(j)_.setAttribute("color",j)}else _.setAttribute("type","canvas");if(this.#A)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#x)this.#NJ();if(this.#w)this.#MJ();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#o),j.appendChild(_),this.appendChild(j),this.#K=j}else this.appendChild(_);if(this.#E)this.#d(J,Z,$);if(this.#A)this.#TJ(J,Z,$);this.#$J(this.#$),this.#$J(this.#G),this.#$J(this.#q),this.#zJ(),this.#c(),requestAnimationFrame(()=>this.#v())}#$J(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>{if(Q.target?.classList?.contains("fig-handle-hit-area")&&J.querySelector(".fig-handle-hit-area"))this.#_J(Q,J);else this.#y(Q)},{capture:!0})}#y(J){if(Y(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#T===null)this.#P=document.body.style.getPropertyValue("cursor"),this.#S=document.body.style.getPropertyPriority("cursor");if(this.#T=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#O)this.#O=(Q)=>{if(Q?.pointerId!==void 0&&this.#T!==null&&Q.pointerId!==this.#T)return;if(Q?.type==="blur")this.#n();else requestAnimationFrame(()=>this.#n())};window.addEventListener("pointerup",this.#O),window.addEventListener("pointercancel",this.#O),window.addEventListener("blur",this.#O)}#n(){if(this.#T===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#P)document.body.style.setProperty("cursor",this.#P,this.#S);else document.body.style.removeProperty("cursor");if(this.#T=null,this.#P="",this.#S="",this.#O)window.removeEventListener("pointerup",this.#O),window.removeEventListener("pointercancel",this.#O),window.removeEventListener("blur",this.#O)}#YJ(J){if(!J)return 0;if(J===this.#G)return this.#X;if(!this.#A)return 0;let Q=this.#kJ();return J===this.#$?Q+180:Q}#p(){if(this.#R===null)return;let J=this.#KJ(this.#YJ(this.#f));document.body.style.setProperty("--fig-lab-cursor-rotate",J),document.body.style.setProperty("cursor",J,"important")}#_J(J,Q){if(Y(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#R===null)this.#z=document.body.style.getPropertyValue("cursor"),this.#b=document.body.style.getPropertyPriority("cursor");if(this.#R=J?.pointerId??-1,this.#f=Q,document.body.classList.add("fig-lab-rotate-active"),this.#p(),!this.#C)this.#C=(Z)=>{if(Z?.pointerId!==void 0&&this.#R!==null&&Z.pointerId!==this.#R)return;if(Z?.type==="blur")this.#h();else requestAnimationFrame(()=>this.#h())};window.addEventListener("pointerup",this.#C),window.addEventListener("pointercancel",this.#C),window.addEventListener("blur",this.#C)}#h(){if(this.#R===null)return;if(document.body.classList.remove("fig-lab-rotate-active"),document.body.style.removeProperty("--fig-lab-cursor-rotate"),this.#z)document.body.style.setProperty("cursor",this.#z,this.#b);else document.body.style.removeProperty("cursor");if(this.#R=null,this.#f=null,this.#z="",this.#b="",this.#C)window.removeEventListener("pointerup",this.#C),window.removeEventListener("pointercancel",this.#C),window.removeEventListener("blur",this.#C)}#m(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let q=Q();if(!q)return;q.removeAttribute("show"),q.hidePopup?.()},X=()=>{if(_()){j();return}let q=Q();if(!q)return;if(Z)q.setAttribute("text",Z());q.setAttribute("show","true"),q.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#k||this.#W||this.#H||this.#L}#c(){if(this.#$)this.#m(this.#$,()=>this.#K,()=>this.#o,()=>this.#JJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#G)this.#m(this.#G,()=>this.#N,()=>`Angle ${Math.round(this.#X)}°`,()=>this.#JJ());if(this.#q)this.#m(this.#q,()=>this.#M,()=>this.#u,()=>this.#JJ());if(this.#B){let J=this.#B.querySelector(".fig-canvas-control-radius-hit");this.#BJ(J||this.#B)}if(this.#F==="color"&&this.#$&&this.#K)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#K?.removeAttribute("show"),this.#K?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#t(J,Q){let Z=this.#U;if(!Z?.popup)return;let $=Q-8;Z.popup.anchor={getBoundingClientRect:()=>({left:J,top:$,right:J,bottom:$,width:0,height:0,x:J,y:$})},Z.popup.queueReposition?.()}#BJ(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#U;if(!Z)return;Z.setAttribute("text",this.#r()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#t(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#H)return;this.#t(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#H)return;let Q=this.#U;if(!Q)return;Q.removeAttribute("show")})}#NJ(){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 _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#B=Q,this.#g){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#r()),j.appendChild(Q),this.appendChild(j),this.#U=j}else this.appendChild(Q);this.#PJ(Z)}#MJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#A){let _=document.createElementNS("http://www.w3.org/2000/svg","line");_.classList.add("fig-canvas-control-angle-line-hit"),_.setAttribute("stroke","transparent"),_.setAttribute("stroke-width","12"),_.setAttribute("stroke-linecap","round"),_.style.pointerEvents="stroke",Q.appendChild(_),this.#FJ(_)}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.#D=Q,this.appendChild(Q)}#FJ(J){J.addEventListener("pointerdown",(Q)=>{if(Y(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#I;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Z,G=this.#Q,q=this.#J,B=this.#j;this.#k=!0,this.#W=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let N=(U)=>{let M=Z.getBoundingClientRect(),W=M.width>0?(U.clientX-_)/M.width*100:0,k=M.height>0?(U.clientY-j)/M.height*100:0,D=-Math.min(X,q),O=100-Math.max(X,q),H=-Math.min(G,B),T=100-Math.max(G,B),z=Math.max(D,Math.min(O,W)),P=Math.max(H,Math.min(T,k));this.#Z=X+z,this.#Q=G+P,this.#J=q+z,this.#j=B+P,this.#v(),this.#QJ()},K=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#V(),this.#ZJ(),window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",K),requestAnimationFrame(()=>{this.#k=!1,this.#W=!1})};window.addEventListener("pointermove",N),window.addEventListener("pointerup",K)})}#d(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.#G=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#X)}°`),_.appendChild($),this.appendChild(_),this.#N=_}else this.appendChild($)}#TJ(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.#l),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#q=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#u),_.appendChild($),this.appendChild(_),this.#M=_}else this.appendChild($)}#qJ(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`}#KJ(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`}#LJ(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.#LJ(Z,this.#KJ(Q)),this.#f===J)this.#p()}#DJ(){if(!this.#G||!this.#E)return;this.#UJ(this.#G,this.#X)}#kJ(){return Math.atan2(this.#j-this.#Q,this.#J-this.#Z)*180/Math.PI}#WJ(){if(!this.#A)return;let J=this.#kJ();this.#$?.style.removeProperty("cursor"),this.#q?.style.removeProperty("cursor"),this.#UJ(this.#$,J+180),this.#UJ(this.#q,J)}#GJ(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`}#v(){let J=this.#I;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#GJ(this.#$,this.#Z,this.#Q,Q),this.#B){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#XJ(Q.width),j=this.#B,X=Math.max(_*2,1);j.style.position="absolute",j.style.width=`${X}px`,j.style.height=`${X}px`,j.style.left=`${Z-_}px`,j.style.top=`${$-_}px`,j.setAttribute("viewBox",`0 0 ${X} ${X}`);let G=j.querySelectorAll("circle");for(let q of G)q.setAttribute("cx",String(_)),q.setAttribute("cy",String(_)),q.setAttribute("r",String(Math.max(_-1,0)))}if(this.#D&&this.#w){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_,j;if(this.#A)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let q=this.#XJ(Q.width),B=this.#X*Math.PI/180;_=Z+q*Math.cos(B),j=$+q*Math.sin(B)}let X=this.#D;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 G=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let q of G)q.setAttribute("x1",String(Z)),q.setAttribute("y1",String($)),q.setAttribute("x2",String(_)),q.setAttribute("y2",String(j))}if(this.#G&&this.#E){let Z=this.#Z/100*Q.width,$=this.#Q/100*Q.height,_=this.#XJ(Q.width),j=this.#X*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),q=Q.width>0?X/Q.width*100:0,B=Q.height>0?G/Q.height*100:0;this.#GJ(this.#G,q,B,Q)}if(this.#q&&this.#A)this.#GJ(this.#q,this.#J,this.#j,Q);this.#DJ(),this.#WJ()}#QJ(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#ZJ(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#V(){this.setAttribute("value",JSON.stringify(this.value))}#zJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#QJ();return}this.#k=!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.#K)this.#K.removeAttribute("show"),this.#K.hidePopup?.();this.#v(),this.#QJ()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#ZJ();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.#K)this.#K.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#k=!1})}),this.#G)this.#G.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#I;if(!Q)return;this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Z/100*Z.width,_=this.#Q/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#G.offsetWidth/2,q=this.#G.offsetHeight/2,B=j+G-$,N=X+q-_,K=Math.atan2(N,B)*180/Math.PI;if(this.#i(J.detail?.shiftKey))K=Math.round(K/15)*15;this.#X=K;let U=Math.sqrt(B*B+N*N);if(this.#i(J.detail?.shiftKey)){let M=this.#Y?5:10;if(this.#Y){let W=U/Z.width*100;W=Math.round(W/M)*M,U=W/100*Z.width}else U=Math.round(U/M)*M}if(this.#Y)this.#_=Math.max(0,U/Z.width*100);else this.#_=Math.max(0,U);if(this.#N)this.#N.setAttribute("text",`Angle ${Math.round(this.#X)}°`),this.#N.setAttribute("show","true"),this.#N.showPopup?.();this.#v(),this.#QJ()}),this.#G.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#N)this.#N.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#L=!1})}),this.#G.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#I;if(!Z)return;if(this.#L=!0,this.classList.add("fig-canvas-control-ring-active"),this.#G.setAttribute("selected",""),this.#N)this.#N.setAttribute("show","true"),this.#N.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Z/100*X.width,q=this.#Q/100*X.height,B=j.clientX-X.left-G,N=j.clientY-X.top-q,K=Math.atan2(N,B)*180/Math.PI;if(this.#i(j.shiftKey))K=Math.round(K/15)*15;if(this.#X=K,this.#N)this.#N.setAttribute("text",`Angle ${Math.round(K)}°`);this.#v(),this.#QJ()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#G.removeAttribute("selected"),this.#N)this.#N.removeAttribute("show");this.#V(),this.#ZJ(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#q)this.#q.addEventListener("input",(J)=>{J.stopPropagation(),this.#W=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#j/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#j=Math.round(Math.max(0,Math.min(100,Z*100))),this.#M)this.#M.removeAttribute("show"),this.#M.hidePopup?.();this.#v(),this.#QJ()}),this.#q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#M)this.#M.removeAttribute("show");this.#v(),this.#V(),this.#ZJ(),requestAnimationFrame(()=>{this.#W=!1})}),this.#HJ(this.#$,!0),this.#HJ(this.#q,!1)}#HJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#I;if(!_)return;this.#k=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Z,G=Q?this.#j:this.#Q,q=Q?this.#Z:this.#J,B=Q?this.#Q:this.#j,N=X/100*j.width,K=G/100*j.height,U=q/100*j.width,M=B/100*j.height,W=Math.sqrt((U-N)**2+(M-K)**2),k=Q?this.#K:this.#M;if(k)k.removeAttribute("show"),k.hidePopup?.();let D=(H)=>{let T=_.getBoundingClientRect(),z=X/100*T.width,P=G/100*T.height,C=H.clientX-T.left-z,I=H.clientY-T.top-P,S=Math.atan2(I,C);if(this.#i(H.shiftKey))S=Math.round(S*180/Math.PI/15)*15*Math.PI/180;let d=z+W*Math.cos(S),l=P+W*Math.sin(S),V=Math.max(0,Math.min(100,d/T.width*100)),f=Math.max(0,Math.min(100,l/T.height*100));if(Q)this.#Z=V,this.#Q=f;else this.#J=V,this.#j=f;this.#v(),this.#QJ()},O=()=>{if(this.#k=!1,k)k.removeAttribute("show");this.#V(),this.#ZJ(),window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",O)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",O)})}#PJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#H)return;let $=this.#I;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Z/100*_.width,X=this.#Q/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;this.#LJ(J,this.#qJ(G))});let Q=(Z)=>{if(Y(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#H=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#I;if(!$)return;if(this.#U)this.#U.setAttribute("show","true"),this.#U.showPopup?.(),this.#t(Z.clientX,Z.clientY);if(this.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();let _=this.#G?.style.pointerEvents,j=this.#G?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#G)this.#G.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let q=$.getBoundingClientRect(),B=this.#Z/100*q.width,N=this.#Q/100*q.height,K=Math.atan2(Z.clientY-q.top-N,Z.clientX-q.left-B)*180/Math.PI,U=Math.round(K);document.body.style.cursor=this.#qJ(U);let M=(k)=>{let D=$.getBoundingClientRect(),O=this.#Z/100*D.width,H=this.#Q/100*D.height,T=k.clientX-D.left-O,z=k.clientY-D.top-H,P=Math.round(Math.atan2(z,T)*180/Math.PI);if(P!==U)U=P,document.body.style.cursor=this.#qJ(P);let C=Math.sqrt(T*T+z*z);if(this.#i(k.shiftKey)){let I=this.#Y?5:10;if(this.#Y){let S=C/D.width*100;S=Math.round(S/I)*I,C=S/100*D.width}else C=Math.round(C/I)*I}if(this.#Y)this.#_=Math.max(0,C/D.width*100);else this.#_=Math.max(0,C);if(this.#U)this.#U.setAttribute("text",this.#r()),this.#t(k.clientX,k.clientY);this.#v(),this.#QJ()},W=()=>{if(this.#H=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#G)this.#G.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#U)this.#U.removeAttribute("show");this.#V(),this.#ZJ(),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",W)};window.addEventListener("pointermove",M),window.addEventListener("pointerup",W)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#OJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}F("fig-canvas-control",c);class L extends HTMLElement{#Z=[L.#S()];#Q=0;#J=2;#j=240;#_=120;#Y={min:-1,max:1};#X=null;#$=null;#q=null;#G=null;#B=0;#D=null;#K=null;#M=null;#U=null;#N=[];#k=[];#W=[];#H=[];#L=new Set;#T=null;#P=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#S(J="sine"){return{type:J,frequency:1,amplitude:1,phase:0,offset:0}}static get observedAttributes(){return["value","precision","aspect-ratio","edit","disabled"]}connectedCallback(){this.#J=this.#O("precision",2),this.#C(this.getAttribute("value")),this.#b(),this.#u(),this.#y()}disconnectedCallback(){if(this.#X=null,this.#c(),this.#T)this.#T.disconnect(),this.#T=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#C(Z),this.isConnected)this.#u();return}if(J==="precision"){if(this.#J=this.#O("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#b(),this.#$)this.#m();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#u()}}get value(){return JSON.stringify(this.data)}set value(J){this.setAttribute("value",typeof J==="object"&&J!==null?JSON.stringify(J):J)}get data(){return{waves:this.#Z.map((J)=>this.#x(J))}}get preset(){let J=this.#E;return L.TYPES.find((Q)=>Q.value===J.type)?.name}#O(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#R(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}#f(){return this.getAttribute("edit")!=="false"}#z(){return this.#R("disabled",!1)}#b(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#C(J){if(!J)return!1;let Q=null;if(typeof J==="string")try{Q=JSON.parse(J)}catch{Q=null}else if(typeof J==="object")Q=J;if(!Q)return!1;let Z=Array.isArray(Q)?Q:Array.isArray(Q.waves)?Q.waves:[Q];if(this.#Z=Z.map(($)=>this.#F($)),!this.#Z.length)this.#Z=[L.#S()];return this.#Q=Math.min(this.#Q,this.#Z.length-1),!0}#F(J={}){return{type:this.#A(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)}}#x(J){return{type:J.type,frequency:this.#g(J.frequency),amplitude:this.#g(J.amplitude),phase:this.#g(J.phase),offset:this.#g(J.offset)}}get#E(){if(!this.#Z[this.#Q])this.#Q=0;return this.#Z[this.#Q]||L.#S()}#A(J){let Q=String(J||"").toLowerCase();return L.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#w(J,Q,Z,$){let _=Number.parseFloat(J);if(!Number.isFinite(_))return Q;return Math.min($,Math.max(Z,_))}#g(J){let Q=10**this.#J;return Math.round(J*Q)/Q}static#l(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#i(J){return L.TYPES.find((Q)=>Q.value===J)?.name||"Wave"}static waveIcon(J,Q=24){let _=Q-10,j="";for(let X=0;X<=32;X++){let G=X/32,q=L.#o(J,G),B=5+G*_,N=5+(1-(q+1)/2)*_;j+=`${X===0?"M":"L"}${B.toFixed(1)},${N.toFixed(1)}`}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/></svg>`}static#o(J,Q,Z=0){let $=Q+Z/360,_=$-Math.floor($),j=$*Math.PI*2;switch(J){case"square":return Math.sin(j)>=0?1:-1;case"sawtooth":return _*2-1;case"triangle":return 1-Math.abs(_*4-2);default:return Math.sin(j)}}#u(){this.#c(),this.innerHTML=this.#jJ(),this.#a(),this.#n(),this.#m(),this.#FJ(),this.#JJ()}#jJ(){let J=this.#z()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
2
|
<svg viewBox="0 0 ${this.#j} ${this.#_}" class="propskit-oscillator-svg">
|
|
3
3
|
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#j}" height="${this.#_}"></rect>
|
|
4
4
|
<line class="propskit-oscillator-baseline"></line>
|
|
@@ -8,9 +8,9 @@ function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y ex
|
|
|
8
8
|
<foreignObject class="propskit-oscillator-handle propskit-oscillator-frequency-handle" data-handle="frequency" width="20" height="20"><div class="propskit-oscillator-handle-inner"><fig-tooltip text="Frequency"><fig-handle size="small" aria-label="Oscillator frequency handle"${J}></fig-handle></fig-tooltip></div></foreignObject>
|
|
9
9
|
</svg>
|
|
10
10
|
</div>
|
|
11
|
-
${this.#
|
|
12
|
-
${this.#Z.map((Q,Z)=>this.#
|
|
13
|
-
</div>`}#
|
|
11
|
+
${this.#f()?this.#I(J):""}`}#I(J){return`<div class="propskit-oscillator-waves">
|
|
12
|
+
${this.#Z.map((Q,Z)=>this.#s(Q,Z,J)).join("")}
|
|
13
|
+
</div>`}#s(J,Q,Z){let $=Z||this.#Z.length<=1?" disabled":"",_=Q===this.#Q?" data-active":"",j=L.#i(J.type);return`<fig-group class="propskit-oscillator-wave" collapsible borderless compact="true"${this.#L.has(Q)?' open="true"':' open="false"'} data-wave-index="${Q}">
|
|
14
14
|
<fig-header borderless>
|
|
15
15
|
<h3>${j}</h3>
|
|
16
16
|
<fig-tooltip text="Remove form">
|
|
@@ -19,20 +19,20 @@ function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y ex
|
|
|
19
19
|
<fig-tooltip text="Add form">
|
|
20
20
|
<fig-button class="propskit-oscillator-add-type-button" type="select" variant="ghost" icon data-wave-index="${Q}" aria-label="Add form"${Z}>
|
|
21
21
|
<fig-icon name="add"></fig-icon>
|
|
22
|
-
${this.#
|
|
22
|
+
${this.#XJ("propskit-oscillator-add-type","sine",Z,Q)}
|
|
23
23
|
</fig-button>
|
|
24
24
|
</fig-tooltip>
|
|
25
25
|
</fig-header>
|
|
26
26
|
<div class="propskit-oscillator-fields" data-wave-index="${Q}"${_}>
|
|
27
|
-
${this.#
|
|
28
|
-
${this.#
|
|
29
|
-
${this.#
|
|
30
|
-
${this.#
|
|
27
|
+
${this.#r(Q,"frequency","Frequency",0.1,16,0.1,"")}
|
|
28
|
+
${this.#r(Q,"amplitude","Amplitude",-4,4,0.1,"")}
|
|
29
|
+
${this.#r(Q,"phase","Phase",-360,360,1,"°")}
|
|
30
|
+
${this.#r(Q,"offset","Offset",-4,4,0.1,"")}
|
|
31
31
|
</div>
|
|
32
|
-
</fig-group>`}#
|
|
33
|
-
${
|
|
34
|
-
<label>${
|
|
35
|
-
</option>`}).join(""),j=$===null?"":` data-wave-index="${M.#d(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#i(J,Q,Z,$,_,j,G){let X=this.#P()?" disabled":"",q=G?` units="${M.#d(G)}"`:"",B=this.#Z[J]||M.#R();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(B[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${q}${X}></propskit-slider>`}#o(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#q=this.querySelector(".propskit-oscillator-path"),this.#X=this.querySelector(".propskit-oscillator-playhead"),this.#z=this.querySelector(".propskit-oscillator-baseline"),this.#U=this.querySelector(".propskit-oscillator-bounds"),this.#k=this.querySelector('[data-handle="amplitude"]'),this.#K=this.querySelector('[data-handle="frequency"]'),this.#L=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#N=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#W=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#D=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#u(J){let Q=new Set;for(let Z of this.#M)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#M=Q}#n(J){let Q=new Set;for(let Z of this.#M)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#M=Q}#y(){if(this.#T||!window.ResizeObserver)return;this.#T=new ResizeObserver(()=>{if(this.#r())this.#JJ()}),this.#T.observe(this)}#r(){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.#j||Z!==this.#_;return this.#j=Q,this.#_=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#XJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#a(Z/Q)));return{min:-J,max:J}}#s(J){let{min:Q,max:Z}=this.#Y;return this.#_-(J-Q)/(Z-Q)*this.#_}#_J(J){let{min:Q,max:Z}=this.#Y;return Q+(1-J/this.#_)*(Z-Q)}#a(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,_=M.#l(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#JJ(){if(!this.#$||!this.#q)return;if(this.#r(),this.#Y=this.#XJ(),this.#U)this.#U.setAttribute("width",this.#j),this.#U.setAttribute("height",this.#_);let J=Math.max(...this.#Z.map((j)=>j.frequency)),Z=this.#Z.some((j)=>j.type==="square"||j.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let j=0;j<=Z;j++){let G=j/Z,X=G*this.#j,q=this.#s(this.#a(G));$+=`${j===0?"M":"L"}${X.toFixed(1)},${q.toFixed(1)}`}this.#q.setAttribute("d",$);let _=this.#s(0);this.#z?.setAttribute("x1","0"),this.#z?.setAttribute("y1",_),this.#z?.setAttribute("x2",this.#j),this.#z?.setAttribute("y2",_),this.#UJ()}#qJ(){if(this.#B||!this.#X)return;let J=(Q)=>{if(!this.isConnected||!this.#X){this.#B=0;return}this.#ZJ(Q%1000/1000),this.#B=requestAnimationFrame(J)};this.#B=requestAnimationFrame(J)}#BJ(){if(!this.#B)return;cancelAnimationFrame(this.#B),this.#B=0}#ZJ(J){if(!this.#X)return;let Q=J*this.#j,Z=this.#s(this.#a(J));this.#X.setAttribute("cx",Q.toFixed(1)),this.#X.setAttribute("cy",Z.toFixed(1))}#UJ(){let Q=this.#E,Z=this.#DJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#s(this.#a(Z/this.#j)),j=this.#s(this.#a($/this.#j));this.#kJ(this.#k,Z,_,8),this.#kJ(this.#K,$,j,8)}#DJ(){let J=this.#E,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#j-8,_*this.#j))}#kJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#FJ(){for(let Q of this.#L)Q.addEventListener("change",(Z)=>{if(this.#P())return;let $=this.#p(Q);this.#jJ($),this.#Z[$].type=this.#C(Z.detail??Z.target?.value),this.#$J(),this.#f("input"),this.#f("change")});for(let Q of this.#N)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#O=Q;try{this.#YJ(this.#p(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#O=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#YJ(this.#p(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#W)Q.addEventListener("pointerdown",()=>{this.#jJ(this.#p(Q))}),Q.addEventListener("focusin",()=>{this.#jJ(this.#p(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#p(Q);if(Z.detail?.open)this.#M.add($);else this.#M.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.#P())return;let j=this.#p(Q)+1,G=this.#C($.detail??Q.value);this.#Z.splice(j,0,M.#R(G)),this.#n(j),this.#Q=j,this.#g(),this.#f("input"),this.#f("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.#P()||this.#Z.length<=1)return;let $=this.#p(Q);this.#Z.splice($,1),this.#u($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#g(),this.#f("input"),this.#f("change")});for(let Q of[this.#k,this.#K])this.#WJ(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#P())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#MJ(Q,"offset")})}#p(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}#WJ(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#P())return;$.preventDefault(),$.stopImmediatePropagation(),this.#MJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#P())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#LJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#jJ(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#e(),this.#UJ()}#YJ(J,Q,Z,$){if(this.#P())return;this.#jJ(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#t();return}this.#Z[J]=this.#F({...this.#Z[J],[Q]:_}),this.#$J({skipFieldSync:$=="input"}),this.#f($)}#LJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#E;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Z[this.#Q]=this.#F($),this.#$J(),this.#f("input"),this.#f("change"),!0}#NJ(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}}#MJ(J,Q){this.#G=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 _=(G)=>{if(!this.#G)return;let X=this.#NJ(G),q=this.#E;if(Q==="frequency"){let B=Math.max(1,Math.min(this.#j,X.x));q.frequency=this.#j/B}else if(Q==="offset"){let B=this.#I(X.x/this.#j,0,0,1),N=this.#zJ(q,B);q.offset=this.#_J(X.y)-this.#KJ(this.#Q,B)-N*q.amplitude}else if(Q==="amplitude"){let B=this.#I(X.x/this.#j,0,0,1),N=this.#zJ(q,B),K=this.#_J(X.y)-this.#KJ(this.#Q,B)-q.offset;q.amplitude=Math.abs(N)<0.001?q.amplitude:K/N}this.#Z[this.#Q]=this.#F(q),this.#$J(),this.#f("input")},j=()=>{if(this.#G=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#f("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#KJ(J,Q){return this.#Z.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,G=M.#l($.type,j,$.phase);return Z+$.offset+G*$.amplitude},0)}#zJ(J,Q){return M.#l(J.type,Q*J.frequency,J.phase)}#$J({skipFieldSync:J=!1}={}){if(this.#m(),!J)this.#t();this.#e(),this.#JJ()}#m(){for(let J of this.#L){let Q=this.#p(J);J.value=this.#Z[Q]?.type||"sine"}}#t(){for(let J of this.#N){if(J===this.#O)continue;let Q=this.#p(J),Z=J.getAttribute("name"),$=this.#c(this.#Z[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#e(){for(let J of this.#D)if(this.#p(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#f(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:M.#v(this.#E.type)}}))}}customElements.define("propskit-oscillator",M);class c extends HTMLElement{#Z;#Q;#J=null;#j;#_;#Y;#G;#$;#q;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.#j=this.#O.bind(this),this.#_=this.#h.bind(this),this.#Y=this.#E.bind(this),this.#G=this.#C.bind(this),this.#$=this.#I.bind(this),this.#q=this.#R.bind(this)}connectedCallback(){requestAnimationFrame(()=>{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.#B("dial",!0),this.showRotations=this.#z(),this.#X(),this.#M(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#T()}#X(){this.innerHTML=this.#U()}#B(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}#z(){if(this.hasAttribute("rotations"))return this.#B("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#B("show-rotations",!1);return!1}#U(){let J=this.#N(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
32
|
+
</fig-group>`}#XJ(J,Q,Z,$=null){let _=L.TYPES.map((X)=>{let G=X.value===Q?" selected":"";return`<option value="${X.value}"${G}>
|
|
33
|
+
${L.waveIcon(X.value,24)}
|
|
34
|
+
<label>${X.name}</label>
|
|
35
|
+
</option>`}).join(""),j=$===null?"":` data-wave-index="${L.#l(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#r(J,Q,Z,$,_,j,X){let G=this.#z()?" disabled":"",q=X?` units="${L.#l(X)}"`:"",B=this.#Z[J]||L.#S();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#g(B[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${q}${G}></propskit-slider>`}#a(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#q=this.querySelector(".propskit-oscillator-path"),this.#G=this.querySelector(".propskit-oscillator-playhead"),this.#D=this.querySelector(".propskit-oscillator-baseline"),this.#K=this.querySelector(".propskit-oscillator-bounds"),this.#M=this.querySelector('[data-handle="amplitude"]'),this.#U=this.querySelector('[data-handle="frequency"]'),this.#k=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#N=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#H=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#W=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#e(J){let Q=new Set;for(let Z of this.#L)if(Z<J)Q.add(Z);else if(Z>J)Q.add(Z-1);this.#L=Q}#$J(J){let Q=new Set;for(let Z of this.#L)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#L=Q}#y(){if(this.#T||!window.ResizeObserver)return;this.#T=new ResizeObserver(()=>{if(this.#n())this.#m()}),this.#T.observe(this)}#n(){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.#j||Z!==this.#_;return this.#j=Q,this.#_=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#YJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#h(Z/Q)));return{min:-J,max:J}}#p(J){let{min:Q,max:Z}=this.#Y;return this.#_-(J-Q)/(Z-Q)*this.#_}#_J(J){let{min:Q,max:Z}=this.#Y;return Q+(1-J/this.#_)*(Z-Q)}#h(J){return this.#Z.reduce((Q,Z)=>{let $=J*Z.frequency,_=L.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#m(){if(!this.#$||!this.#q)return;if(this.#n(),this.#Y=this.#YJ(),this.#K)this.#K.setAttribute("width",this.#j),this.#K.setAttribute("height",this.#_);let J=Math.max(...this.#Z.map((j)=>j.frequency)),Z=this.#Z.some((j)=>j.type==="square"||j.type==="sawtooth")?Math.max(192,Math.ceil(J*64)):Math.max(96,Math.ceil(J*64)),$="";for(let j=0;j<=Z;j++){let X=j/Z,G=X*this.#j,q=this.#p(this.#h(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${q.toFixed(1)}`}this.#q.setAttribute("d",$);let _=this.#p(0);this.#D?.setAttribute("x1","0"),this.#D?.setAttribute("y1",_),this.#D?.setAttribute("x2",this.#j),this.#D?.setAttribute("y2",_),this.#BJ()}#JJ(){if(this.#B||!this.#G)return;let J=(Q)=>{if(!this.isConnected||!this.#G){this.#B=0;return}this.#t(Q%1000/1000),this.#B=requestAnimationFrame(J)};this.#B=requestAnimationFrame(J)}#c(){if(!this.#B)return;cancelAnimationFrame(this.#B),this.#B=0}#t(J){if(!this.#G)return;let Q=J*this.#j,Z=this.#p(this.#h(J));this.#G.setAttribute("cx",Q.toFixed(1)),this.#G.setAttribute("cy",Z.toFixed(1))}#BJ(){let Q=this.#E,Z=this.#NJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#p(this.#h(Z/this.#j)),j=this.#p(this.#h($/this.#j));this.#MJ(this.#M,Z,_,8),this.#MJ(this.#U,$,j,8)}#NJ(){let J=this.#E,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#j-8,_*this.#j))}#MJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#FJ(){for(let Q of this.#k)Q.addEventListener("change",(Z)=>{if(this.#z())return;let $=this.#d(Q);this.#qJ($),this.#Z[$].type=this.#A(Z.detail??Z.target?.value),this.#GJ(),this.#V("input"),this.#V("change")});for(let Q of this.#N)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#P=Q;try{this.#KJ(this.#d(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#P=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#KJ(this.#d(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#H)Q.addEventListener("pointerdown",()=>{this.#qJ(this.#d(Q))}),Q.addEventListener("focusin",()=>{this.#qJ(this.#d(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#d(Q);if(Z.detail?.open)this.#L.add($);else this.#L.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.#z())return;let j=this.#d(Q)+1,X=this.#A($.detail??Q.value);this.#Z.splice(j,0,L.#S(X)),this.#$J(j),this.#Q=j,this.#u(),this.#V("input"),this.#V("change")})}for(let Q of this.querySelectorAll(".propskit-oscillator-add-type-button")){let Z=($)=>{$.stopPropagation()};Q.addEventListener("pointerdown",Z),Q.addEventListener("click",Z),Q.closest("fig-tooltip")?.addEventListener("pointerdown",Z),Q.closest("fig-tooltip")?.addEventListener("click",Z)}for(let Q of this.querySelectorAll(".propskit-oscillator-remove-button"))Q.addEventListener("pointerdown",(Z)=>{Z.stopPropagation()}),Q.addEventListener("click",(Z)=>{if(Z.stopPropagation(),this.#z()||this.#Z.length<=1)return;let $=this.#d(Q);this.#Z.splice($,1),this.#e($),this.#Q=Math.min(this.#Q,this.#Z.length-1),this.#u(),this.#V("input"),this.#V("change")});for(let Q of[this.#M,this.#U])this.#TJ(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#z())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#DJ(Q,"offset")})}#d(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}#TJ(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#z())return;$.preventDefault(),$.stopImmediatePropagation(),this.#DJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#z())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#LJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#qJ(J){let Q=Math.min(this.#Z.length-1,Math.max(0,J));if(Q===this.#Q)return;this.#Q=Q,this.#ZJ(),this.#BJ()}#KJ(J,Q,Z,$){if(this.#z())return;this.#qJ(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#QJ();return}this.#Z[J]=this.#F({...this.#Z[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#V($)}#LJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#E;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Z[this.#Q]=this.#F($),this.#GJ(),this.#V("input"),this.#V("change"),!0}#UJ(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}}#DJ(J,Q){this.#X=Q,this.#$?.classList.add("dragging");let Z=Q==="frequency"?"ew-resize":Q==="amplitude"?"ns-resize":"",$=document.body.style.cursor;if(Z)document.body.style.cursor=Z;let _=(X)=>{if(!this.#X)return;let G=this.#UJ(X),q=this.#E;if(Q==="frequency"){let B=Math.max(1,Math.min(this.#j,G.x));q.frequency=this.#j/B}else if(Q==="offset"){let B=this.#w(G.x/this.#j,0,0,1),N=this.#WJ(q,B);q.offset=this.#_J(G.y)-this.#kJ(this.#Q,B)-N*q.amplitude}else if(Q==="amplitude"){let B=this.#w(G.x/this.#j,0,0,1),N=this.#WJ(q,B),K=this.#_J(G.y)-this.#kJ(this.#Q,B)-q.offset;q.amplitude=Math.abs(N)<0.001?q.amplitude:K/N}this.#Z[this.#Q]=this.#F(q),this.#GJ(),this.#V("input")},j=()=>{if(this.#X=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#V("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#kJ(J,Q){return this.#Z.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=L.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#WJ(J,Q){return L.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#v(),!J)this.#QJ();this.#ZJ(),this.#m()}#v(){for(let J of this.#k){let Q=this.#d(J);J.value=this.#Z[Q]?.type||"sine"}}#QJ(){for(let J of this.#N){if(J===this.#P)continue;let Q=this.#d(J),Z=J.getAttribute("name"),$=this.#g(this.#Z[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#ZJ(){for(let J of this.#W)if(this.#d(J)===this.#Q)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#V(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:L.#i(this.#E.type)}}))}}F("propskit-oscillator",L);class v extends HTMLElement{#Z;#Q;#J=null;#j;#_;#Y;#X;#$;#q;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.#j=this.#P.bind(this),this.#_=this.#x.bind(this),this.#Y=this.#E.bind(this),this.#X=this.#A.bind(this),this.#$=this.#w.bind(this),this.#q=this.#S.bind(this)}connectedCallback(){requestAnimationFrame(()=>{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.#B("dial",!0),this.showRotations=this.#D(),this.#G(),this.#L(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#T()}#G(){this.innerHTML=this.#K()}#B(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#D(){if(this.hasAttribute("rotations"))return this.#B("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#B("show-rotations",!1);return!1}#K(){let J=this.#N(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
36
36
|
${this.dial?`<div class="fig-input-angle-plane" tabindex="0">
|
|
37
37
|
<div class="fig-input-angle-handle"></div>
|
|
38
38
|
</div>`:""}
|
|
@@ -45,9 +45,9 @@ function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y ex
|
|
|
45
45
|
units="${this.units}">
|
|
46
46
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
47
47
|
</fig-input-number>`:""}
|
|
48
|
-
`}#k(){let J=Math.abs(this.#L(this.angle));return Math.floor(J/360)}#K(){if(!this.rotationSpan)return;let J=this.#k();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#N(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#L(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#D(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#W(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 $}}#M(){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.#K(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#Y),window.addEventListener("keydown",this.#G),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q);this.addEventListener("change",this.#j,!0)}#T(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#Y),window.removeEventListener("keydown",this.#G),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q);this.removeEventListener("change",this.#j,!0)}#O(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]),_=Z[2].toLowerCase();if(_==="deg")_="°";if(_!==this.units){let j=this.#W($,_,this.units);J.target.value=String(j)}}}#R(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#H(),this.#F(),this.#K(),this.#b(),this.#S()}#H(){let Q=this.#L(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#V(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#A(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,_=J.clientX-Z,j=J.clientY-$;return Math.atan2(j,_)*180/Math.PI}#P(J){let Z=(this.#A(J)%360+360)%360;if(Z=this.#V(Z),this.min!==null||this.max!==null)this.angle=this.#D(Z);else if(this.#J===null){this.#J=Z;let j=(this.#L(this.angle)%360+360)%360,G=Z-j;if(G>180)G-=360;if(G<-180)G+=360;this.angle+=this.#D(G)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#D(_),this.#J=Z}if(this.#H(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#K(),this.#b()}#b(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#S(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#F(){if(this.handle){let Q=this.#L(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,_=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${_}px)`}}#h(J){this.isDragging=!0,this.#J=null,this.#P(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#P($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#S()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#E(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#P(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#P($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#S()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#C(J){if(J.key==="Shift")this.isShiftHeld=!0}#I(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"]}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}if(this.angle=J,this.#H(),this.#F(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#K()}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;this.value=Number(Z);break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#X(),this.#M(),this.#F()}break;case"dial":if(this.dial=this.#B("dial",!0),this.isConnected)this.#X(),this.#M(),this.#F();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#X(),this.#M(),this.#F();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#M(),this.#F();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#M(),this.#F();break;case"rotations":case"show-rotations":if(this.showRotations=this.#z(),this.isConnected)this.#X(),this.#M(),this.#F();break}}}customElements.define("fig-input-angle",c);class O extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Z=6;static#Q=["input","button","select","textarea","a[href]","label","summary","fig-button","fig-dropdown","fig-slider","fig-input-number","fig-input-text","propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","fig-checkbox","fig-switch","fig-combo-input","fig-segmented-control","fig-input-color","fig-input-fill",'[contenteditable="true"]'];#J=null;#j=new Map;#_=null;#Y=null;connectedCallback(){this.style.display="contents",this.#B(),this.#J=new MutationObserver(()=>this.#B()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#F(),this.#h(),this.#P()}attributeChangedCallback(){if(this.isConnected)this.#B()}get#G(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#q(){return(this.getAttribute("handle")||"").trim()}#X(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#B(){let J=this.#X(),Q=new Set(J);for(let[Z,$]of this.#j)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#j.delete(Z);if(this.#k(J),this.#z(J),this.#G||J.length<2){this.#F();return}for(let Z of J){let $=this.#N(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#L(Z,$)}this.#K(J),this.#U(J)}#z(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#U(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#k(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#K(J){if(!this.#q)return;for(let Q of J){let Z=Q.querySelector(this.#q);if(Z)Z.setAttribute("data-reorder-handle","")}}#N(J){if(this.#q)return J.querySelector(this.#q);return J}#L(J,Q){let Z=($)=>{if(this.#G||this.#X().length<2)return;if($.button!==0)return;if(!this.#q&&this.#D($.target,J))return;this.#T($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#D(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of O.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#W="fig-reorder-dragging";static#M(J){document.body.classList.toggle(O.#W,J)}#T(J,Q,Z){this.#h(),O.#M(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#X().indexOf(Q),targetIndex:this.#X().indexOf(Q),startX:J.clientX,startY:J.clientY,active:!1,onMove:null,onUp:null,onKeyDown:null};$.onMove=(_)=>{if(_.pointerId!==$.pointerId)return;let j=_.clientX-$.startX,G=_.clientY-$.startY;if(!$.active){if(j*j+G*G<O.#Z*O.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let X=this.#$==="horizontal"?_.clientX:_.clientY,q=this.#O(X);$.targetIndex=q,this.#A(q,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#S($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#S($,_.type==="pointercancel")},this.#_=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#O(J){let Q=this.#X(),Z=this.#$==="horizontal";for(let $=0;$<Q.length;$++){let _=Q[$].getBoundingClientRect(),j=Z?_.left+_.width/2:_.top+_.height/2;if(J<j)return $}return Q.length}#R(J,Q){let Z=this.#X(),$=Z.indexOf(J);if($===-1)return!1;let _=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(_>=Z.length&&$===Z.length-1)return!1;return!0}#H(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,_=-1/0;for(let j of J){let G=j.getBoundingClientRect();Q=Math.min(Q,G.left),Z=Math.max(Z,G.right),$=Math.min($,G.top),_=Math.max(_,G.bottom)}return{left:Q,top:$,width:Z-Q,height:_-$}}#V(){if(this.#Y)return this.#Y;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#Y=J,J}#A(J,Q){let Z=this.#X();if(!this.#R(Q,J)){this.#P();return}let $=this.#H(Z);if(!$){this.#P();return}let _=this.#V();if(_.setAttribute("data-axis",this.#$),this.#$==="horizontal"){let G;if(J<=0)G=Z[0].getBoundingClientRect().left;else if(J>=Z.length)G=Z[Z.length-1].getBoundingClientRect().right;else G=Z[J].getBoundingClientRect().left;_.style.left=`${G-1}px`,_.style.top=`${$.top}px`,_.style.width="2px",_.style.height=`${$.height}px`;return}let j;if(J<=0)j=Z[0].getBoundingClientRect().top;else if(J>=Z.length)j=Z[Z.length-1].getBoundingClientRect().bottom;else j=Z[J].getBoundingClientRect().top;_.style.left=`${$.left}px`,_.style.top=`${j-1}px`,_.style.width=`${$.width}px`,_.style.height="2px"}#P(){this.#Y?.remove(),this.#Y=null}#b(J,Q){let Z=this.#X(),$=Math.max(0,Math.min(Q,Z.length));if($>=Z.length){if(Z[Z.length-1]!==J)this.appendChild(J);return}let _=Z[$];if(_!==J)this.insertBefore(J,_)}#S(J,Q){let{item:Z,oldIndex:$,active:_,onMove:j,onUp:G,onKeyDown:X}=J;if(window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("keydown",X),_){if(!Q){this.#b(Z,J.targetIndex);let q=this.#X().indexOf(Z);if(q!==-1&&q!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:q,item:Z}}))}}if(Z.classList.remove("dragging"),O.#M(!1),this.#P(),this.#_===J)this.#_=null}#F(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#h(){if(!this.#_)return;this.#S(this.#_,!0)}}customElements.define("fig-reorder",O);var f=0;function v(J="fig-select"){return f+=1,`${J}-${f}`}function l(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
|
|
48
|
+
`}#M(){let J=Math.abs(this.#k(this.angle));return Math.floor(J/360)}#U(){if(!this.rotationSpan)return;let J=this.#M();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#N(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#k(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#W(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#H(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 $}}#L(){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.#U(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#Y),window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q);this.addEventListener("change",this.#j,!0)}#T(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#Y),window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q);this.removeEventListener("change",this.#j,!0)}#P(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]),_=Z[2].toLowerCase();if(_==="deg")_="°";if(_!==this.units){let j=this.#H($,_,this.units);J.target.value=String(j)}}}#S(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#O(),this.#F(),this.#U(),this.#b(),this.#C()}#O(){let Q=this.#k(this.angle)*Math.PI/180;this.#Z=Math.cos(Q),this.#Q=Math.sin(Q)}#R(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#f(J){let Q=this.plane.getBoundingClientRect(),Z=Q.left+Q.width/2,$=Q.top+Q.height/2,_=J.clientX-Z,j=J.clientY-$;return Math.atan2(j,_)*180/Math.PI}#z(J){let Z=(this.#f(J)%360+360)%360;if(Z=this.#R(Z),this.min!==null||this.max!==null)this.angle=this.#W(Z);else if(this.#J===null){this.#J=Z;let j=(this.#k(this.angle)%360+360)%360,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#W(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#W(_),this.#J=Z}if(this.#O(),this.#F(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#U(),this.#b()}#b(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#F(){if(this.handle){let Q=this.#k(this.angle)*Math.PI/180,Z=this.plane.offsetWidth/2-this.handle.offsetWidth/2,$=Math.cos(Q)*Z,_=Math.sin(Q)*Z;this.handle.style.transform=`translate(${$}px, ${_}px)`}}#x(J){this.isDragging=!0,this.#J=null,this.#z(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#z($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#C()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#E(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#z(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#z($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#C()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#A(J){if(J.key==="Shift")this.isShiftHeld=!0}#w(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"]}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}if(this.angle=J,this.#O(),this.#F(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#U()}attributeChangedCallback(J,Q,Z){switch(J){case"value":if(this.isDragging)break;this.value=Number(Z);break;case"precision":this.precision=parseInt(Z);break;case"text":if(Z!==Q){if(this.text=Z?.toLowerCase()==="true",this.isConnected)this.#G(),this.#L(),this.#F()}break;case"dial":if(this.dial=this.#B("dial",!0),this.isConnected)this.#G(),this.#L(),this.#F();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#G(),this.#L(),this.#F();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#G(),this.#L(),this.#F();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#G(),this.#L(),this.#F();break;case"rotations":case"show-rotations":if(this.showRotations=this.#D(),this.isConnected)this.#G(),this.#L(),this.#F();break}}}F("fig-input-angle",v);class R extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Z=6;static#Q=["input","button","select","textarea","a[href]","label","summary","fig-button","fig-dropdown","fig-slider","fig-input-number","fig-input-text","propskit-color","propskit-number","propskit-select","propskit-slider","propskit-switch","propskit-text","fig-checkbox","fig-switch","fig-combo-input","fig-segmented-control","fig-input-color","fig-input-fill",'[contenteditable="true"]'];#J=null;#j=new Map;#_=null;#Y=null;connectedCallback(){this.style.display="contents",this.#B(),this.#J=new MutationObserver(()=>this.#B()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#F(),this.#x(),this.#z()}attributeChangedCallback(){if(this.isConnected)this.#B()}get#X(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#q(){return(this.getAttribute("handle")||"").trim()}#G(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#B(){let J=this.#G(),Q=new Set(J);for(let[Z,$]of this.#j)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#j.delete(Z);if(this.#M(J),this.#D(J),this.#X||J.length<2){this.#F();return}for(let Z of J){let $=this.#N(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#k(Z,$)}this.#U(J),this.#K(J)}#D(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#K(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#M(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#U(J){if(!this.#q)return;for(let Q of J){let Z=Q.querySelector(this.#q);if(Z)Z.setAttribute("data-reorder-handle","")}}#N(J){if(this.#q)return J.querySelector(this.#q);return J}#k(J,Q){let Z=($)=>{if(this.#X||this.#G().length<2)return;if($.button!==0)return;if(!this.#q&&this.#W($.target,J))return;this.#T($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#W(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of R.#Q)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#H="fig-reorder-dragging";static#L(J){document.body.classList.toggle(R.#H,J)}#T(J,Q,Z){this.#x(),R.#L(!0);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=(_)=>{if(_.pointerId!==$.pointerId)return;let j=_.clientX-$.startX,X=_.clientY-$.startY;if(!$.active){if(j*j+X*X<R.#Z*R.#Z)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#$==="horizontal"?_.clientX:_.clientY,q=this.#P(G);$.targetIndex=q,this.#f(q,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#C($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#C($,_.type==="pointercancel")},this.#_=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#P(J){let Q=this.#G(),Z=this.#$==="horizontal";for(let $=0;$<Q.length;$++){let _=Q[$].getBoundingClientRect(),j=Z?_.left+_.width/2:_.top+_.height/2;if(J<j)return $}return Q.length}#S(J,Q){let Z=this.#G(),$=Z.indexOf(J);if($===-1)return!1;let _=Math.max(0,Math.min(Q,Z.length));if(Q===$)return!1;if(_>=Z.length&&$===Z.length-1)return!1;return!0}#O(J){if(!J.length)return null;let Q=1/0,Z=-1/0,$=1/0,_=-1/0;for(let j of J){let X=j.getBoundingClientRect();Q=Math.min(Q,X.left),Z=Math.max(Z,X.right),$=Math.min($,X.top),_=Math.max(_,X.bottom)}return{left:Q,top:$,width:Z-Q,height:_-$}}#R(){if(this.#Y)return this.#Y;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#Y=J,J}#f(J,Q){let Z=this.#G();if(!this.#S(Q,J)){this.#z();return}let $=this.#O(Z);if(!$){this.#z();return}let _=this.#R();if(_.setAttribute("data-axis",this.#$),this.#$==="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;_.style.left=`${X-1}px`,_.style.top=`${$.top}px`,_.style.width="2px",_.style.height=`${$.height}px`;return}let j;if(J<=0)j=Z[0].getBoundingClientRect().top;else if(J>=Z.length)j=Z[Z.length-1].getBoundingClientRect().bottom;else j=Z[J].getBoundingClientRect().top;_.style.left=`${$.left}px`,_.style.top=`${j-1}px`,_.style.width=`${$.width}px`,_.style.height="2px"}#z(){this.#Y?.remove(),this.#Y=null}#b(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 _=Z[$];if(_!==J)this.insertBefore(J,_)}#C(J,Q){let{item:Z,oldIndex:$,active:_,onMove:j,onUp:X,onKeyDown:G}=J;if(window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("keydown",G),_){if(!Q){this.#b(Z,J.targetIndex);let q=this.#G().indexOf(Z);if(q!==-1&&q!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:q,item:Z}}))}}if(Z.classList.remove("dragging"),R.#L(!1),this.#z(),this.#_===J)this.#_=null}#F(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#x(){if(!this.#_)return;this.#C(this.#_,!0)}}F("fig-reorder",R);var E=0;function u(J="fig-select"){return E+=1,`${J}-${E}`}function i(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
|
|
49
49
|
`)?`
|
|
50
|
-
`:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function
|
|
50
|
+
`:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function o(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}function a(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}class s extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let J=this.getAttribute("value");if(J!==null)return J;return(this.textContent||"").trim()}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get disabled(){return Y(this,"disabled")}set disabled(J){if(J)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return Y(this,"selected")}set selected(J){if(J)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="disabled")this.#Z()}#Z(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}F("fig-select-option",s);function n(J,Q,Z=2){if(!J||!Q)return!1;let $=Q.scrollHeight-Q.clientHeight>Z,_=!$||Q.scrollTop<=Z,j=!$||Q.scrollTop+Q.clientHeight>=Q.scrollHeight-Z;return J.classList.toggle("overflow-start",!_),J.classList.toggle("overflow-end",!j),$}function y(J,Q=1){if(!J)return;J.scrollBy({top:J.clientHeight*0.8*Q,behavior:"smooth"})}function t({onStart:J,onEnd:Q}={}){let Z=($,_)=>{let j=document.createElement("button");j.type="button",j.className=`fig-overflow fig-overflow-${$}`,j.dataset.figOverflow=$,j.setAttribute("data-fig-select-nav",$),j.setAttribute("tabindex","-1"),j.setAttribute("aria-label",$==="start"?"Scroll up":"Scroll down");let X=document.createElement("fig-icon");return X.setAttribute("name","chevron"),X.setAttribute("size","small"),X.className="fig-overflow-chevron",j.appendChild(X),j.addEventListener("click",(G)=>{G.preventDefault(),G.stopPropagation(),_?.(G)}),j};return{start:Z("start",J),end:Z("end",Q)}}class r extends HTMLElement{#Z=null;#Q=null;#J=null;#j=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#_(),this.#Y(),this.addEventListener("scroll",this.#j,{passive:!0}),this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.syncOverflow()),this.#J.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#X()}syncOverflow(){return n(this,this)}scrollToOption(J,Q="auto"){if(!J||!this.contains(J))return;requestAnimationFrame(()=>{if(!J.isConnected)return;if(this.scrollHeight<=this.clientHeight+1){this.syncOverflow();return}let Z=J.getBoundingClientRect(),$=this.getBoundingClientRect(),_=Z.top-$.top+this.scrollTop,j=this.scrollHeight-this.clientHeight,X=Math.max(0,Math.min(_+Z.height/2-this.clientHeight/2,j));this.scrollTo({top:X,behavior:Q}),this.syncOverflow()})}#_(){let J=this.querySelector(":scope > fig-chooser");if(!J)return;while(J.firstChild)this.insertBefore(J.firstChild,J);J.remove()}#Y(){if(this.#Z&&this.#Q&&this.contains(this.#Z)&&this.contains(this.#Q))return;this.#X();let J=t({onStart:()=>y(this,-1),onEnd:()=>y(this,1)});this.#Z=J.start,this.#Q=J.end,this.prepend(this.#Z),this.append(this.#Q)}#X(){this.#Z?.remove(),this.#Q?.remove(),this.#Z=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}F("fig-select-options",r);class p extends HTMLElement{#Z=null;#Q=null;#J=null;#j=null;#_=null;#Y=!1;#X=-1;#$=!1;#q=!1;#G=null;#B=!1;#D=null;#K=null;#M=!1;#U=this.#n.bind(this);#N=this.#YJ.bind(this);#k=this.#p.bind(this);#W=this.#_J.bind(this);#H=this.#u.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get open(){return Y(this,"open")}set open(J){if(J)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#Y)this.#f();if(this.#T(),this.#R(),this.#a(),this.#r(),this.#y(),this.#jJ(),this.open)this.#BJ()}disconnectedCallback(){this.#o(),document.removeEventListener("keydown",this.#k,!0),this.#_?.disconnect(),this.#_=null}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Y)return;if(J==="options"){this.#R(),this.#y();return}if(J==="value"||J==="label"){this.#y();return}if(J==="disabled"){this.#a();return}if(J==="open"){if(Z===null||Z==="false")this.#NJ();else this.#BJ();return}if(J==="position"||J==="offset"||J==="closedby")this.#r()}focus(J){this.#Z?.focus(J)}blur(){this.#Z?.blur()}#L(J){return J?.nodeType===1&&(J.tagName==="FIG-SELECT-OPTION"||J.tagName==="FIG-MENU-SEPARATOR"||J.tagName==="FIG-SELECT-OPTIONS")}#T(){for(let J of this.querySelectorAll(":scope > fig-select-options"))if(!J.hasAttribute("slot"))J.setAttribute("slot","panel")}#P(){let Q=(this.#j?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#S(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#O(){let J=this.#P();if(J){if(!J.hasAttribute("slot"))J.setAttribute("slot","panel");return J}return J=document.createElement("fig-select-options"),J.setAttribute("slot","panel"),J.setAttribute("data-fig-generated",""),this.appendChild(J),J}#R(){if(this.#S())return;let J=this.hasAttribute("options"),Q=J?this.#O():this.#P();if(!Q)return;this.#M=!0;try{for(let _ of Q.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))_.remove();if(!J)return;let Z=i(this.getAttribute("options")),$=Q.querySelector(":scope > .fig-overflow-end");for(let _ of Z){let j=document.createElement("fig-select-option");if(j.setAttribute("data-fig-generated",""),j.setAttribute("value",o(_)),j.textContent=a(_),$)Q.insertBefore(j,$);else Q.appendChild(j)}}finally{this.#M=!1}}#f(){this.#Y=!0;let J=this.attachShadow({mode:"open"});J.innerHTML=`
|
|
51
51
|
<style>
|
|
52
52
|
:host {
|
|
53
53
|
display: inline-flex;
|
|
@@ -123,4 +123,4 @@ function Y(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class y ex
|
|
|
123
123
|
max-height: inherit;
|
|
124
124
|
}
|
|
125
125
|
</style>
|
|
126
|
-
`;let Q=document.createElement("fig-button");Q.className="fig-select-trigger",Q.setAttribute("part","trigger"),Q.setAttribute("variant","ghost"),Q.setAttribute("aria-haspopup","listbox"),Q.setAttribute("aria-expanded","false");let Z=document.createElement("span");Z.className="fig-select-label",Z.setAttribute("part","label"),Q.appendChild(Z);let $=document.createElement("dialog",{is:"fig-popup"})
|
|
126
|
+
`;let Q=document.createElement("fig-button");Q.className="fig-select-trigger",Q.setAttribute("part","trigger"),Q.setAttribute("variant","ghost"),Q.setAttribute("aria-haspopup","listbox"),Q.setAttribute("aria-expanded","false");let Z=document.createElement("span");Z.className="fig-select-label",Z.setAttribute("part","label"),Q.appendChild(Z);let $=document.createElement("dialog",{is:"fig-popup"});if($.setAttribute("is","fig-popup"),$.setAttribute("part","listbox"),$.setAttribute("theme","menu"),$.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)$.setAttribute("popover","manual");$.id=u("fig-select-list"),Q.setAttribute("aria-controls",$.id);let _=document.createElement("slot");if(_.setAttribute("name","panel"),$.appendChild(_),J.append(Q,$),this.#Z=Q,this.#J=Z,this.#Q=$,this.#j=_,$.anchor=Q,this.#T(),this.#i(),this.#z(),!this.hasAttribute("value")){let j=this.#I().find((X)=>Y(X,"selected"));if(j)this.setAttribute("value",j.value)}}#z(){if(!this.#Q||this.#q)return;if(typeof this.#Q.positionPopup!=="function")return;this.#G=this.#Q.positionPopup.bind(this.#Q),this.#Q.positionPopup=()=>{if(!this.open){this.#G?.();return}this.#l()},this.#q=!0}#b(J){if(!J)return null;let Q=document.createRange();Q.selectNodeContents(J);let Z=[...Q.getClientRects()].filter(($)=>$.width>0&&$.height>0);if(Z.length)return Z[0];return J.getBoundingClientRect()}#C(){if(typeof this.#Q?.parseViewportMargins==="function")return this.#Q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#F(){let J=this.#J?.getBoundingClientRect();if(!J)return null;return{x:J.x,y:J.y,width:J.width,height:J.height}}#x(){let J=window.visualViewport;return{width:J?.width??window.innerWidth,height:J?.height??window.innerHeight,offsetLeft:J?.offsetLeft??0,offsetTop:J?.offsetTop??0}}#E(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.x-Q.x)>Z||Math.abs(J.y-Q.y)>Z||Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z}#A(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z||Math.abs(J.offsetLeft-Q.offsetLeft)>Z||Math.abs(J.offsetTop-Q.offsetTop)>Z}#w(){if(!this.#B)return!1;let J=this.#E(this.#D,this.#F()),Q=this.#A(this.#K,this.#x());return!J&&!Q}#g(){this.#D=this.#F(),this.#K=this.#x()}#l(){if(this.#w())return;let J=this.#Q,Q=this.#J;if(!J||!Q){this.#G?.();return}let Z=this.#I(),$=Z.find((k)=>this.#s(k)===this.value)||Z[0];if(!$){this.#G?.();return}this.#G?.();let _=J.getBoundingClientRect(),j=Q.getBoundingClientRect(),X=this.#b($);if(!_.width||!_.height||!j.width||!X)return;let G=X.left-_.left,q=X.top-_.top,N=Y(this,"full")?this.getBoundingClientRect().left:j.left-G,K=j.top-q,U=this.#C();if(typeof J.clampToViewport==="function")({left:N,top:K}=J.clampToViewport({left:N,top:K},_,U));else{let{left:k,top:D}=U,O=window.innerWidth-_.width-U.right,H=window.innerHeight-_.height-U.bottom;N=Math.min(Math.max(N,k),Math.max(k,O)),K=Math.min(Math.max(K,D),Math.max(D,H))}J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(N)}px`,"important"),J.style.setProperty("top",`${Math.round(K)}px`,"important");let M=this.#P(),W=this.#b($);if(W&&M&&M.scrollHeight>M.clientHeight+1){let k=W.top-j.top;if(Math.abs(k)>0.5)M.scrollTop+=k;M.syncOverflow?.()}if(this.#B||this.open)this.#g()}#i(){this.#Z?.addEventListener("click",this.#U),this.#Z?.addEventListener("keydown",this.#k),this.addEventListener("click",this.#N),this.#Q?.addEventListener("keydown",this.#k),this.#Q?.addEventListener("close",this.#W),this.#j?.addEventListener("slotchange",this.#H)}#o(){this.#Z?.removeEventListener("click",this.#U),this.#Z?.removeEventListener("keydown",this.#k),this.removeEventListener("click",this.#N),this.#Q?.removeEventListener("keydown",this.#k),this.#Q?.removeEventListener("close",this.#W),this.#j?.removeEventListener("slotchange",this.#H)}#u(){this.#T(),this.#y()}#jJ(){if(this.#_)return;this.#_=new MutationObserver((J)=>{if(this.#$||this.#M)return;let Q=!1;for(let Z of J){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#L($))||[...Z.removedNodes].some(($)=>this.#L($)))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"&&(Z.attributeName==="value"||Z.attributeName==="disabled"||Z.attributeName==="label"))Q=!0;if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#y()}),this.#_.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#I({enabledOnly:J=!1}={}){let Q=this.#P(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!J)return Z;return Z.filter(($)=>!Y($,"disabled"))}#s(J){if(!J)return"";if(typeof J.value==="string")return J.value;let Q=J.getAttribute?.("value");if(Q!=null)return Q;return(J.textContent||"").trim()}#XJ(J){if(!J)return"";let Q=J.getAttribute?.("label");if(Q!=null&&Q!=="")return Q.trim();let Z=[];for(let $ of J.childNodes){if($.nodeType===Node.TEXT_NODE){let X=$.textContent?.trim();if(X)Z.push(X);continue}if(!($ instanceof Element))continue;let _=$.getAttribute("slot");if(_==="prepend"||_==="append")continue;let j=$.textContent?.trim();if(j)Z.push(j)}if(Z.length)return Z.join(" ").trim();return(J.textContent||"").trim()}#r(){if(!this.#Q)return;this.#Q.setAttribute("position",this.getAttribute("position")||"bottom left");let J=this.getAttribute("offset");if(J)this.#Q.setAttribute("offset",J);else this.#Q.removeAttribute("offset");let Q=this.getAttribute("closedby");if(Q)this.#Q.setAttribute("closedby",Q);else this.#Q.removeAttribute("closedby")}#a(){let J=Y(this,"disabled");if(this.#Z)if(J)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(J&&this.open)this.open=!1}#e(J){if(!J.length)return null;let Q=J.find((Z)=>Y(Z,"selected"));if(Q&&!Y(Q,"disabled"))return Q;return J.find((Z)=>!Y(Z,"disabled"))||J[0]||null}#$J(J){this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#y(){if(this.#$)return;this.#$=!0;try{let J=this.#I(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?J.find((G)=>this.#s(G)===Z):null,_=!1;if(!$){if(Q){if(!J.length){if(this.#J)this.#J.textContent=Z||this.getAttribute("label")||"";return}if($=this.#e(J),$){let G=this.#s($);if(Z!==G)this.setAttribute("value",G),_=!0}else this.removeAttribute("value"),_=!0}else if($=J.find((G)=>Y(G,"selected")),$)this.setAttribute("value",this.#s($)),_=!0}for(let G of J){let q=G===$;if(G.setAttribute("aria-selected",q?"true":"false"),q)G.setAttribute("selected","");else G.removeAttribute("selected")}let j=$&&this.#XJ($)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=j;let X=this.getAttribute("label")||"Select";if(this.#Z?.setAttribute("aria-label",X),this.#P()?.syncOverflow?.(),_)this.#$J(this.getAttribute("value")??"")}finally{this.#$=!1}}#n(J){if(Y(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=!this.open;if(Q&&this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=Q}#YJ(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(Y(Z,"disabled"))return;this.#h(Z)}#p(J){if(J.currentTarget===document&&J.key!=="Escape")return;if(!(this.open&&(this.#Q?.matches?.(":open")??!1))){if(this.#Z?.contains(J.target)&&(J.key==="ArrowDown"||J.key==="Enter"||J.key===" ")){if(J.preventDefault(),this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0,requestAnimationFrame(()=>{let _=this.#I({enabledOnly:!0}).findIndex((j)=>this.#s(j)===this.value);this.#c(_>=0?_:0)})}return}let Z=this.#I({enabledOnly:!0});if(!Z.length)return;switch(J.key){case"ArrowDown":J.preventDefault(),this.#JJ(),this.#c(this.#X+1);break;case"ArrowUp":J.preventDefault(),this.#JJ(),this.#c(this.#X-1);break;case"Home":J.preventDefault(),this.#c(0);break;case"End":J.preventDefault(),this.#c(Z.length-1);break;case"Escape":J.preventDefault(),this.open=!1,this.#Z?.focus();break;case"Enter":case" ":{this.#JJ();let $=Z[this.#X];if(!$)return;J.preventDefault(),this.#h($);break}}}#_J(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Z?.setAttribute("aria-expanded","false"),this.#Z?.focus(),this.#X=-1}#h(J){let Q=this.#s(J);this.setAttribute("value",Q),this.#y(),this.#$J(Q),this.open=!1}#m(){return this.#I({enabledOnly:!0})}#JJ(){let J=this.#m();if(!J.length){this.#X=-1;return}let Q=J.find(($)=>$===document.activeElement),Z=Q?J.indexOf(Q):-1;this.#X=Z>=0?Z:this.#X}#c(J){let Q=this.#m();if(!Q.length)return;let Z=(J%Q.length+Q.length)%Q.length;this.#X=Z,Q[Z]?.focus()}#t(){if(!this.#Q||!this.#Z)return;let J=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#Z.getBoundingClientRect().width),Z=Math.max(J,Q,96);if(Y(this,"full"))this.#Q.style.setProperty("width",`${Z}px`,"important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width",`${Z}px`,"important");else this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#BJ(){if(!this.#Q||Y(this,"disabled"))return;if(this.#Z)this.#Q.anchor=this.#Z;this.#z(),this.#B=!1,this.#D=null,this.#K=null,this.#y(),this.#t(),this.#Q.open=!0,document.addEventListener("keydown",this.#k,!0),this.#Z?.setAttribute("aria-expanded","true"),this.#X=-1,requestAnimationFrame(()=>{this.#t(),this.#l();let J=this.#P(),Z=this.#m().findIndex(($)=>this.#s($)===this.value);if(Z>=0)this.#c(Z);else if(this.#Z?.hasAttribute("data-focus-visible")||this.#Z?.matches?.(":focus-visible"))this.#c(0);J?.syncOverflow?.(),this.#B=!0,this.#g()})}#NJ(){if(!this.#Q)return;this.#B=!1,this.#D=null,this.#K=null,document.removeEventListener("keydown",this.#k,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}F("fig-select",p);
|