@rogieking/figui3 6.15.0 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/fig-editor.css +1 -1
- package/dist/fig-lab.css +1 -1
- package/dist/fig-lab.js +5 -5
- package/fig-lab.css +118 -0
- package/fig-lab.js +264 -0
- package/package.json +1 -1
package/dist/fig-lab.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#_()}#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.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#O(){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-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",R(this,"checked")?"on":"off"),this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(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}))}get checked(){return this.#J?this.#J.value==="on":R(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",I);class E extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#_()}#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-dropdown");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Select")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(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}))}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",E);class A extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#_()}#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.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z)}#_(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Text")}#O(){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.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(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}))}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",A);class b extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=null;#$=null;static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#G();if(this.#_(),this.#k(),this.#Y(),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#_();if(Z)this.#k()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){this.#X?.disconnect(),this.#N()}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#_()}#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.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#_(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#O(){let J=new Set(["label","direction","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#k(){if(!this.#J)return;let J=this.#O(),Q=new Set(J);for(let Z of this.#K)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#K=Q}#Y(){if(!this.#J)return;this.#B??=this.#q.bind(this,"input"),this.#$??=this.#q.bind(this,"change"),this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#$)}#N(){if(!this.#J)return;if(this.#B)this.#J.removeEventListener("input",this.#B);if(this.#$)this.#J.removeEventListener("change",this.#$)}#q(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}))}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",b);class y extends HTMLElement{#Q=null;#Z=null;#J=null;#j=!1;#X=null;#K=new Set;#B=0;#$=0;#G=null;#_=null;#O=0;#k=null;#Y=!1;#N=0;#q=null;#P=0;#U=null;#T=null;#C=null;#L=this.#o.bind(this);#F=this.#p.bind(this);#V=this.#d.bind(this);#H=this.#$J.bind(this);#z=this.#e.bind(this);#f=this.#s.bind(this);#g=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.#Q)this.#S();if(this.#W(),this.#M(),this.#QJ(),this.#x(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#z),this.addEventListener("contextmenu",this.#z),!this.#X)this.#X=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#g.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#W();if(Z)this.#M(),this.#x()});this.#X.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#X?.disconnect(),this.#B)cancelAnimationFrame(this.#B),this.#B=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#i(),this.#m(),this.#h(),this.#y(),this.#ZJ(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#z),this.#_?.removeEventListener("change",this.#f)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#W()}#S(){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.#b()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#j=Boolean(Q),this.replaceChildren(Z),this.#D();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#D(){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.#f),this.#_=J,this.appendChild(J)}#W(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Z.parentElement===this.#Q)this.#Z.remove()}else{if(!this.#j)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#M(){if(!this.#J)return;let J=this.#b(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#K)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.#K=Q,this.#I()}#b(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#I(){if(this.#B)cancelAnimationFrame(this.#B);this.#B=requestAnimationFrame(()=>{this.#B=0,this.#n(),this.#E()})}#x(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#E()})}#E(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#G)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#y(),this.#G=J,!this.#G)return;this.#G.addEventListener("dblclick",this.#H,{capture:!0})}#y(){if(!this.#G)return;this.#G.removeEventListener("dblclick",this.#H,{capture:!0}),this.#G=null}#$J(J){J.preventDefault(),J.stopImmediatePropagation(),this.#t()}#o(J){if(J.button!==0||R(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.#G;if(!Q)return;this.#m(),this.#h(),this.#G=Q,this.#Y=!0,this.#U=J.pointerId,this.#N=this.#JJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#q={left:Z.left,right:Z.right,width:Z.width},this.#P=$.width,window.addEventListener("pointermove",this.#F,{passive:!0}),window.addEventListener("pointerup",this.#V,{once:!0}),window.addEventListener("pointercancel",this.#V,{once:!0}),window.addEventListener("blur",this.#V,{once:!0})}#p(J){if(!this.#Y)return;if(J.pointerId!==this.#U)return;if(J.buttons===0){this.#d(J);return}this.#BJ(J.clientX)}#d(J){if(J?.pointerId!==void 0&&this.#U!==null&&J.pointerId!==this.#U)return;this.#m(),this.#h()}#m(){window.removeEventListener("pointermove",this.#F),window.removeEventListener("pointerup",this.#V),window.removeEventListener("pointercancel",this.#V),window.removeEventListener("blur",this.#V),this.#Y=!1,this.#U=null}#e(J){if(R(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#i(),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.#_?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#s(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#t()}#i(){if(this.#O)clearTimeout(this.#O),this.#O=0;this.#k=null}#JJ(){let J=getComputedStyle(this).getPropertyValue("--propskit-slider-elastic-distance").trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:"var(--propskit-slider-elastic-distance)"}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#BJ(J){let Q=this.#q;if(!Q||!this.#N){this.#h();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#a();return}let $=Math.max(-this.#N,Math.min(this.#N,Z*0.5)),_=Math.abs($),j=this.#P?(this.#P+_)/this.#P: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")}#h(){this.#a(),this.#N=0,this.#q=null,this.#P=0,this.#U=null}#a(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#KJ(J){let Q=this.#G;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 B=Math.round((G-_)/X)*X+_,K=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(K)))}#v(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#G?.min??"0"}#t(){this.#i(),this.#r(this.#v(),"input"),this.#r(this.#v(),"change")}#r(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}))}#n(){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.#T)this.#T=this.#_J.bind(this,"input");if(!this.#C)this.#C=this.#_J.bind(this,"change");this.#J.addEventListener("input",this.#T),this.#J.addEventListener("change",this.#C)}#ZJ(){if(!this.#J)return;if(this.#T)this.#J.removeEventListener("input",this.#T);if(this.#C)this.#J.removeEventListener("change",this.#C)}#_J(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#h();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.#t()}}customElements.define("propskit-slider",y);class x extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#j=75;#X=0;#K=!1;#B=0;#$=null;#G=null;#_=null;#O=null;#k=null;#Y=null;#N=null;#q=null;#P=null;#U=!1;#T=!1;#C=!1;#L=!1;#F=null;#V="";#H="";#z=null;get#f(){return this.getAttribute("type")||"point"}get#g(){return this.#f==="point-radius"||this.#f==="point-radius-angle"}get#S(){return this.#f==="point-radius-angle"}get#D(){return this.#f==="point-point"}get#W(){return this.#f==="point-radius-angle"||this.#f==="point-point"}get#M(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#b(){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.#b;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#x(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Q)}%, ${Math.round(this.#Z)}%`}get#E(){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#c(){return this.getAttribute("drag-surface")||"parent"}get#y(){let J=this.#c;if(J==="parent")return this.parentElement;return this.closest(J)}get#$J(){let J=this.#c;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#o(J){if(this.#K)return this.#X/100*J;return this.#X}#p(){if(this.#K)return`Radius ${Math.round(this.#X)}%`;return`Radius ${Math.round(this.#X)}`}connectedCallback(){this.#d(),this.#m()}disconnectedCallback(){this.#NJ(),this.#s(),document.body.classList.remove("fig-lab-move-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#U&&!this.#T&&!this.#C&&!this.#L)if(this.#d(),this.#$)this.#A();else this.#m();if(J==="type")this.#d(),this.#m();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#m();if(J==="tooltips")this.#m();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#G)this.#G.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#Y)this.#Y.setAttribute("text",this.#x);if(this.#N)this.#N.setAttribute("text",this.#E)}}#d(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Q=Q.x;if(typeof Q.y==="number")this.#Z=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#K=!0,this.#X=parseFloat(Z);else this.#K=!1,this.#X=parseFloat(Z);if(!Number.isFinite(this.#X))this.#X=0}if(typeof Q.angle==="number")this.#B=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#j=Q.y2}catch{}}get value(){let J={x:this.#Q,y:this.#Z};if(this.#f==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#g)J.radius=this.#K?`${this.#X}%`:this.#X;if(this.#S)J.angle=this.#B;if(this.#D)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)}#m(){this.innerHTML="",this.#$=null,this.#G=null,this.#_=null,this.#O=null,this.#k=null,this.#Y=null,this.#N=null,this.#q=null,this.#P=null;let J=R(this,"disabled"),Q=this.#f,Z=this.#M,$=this.#$J,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#b),_.setAttribute("value",`${this.#Q}% ${this.#Z}%`),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.#D)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#g)this.#KJ();if(this.#W)this.#v();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#x),j.appendChild(_),this.appendChild(j),this.#Y=j}else this.appendChild(_);if(this.#S)this.#r(J,Z,$);if(this.#D)this.#n(J,Z,$);this.#e(this.#$),this.#e(this.#_),this.#e(this.#G),this.#OJ(),this.#BJ(),requestAnimationFrame(()=>this.#A())}#e(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>this.#XJ(Q),{capture:!0})}#XJ(J){if(R(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#F===null)this.#V=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#F=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#z)this.#z=(Q)=>{if(Q?.pointerId!==void 0&&this.#F!==null&&Q.pointerId!==this.#F)return;if(Q?.type==="blur")this.#s();else requestAnimationFrame(()=>this.#s())};window.addEventListener("pointerup",this.#z),window.addEventListener("pointercancel",this.#z),window.addEventListener("blur",this.#z)}#s(){if(this.#F===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#V)document.body.style.setProperty("cursor",this.#V,this.#H);else document.body.style.removeProperty("cursor");if(this.#F=null,this.#V="",this.#H="",this.#z)window.removeEventListener("pointerup",this.#z),window.removeEventListener("pointercancel",this.#z),window.removeEventListener("blur",this.#z)}#i(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let B=Q();if(!B)return;B.removeAttribute("show"),B.hidePopup?.()},X=()=>{if(_()){j();return}let B=Q();if(!B)return;if(Z)B.setAttribute("text",Z());B.setAttribute("show","true"),B.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#U||this.#T||this.#C||this.#L}#BJ(){if(this.#$)this.#i(this.#$,()=>this.#Y,()=>this.#x,()=>this.#JJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#_)this.#i(this.#_,()=>this.#P,()=>`Angle ${Math.round(this.#B)}°`,()=>this.#JJ());if(this.#G)this.#i(this.#G,()=>this.#N,()=>this.#E,()=>this.#JJ());if(this.#O){let J=this.#O.querySelector(".fig-canvas-control-radius-hit");this.#a(J||this.#O)}if(this.#f==="color"&&this.#$&&this.#Y)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#Y?.removeAttribute("show"),this.#Y?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#h(J,Q){let Z=this.#q;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?.()}#a(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#q;if(!Z)return;Z.setAttribute("text",this.#p()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#C)return;this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#C)return;let Q=this.#q;if(!Q)return;Q.removeAttribute("show")})}#KJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");Q.classList.add("fig-canvas-control-radius"),Q.setAttribute("overflow","visible");let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-hit"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");$.classList.add("fig-canvas-control-radius-halo"),Q.appendChild($);let _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#O=Q,this.#M){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#p()),j.appendChild(Q),this.appendChild(j),this.#q=j}else this.appendChild(Q);this.#kJ(Z)}#v(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#D){let _=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.#t(_)}let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.classList.add("fig-canvas-control-angle-line-halo"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","line");$.classList.add("fig-canvas-control-angle-line"),Q.appendChild($),this.#k=Q,this.appendChild(Q)}#t(J){J.addEventListener("pointerdown",(Q)=>{if(R(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#y;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Q,G=this.#Z,B=this.#J,K=this.#j;this.#U=!0,this.#T=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let O=(N)=>{let P=Z.getBoundingClientRect(),S=P.width>0?(N.clientX-_)/P.width*100:0,k=P.height>0?(N.clientY-j)/P.height*100:0,L=-Math.min(X,B),f=100-Math.max(X,B),V=-Math.min(G,K),U=100-Math.max(G,K),M=Math.max(L,Math.min(f,S)),z=Math.max(V,Math.min(U,k));this.#Q=X+M,this.#Z=G+z,this.#J=B+M,this.#j=K+z,this.#A(),this.#R()},Y=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#w(),this.#l(),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Y),requestAnimationFrame(()=>{this.#U=!1,this.#T=!1})};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Y)})}#r(J,Q,Z){let $=document.createElement("fig-handle");if($.setAttribute("type","canvas"),$.setAttribute("drag","true"),$.setAttribute("drag-surface",Z),$.setAttribute("drag-axes","x,y"),$.setAttribute("size","small"),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),J)$.setAttribute("disabled","");if(this.#_=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",`${Math.round(this.#B)}°`),_.appendChild($),this.appendChild(_),this.#P=_}else this.appendChild($)}#n(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.#b),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#j}%`),J)$.setAttribute("disabled","");if(this.#G=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#E),_.appendChild($),this.appendChild(_),this.#N=_}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`}#ZJ(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#_J(){if(!this.#_||!this.#S)return;let J=this.#_.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#ZJ(this.#B)}#qJ(){return Math.atan2(this.#j-this.#Z,this.#J-this.#Q)*180/Math.PI}#PJ(){if(!this.#D)return;let J=this.#qJ(),Q=(Z,$)=>{if(!Z)return;let _=Z.querySelector(".fig-handle-hit-area");if(_)_.style.cursor=this.#ZJ($)};Q(this.#$,J+180),Q(this.#G,J)}#jJ(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`}#A(){let J=this.#y;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#jJ(this.#$,this.#Q,this.#Z,Q),this.#O){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#O,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 B of G)B.setAttribute("cx",String(_)),B.setAttribute("cy",String(_)),B.setAttribute("r",String(Math.max(_-1,0)))}if(this.#k&&this.#W){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_,j;if(this.#D)_=this.#J/100*Q.width,j=this.#j/100*Q.height;else{let B=this.#o(Q.width),K=this.#B*Math.PI/180;_=Z+B*Math.cos(K),j=$+B*Math.sin(K)}let X=this.#k;X.style.width=`${Q.width}px`,X.style.height=`${Q.height}px`,X.style.left="0",X.style.top="0",X.setAttribute("viewBox",`0 0 ${Q.width} ${Q.height}`);let G=X.querySelectorAll(".fig-canvas-control-angle-line, .fig-canvas-control-angle-line-halo");for(let B of G)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(_)),B.setAttribute("y2",String(j))}if(this.#_&&this.#S){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#B*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),B=Q.width>0?X/Q.width*100:0,K=Q.height>0?G/Q.height*100:0;this.#jJ(this.#_,B,K,Q)}if(this.#G&&this.#D)this.#jJ(this.#G,this.#J,this.#j,Q);this.#_J(),this.#PJ()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#l(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#w(){this.setAttribute("value",JSON.stringify(this.value))}#OJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#R();return}this.#U=!0;let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();this.#A(),this.#R()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#l();return}let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#U=!1})}),this.#_)this.#_.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#y;if(!Q)return;this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Q/100*Z.width,_=this.#Z/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#_.offsetWidth/2,B=this.#_.offsetHeight/2,K=j+G-$,O=X+B-_,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(J.detail?.shiftKey))Y=Math.round(Y/15)*15;this.#B=Y;let N=Math.sqrt(K*K+O*O);if(this.#I(J.detail?.shiftKey)){let P=this.#K?5:10;if(this.#K){let S=N/Z.width*100;S=Math.round(S/P)*P,N=S/100*Z.width}else N=Math.round(N/P)*P}if(this.#K)this.#X=Math.max(0,N/Z.width*100);else this.#X=Math.max(0,N);if(this.#P)this.#P.setAttribute("text",`Angle ${Math.round(this.#B)}°`),this.#P.setAttribute("show","true"),this.#P.showPopup?.();this.#A(),this.#R()}),this.#_.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#P)this.#P.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#L=!1})}),this.#_.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#y;if(!Z)return;if(this.#L=!0,this.classList.add("fig-canvas-control-ring-active"),this.#_.setAttribute("selected",""),this.#P)this.#P.setAttribute("show","true"),this.#P.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Q/100*X.width,B=this.#Z/100*X.height,K=j.clientX-X.left-G,O=j.clientY-X.top-B,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(j.shiftKey))Y=Math.round(Y/15)*15;if(this.#B=Y,this.#P)this.#P.setAttribute("text",`Angle ${Math.round(Y)}°`);this.#A(),this.#R()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#_.removeAttribute("selected"),this.#P)this.#P.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#G)this.#G.addEventListener("input",(J)=>{J.stopPropagation(),this.#T=!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.#N)this.#N.removeAttribute("show"),this.#N.hidePopup?.();this.#A(),this.#R()}),this.#G.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#N)this.#N.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#T=!1})}),this.#YJ(this.#$,!0),this.#YJ(this.#G,!1)}#YJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#y;if(!_)return;this.#U=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Q,G=Q?this.#j:this.#Z,B=Q?this.#Q:this.#J,K=Q?this.#Z:this.#j,O=X/100*j.width,Y=G/100*j.height,N=B/100*j.width,P=K/100*j.height,S=Math.sqrt((N-O)**2+(P-Y)**2),k=Q?this.#Y:this.#N;if(k)k.removeAttribute("show"),k.hidePopup?.();let L=(V)=>{let U=_.getBoundingClientRect(),M=X/100*U.width,z=G/100*U.height,T=V.clientX-U.left-M,D=V.clientY-U.top-z,C=Math.atan2(D,T);if(this.#I(V.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let w=M+S*Math.cos(C),g=z+S*Math.sin(C),W=Math.max(0,Math.min(100,w/U.width*100)),H=Math.max(0,Math.min(100,g/U.height*100));if(Q)this.#Q=W,this.#Z=H;else this.#J=W,this.#j=H;this.#A(),this.#R()},f=()=>{if(this.#U=!1,k)k.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",f)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",f)})}#kJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#C)return;let $=this.#y;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Q/100*_.width,X=this.#Z/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;J.style.cursor=this.#QJ(G)});let Q=(Z)=>{if(R(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#C=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#y;if(!$)return;if(this.#q)this.#q.setAttribute("show","true"),this.#q.showPopup?.(),this.#h(Z.clientX,Z.clientY);if(this.#P)this.#P.removeAttribute("show"),this.#P.hidePopup?.();let _=this.#_?.style.pointerEvents,j=this.#_?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#_)this.#_.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),K=this.#Q/100*B.width,O=this.#Z/100*B.height,Y=Math.atan2(Z.clientY-B.top-O,Z.clientX-B.left-K)*180/Math.PI,N=Math.round(Y);document.body.style.cursor=this.#QJ(N);let P=(k)=>{let L=$.getBoundingClientRect(),f=this.#Q/100*L.width,V=this.#Z/100*L.height,U=k.clientX-L.left-f,M=k.clientY-L.top-V,z=Math.round(Math.atan2(M,U)*180/Math.PI);if(z!==N)N=z,document.body.style.cursor=this.#QJ(z);let T=Math.sqrt(U*U+M*M);if(this.#I(k.shiftKey)){let D=this.#K?5:10;if(this.#K){let C=T/L.width*100;C=Math.round(C/D)*D,T=C/100*L.width}else T=Math.round(T/D)*D}if(this.#K)this.#X=Math.max(0,T/L.width*100);else this.#X=Math.max(0,T);if(this.#q)this.#q.setAttribute("text",this.#p()),this.#h(k.clientX,k.clientY);this.#A(),this.#R()},S=()=>{if(this.#C=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#_)this.#_.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#q)this.#q.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",P),window.addEventListener("pointerup",S)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#NJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",x);class q extends HTMLElement{#Q=[q.#H()];#Z=0;#J=2;#j=240;#X=120;#K={min:-1,max:1};#B=null;#$=null;#G=null;#_=null;#O=0;#k=null;#Y=null;#N=null;#q=null;#P=[];#U=[];#T=[];#C=[];#L=new Set;#F=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#H(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.#z("precision",2),this.#W(this.getAttribute("value")),this.#D(),this.#p(),this.#h()}disconnectedCallback(){if(this.#B=null,this.#ZJ(),this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#W(Z),this.isConnected)this.#p();return}if(J==="precision"){if(this.#J=this.#z("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#D(),this.#$)this.#n();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#p()}}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.#Q.map((J)=>this.#b(J))}}get preset(){let J=this.#I;return q.TYPES.find((Q)=>Q.value===J.type)?.name}#z(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#f(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}#g(){return this.getAttribute("edit")!=="false"}#S(){return this.#f("disabled",!1)}#D(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#W(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.#Q=Z.map(($)=>this.#M($)),!this.#Q.length)this.#Q=[q.#H()];return this.#Z=Math.min(this.#Z,this.#Q.length-1),!0}#M(J={}){return{type:this.#x(J.type),frequency:this.#E(J.frequency,1,0.1,16),amplitude:this.#E(J.amplitude,1,-4,4),phase:this.#E(J.phase,0,-360,360),offset:this.#E(J.offset,0,-4,4)}}#b(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Q[this.#Z])this.#Z=0;return this.#Q[this.#Z]||q.#H()}#x(J){let Q=String(J||"").toLowerCase();return q.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#E(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#y(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#$J(J){return q.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,B=q.#o(J,G),K=5+G*_,O=5+(1-(B+1)/2)*_;j+=`${X===0?"M":"L"}${K.toFixed(1)},${O.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)}}#p(){this.#ZJ(),this.innerHTML=this.#d(),this.#i(),this.#a(),this.#n(),this.#A(),this.#QJ()}#d(){let J=this.#S()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
|
-
<svg viewBox="0 0 ${this.#
|
|
3
|
-
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#
|
|
1
|
+
function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#K()}#X(){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.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#K(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#U(){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-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("value",R(this,"checked")?"on":"off"),this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.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.#$)}#q(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}))}#P(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":R(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",I);class E extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#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-color");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#K(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Color")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label","text"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#J.setAttribute("text","true"),this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.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.#$)}#q(J,Q){Q.stopImmediatePropagation();let Z=this.#J?.getAttribute("value")??"";this.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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-input-color"))return;this.focus()}get value(){return this.#J?.getAttribute("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?.querySelector("input:not([tabindex='-1'])")?.focus(J)}}customElements.define("propskit-color",E);class A extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#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-dropdown");for(let j of J)if(j!==Q)_.appendChild(j);Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#K(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Select")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id","size","aria-label"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.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.#$)}#q(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}))}#P(J){if(J.target instanceof Element&&J.target.closest("fig-dropdown"))return;let Q=this.#J?.querySelector("select");if(Q?.focus(),typeof Q?.showPicker==="function")try{Q.showPicker()}catch{}}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",A);class b extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction","aria-label"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction"||$.attributeName==="aria-label")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction"||J==="aria-label")this.#K()}#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.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z)}#K(){if(!this.#Q||!this.#Z||!this.#J)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal"),this.#J.setAttribute("aria-label",this.getAttribute("aria-label")||this.#Z.textContent?.trim()||"Text")}#U(){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-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.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.#$)}#q(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}))}#P(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",b);class y extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=null;#$=null;#B=this.#P.bind(this);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#K(),this.#Y(),this.#k(),this.removeEventListener("click",this.#B),this.addEventListener("click",this.#B),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J){if($.type!=="attributes")continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#K();if(Z)this.#Y()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){this.#j?.disconnect(),this.#N(),this.removeEventListener("click",this.#B)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#K()}#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.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z);for(let j of J)if(j!==Q)_.appendChild(j)}#K(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()==="")this.#Z.remove();else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#U(){let J=new Set(["label","direction","oninput","onchange","class","style","id"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!Q.startsWith("data-"))}#Y(){if(!this.#J)return;let J=this.#U(),Q=new Set(J);for(let Z of this.#O)if(!Q.has(Z))this.#J.removeAttribute(Z);for(let Z of J)this.#J.setAttribute(Z,this.getAttribute(Z)??"");this.#O=Q}#k(){if(!this.#J)return;this.#G??=this.#q.bind(this,"input"),this.#$??=this.#q.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.#$)}#q(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}))}#P(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",y);class x extends HTMLElement{#Q=null;#Z=null;#J=null;#_=!1;#j=null;#O=new Set;#G=0;#$=0;#B=null;#X=null;#K=0;#U=null;#Y=!1;#k=0;#N=null;#q=0;#P=null;#T=null;#C=null;#L=this.#o.bind(this);#F=this.#p.bind(this);#V=this.#d.bind(this);#H=this.#$J.bind(this);#z=this.#e.bind(this);#f=this.#s.bind(this);#g=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.#Q)this.#S();if(this.#W(),this.#M(),this.#QJ(),this.#x(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.addEventListener("pointerdown",this.#L,{capture:!0,passive:!0}),this.removeEventListener("contextmenu",this.#z),this.addEventListener("contextmenu",this.#z),!this.#j)this.#j=new MutationObserver((J)=>{let Q=!1,Z=!1;for(let $ of J)if($.type==="attributes"){if($.attributeName&&this.#g.has($.attributeName))continue;if($.attributeName==="label"||$.attributeName==="direction")Q=!0;else Z=!0}if(Q)this.#W();if(Z)this.#M(),this.#x()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#G)cancelAnimationFrame(this.#G),this.#G=0;if(this.#$)cancelAnimationFrame(this.#$),this.#$=0;this.#i(),this.#m(),this.#h(),this.#y(),this.#ZJ(),this.removeEventListener("pointerdown",this.#L,{capture:!0}),this.removeEventListener("contextmenu",this.#z),this.#X?.removeEventListener("change",this.#f)}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#Q)return;if(J==="label"||J==="direction")this.#W()}#S(){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.#b()){let X=this.getAttribute(j);_.setAttribute(j,X??"")}Z.append($,_),this.#Q=Z,this.#Z=$,this.#J=_,this.#_=Boolean(Q),this.replaceChildren(Z),this.#D();for(let j of J){if(j===Q)continue;this.#J.appendChild(j)}}#D(){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.#f),this.#X=J,this.appendChild(J)}#W(){if(!this.#Q||!this.#Z)return;let J=this.hasAttribute("label"),Q=this.getAttribute("label");if(J&&(Q??"").trim()===""){if(this.#Z.parentElement===this.#Q)this.#Z.remove()}else{if(!this.#_)this.#Z.textContent=J?Q??"":"Label";if(this.#Z.parentElement!==this.#Q)this.#Q.prepend(this.#Z)}this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#M(){if(!this.#J)return;let J=this.#b(),Q=new Set(J.filter(($)=>$!=="text"));for(let $ of this.#O)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.#O=Q,this.#I()}#b(){let J=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter((Q)=>!J.has(Q)&&!this.#g.has(Q))}#I(){if(this.#G)cancelAnimationFrame(this.#G);this.#G=requestAnimationFrame(()=>{this.#G=0,this.#n(),this.#E()})}#x(){if(this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{this.#$=0,this.#E()})}#E(){let J=this.#J?.querySelector('input[type="range"]'),Q=this.#J?.querySelector("fig-input-number input");if(J!==this.#B)this.#c(J);J?.removeAttribute("tabindex"),Q?.setAttribute("tabindex","-1")}#c(J){if(this.#y(),this.#B=J,!this.#B)return;this.#B.addEventListener("dblclick",this.#H,{capture:!0})}#y(){if(!this.#B)return;this.#B.removeEventListener("dblclick",this.#H,{capture:!0}),this.#B=null}#$J(J){J.preventDefault(),J.stopImmediatePropagation(),this.#t()}#o(J){if(J.button!==0||R(this,"disabled"))return;if(this.getAttribute("elastic")==="false")return;if(J.target?.closest?.("fig-input-number"))return;let Q=this.#J?.querySelector('input[type="range"]')??this.#B;if(!Q)return;this.#m(),this.#h(),this.#B=Q,this.#Y=!0,this.#P=J.pointerId,this.#k=this.#JJ();let Z=Q.getBoundingClientRect(),$=this.getBoundingClientRect();this.#N={left:Z.left,right:Z.right,width:Z.width},this.#q=$.width,window.addEventListener("pointermove",this.#F,{passive:!0}),window.addEventListener("pointerup",this.#V,{once:!0}),window.addEventListener("pointercancel",this.#V,{once:!0}),window.addEventListener("blur",this.#V,{once:!0})}#p(J){if(!this.#Y)return;if(J.pointerId!==this.#P)return;if(J.buttons===0){this.#d(J);return}this.#BJ(J.clientX)}#d(J){if(J?.pointerId!==void 0&&this.#P!==null&&J.pointerId!==this.#P)return;this.#m(),this.#h()}#m(){window.removeEventListener("pointermove",this.#F),window.removeEventListener("pointerup",this.#V),window.removeEventListener("pointercancel",this.#V),window.removeEventListener("blur",this.#V),this.#Y=!1,this.#P=null}#e(J){if(R(this,"disabled"))return;J.preventDefault(),J.stopPropagation(),J.stopImmediatePropagation(),this.#i(),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.#X?.showAt?.(J,Q)})};window.addEventListener("pointerup",_,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(_,180)}#s(J){if(J.stopPropagation(),J.detail?.value!=="reset-default")return;this.#t()}#i(){if(this.#K)clearTimeout(this.#K),this.#K=0;this.#U=null}#JJ(){let J=getComputedStyle(this).getPropertyValue("--propskit-slider-elastic-distance").trim();if(J.includes("var(")||!J.endsWith("px")){let Z=document.createElement("div");Object.assign(Z.style,{position:"absolute",visibility:"hidden",pointerEvents:"none",width:"var(--propskit-slider-elastic-distance)"}),this.appendChild(Z),J=getComputedStyle(Z).width,Z.remove()}let Q=Number.parseFloat(J);return Number.isFinite(Q)?Math.max(0,Q):0}#BJ(J){let Q=this.#N;if(!Q||!this.#k){this.#h();return}let Z=J<Q.left?J-Q.left:J>Q.right?J-Q.right:0;if(!Z){this.#a();return}let $=Math.max(-this.#k,Math.min(this.#k,Z*0.5)),_=Math.abs($),j=this.#q?(this.#q+_)/this.#q: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")}#h(){this.#a(),this.#k=0,this.#N=null,this.#q=0,this.#P=null}#a(){this.removeAttribute("data-elastic-dragging"),this.style.removeProperty("--propskit-slider-elastic-size"),this.style.removeProperty("--propskit-slider-elastic-scale")}#KJ(J){let Q=this.#B;if(!Q)return this.#J?.value??"";let Z=Q.getBoundingClientRect(),$=Z.width?Math.min(1,Math.max(0,(J.clientX-Z.left)/Z.width)):0,_=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 B=Math.round((G-_)/X)*X+_,K=Math.max(0,`${X}`.split(".")[1]?.length||0);return String(Number(B.toFixed(K)))}#v(){return this.getAttribute("default")??this.#J?.getAttribute("default")??this.getAttribute("value")??this.#J?.getAttribute("value")??this.#B?.min??"0"}#t(){this.#i(),this.#r(this.#v(),"input"),this.#r(this.#v(),"change")}#r(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}))}#n(){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.#T)this.#T=this.#_J.bind(this,"input");if(!this.#C)this.#C=this.#_J.bind(this,"change");this.#J.addEventListener("input",this.#T),this.#J.addEventListener("change",this.#C)}#ZJ(){if(!this.#J)return;if(this.#T)this.#J.removeEventListener("input",this.#T);if(this.#C)this.#J.removeEventListener("change",this.#C)}#_J(J,Q){if(Q.stopImmediatePropagation(),J==="change")this.#h();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.#t()}}customElements.define("propskit-slider",x);class h extends HTMLElement{static observedAttributes=["type","value","color","name","tooltips","disabled","drag-surface","snapping"];#Q=50;#Z=50;#J=75;#_=75;#j=0;#O=!1;#G=0;#$=null;#B=null;#X=null;#K=null;#U=null;#Y=null;#k=null;#N=null;#q=null;#P=!1;#T=!1;#C=!1;#L=!1;#F=null;#V="";#H="";#z=null;get#f(){return this.getAttribute("type")||"point"}get#g(){return this.#f==="point-radius"||this.#f==="point-radius-angle"}get#S(){return this.#f==="point-radius-angle"}get#D(){return this.#f==="point-point"}get#W(){return this.#f==="point-radius-angle"||this.#f==="point-point"}get#M(){let J=this.getAttribute("tooltips");return J===null||J!=="false"}get#b(){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.#b;if(Q==="true")return!0;if(Q==="modifier")return!!J;return!1}get#x(){let J=this.getAttribute("name");if(J)return J.split(",")[0].trim();return`${Math.round(this.#Q)}%, ${Math.round(this.#Z)}%`}get#E(){let J=this.getAttribute("name");if(J){let Q=J.split(",");if(Q.length>1)return Q[1].trim()}return`${Math.round(this.#J)}%, ${Math.round(this.#_)}%`}get#c(){return this.getAttribute("drag-surface")||"parent"}get#y(){let J=this.#c;if(J==="parent")return this.parentElement;return this.closest(J)}get#$J(){let J=this.#c;if(J==="parent"){let Q=this.parentElement;if(Q)return Q.setAttribute("data-fig-canvas-control-surface",""),"[data-fig-canvas-control-surface]"}return J}#o(J){if(this.#O)return this.#j/100*J;return this.#j}#p(){if(this.#O)return`Radius ${Math.round(this.#j)}%`;return`Radius ${Math.round(this.#j)}`}connectedCallback(){this.#d(),this.#m()}disconnectedCallback(){this.#NJ(),this.#s(),document.body.classList.remove("fig-lab-move-active")}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"&&!this.#P&&!this.#T&&!this.#C&&!this.#L)if(this.#d(),this.#$)this.#A();else this.#m();if(J==="type")this.#d(),this.#m();if(J==="color"&&this.#$)if(Z)this.#$.setAttribute("color",Z);else this.#$.removeAttribute("color");if(J==="disabled")this.#m();if(J==="tooltips")this.#m();if(J==="snapping"&&this.#$){if(this.#$.setAttribute("drag-snapping",Z||"false"),this.#B)this.#B.setAttribute("drag-snapping",Z||"false")}if(J==="name"){if(this.#Y)this.#Y.setAttribute("text",this.#x);if(this.#k)this.#k.setAttribute("text",this.#E)}}#d(){let J=this.getAttribute("value");if(!J)return;try{let Q=JSON.parse(J);if(typeof Q.x==="number")this.#Q=Q.x;if(typeof Q.y==="number")this.#Z=Q.y;if(Q.radius!==void 0){let Z=String(Q.radius);if(Z.endsWith("%"))this.#O=!0,this.#j=parseFloat(Z);else this.#O=!1,this.#j=parseFloat(Z);if(!Number.isFinite(this.#j))this.#j=0}if(typeof Q.angle==="number")this.#G=Q.angle;if(typeof Q.x2==="number")this.#J=Q.x2;if(typeof Q.y2==="number")this.#_=Q.y2}catch{}}get value(){let J={x:this.#Q,y:this.#Z};if(this.#f==="color"){let Q=this.getAttribute("color")||this.#$?.getAttribute("color");if(Q)J.color=Q}if(this.#g)J.radius=this.#O?`${this.#j}%`:this.#j;if(this.#S)J.angle=this.#G;if(this.#D)J.x2=this.#J,J.y2=this.#_;return J}set value(J){if(typeof J==="object")this.setAttribute("value",JSON.stringify(J));else if(typeof J==="string")this.setAttribute("value",J)}#m(){this.innerHTML="",this.#$=null,this.#B=null,this.#X=null,this.#K=null,this.#U=null,this.#Y=null,this.#k=null,this.#N=null,this.#q=null;let J=R(this,"disabled"),Q=this.#f,Z=this.#M,$=this.#$J,_=document.createElement("fig-handle");if(_.setAttribute("drag","true"),_.setAttribute("drag-surface",$),_.setAttribute("drag-axes","x,y"),_.setAttribute("drag-snapping",this.#b),_.setAttribute("value",`${this.#Q}% ${this.#Z}%`),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.#D)_.setAttribute("hit-area","12 circle"),_.setAttribute("hit-area-mode","delegate");if(this.#$=_,this.#g)this.#KJ();if(this.#W)this.#v();if(Z){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#x),j.appendChild(_),this.appendChild(j),this.#Y=j}else this.appendChild(_);if(this.#S)this.#r(J,Z,$);if(this.#D)this.#n(J,Z,$);this.#e(this.#$),this.#e(this.#X),this.#e(this.#B),this.#OJ(),this.#BJ(),requestAnimationFrame(()=>this.#A())}#e(J){if(!J)return;J.addEventListener("pointerdown",(Q)=>this.#XJ(Q),{capture:!0})}#XJ(J){if(R(this,"disabled"))return;if(J?.button!==void 0&&J.button!==0)return;if(J?.isPrimary===!1)return;if(this.#F===null)this.#V=document.body.style.getPropertyValue("cursor"),this.#H=document.body.style.getPropertyPriority("cursor");if(this.#F=J?.pointerId??-1,document.body.classList.add("fig-lab-move-active"),document.body.style.setProperty("cursor","var(--fig-lab-cursor-move)","important"),!this.#z)this.#z=(Q)=>{if(Q?.pointerId!==void 0&&this.#F!==null&&Q.pointerId!==this.#F)return;if(Q?.type==="blur")this.#s();else requestAnimationFrame(()=>this.#s())};window.addEventListener("pointerup",this.#z),window.addEventListener("pointercancel",this.#z),window.addEventListener("blur",this.#z)}#s(){if(this.#F===null)return;if(document.body.classList.remove("fig-lab-move-active"),this.#V)document.body.style.setProperty("cursor",this.#V,this.#H);else document.body.style.removeProperty("cursor");if(this.#F=null,this.#V="",this.#H="",this.#z)window.removeEventListener("pointerup",this.#z),window.removeEventListener("pointercancel",this.#z),window.removeEventListener("blur",this.#z)}#i(J,Q,Z,$){if(!J)return;let _=()=>!!$?.(),j=()=>{let B=Q();if(!B)return;B.removeAttribute("show"),B.hidePopup?.()},X=()=>{if(_()){j();return}let B=Q();if(!B)return;if(Z)B.setAttribute("text",Z());B.setAttribute("show","true"),B.showPopup?.()},G=()=>{j()};J.addEventListener("pointerenter",X),J.addEventListener("pointerleave",G)}#JJ(){return this.#P||this.#T||this.#C||this.#L}#BJ(){if(this.#$)this.#i(this.#$,()=>this.#Y,()=>this.#x,()=>this.#JJ()||!!this.#$?.querySelector("fig-color-tip"));if(this.#X)this.#i(this.#X,()=>this.#q,()=>`Angle ${Math.round(this.#G)}°`,()=>this.#JJ());if(this.#B)this.#i(this.#B,()=>this.#k,()=>this.#E,()=>this.#JJ());if(this.#K){let J=this.#K.querySelector(".fig-canvas-control-radius-hit");this.#a(J||this.#K)}if(this.#f==="color"&&this.#$&&this.#Y)new MutationObserver(()=>{if(this.#$?.querySelector("fig-color-tip"))this.#Y?.removeAttribute("show"),this.#Y?.hidePopup?.()}).observe(this.#$,{childList:!0,subtree:!0})}#h(J,Q){let Z=this.#N;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?.()}#a(J){if(!J)return;J.addEventListener("pointerenter",(Q)=>{let Z=this.#N;if(!Z)return;Z.setAttribute("text",this.#p()),Z.setAttribute("show","true"),Z.showPopup?.(),this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointermove",(Q)=>{if(this.#C)return;this.#h(Q.clientX,Q.clientY)}),J.addEventListener("pointerleave",()=>{if(this.#C)return;let Q=this.#N;if(!Q)return;Q.removeAttribute("show")})}#KJ(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");Q.classList.add("fig-canvas-control-radius"),Q.setAttribute("overflow","visible");let Z=document.createElementNS("http://www.w3.org/2000/svg","circle");Z.classList.add("fig-canvas-control-radius-hit"),Q.appendChild(Z);let $=document.createElementNS("http://www.w3.org/2000/svg","circle");$.classList.add("fig-canvas-control-radius-halo"),Q.appendChild($);let _=document.createElementNS("http://www.w3.org/2000/svg","circle");if(Q.appendChild(_),this.#K=Q,this.#M){let j=document.createElement("fig-tooltip");j.setAttribute("action","manual"),j.setAttribute("theme","canvas"),j.setAttribute("pointer","false"),j.setAttribute("text",this.#p()),j.appendChild(Q),this.appendChild(j),this.#N=j}else this.appendChild(Q);this.#kJ(Z)}#v(){let Q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(Q.classList.add("fig-canvas-control-angle-svg"),Q.setAttribute("overflow","visible"),Q.style.position="absolute",Q.style.pointerEvents="none",this.#D){let _=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.#t(_)}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.#U=Q,this.appendChild(Q)}#t(J){J.addEventListener("pointerdown",(Q)=>{if(R(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=this.#y;if(!Z)return;let $=Z.getBoundingClientRect(),_=Q.clientX,j=Q.clientY,X=this.#Q,G=this.#Z,B=this.#J,K=this.#_;this.#P=!0,this.#T=!0,document.body.classList.add("fig-lab-move-active"),J.style.pointerEvents="none";let O=(N)=>{let P=Z.getBoundingClientRect(),S=P.width>0?(N.clientX-_)/P.width*100:0,k=P.height>0?(N.clientY-j)/P.height*100:0,L=-Math.min(X,B),f=100-Math.max(X,B),V=-Math.min(G,K),U=100-Math.max(G,K),M=Math.max(L,Math.min(f,S)),z=Math.max(V,Math.min(U,k));this.#Q=X+M,this.#Z=G+z,this.#J=B+M,this.#_=K+z,this.#A(),this.#R()},Y=()=>{document.body.classList.remove("fig-lab-move-active"),J.style.pointerEvents="stroke",this.#w(),this.#l(),window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Y),requestAnimationFrame(()=>{this.#P=!1,this.#T=!1})};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Y)})}#r(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.#q=_}else this.appendChild($)}#n(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.#b),$.setAttribute("hit-area","12 circle"),$.setAttribute("hit-area-mode","delegate"),$.setAttribute("value",`${this.#J}% ${this.#_}%`),J)$.setAttribute("disabled","");if(this.#B=$,Q){let _=document.createElement("fig-tooltip");_.setAttribute("action","manual"),_.setAttribute("theme","canvas"),_.setAttribute("pointer","false"),_.setAttribute("text",this.#E),_.appendChild($),this.appendChild(_),this.#k=_}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`}#ZJ(J){return`url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='rotate(${Math.round(J-45)} 16 16)'%3E%3Cg filter='url(%23f)'%3E%3Cpath d='M12.5607 22.4393L12.0216 21.9002C17.1558 21.2216 21.2216 17.1558 21.9002 12.0216L22.4393 12.5607C23.0251 13.1464 23.9749 13.1464 24.5607 12.5607C25.1464 11.9749 25.1464 11.0251 24.5607 10.4393L21.5607 7.43934C20.9749 6.85355 20.0251 6.85355 19.4393 7.43934L16.4393 10.4393C15.8536 11.0251 15.8536 11.9749 16.4393 12.5607C17.0251 13.1464 17.9749 13.1464 18.5607 12.5607L18.8056 12.3157C18.1013 15.5527 15.5527 18.1013 12.3157 18.8056L12.5607 18.5607C13.1464 17.9749 13.1464 17.0251 12.5607 16.4393C11.9749 15.8536 11.0251 15.8536 10.4393 16.4393L7.43934 19.4393C6.85356 20.0251 6.85356 20.9749 7.43934 21.5607L10.4393 24.5607C11.0251 25.1464 11.9749 25.1464 12.5607 24.5607C13.1464 23.9749 13.1464 23.0251 12.5607 22.4393Z' fill='white'/%3E%3C/g%3E%3Cpath d='M23.8536 11.8536C23.6583 12.0488 23.3417 12.0488 23.1464 11.8536L21 9.70711V10.5C21 16.299 16.299 21 10.5 21H9.70711L11.8536 23.1464C12.0488 23.3417 12.0488 23.6583 11.8536 23.8536C11.6583 24.0488 11.3417 24.0488 11.1464 23.8536L8.14645 20.8536C7.95119 20.6583 7.95119 20.3417 8.14645 20.1464L11.1464 17.1464C11.3417 16.9512 11.6583 16.9512 11.8536 17.1464C12.0488 17.3417 12.0488 17.6583 11.8536 17.8536L9.70711 20H10.5C15.7467 20 20 15.7467 20 10.5V9.70711L17.8536 11.8536C17.6583 12.0488 17.3417 12.0488 17.1464 11.8536C16.9512 11.6583 16.9512 11.3417 17.1464 11.1464L20.1464 8.14645C20.3417 7.95119 20.6583 7.95119 20.8536 8.14645L23.8536 11.1464C24.0488 11.3417 24.0488 11.6583 23.8536 11.8536Z' fill='black'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='f' x='4' y='5' width='24' height='24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='a'/%3E%3CfeColorMatrix in='SourceAlpha' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='b'/%3E%3CfeOffset dy='1'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0'/%3E%3CfeBlend in2='a' result='c'/%3E%3CfeBlend in='SourceGraphic' in2='c'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E") 16 16, pointer`}#_J(){if(!this.#X||!this.#S)return;let J=this.#X.querySelector(".fig-handle-hit-area");if(!J)return;J.style.cursor=this.#ZJ(this.#G)}#qJ(){return Math.atan2(this.#_-this.#Z,this.#J-this.#Q)*180/Math.PI}#PJ(){if(!this.#D)return;let J=this.#qJ(),Q=(Z,$)=>{if(!Z)return;let _=Z.querySelector(".fig-handle-hit-area");if(_)_.style.cursor=this.#ZJ($)};Q(this.#$,J+180),Q(this.#B,J)}#jJ(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`}#A(){let J=this.#y;if(!J||!this.#$)return;let Q=J.getBoundingClientRect();if(this.#jJ(this.#$,this.#Q,this.#Z,Q),this.#K){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#K,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 B of G)B.setAttribute("cx",String(_)),B.setAttribute("cy",String(_)),B.setAttribute("r",String(Math.max(_-1,0)))}if(this.#U&&this.#W){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_,j;if(this.#D)_=this.#J/100*Q.width,j=this.#_/100*Q.height;else{let B=this.#o(Q.width),K=this.#G*Math.PI/180;_=Z+B*Math.cos(K),j=$+B*Math.sin(K)}let X=this.#U;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 B of G)B.setAttribute("x1",String(Z)),B.setAttribute("y1",String($)),B.setAttribute("x2",String(_)),B.setAttribute("y2",String(j))}if(this.#X&&this.#S){let Z=this.#Q/100*Q.width,$=this.#Z/100*Q.height,_=this.#o(Q.width),j=this.#G*Math.PI/180,X=Z+_*Math.cos(j),G=$+_*Math.sin(j),B=Q.width>0?X/Q.width*100:0,K=Q.height>0?G/Q.height*100:0;this.#jJ(this.#X,B,K,Q)}if(this.#B&&this.#D)this.#jJ(this.#B,this.#J,this.#_,Q);this.#_J(),this.#PJ()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#l(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}#w(){this.setAttribute("value",JSON.stringify(this.value))}#OJ(){if(!this.#$)return;if(this.#$.addEventListener("input",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#R();return}this.#P=!0;let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show"),this.#Y.hidePopup?.();this.#A(),this.#R()}),this.#$.addEventListener("change",(J)=>{if(J.stopPropagation(),J.detail?.color){this.setAttribute("color",J.detail.color),this.#l();return}let Q=J.detail?.px??this.#Q/100,Z=J.detail?.py??this.#Z/100;if(this.#Q=Math.round(Math.max(0,Math.min(100,Q*100))),this.#Z=Math.round(Math.max(0,Math.min(100,Z*100))),this.#Y)this.#Y.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#P=!1})}),this.#X)this.#X.addEventListener("input",(J)=>{J.stopPropagation();let Q=this.#y;if(!Q)return;this.#L=!0,this.classList.add("fig-canvas-control-ring-active");let Z=Q.getBoundingClientRect(),$=this.#Q/100*Z.width,_=this.#Z/100*Z.height,j=J.detail?.x??0,X=J.detail?.y??0,G=this.#X.offsetWidth/2,B=this.#X.offsetHeight/2,K=j+G-$,O=X+B-_,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(J.detail?.shiftKey))Y=Math.round(Y/15)*15;this.#G=Y;let N=Math.sqrt(K*K+O*O);if(this.#I(J.detail?.shiftKey)){let P=this.#O?5:10;if(this.#O){let S=N/Z.width*100;S=Math.round(S/P)*P,N=S/100*Z.width}else N=Math.round(N/P)*P}if(this.#O)this.#j=Math.max(0,N/Z.width*100);else this.#j=Math.max(0,N);if(this.#q)this.#q.setAttribute("text",`Angle ${Math.round(this.#G)}°`),this.#q.setAttribute("show","true"),this.#q.showPopup?.();this.#A(),this.#R()}),this.#X.addEventListener("change",(J)=>{if(J.stopPropagation(),this.classList.remove("fig-canvas-control-ring-active"),this.#q)this.#q.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#L=!1})}),this.#X.addEventListener("hitareadown",(J)=>{J.stopPropagation();let Q=J.detail?.originalEvent;if(!Q)return;Q.preventDefault();let Z=this.#y;if(!Z)return;if(this.#L=!0,this.classList.add("fig-canvas-control-ring-active"),this.#X.setAttribute("selected",""),this.#q)this.#q.setAttribute("show","true"),this.#q.showPopup?.();let $=(j)=>{let X=Z.getBoundingClientRect(),G=this.#Q/100*X.width,B=this.#Z/100*X.height,K=j.clientX-X.left-G,O=j.clientY-X.top-B,Y=Math.atan2(O,K)*180/Math.PI;if(this.#I(j.shiftKey))Y=Math.round(Y/15)*15;if(this.#G=Y,this.#q)this.#q.setAttribute("text",`Angle ${Math.round(Y)}°`);this.#A(),this.#R()},_=()=>{if(this.#L=!1,this.classList.remove("fig-canvas-control-ring-active"),this.#X.removeAttribute("selected"),this.#q)this.#q.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",_)});if(this.#B)this.#B.addEventListener("input",(J)=>{J.stopPropagation(),this.#T=!0;let Q=J.detail?.px??this.#J/100,Z=J.detail?.py??this.#_/100;if(this.#J=Math.round(Math.max(0,Math.min(100,Q*100))),this.#_=Math.round(Math.max(0,Math.min(100,Z*100))),this.#k)this.#k.removeAttribute("show"),this.#k.hidePopup?.();this.#A(),this.#R()}),this.#B.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#k)this.#k.removeAttribute("show");this.#A(),this.#w(),this.#l(),requestAnimationFrame(()=>{this.#T=!1})}),this.#YJ(this.#$,!0),this.#YJ(this.#B,!1)}#YJ(J,Q){if(!J)return;J.addEventListener("hitareadown",(Z)=>{Z.stopPropagation();let $=Z.detail?.originalEvent;if(!$)return;$.preventDefault();let _=this.#y;if(!_)return;this.#P=!0;let j=_.getBoundingClientRect(),X=Q?this.#J:this.#Q,G=Q?this.#_:this.#Z,B=Q?this.#Q:this.#J,K=Q?this.#Z:this.#_,O=X/100*j.width,Y=G/100*j.height,N=B/100*j.width,P=K/100*j.height,S=Math.sqrt((N-O)**2+(P-Y)**2),k=Q?this.#Y:this.#k;if(k)k.removeAttribute("show"),k.hidePopup?.();let L=(V)=>{let U=_.getBoundingClientRect(),M=X/100*U.width,z=G/100*U.height,T=V.clientX-U.left-M,D=V.clientY-U.top-z,C=Math.atan2(D,T);if(this.#I(V.shiftKey))C=Math.round(C*180/Math.PI/15)*15*Math.PI/180;let g=M+S*Math.cos(C),c=z+S*Math.sin(C),W=Math.max(0,Math.min(100,g/U.width*100)),H=Math.max(0,Math.min(100,c/U.height*100));if(Q)this.#Q=W,this.#Z=H;else this.#J=W,this.#_=H;this.#A(),this.#R()},f=()=>{if(this.#P=!1,k)k.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",f)};window.addEventListener("pointermove",L),window.addEventListener("pointerup",f)})}#kJ(J){if(!J)return;J.addEventListener("pointermove",(Z)=>{if(this.#C)return;let $=this.#y;if(!$)return;let _=$.getBoundingClientRect(),j=this.#Q/100*_.width,X=this.#Z/100*_.height,G=Math.atan2(Z.clientY-_.top-X,Z.clientX-_.left-j)*180/Math.PI;J.style.cursor=this.#QJ(G)});let Q=(Z)=>{if(R(this,"disabled"))return;Z.preventDefault(),Z.stopPropagation(),this.#C=!0,this.classList.add("fig-canvas-control-ring-active");let $=this.#y;if(!$)return;if(this.#N)this.#N.setAttribute("show","true"),this.#N.showPopup?.(),this.#h(Z.clientX,Z.clientY);if(this.#q)this.#q.removeAttribute("show"),this.#q.hidePopup?.();let _=this.#X?.style.pointerEvents,j=this.#X?.querySelector(".fig-handle-hit-area"),X=j?.style.pointerEvents;if(this.#X)this.#X.style.pointerEvents="none";if(j)j.style.pointerEvents="none";let G=document.body.style.cursor;J.style.pointerEvents="none";let B=$.getBoundingClientRect(),K=this.#Q/100*B.width,O=this.#Z/100*B.height,Y=Math.atan2(Z.clientY-B.top-O,Z.clientX-B.left-K)*180/Math.PI,N=Math.round(Y);document.body.style.cursor=this.#QJ(N);let P=(k)=>{let L=$.getBoundingClientRect(),f=this.#Q/100*L.width,V=this.#Z/100*L.height,U=k.clientX-L.left-f,M=k.clientY-L.top-V,z=Math.round(Math.atan2(M,U)*180/Math.PI);if(z!==N)N=z,document.body.style.cursor=this.#QJ(z);let T=Math.sqrt(U*U+M*M);if(this.#I(k.shiftKey)){let D=this.#O?5:10;if(this.#O){let C=T/L.width*100;C=Math.round(C/D)*D,T=C/100*L.width}else T=Math.round(T/D)*D}if(this.#O)this.#j=Math.max(0,T/L.width*100);else this.#j=Math.max(0,T);if(this.#N)this.#N.setAttribute("text",this.#p()),this.#h(k.clientX,k.clientY);this.#A(),this.#R()},S=()=>{if(this.#C=!1,this.classList.remove("fig-canvas-control-ring-active"),J.style.pointerEvents="",this.#X)this.#X.style.pointerEvents=_??"";if(j)j.style.pointerEvents=X??"";if(document.body.style.cursor=G,this.#N)this.#N.removeAttribute("show");this.#w(),this.#l(),window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",P),window.addEventListener("pointerup",S)};J.addEventListener("pointerdown",Q),this._radiusDragCleanup=()=>J.removeEventListener("pointerdown",Q)}#NJ(){if(this._radiusDragCleanup)this._radiusDragCleanup(),this._radiusDragCleanup=null}}customElements.define("fig-canvas-control",h);class q extends HTMLElement{#Q=[q.#H()];#Z=0;#J=2;#_=240;#j=120;#O={min:-1,max:1};#G=null;#$=null;#B=null;#X=null;#K=0;#U=null;#Y=null;#k=null;#N=null;#q=[];#P=[];#T=[];#C=[];#L=new Set;#F=null;#V=null;static TYPES=[{name:"Wave",value:"sine"},{name:"Square",value:"square"},{name:"Sawtooth",value:"sawtooth"},{name:"Triangle",value:"triangle"}];static#H(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.#z("precision",2),this.#W(this.getAttribute("value")),this.#D(),this.#p(),this.#h()}disconnectedCallback(){if(this.#G=null,this.#ZJ(),this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="value"){if(this.#W(Z),this.isConnected)this.#p();return}if(J==="precision"){if(this.#J=this.#z("precision",2),this.isConnected)this.#GJ();return}if(J==="aspect-ratio"){if(this.#D(),this.#$)this.#n();return}if(J==="edit"||J==="disabled"){if(this.isConnected)this.#p()}}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.#Q.map((J)=>this.#b(J))}}get preset(){let J=this.#I;return q.TYPES.find((Q)=>Q.value===J.type)?.name}#z(J,Q){let Z=Number.parseInt(this.getAttribute(J)||"",10);return Number.isFinite(Z)?Math.max(0,Math.min(100,Z)):Q}#f(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}#g(){return this.getAttribute("edit")!=="false"}#S(){return this.#f("disabled",!1)}#D(){let J=this.getAttribute("aspect-ratio")||"2 / 1";this.style.setProperty("--aspect-ratio",J)}#W(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.#Q=Z.map(($)=>this.#M($)),!this.#Q.length)this.#Q=[q.#H()];return this.#Z=Math.min(this.#Z,this.#Q.length-1),!0}#M(J={}){return{type:this.#x(J.type),frequency:this.#E(J.frequency,1,0.1,16),amplitude:this.#E(J.amplitude,1,-4,4),phase:this.#E(J.phase,0,-360,360),offset:this.#E(J.offset,0,-4,4)}}#b(J){return{type:J.type,frequency:this.#c(J.frequency),amplitude:this.#c(J.amplitude),phase:this.#c(J.phase),offset:this.#c(J.offset)}}get#I(){if(!this.#Q[this.#Z])this.#Z=0;return this.#Q[this.#Z]||q.#H()}#x(J){let Q=String(J||"").toLowerCase();return q.TYPES.some((Z)=>Z.value===Q)?Q:"sine"}#E(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#y(J){return String(J).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}static#$J(J){return q.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,B=q.#o(J,G),K=5+G*_,O=5+(1-(B+1)/2)*_;j+=`${X===0?"M":"L"}${K.toFixed(1)},${O.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)}}#p(){this.#ZJ(),this.innerHTML=this.#d(),this.#i(),this.#a(),this.#n(),this.#A(),this.#QJ()}#d(){let J=this.#S()?" disabled":"";return`<div class="propskit-oscillator-svg-container">
|
|
2
|
+
<svg viewBox="0 0 ${this.#_} ${this.#j}" class="propskit-oscillator-svg">
|
|
3
|
+
<rect class="propskit-oscillator-bounds" x="0" y="0" width="${this.#_}" height="${this.#j}"></rect>
|
|
4
4
|
<line class="propskit-oscillator-baseline"></line>
|
|
5
5
|
<path class="propskit-oscillator-path"></path>
|
|
6
6
|
<circle class="propskit-oscillator-playhead"></circle>
|
|
@@ -32,7 +32,7 @@ function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I ex
|
|
|
32
32
|
</fig-group>`}#XJ(J,Q,Z,$=null){let _=q.TYPES.map((X)=>{let G=X.value===Q?" selected":"";return`<option value="${X.value}"${G}>
|
|
33
33
|
${q.waveIcon(X.value,24)}
|
|
34
34
|
<label>${X.name}</label>
|
|
35
|
-
</option>`}).join(""),j=$===null?"":` data-wave-index="${q.#y(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#s(J,Q,Z,$,_,j,X){let G=this.#S()?" disabled":"",B=X?` units="${q.#y(X)}"`:"",K=this.#Q[J]||q.#H();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(K[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${B}${G}></propskit-slider>`}#i(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#G=this.querySelector(".propskit-oscillator-path"),this.#_=this.querySelector(".propskit-oscillator-playhead"),this.#k=this.querySelector(".propskit-oscillator-baseline"),this.#Y=this.querySelector(".propskit-oscillator-bounds"),this.#N=this.querySelector('[data-handle="amplitude"]'),this.#q=this.querySelector('[data-handle="frequency"]'),this.#U=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#P=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#C=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#T=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#JJ(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}#BJ(J){let Q=new Set;for(let Z of this.#L)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#L=Q}#h(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#a())this.#n()}),this.#F.observe(this)}#a(){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.#X;return this.#j=Q,this.#X=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#KJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#r(Z/Q)));return{min:-J,max:J}}#v(J){let{min:Q,max:Z}=this.#K;return this.#X-(J-Q)/(Z-Q)*this.#X}#t(J){let{min:Q,max:Z}=this.#K;return Q+(1-J/this.#X)*(Z-Q)}#r(J){return this.#Q.reduce((Q,Z)=>{let $=J*Z.frequency,_=q.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#n(){if(!this.#$||!this.#G)return;if(this.#a(),this.#K=this.#KJ(),this.#Y)this.#Y.setAttribute("width",this.#j),this.#Y.setAttribute("height",this.#X);let J=Math.max(...this.#Q.map((j)=>j.frequency)),Z=this.#Q.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,B=this.#v(this.#r(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${B.toFixed(1)}`}this.#G.setAttribute("d",$);let _=this.#v(0);this.#k?.setAttribute("x1","0"),this.#k?.setAttribute("y1",_),this.#k?.setAttribute("x2",this.#j),this.#k?.setAttribute("y2",_),this.#qJ()}#QJ(){if(this.#O||!this.#_)return;let J=(Q)=>{if(!this.isConnected||!this.#_){this.#O=0;return}this.#_J(Q%1000/1000),this.#O=requestAnimationFrame(J)};this.#O=requestAnimationFrame(J)}#ZJ(){if(!this.#O)return;cancelAnimationFrame(this.#O),this.#O=0}#_J(J){if(!this.#_)return;let Q=J*this.#j,Z=this.#v(this.#r(J));this.#_.setAttribute("cx",Q.toFixed(1)),this.#_.setAttribute("cy",Z.toFixed(1))}#qJ(){let Q=this.#I,Z=this.#PJ(),$=Math.max(8,Math.min(this.#j-8,this.#j/Q.frequency)),_=this.#v(this.#r(Z/this.#j)),j=this.#v(this.#r($/this.#j));this.#jJ(this.#N,Z,_,8),this.#jJ(this.#q,$,j,8)}#PJ(){let J=this.#I,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-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))}#jJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#A(){for(let Q of this.#U)Q.addEventListener("change",(Z)=>{if(this.#S())return;let $=this.#R(Q);this.#w($),this.#Q[$].type=this.#x(Z.detail??Z.target?.value),this.#GJ(),this.#u("input"),this.#u("change")});for(let Q of this.#P)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#V=Q;try{this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#V=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#C)Q.addEventListener("pointerdown",()=>{this.#w(this.#R(Q))}),Q.addEventListener("focusin",()=>{this.#w(this.#R(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#R(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.#S())return;let j=this.#R(Q)+1,X=this.#x($.detail??Q.value);this.#Q.splice(j,0,q.#H(X)),this.#BJ(j),this.#Z=j,this.#p(),this.#u("input"),this.#u("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.#S()||this.#Q.length<=1)return;let $=this.#R(Q);this.#Q.splice($,1),this.#JJ($),this.#Z=Math.min(this.#Z,this.#Q.length-1),this.#p(),this.#u("input"),this.#u("change")});for(let Q of[this.#N,this.#q])this.#l(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#S())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#NJ(Q,"offset")})}#R(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Q.length-1,Math.max(0,Q)):0}#l(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#S())return;$.preventDefault(),$.stopImmediatePropagation(),this.#NJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#S())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#YJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#w(J){let Q=Math.min(this.#Q.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#MJ(),this.#qJ()}#OJ(J,Q,Z,$){if(this.#S())return;this.#w(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#SJ();return}this.#Q[J]=this.#M({...this.#Q[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#u($)}#YJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Q[this.#Z]=this.#M($),this.#GJ(),this.#u("input"),this.#u("change"),!0}#kJ(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}}#NJ(J,Q){this.#B=Q,this.#$?.classList.add("dragging");let Z=Q==="frequency"?"ew-resize":Q==="amplitude"?"ns-resize":"",$=document.body.style.cursor;if(Z)document.body.style.cursor=Z;let _=(X)=>{if(!this.#B)return;let G=this.#kJ(X),B=this.#I;if(Q==="frequency"){let K=Math.max(1,Math.min(this.#j,G.x));B.frequency=this.#j/K}else if(Q==="offset"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K);B.offset=this.#t(G.y)-this.#LJ(this.#Z,K)-O*B.amplitude}else if(Q==="amplitude"){let K=this.#E(G.x/this.#j,0,0,1),O=this.#UJ(B,K),Y=this.#t(G.y)-this.#LJ(this.#Z,K)-B.offset;B.amplitude=Math.abs(O)<0.001?B.amplitude:Y/O}this.#Q[this.#Z]=this.#M(B),this.#GJ(),this.#u("input")},j=()=>{if(this.#B=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#LJ(J,Q){return this.#Q.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=q.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#UJ(J,Q){return q.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#zJ(),!J)this.#SJ();this.#MJ(),this.#n()}#zJ(){for(let J of this.#U){let Q=this.#R(J);J.value=this.#Q[Q]?.type||"sine"}}#SJ(){for(let J of this.#P){if(J===this.#V)continue;let Q=this.#R(J),Z=J.getAttribute("name"),$=this.#c(this.#Q[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#MJ(){for(let J of this.#T)if(this.#R(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#u(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:q.#$J(this.#I.type)}}))}}customElements.define("propskit-oscillator",q);class h extends HTMLElement{#Q;#Z;#J=null;#j;#X;#K;#B;#$;#G;constructor(){super();this.angle=0,this.#Q=1,this.#Z=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#j=this.#V.bind(this),this.#X=this.#b.bind(this),this.#K=this.#I.bind(this),this.#B=this.#x.bind(this),this.#$=this.#E.bind(this),this.#G=this.#H.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.#O("dial",!0),this.showRotations=this.#k(),this.#_(),this.#L(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#F()}#_(){this.innerHTML=this.#Y()}#O(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#k(){if(this.hasAttribute("rotations"))return this.#O("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#O("show-rotations",!1);return!1}#Y(){let J=this.#P(),Q=this.min!==null?`min="${this.min}"`:"",Z=this.max!==null?`max="${this.max}"`:"";return`
|
|
35
|
+
</option>`}).join(""),j=$===null?"":` data-wave-index="${q.#y(String($))}"`;return`<fig-dropdown class="${J}" value="${Q}" experimental="modern" type="dropdown" label="Add form"${j}${Z}>${_}</fig-dropdown>`}#s(J,Q,Z,$,_,j,X){let G=this.#S()?" disabled":"",B=X?` units="${q.#y(X)}"`:"",K=this.#Q[J]||q.#H();return`<propskit-slider class="propskit-oscillator-field" label="${Z}" direction="horizontal" name="${Q}" data-wave-index="${J}" value="${this.#c(K[Q])}" min="${$}" max="${_}" step="${j}" precision="${this.#J}" elastic="false"${B}${G}></propskit-slider>`}#i(){this.#$=this.querySelector(".propskit-oscillator-svg"),this.#B=this.querySelector(".propskit-oscillator-path"),this.#X=this.querySelector(".propskit-oscillator-playhead"),this.#U=this.querySelector(".propskit-oscillator-baseline"),this.#Y=this.querySelector(".propskit-oscillator-bounds"),this.#k=this.querySelector('[data-handle="amplitude"]'),this.#N=this.querySelector('[data-handle="frequency"]'),this.#P=Array.from(this.querySelectorAll(".propskit-oscillator-wave-type")),this.#q=Array.from(this.querySelectorAll("propskit-slider[name]")),this.#C=Array.from(this.querySelectorAll("fig-group.propskit-oscillator-wave")),this.#T=Array.from(this.querySelectorAll(".propskit-oscillator-fields"))}#JJ(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}#BJ(J){let Q=new Set;for(let Z of this.#L)Q.add(Z>=J?Z+1:Z);Q.add(J),this.#L=Q}#h(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#a())this.#n()}),this.#F.observe(this)}#a(){if(!this.#$)return!1;let J=this.#$.getBoundingClientRect(),Q=Math.max(1,Math.round(J.width||240)),Z=Math.max(1,Math.round(J.height||120)),$=Q!==this.#_||Z!==this.#j;return this.#_=Q,this.#j=Z,this.#$.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#KJ(){let J=1,Q=256;for(let Z=0;Z<=Q;Z++)J=Math.max(J,Math.abs(this.#r(Z/Q)));return{min:-J,max:J}}#v(J){let{min:Q,max:Z}=this.#O;return this.#j-(J-Q)/(Z-Q)*this.#j}#t(J){let{min:Q,max:Z}=this.#O;return Q+(1-J/this.#j)*(Z-Q)}#r(J){return this.#Q.reduce((Q,Z)=>{let $=J*Z.frequency,_=q.#o(Z.type,$,Z.phase);return Q+Z.offset+_*Z.amplitude},0)}#n(){if(!this.#$||!this.#B)return;if(this.#a(),this.#O=this.#KJ(),this.#Y)this.#Y.setAttribute("width",this.#_),this.#Y.setAttribute("height",this.#j);let J=Math.max(...this.#Q.map((j)=>j.frequency)),Z=this.#Q.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.#_,B=this.#v(this.#r(X));$+=`${j===0?"M":"L"}${G.toFixed(1)},${B.toFixed(1)}`}this.#B.setAttribute("d",$);let _=this.#v(0);this.#U?.setAttribute("x1","0"),this.#U?.setAttribute("y1",_),this.#U?.setAttribute("x2",this.#_),this.#U?.setAttribute("y2",_),this.#qJ()}#QJ(){if(this.#K||!this.#X)return;let J=(Q)=>{if(!this.isConnected||!this.#X){this.#K=0;return}this.#_J(Q%1000/1000),this.#K=requestAnimationFrame(J)};this.#K=requestAnimationFrame(J)}#ZJ(){if(!this.#K)return;cancelAnimationFrame(this.#K),this.#K=0}#_J(J){if(!this.#X)return;let Q=J*this.#_,Z=this.#v(this.#r(J));this.#X.setAttribute("cx",Q.toFixed(1)),this.#X.setAttribute("cy",Z.toFixed(1))}#qJ(){let Q=this.#I,Z=this.#PJ(),$=Math.max(8,Math.min(this.#_-8,this.#_/Q.frequency)),_=this.#v(this.#r(Z/this.#_)),j=this.#v(this.#r($/this.#_));this.#jJ(this.#k,Z,_,8),this.#jJ(this.#N,$,j,8)}#PJ(){let J=this.#I,Q=J.phase/360,Z=Math.max(0.1,J.frequency),$=0.25;if(J.type==="triangle")$=0.5;if(J.type==="sawtooth")$=1;let _=($-Q)/Z;while(_<0)_+=1/Z;while(_>1)_-=1/Z;if(_<0||_>1||!Number.isFinite(_))_=0.25;return Math.max(8,Math.min(this.#_-8,_*this.#_))}#jJ(J,Q,Z,$){if(!J)return;J.setAttribute("x",Q-$),J.setAttribute("y",Z-$),J.setAttribute("width",$*2),J.setAttribute("height",$*2)}#A(){for(let Q of this.#P)Q.addEventListener("change",(Z)=>{if(this.#S())return;let $=this.#R(Q);this.#w($),this.#Q[$].type=this.#x(Z.detail??Z.target?.value),this.#GJ(),this.#u("input"),this.#u("change")});for(let Q of this.#q)Q.addEventListener("input",(Z)=>{Z.stopPropagation(),this.#V=Q;try{this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"input")}finally{this.#V=null}}),Q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#OJ(this.#R(Q),Q.getAttribute("name"),Z.detail??Z.currentTarget?.value??Z.target?.value,"change")});for(let Q of this.#C)Q.addEventListener("pointerdown",()=>{this.#w(this.#R(Q))}),Q.addEventListener("focusin",()=>{this.#w(this.#R(Q))}),Q.addEventListener("openchange",(Z)=>{let $=this.#R(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.#S())return;let j=this.#R(Q)+1,X=this.#x($.detail??Q.value);this.#Q.splice(j,0,q.#H(X)),this.#BJ(j),this.#Z=j,this.#p(),this.#u("input"),this.#u("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.#S()||this.#Q.length<=1)return;let $=this.#R(Q);this.#Q.splice($,1),this.#JJ($),this.#Z=Math.min(this.#Z,this.#Q.length-1),this.#p(),this.#u("input"),this.#u("change")});for(let Q of[this.#k,this.#N])this.#l(Q);this.querySelector(".propskit-oscillator-svg-container")?.addEventListener("pointerdown",(Q)=>{if(this.#S())return;if(Q.target?.closest?.(".propskit-oscillator-handle, fig-handle"))return;this.#NJ(Q,"offset")})}#R(J){let Q=Number.parseInt(J?.getAttribute("data-wave-index")||"",10);return Number.isFinite(Q)?Math.min(this.#Q.length-1,Math.max(0,Q)):0}#l(J){let Q=J?.querySelector("fig-handle"),Z=J?.getAttribute("data-handle");if(!Q||!Z)return;Q.addEventListener("pointerdown",($)=>{if(this.#S())return;$.preventDefault(),$.stopImmediatePropagation(),this.#NJ($,Z)},{capture:!0}),Q.addEventListener("keydown",($)=>{if(this.#S())return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!this.#YJ($,Z))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#w(J){let Q=Math.min(this.#Q.length-1,Math.max(0,J));if(Q===this.#Z)return;this.#Z=Q,this.#MJ(),this.#qJ()}#OJ(J,Q,Z,$){if(this.#S())return;this.#w(J);let _=Number.parseFloat(Z);if(!Number.isFinite(_)){if($==="change")this.#SJ();return}this.#Q[J]=this.#M({...this.#Q[J],[Q]:_}),this.#GJ({skipFieldSync:$=="input"}),this.#u($)}#YJ(J,Q){let Z=J.shiftKey?0.5:0.1,$=this.#I;switch(Q){case"amplitude":if(J.key==="ArrowUp")$.amplitude+=Z;else if(J.key==="ArrowDown")$.amplitude-=Z;else if(J.key==="Home")$.amplitude=-4;else if(J.key==="End")$.amplitude=4;else return!1;break;case"offset":if(J.key==="ArrowUp")$.offset+=Z;else if(J.key==="ArrowDown")$.offset-=Z;else if(J.key==="Home")$.offset=-4;else if(J.key==="End")$.offset=4;else return!1;break;case"frequency":if(J.key==="ArrowLeft")$.frequency-=Z;else if(J.key==="ArrowRight")$.frequency+=Z;else if(J.key==="Home")$.frequency=0.1;else if(J.key==="End")$.frequency=16;else return!1;break;default:return!1}return this.#Q[this.#Z]=this.#M($),this.#GJ(),this.#u("input"),this.#u("change"),!0}#kJ(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}}#NJ(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 _=(X)=>{if(!this.#G)return;let G=this.#kJ(X),B=this.#I;if(Q==="frequency"){let K=Math.max(1,Math.min(this.#_,G.x));B.frequency=this.#_/K}else if(Q==="offset"){let K=this.#E(G.x/this.#_,0,0,1),O=this.#UJ(B,K);B.offset=this.#t(G.y)-this.#LJ(this.#Z,K)-O*B.amplitude}else if(Q==="amplitude"){let K=this.#E(G.x/this.#_,0,0,1),O=this.#UJ(B,K),Y=this.#t(G.y)-this.#LJ(this.#Z,K)-B.offset;B.amplitude=Math.abs(O)<0.001?B.amplitude:Y/O}this.#Q[this.#Z]=this.#M(B),this.#GJ(),this.#u("input")},j=()=>{if(this.#G=null,this.#$?.classList.remove("dragging"),Z)document.body.style.cursor=$;document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",j),this.#u("change")};document.addEventListener("pointermove",_),document.addEventListener("pointerup",j)}#LJ(J,Q){return this.#Q.reduce((Z,$,_)=>{if(_===J)return Z;let j=Q*$.frequency,X=q.#o($.type,j,$.phase);return Z+$.offset+X*$.amplitude},0)}#UJ(J,Q){return q.#o(J.type,Q*J.frequency,J.phase)}#GJ({skipFieldSync:J=!1}={}){if(this.#zJ(),!J)this.#SJ();this.#MJ(),this.#n()}#zJ(){for(let J of this.#P){let Q=this.#R(J);J.value=this.#Q[Q]?.type||"sine"}}#SJ(){for(let J of this.#q){if(J===this.#V)continue;let Q=this.#R(J),Z=J.getAttribute("name"),$=this.#c(this.#Q[Q]?.[Z]??0),_=J.querySelector("fig-slider");if(_)_.value=$;else J.setAttribute("value",String($))}}#MJ(){for(let J of this.#T)if(this.#R(J)===this.#Z)J.setAttribute("data-active","");else J.removeAttribute("data-active")}#u(J){this.dispatchEvent(new CustomEvent(J,{bubbles:!0,detail:{value:this.value,data:this.data,preset:q.#$J(this.#I.type)}}))}}customElements.define("propskit-oscillator",q);class w extends HTMLElement{#Q;#Z;#J=null;#_;#j;#O;#G;#$;#B;constructor(){super();this.angle=0,this.#Q=1,this.#Z=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="°",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#_=this.#V.bind(this),this.#j=this.#b.bind(this),this.#O=this.#I.bind(this),this.#G=this.#x.bind(this),this.#$=this.#E.bind(this),this.#B=this.#H.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.#K("dial",!0),this.showRotations=this.#U(),this.#X(),this.#L(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#F()}#X(){this.innerHTML=this.#Y()}#K(J,Q=!1){let Z=this.getAttribute(J);if(Z===null)return Q;let $=Z.trim().toLowerCase();if($===""||$==="true")return!0;if($==="false")return!1;return!0}#U(){if(this.hasAttribute("rotations"))return this.#K("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#K("show-rotations",!1);return!1}#Y(){let J=this.#q(),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,4 +45,4 @@ function R(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}class I 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
|
-
`}#N(){let J=Math.abs(this.#U(this.angle));return Math.floor(J/360)}#q(){if(!this.rotationSpan)return;let J=this.#N();if(J>1)this.rotationSpan.textContent=`×${J}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#P(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#U(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#T(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#C(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.#q(),this.plane?.addEventListener("mousedown",this.#X),this.plane?.addEventListener("touchstart",this.#K),window.addEventListener("keydown",this.#B),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#G);this.addEventListener("change",this.#j,!0)}#F(){if(this.plane?.removeEventListener("mousedown",this.#X),this.plane?.removeEventListener("touchstart",this.#K),window.removeEventListener("keydown",this.#B),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#G);this.removeEventListener("change",this.#j,!0)}#V(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.#C($,_,this.units);J.target.value=String(j)}}}#H(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#z(),this.#M(),this.#q(),this.#D(),this.#W()}#z(){let Q=this.#U(this.angle)*Math.PI/180;this.#Q=Math.cos(Q),this.#Z=Math.sin(Q)}#f(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#g(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}#S(J){let Z=(this.#g(J)%360+360)%360;if(Z=this.#f(Z),this.min!==null||this.max!==null)this.angle=this.#T(Z);else if(this.#J===null){this.#J=Z;let j=(this.#U(this.angle)%360+360)%360,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#T(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#T(_),this.#J=Z}if(this.#z(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#q(),this.#D()}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#W(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#M(){if(this.handle){let Q=this.#U(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)`}}#b(J){this.isDragging=!0,this.#J=null,this.#S(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#W()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#I(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#S(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#W()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#x(J){if(J.key==="Shift")this.isShiftHeld=!0}#E(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.#Q}get opposite(){return this.#Z}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}if(this.angle=J,this.#z(),this.#M(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#q()}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.#_(),this.#L(),this.#M()}break;case"dial":if(this.dial=this.#O("dial",!0),this.isConnected)this.#_(),this.#L(),this.#M();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#_(),this.#L(),this.#M();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#_(),this.#L(),this.#M();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#_(),this.#L(),this.#M();break;case"rotations":case"show-rotations":if(this.showRotations=this.#k(),this.isConnected)this.#_(),this.#L(),this.#M();break}}}customElements.define("fig-input-angle",h);class F extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Q=6;static#Z=["input","button","select","textarea","a[href]","label","summary","fig-button","fig-dropdown","fig-slider","fig-input-number","fig-input-text","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;#X=null;#K=null;connectedCallback(){this.style.display="contents",this.#O(),this.#J=new MutationObserver(()=>this.#O()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#M(),this.#b(),this.#S()}attributeChangedCallback(){if(this.isConnected)this.#O()}get#B(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#G(){return(this.getAttribute("handle")||"").trim()}#_(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#O(){let J=this.#_(),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.#N(J),this.#k(J),this.#B||J.length<2){this.#M();return}for(let Z of J){let $=this.#P(Z),_=this.#j.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#j.delete(Z);if(!$)continue;this.#U(Z,$)}this.#q(J),this.#Y(J)}#k(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#Y(J){for(let Q of J)Q.setAttribute("data-reorder-item","")}#N(J){for(let Q of J)Q.querySelectorAll("[data-reorder-handle]").forEach((Z)=>Z.removeAttribute("data-reorder-handle"))}#q(J){if(!this.#G)return;for(let Q of J){let Z=Q.querySelector(this.#G);if(Z)Z.setAttribute("data-reorder-handle","")}}#P(J){if(this.#G)return J.querySelector(this.#G);return J}#U(J,Q){let Z=($)=>{if(this.#B||this.#_().length<2)return;if($.button!==0)return;if(!this.#G&&this.#T($.target,J))return;this.#F($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#j.set(J,{target:Q,onPointerDown:Z})}#T(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of F.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#C="fig-reorder-dragging";static#L(J){document.body.classList.toggle(F.#C,J)}#F(J,Q,Z){this.#b(),F.#L(!0);let $={item:Q,target:Z,pointerId:J.pointerId,oldIndex:this.#_().indexOf(Q),targetIndex:this.#_().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<F.#Q*F.#Q)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#$==="horizontal"?_.clientX:_.clientY,B=this.#V(G);$.targetIndex=B,this.#g(B,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#W($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#W($,_.type==="pointercancel")},this.#X=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#V(J){let Q=this.#_(),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}#H(J,Q){let Z=this.#_(),$=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}#z(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:_-$}}#f(){if(this.#K)return this.#K;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#K=J,J}#g(J,Q){let Z=this.#_();if(!this.#H(Q,J)){this.#S();return}let $=this.#z(Z);if(!$){this.#S();return}let _=this.#f();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"}#S(){this.#K?.remove(),this.#K=null}#D(J,Q){let Z=this.#_(),$=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,_)}#W(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.#D(Z,J.targetIndex);let B=this.#_().indexOf(Z);if(B!==-1&&B!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}))}}if(Z.classList.remove("dragging"),F.#L(!1),this.#S(),this.#X===J)this.#X=null}#M(){for(let[,J]of this.#j)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#j.clear()}#b(){if(!this.#X)return;this.#W(this.#X,!0)}}customElements.define("fig-reorder",F);
|
|
48
|
+
`}#k(){let J=Math.abs(this.#P(this.angle));return Math.floor(J/360)}#N(){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"}#q(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#P(J){switch(this.units){case"rad":return J*180/Math.PI;case"turn":return J*360;default:return J}}#T(J){switch(this.units){case"rad":return J*Math.PI/180;case"turn":return J/360;default:return J}}#C(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.#N(),this.plane?.addEventListener("mousedown",this.#j),this.plane?.addEventListener("touchstart",this.#O),window.addEventListener("keydown",this.#G),window.addEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#B);this.addEventListener("change",this.#_,!0)}#F(){if(this.plane?.removeEventListener("mousedown",this.#j),this.plane?.removeEventListener("touchstart",this.#O),window.removeEventListener("keydown",this.#G),window.removeEventListener("keyup",this.#$),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#B);this.removeEventListener("change",this.#_,!0)}#V(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.#C($,_,this.units);J.target.value=String(j)}}}#H(J){J.stopPropagation(),this.angle=Number(J.target.value),this.#z(),this.#M(),this.#N(),this.#D(),this.#W()}#z(){let Q=this.#P(this.angle)*Math.PI/180;this.#Q=Math.cos(Q),this.#Z=Math.sin(Q)}#f(J){if(!this.isShiftHeld)return J;let Q=45;return Math.round(J/Q)*Q}#g(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}#S(J){let Z=(this.#g(J)%360+360)%360;if(Z=this.#f(Z),this.min!==null||this.max!==null)this.angle=this.#T(Z);else if(this.#J===null){this.#J=Z;let j=(this.#P(this.angle)%360+360)%360,X=Z-j;if(X>180)X-=360;if(X<-180)X+=360;this.angle+=this.#T(X)}else{let _=Z-this.#J;if(_>180)_-=360;if(_<-180)_+=360;this.angle+=this.#T(_),this.#J=Z}if(this.#z(),this.#M(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#N(),this.#D()}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#W(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,angle:this.angle}}))}#M(){if(this.handle){let Q=this.#P(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)`}}#b(J){this.isDragging=!0,this.#J=null,this.#S(J);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($)},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",Z),this.#W()};window.addEventListener("mousemove",Q),window.addEventListener("mouseup",Z)}#I(J){J.preventDefault(),this.isDragging=!0,this.#J=null,this.#S(J.touches[0]);let Q=($)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#S($.touches[0])},Z=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",Q),window.removeEventListener("touchend",Z),this.#W()};window.addEventListener("touchmove",Q),window.addEventListener("touchend",Z)}#x(J){if(J.key==="Shift")this.isShiftHeld=!0}#E(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.#Q}get opposite(){return this.#Z}set value(J){if(isNaN(J)){console.error("Invalid value: must be a number.");return}if(this.angle=J,this.#z(),this.#M(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#N()}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.#L(),this.#M()}break;case"dial":if(this.dial=this.#K("dial",!0),this.isConnected)this.#X(),this.#L(),this.#M();break;case"units":{let $=Z||"°";if($==="deg")$="°";if(this.units=$,this.isConnected)this.#X(),this.#L(),this.#M();break}case"min":if(this.min=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#L(),this.#M();break;case"max":if(this.max=Z!==null?Number(Z):null,this.isConnected)this.#X(),this.#L(),this.#M();break;case"rotations":case"show-rotations":if(this.showRotations=this.#U(),this.isConnected)this.#X(),this.#L(),this.#M();break}}}customElements.define("fig-input-angle",w);class F extends HTMLElement{static observedAttributes=["axis","handle","disabled"];static#Q=6;static#Z=["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;#_=new Map;#j=null;#O=null;connectedCallback(){this.style.display="contents",this.#K(),this.#J=new MutationObserver(()=>this.#K()),this.#J.observe(this,{childList:!0})}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#M(),this.#b(),this.#S()}attributeChangedCallback(){if(this.isConnected)this.#K()}get#G(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}get#$(){return(this.getAttribute("axis")||"vertical").trim().toLowerCase()==="horizontal"?"horizontal":"vertical"}get#B(){return(this.getAttribute("handle")||"").trim()}#X(){return[...this.children].filter((J)=>J.nodeType===Node.ELEMENT_NODE)}#K(){let J=this.#X(),Q=new Set(J);for(let[Z,$]of this.#_)if(!Q.has(Z))$.target.removeEventListener("pointerdown",$.onPointerDown,!0),this.#_.delete(Z);if(this.#k(J),this.#U(J),this.#G||J.length<2){this.#M();return}for(let Z of J){let $=this.#q(Z),_=this.#_.get(Z);if(_&&_.target===$)continue;if(_)_.target.removeEventListener("pointerdown",_.onPointerDown,!0),this.#_.delete(Z);if(!$)continue;this.#P(Z,$)}this.#N(J),this.#Y(J)}#U(J){for(let Q of J)Q.removeAttribute("data-reorder-item")}#Y(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"))}#N(J){if(!this.#B)return;for(let Q of J){let Z=Q.querySelector(this.#B);if(Z)Z.setAttribute("data-reorder-handle","")}}#q(J){if(this.#B)return J.querySelector(this.#B);return J}#P(J,Q){let Z=($)=>{if(this.#G||this.#X().length<2)return;if($.button!==0)return;if(!this.#B&&this.#T($.target,J))return;this.#F($,J,Q)};Q.addEventListener("pointerdown",Z,!0),this.#_.set(J,{target:Q,onPointerDown:Z})}#T(J,Q){let Z=J;while(Z&&Z!==Q){if(Z instanceof Element){for(let $ of F.#Z)if(Z.matches($))return!0}Z=Z.parentElement}return!1}static#C="fig-reorder-dragging";static#L(J){document.body.classList.toggle(F.#C,J)}#F(J,Q,Z){this.#b(),F.#L(!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,X=_.clientY-$.startY;if(!$.active){if(j*j+X*X<F.#Q*F.#Q)return;$.active=!0,J.preventDefault(),J.stopPropagation(),Q.classList.add("dragging");try{Z.setPointerCapture($.pointerId)}catch{}}_.preventDefault();let G=this.#$==="horizontal"?_.clientX:_.clientY,B=this.#V(G);$.targetIndex=B,this.#g(B,Q)},$.onKeyDown=(_)=>{if(_.key!=="Escape"||!$.active)return;_.preventDefault(),this.#W($,!0)},$.onUp=(_)=>{if(_.pointerId!==$.pointerId)return;this.#W($,_.type==="pointercancel")},this.#j=$,window.addEventListener("pointermove",$.onMove),window.addEventListener("pointerup",$.onUp),window.addEventListener("pointercancel",$.onUp),window.addEventListener("keydown",$.onKeyDown)}#V(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}#H(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}#z(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:_-$}}#f(){if(this.#O)return this.#O;let J=document.createElement("div");return J.className="fig-reorder-indicator",J.setAttribute("data-axis",this.#$),document.body.appendChild(J),this.#O=J,J}#g(J,Q){let Z=this.#X();if(!this.#H(Q,J)){this.#S();return}let $=this.#z(Z);if(!$){this.#S();return}let _=this.#f();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"}#S(){this.#O?.remove(),this.#O=null}#D(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,_)}#W(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.#D(Z,J.targetIndex);let B=this.#X().indexOf(Z);if(B!==-1&&B!==$)this.dispatchEvent(new CustomEvent("reorder",{bubbles:!0,detail:{oldIndex:$,newIndex:B,item:Z}}))}}if(Z.classList.remove("dragging"),F.#L(!1),this.#S(),this.#j===J)this.#j=null}#M(){for(let[,J]of this.#_)J.target.removeEventListener("pointerdown",J.onPointerDown,!0);this.#_.clear()}#b(){if(!this.#j)return;this.#W(this.#j,!0)}}customElements.define("fig-reorder",F);
|
package/fig-lab.css
CHANGED
|
@@ -83,6 +83,124 @@ propskit-switch {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
propskit-color {
|
|
87
|
+
--propskit-color-height: 2rem;
|
|
88
|
+
--propskit-color-vertical-padding: var(--spacer-1);
|
|
89
|
+
--propskit-color-horizontal-padding: var(--spacer-3);
|
|
90
|
+
--figma-focus-outline-offset: 1px;
|
|
91
|
+
|
|
92
|
+
display: block;
|
|
93
|
+
width: 100%;
|
|
94
|
+
height: var(--propskit-color-height);
|
|
95
|
+
padding: var(--propskit-color-vertical-padding)
|
|
96
|
+
var(--propskit-color-horizontal-padding);
|
|
97
|
+
|
|
98
|
+
&[size="large"] {
|
|
99
|
+
--propskit-color-vertical-padding: 0px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&[disabled]:not([disabled="false"]) {
|
|
103
|
+
pointer-events: none;
|
|
104
|
+
|
|
105
|
+
label {
|
|
106
|
+
color: var(--figma-color-text-disabled);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fig-field:not([direction="vertical"]) {
|
|
111
|
+
position: relative;
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
gap: var(--spacer-2);
|
|
115
|
+
height: 100%;
|
|
116
|
+
padding-left: var(--spacer-2);
|
|
117
|
+
border-radius: var(--radius-medium);
|
|
118
|
+
background-color: var(--figma-color-bg-secondary);
|
|
119
|
+
|
|
120
|
+
&::after {
|
|
121
|
+
content: "";
|
|
122
|
+
position: absolute;
|
|
123
|
+
inset: 0;
|
|
124
|
+
border-radius: inherit;
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:hover::after {
|
|
129
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
& > label {
|
|
133
|
+
position: relative;
|
|
134
|
+
z-index: 1;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
flex: 0 0 auto;
|
|
138
|
+
width: auto;
|
|
139
|
+
max-width: 50%;
|
|
140
|
+
min-width: 0;
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 0;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
color: var(--figma-color-text-secondary);
|
|
145
|
+
text-overflow: ellipsis;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
pointer-events: none;
|
|
148
|
+
|
|
149
|
+
fig-icon:first-child {
|
|
150
|
+
margin-left: calc(var(--spacer-1) * -1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
fig-input-color {
|
|
155
|
+
--figma-focus-outline-offset: 1px;
|
|
156
|
+
|
|
157
|
+
position: relative;
|
|
158
|
+
align-self: center;
|
|
159
|
+
flex: 0 1 auto !important;
|
|
160
|
+
width: fit-content !important;
|
|
161
|
+
max-width: none;
|
|
162
|
+
min-width: 0;
|
|
163
|
+
margin-left: auto;
|
|
164
|
+
height: calc(
|
|
165
|
+
var(--propskit-color-height) - var(--propskit-color-vertical-padding) * 2
|
|
166
|
+
);
|
|
167
|
+
border-radius: var(--radius-medium);
|
|
168
|
+
background-color: transparent;
|
|
169
|
+
box-shadow: none;
|
|
170
|
+
|
|
171
|
+
> .input-combo {
|
|
172
|
+
flex: 0 0 auto;
|
|
173
|
+
width: auto;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fig-input-text {
|
|
177
|
+
flex: 0 0 3.25rem;
|
|
178
|
+
width: 3.25rem;
|
|
179
|
+
|
|
180
|
+
input {
|
|
181
|
+
field-sizing: fixed;
|
|
182
|
+
box-sizing: border-box;
|
|
183
|
+
width: 100%;
|
|
184
|
+
min-width: 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
fig-input-number {
|
|
189
|
+
flex: 0 0 3rem;
|
|
190
|
+
width: 3rem;
|
|
191
|
+
min-width: 3rem;
|
|
192
|
+
|
|
193
|
+
input {
|
|
194
|
+
field-sizing: fixed;
|
|
195
|
+
box-sizing: border-box;
|
|
196
|
+
width: 100%;
|
|
197
|
+
min-width: 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
86
204
|
propskit-select {
|
|
87
205
|
--propskit-select-height: 2rem;
|
|
88
206
|
--propskit-select-vertical-padding: var(--spacer-1);
|