builder-settings-types 0.0.406 → 0.0.407

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ef="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Un=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ef[r[t]&63];return e};function tf(t){let e=0,r=t.parentElement;for(;r;)r.classList.contains("setting-group")&&r!==t&&e++,r=r.parentElement;return e}function Dn(t,e){const r=Math.min(Math.max(e,0),5);t.setAttribute("data-nesting-level",r.toString()),r>0?t.style.setProperty("--visual-indent",`${r*2}px`):(t.style.removeProperty("--visual-indent"),t.style.marginLeft="")}function Ni(t,e=0){t.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(a=>{const n=a,i=e+1;Dn(n,i),Ni(n,i)})}const rf={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class af{constructor(e={}){this.observedElements=new Set,this.config={...rf,...e},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(e=>{let r=!1;e.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("setting-group")?[n]:Array.from(n.querySelectorAll(".setting-group"))).length>0&&(r=!0)})}),r&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(e){this.observedElements.add(e),this.updateElementNesting(e)}untrackElement(e){this.observedElements.delete(e)}updateElementNesting(e){const r=tf(e);this.applyNestingWithConfig(e,r)}updateAllNesting(){this.observedElements.forEach(e=>{e.isConnected?this.updateElementNesting(e):this.observedElements.delete(e)})}applyNestingWithConfig(e,r){const a=Math.min(Math.max(r,0),this.config.maxLevel);if(e.setAttribute("data-nesting-level",a.toString()),a>0){const n=a*this.config.visualIndentMultiplier;e.style.setProperty("--visual-indent",`${n}px`)}else e.style.removeProperty("--visual-indent"),e.style.marginLeft=""}recalculateNesting(e=document.body){e.querySelectorAll(".setting-group").forEach(a=>{const n=a;this.updateElementNesting(n),this.trackElement(n)})}getNestingStats(){const e={};return this.observedElements.forEach(r=>{const a=parseInt(r.getAttribute("data-nesting-level")||"0",10);e[a]=(e[a]||0)+1}),e}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const Ys=new af;function Hn(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array)return t.map(e=>Hn(e));if(typeof t=="object"){const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Hn(t[r]));return e}return t}function nf(t){switch(t){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const lt=class lt{constructor(e={}){this.props=e,this.dataPropsPath="",this.id=e.id||Un(),this.value=this.props.default,this.desktop=this.props.default,this.title=e.title||"",this.includeGetJson=e.includeGetJson!==void 0?e.includeGetJson:!0}static SetUploadUrl(e){globalThis.DefaultUploadUrl=e,lt.DefaultUploadUrl=e}static SetDefaultLanguage(e){globalThis.DefaultLanguage=e,lt.DefaultLanguage=e}static CurrentLanguage(e){return e!==void 0&&(lt.currentLanguage=e,lt.currentLanguageExplicitlySet=!0,lt.languageChangeCallbacks.forEach(r=>r(e))),lt.currentLanguage||lt.DefaultLanguage}static HasExplicitCurrentLanguage(){return lt.currentLanguageExplicitlySet}static onLanguageChange(e){return lt.languageChangeCallbacks.add(e),()=>{lt.languageChangeCallbacks.delete(e)}}static SetGlobalVariables(e){lt.GlobalVariables={...lt.GlobalVariables,...e}}destroy(){throw new Error("Method not implemented.")}setOnChange(e){return this.onChange=e,this}setOnBlur(e){return this.onBlur=e,this}setDataPropsPath(e){this.dataPropsPath=e}getDataPropsPath(){return this.dataPropsPath}setComponentPath(e){}setValue(e){console.log("📤 [setValue]",this.title||this.id,":",this.value,"→",e),this.value=e,this.inputEl&&(this.inputEl.value=String(e)),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}clone(){const e=this.constructor,r=Hn(this.props),a=new e(r);return a.value=Hn(this.value),a}createInput(e){e={...this.props.inputProps,...e};const r=document.createElement("div");if(r.className=e.wrapperClassName||"",e.title||e.icon){const o=document.createElement("div");if(o.className="icon-container",e.icon){const l=this.createIcon(e.icon,e.iconClassName);o.appendChild(l)}if(e.title){const l=this.createLabel(e.title,e.labelClassName);o.appendChild(l)}r.appendChild(o)}const a=document.createElement("div");a.className=e.wrapperClassName||"";const n=document.createElement("input");this.inputEl=n,n.value=String(e.value||nf(e.inputType)),n.type=e.inputType,n.placeholder=e.placeholder||"",n.className=e.inputClassName||"",this.dataPropsPath&&n.setAttribute("data-test-id",this.dataPropsPath);const i=o=>{const l=o.target;let c=l.value;switch(e.inputType){case"number":c=Number(l.value);break;case"color":c=l.value;break;case"date":c=l.value;break;case"select":c=l.value;break;case"text":c=l.value;break;case"button":c=l.value;break;default:c=l.value}this.value=c,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return n.addEventListener("input",i),n.addEventListener("change",i),n.addEventListener("blur",s),e.inputCustomizer&&e.inputCustomizer(n),a.appendChild(n),r.appendChild(a),r}createLabel(e,r){const a=document.createElement("span");return a.textContent=e,a.className="input-label "+(r||""),a}createIcon(e,r){const a=document.createElement("span");return a.className="input-icon "+(r||""),a.innerHTML=e,a}};lt.currentLanguageExplicitlySet=!1,lt.languageChangeCallbacks=new Set,lt.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},lt.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let Le=lt;function dr(t){return t instanceof Le}function $e(t){return t instanceof ir}function Mi(t){return dr(t)||$e(t)}const Qi=(t,e,r)=>{let a=!1,n=0,i=0,s=0,o=0;const l=h=>{if(h.target.closest("button"))return;a=!0,n=h.clientX,i=h.clientY;const u=e.getBoundingClientRect();s=u.left,o=u.top,document.addEventListener("mousemove",c),document.addEventListener("mouseup",f),document.body.style.userSelect="none"},c=h=>{if(!a)return;const u=h.clientX-n,p=h.clientY-i,m=window.innerWidth,d=window.innerHeight,g=e.offsetWidth,x=e.offsetHeight;let w=s+u,v=o+p;w=Math.max(8,Math.min(m-g-8,w)),v=Math.max(8,Math.min(d-x-8,v)),e.style.left=`${w}px`,e.style.top=`${v}px`,r==null||r(w,v)},f=()=>{a=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f),document.body.style.userSelect=""};t.addEventListener("mousedown",l)},ta=t=>{if(!t)return null;let e=t.trim();return!e.startsWith("#")||(e=e.slice(1),e.length===3&&(e=e.split("").map(r=>r+r).join("")),!/^[0-9a-fA-F]{6}$/.test(e))?null:`#${e.toUpperCase()}`},Rn=(t,e,r)=>`#${[t,e,r].map(a=>Math.max(0,Math.min(255,a)).toString(16).padStart(2,"0")).join("")}`,Pt=t=>{const e=t.replace("#",""),r=e.length===3?e.split("").map(a=>a+a).join(""):e;return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}},ya=t=>{const{r:e,g:r,b:a}=Pt(t),n=e/255,i=r/255,s=a/255,o=Math.max(n,i,s),l=Math.min(n,i,s),c=o-l;let f=0;c!==0&&(o===n?f=(i-s)/c%6:o===i?f=(s-n)/c+2:f=(n-i)/c+4),f<0&&(f+=6);const h=o===0?0:c/o,u=o;return{h:f*60,s:h,v:u}},ka=(t,e,r)=>{const a=(t%360+360)%360,n=r*e,i=n*(1-Math.abs(a/60%2-1)),s=r-n;let o=0,l=0,c=0;return a<60?(o=n,l=i,c=0):a<120?(o=i,l=n,c=0):a<180?(o=0,l=n,c=i):a<240?(o=0,l=i,c=n):a<300?(o=i,l=0,c=n):(o=n,l=0,c=i),Rn(Math.round((o+s)*255),Math.round((l+s)*255),Math.round((c+s)*255))},m0=(t,e,r)=>{const a=r*(1-e/2),n=a===0||a===1?0:(r-a)/Math.min(a,1-a);return{hue:t,sat:n,lightness:a}},Oi=(t,e,r)=>{const a=(1-Math.abs(2*r-1))*e,n=a*(1-Math.abs(t/60%2-1)),i=r-a/2;let s=0,o=0,l=0;return t<60?(s=a,o=n,l=0):t<120?(s=n,o=a,l=0):t<180?(s=0,o=a,l=n):t<240?(s=0,o=n,l=a):t<300?(s=n,o=0,l=a):(s=a,o=0,l=n),{r:Math.round((s+i)*255),g:Math.round((o+i)*255),b:Math.round((l+i)*255)}},Pi=(t,e)=>{const r=Math.max(0,Math.min(100,e))/100;if(t.startsWith("#")){const{r:n,g:i,b:s}=Pt(t);return`rgba(${n}, ${i}, ${s}, ${r})`}if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${r})`);if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${r})`);if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}if(t.startsWith("hsla(")){const n=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}const a=ta(t);if(a){const{r:n,g:i,b:s}=Pt(a);return`rgba(${n}, ${i}, ${s}, ${r})`}return t},sf=t=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(t.toLowerCase()),g0=t=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(r=>r.test(t.trim())),of=t=>{if(typeof document>"u")return g0(t)||!!ta(t);const e=document.createElement("div");return e.style.color=t,e.style.color!==""},x0=t=>{const e=t.trim();if(/^#[0-9A-Fa-f]{8}$/.test(e)){const i=e.slice(1),s=parseInt(i.slice(0,2),16),o=parseInt(i.slice(2,4),16),l=parseInt(i.slice(4,6),16),c=parseInt(i.slice(6,8),16);return{color:Rn(s,o,l),position:0,opacity:Math.round(c/255*100)}}const r=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(r){const i=parseInt(r[1]),s=parseInt(r[2]),o=parseInt(r[3]),l=r[4]?parseFloat(r[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}const a=e.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(a){const{r:i,g:s,b:o}=Oi(parseFloat(a[1]),parseFloat(a[2])/100,parseFloat(a[3])/100),l=a[4]?parseFloat(a[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}return{color:ta(e)||e,position:0,opacity:100}},Js=t=>{const e=[];let r="",a=0;for(let n=0;n<t.length;n++){const i=t[n];if(i==="(")a++;else if(i===")")a--;else if(i===","&&a===0){e.push(r.trim()),r="";continue}r+=i}return r.trim()&&e.push(r.trim()),e},qs=(t,e)=>{const r=new RegExp(`${e}\\s*\\(`,"i"),a=t.match(r);if(!a)return null;const n=a.index+a[0].length;let i=1,s=n;for(let o=n;o<t.length&&i>0;o++)t[o]==="("?i++:t[o]===")"&&i--,s=o;return i===0?t.substring(n,s):null},lf=t=>{const e=t.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(e)?!1:/^#[0-9a-f]{3,8}$/i.test(e)||/^rgb/i.test(t)||/^hsl/i.test(t)||sf(e)},Zs=t=>{const e=[];return t.forEach((r,a)=>{const n=r.trim();if(!n)return;let i="",s=0;const o=n.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);o&&g0(o[1].trim())?(i=o[1].trim(),s=parseFloat(o[2])):(i=n,s=t.length===1?0:a/(t.length-1)*100);const l=x0(i);l.position=Math.max(0,Math.min(100,Math.round(s))),e.push(l)}),e},Cr=t=>{const e=t.stops&&t.stops.length?t.stops:[{color:"#000000",position:0,opacity:100}];return{type:t.type&&["linear","radial","solid"].includes(t.type)?t.type:"linear",angle:typeof t.angle=="number"?t.angle:90,stops:e.map((r,a)=>({color:r.color||"#000000",position:typeof r.position=="number"?r.position:e.length===1?0:Math.round(a/(e.length-1)*100),opacity:r.opacity===void 0||Number.isNaN(r.opacity)?100:r.opacity}))}},Nt=t=>{const e=t.replace(/;$/,"").trim();if(of(e)){const n=x0(e);return Cr({type:"solid",angle:0,stops:[n]})}const r=qs(e,"linear-gradient");if(r){const n=Js(r);let i=90,s=n;const o=n[0];if(o.includes("deg")){const c=o.match(/(-?\d+(?:\.\d+)?)deg/);c&&(i=parseFloat(c[1]),s=n.slice(1))}else o.includes("to ")&&(i={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[o]??90,s=n.slice(1));const l=Zs(s);return l.length?Cr({type:"linear",angle:i,stops:l}):null}const a=qs(e,"radial-gradient");if(a){const n=Js(a),i=n[0]&&!lf(n[0])?n.slice(1):n,s=Zs(i);return s.length?Cr({type:"radial",angle:0,stops:s}):null}return null},qt=t=>{if(t.type==="solid"){const r=t.stops[0],a=r.color;if(a.startsWith("var(--"))return a;const n=r.opacity??100,i=a.replace("#",""),s=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${s}`}const e=t.stops.map(r=>`${Pi(r.color,r.opacity??100)} ${r.position}%`).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`},cf=t=>Math.round(t/100*255).toString(16).toUpperCase().padStart(2,"0"),Bn=t=>{if(t.type==="solid"){const e=t.stops[0];if(e){const r=e.color;if(r.startsWith("var(--"))return r.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");r.toUpperCase();const a=e.opacity??100;if(a===100)return r;{const n=cf(a);return`${r}${n}`}}return"#000000"}return t.type==="linear"?`Linear ${t.angle}°`:"Radial Gradient"},Za=class Za{static defaults(){return{solid:[],gradient:[]}}static normalizeList(e){const r=new Set,a=[];return e.forEach(n=>{let i=ta(n);i||Nt(n)&&(i=n),i&&(r.has(i)||(r.add(i),a.push(i)))}),a.slice(0,this.MAX_COLORS)}static ensureLoaded(){var e;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const r=(e=window.sessionStorage)==null?void 0:e.getItem(this.STORAGE_KEY);if(!r)return;const a=JSON.parse(r);if(Array.isArray(a))this.colors.solid=this.normalizeList(a);else if(a&&typeof a=="object"){const n=a;n.solid&&(this.colors.solid=this.normalizeList(n.solid)),n.gradient&&(this.colors.gradient=this.normalizeList(n.gradient))}}catch{this.colors=this.defaults()}}static persist(){var e;if(!(typeof window>"u"))try{(e=window.sessionStorage)==null||e.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(e){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[e]}static getColors(e){if(e==="all"){const r=this.list("solid"),a=this.list("gradient"),n=[],i=Math.max(r.length,a.length);for(let s=0;s<i;s++)s<r.length&&n.push(r[s]),s<a.length&&n.push(a[s]);return this.normalizeList(n)}return[...this.list(e)]}static addColor(e,r){if(!e)return;let a=ta(e),n="solid";if(a)n="solid";else{const l=Nt(e);l&&(a=e,n=l.type==="solid"?"solid":"gradient")}if(!a)return;const i=r==="all"?n:r,s=this.list(i),o=s.indexOf(a);o!==-1&&s.splice(o,1),s.unshift(a),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};Za.STORAGE_KEY="settingsLib_recentColors",Za.MAX_COLORS=18,Za.colors=null;let ra=Za;const es=(t,e)=>{const r=document.createElement("div");r.className="color-picker-recent-section";const a=document.createElement("div");a.className="color-picker-recent-title",a.textContent="Recently Used";const n=document.createElement("div");n.className="color-picker-tooltip",n.style.display="none",r.appendChild(n);const i=()=>{n.style.display="none"},s=(f,h)=>{const u=f.getBoundingClientRect();n.textContent=h,n.style.left=`${u.left+u.width/2}px`,n.style.top=`${u.bottom+8}px`,n.style.display="block"},o=document.createElement("div");o.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",r.appendChild(a),r.appendChild(o),r.appendChild(l);const c=()=>{i(),o.innerHTML="";const f=ra.getColors(e);if(f.length===0){o.style.display="none",l.style.display="block";return}o.style.display="grid",l.style.display="none",f.forEach(h=>{const u=document.createElement("button");u.type="button",u.className="color-picker-recent-swatch";const p=ff(h);if(u.title=p,u.setAttribute("aria-label",`Use color: ${p}`),h.includes("gradient(")){u.style.backgroundImage=h,u.style.backgroundColor="transparent";const d=Nt(h);d&&d.stops&&d.stops.length>0&&(u.style.borderColor=d.stops[0].color)}else u.style.backgroundColor=h,u.style.borderColor=h;u.addEventListener("mouseenter",()=>s(u,p)),u.addEventListener("mouseleave",()=>{i(),u.style.boxShadow=""}),u.addEventListener("mousedown",()=>{u.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),u.addEventListener("mouseup",()=>{setTimeout(()=>{u.style.boxShadow=""},150)}),u.addEventListener("click",()=>{i(),t(h)}),o.appendChild(u)})};return c(),{container:r,refresh:c}},ff=t=>{const e=Nt(t);if(e)return Bn(e);const r=ta(t);if(r){const a=Pt(r);return`${r} (RGB: ${a.r}, ${a.g}, ${a.b})`}return t},v0=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ef="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Un=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ef[r[t]&63];return e};function tf(t){let e=0,r=t.parentElement;for(;r;)r.classList.contains("setting-group")&&r!==t&&e++,r=r.parentElement;return e}function Dn(t,e){const r=Math.min(Math.max(e,0),5);t.setAttribute("data-nesting-level",r.toString()),r>0?t.style.setProperty("--visual-indent",`${r*2}px`):(t.style.removeProperty("--visual-indent"),t.style.marginLeft="")}function Ni(t,e=0){t.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(a=>{const n=a,i=e+1;Dn(n,i),Ni(n,i)})}const rf={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class af{constructor(e={}){this.observedElements=new Set,this.config={...rf,...e},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(e=>{let r=!1;e.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("setting-group")?[n]:Array.from(n.querySelectorAll(".setting-group"))).length>0&&(r=!0)})}),r&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(e){this.observedElements.add(e),this.updateElementNesting(e)}untrackElement(e){this.observedElements.delete(e)}updateElementNesting(e){const r=tf(e);this.applyNestingWithConfig(e,r)}updateAllNesting(){this.observedElements.forEach(e=>{e.isConnected?this.updateElementNesting(e):this.observedElements.delete(e)})}applyNestingWithConfig(e,r){const a=Math.min(Math.max(r,0),this.config.maxLevel);if(e.setAttribute("data-nesting-level",a.toString()),a>0){const n=a*this.config.visualIndentMultiplier;e.style.setProperty("--visual-indent",`${n}px`)}else e.style.removeProperty("--visual-indent"),e.style.marginLeft=""}recalculateNesting(e=document.body){e.querySelectorAll(".setting-group").forEach(a=>{const n=a;this.updateElementNesting(n),this.trackElement(n)})}getNestingStats(){const e={};return this.observedElements.forEach(r=>{const a=parseInt(r.getAttribute("data-nesting-level")||"0",10);e[a]=(e[a]||0)+1}),e}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const Ys=new af;function Hn(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array)return t.map(e=>Hn(e));if(typeof t=="object"){const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Hn(t[r]));return e}return t}function nf(t){switch(t){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const lt=class lt{constructor(e={}){this.props=e,this.dataPropsPath="",this.id=e.id||Un(),this.value=this.props.default,this.desktop=this.props.default,this.title=e.title||"",this.includeGetJson=e.includeGetJson!==void 0?e.includeGetJson:!0}static SetUploadUrl(e){globalThis.DefaultUploadUrl=e,lt.DefaultUploadUrl=e}static SetDefaultLanguage(e){globalThis.DefaultLanguage=e,lt.DefaultLanguage=e}static CurrentLanguage(e){return e!==void 0&&(lt.currentLanguage=e,lt.currentLanguageExplicitlySet=!0,lt.languageChangeCallbacks.forEach(r=>r(e))),lt.currentLanguage||lt.DefaultLanguage}static HasExplicitCurrentLanguage(){return lt.currentLanguageExplicitlySet}static onLanguageChange(e){return lt.languageChangeCallbacks.add(e),()=>{lt.languageChangeCallbacks.delete(e)}}static SetGlobalVariables(e){lt.GlobalVariables={...lt.GlobalVariables,...e}}destroy(){throw new Error("Method not implemented.")}setOnChange(e){return this.onChange=e,this}setOnBlur(e){return this.onBlur=e,this}setDataPropsPath(e){this.dataPropsPath=e}getDataPropsPath(){return this.dataPropsPath}setComponentPath(e){}setValue(e){this.value=e,this.inputEl&&(this.inputEl.value=String(e)),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}clone(){const e=this.constructor,r=Hn(this.props),a=new e(r);return a.value=Hn(this.value),a}createInput(e){e={...this.props.inputProps,...e};const r=document.createElement("div");if(r.className=e.wrapperClassName||"",e.title||e.icon){const o=document.createElement("div");if(o.className="icon-container",e.icon){const l=this.createIcon(e.icon,e.iconClassName);o.appendChild(l)}if(e.title){const l=this.createLabel(e.title,e.labelClassName);o.appendChild(l)}r.appendChild(o)}const a=document.createElement("div");a.className=e.wrapperClassName||"";const n=document.createElement("input");this.inputEl=n,n.value=String(e.value||nf(e.inputType)),n.type=e.inputType,n.placeholder=e.placeholder||"",n.className=e.inputClassName||"",this.dataPropsPath&&n.setAttribute("data-test-id",this.dataPropsPath);const i=o=>{const l=o.target;let c=l.value;switch(e.inputType){case"number":c=Number(l.value);break;case"color":c=l.value;break;case"date":c=l.value;break;case"select":c=l.value;break;case"text":c=l.value;break;case"button":c=l.value;break;default:c=l.value}this.value=c,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return n.addEventListener("input",i),n.addEventListener("change",i),n.addEventListener("blur",s),e.inputCustomizer&&e.inputCustomizer(n),a.appendChild(n),r.appendChild(a),r}createLabel(e,r){const a=document.createElement("span");return a.textContent=e,a.className="input-label "+(r||""),a}createIcon(e,r){const a=document.createElement("span");return a.className="input-icon "+(r||""),a.innerHTML=e,a}};lt.currentLanguageExplicitlySet=!1,lt.languageChangeCallbacks=new Set,lt.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},lt.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let Le=lt;function dr(t){return t instanceof Le}function $e(t){return t instanceof ir}function Mi(t){return dr(t)||$e(t)}const Qi=(t,e,r)=>{let a=!1,n=0,i=0,s=0,o=0;const l=h=>{if(h.target.closest("button"))return;a=!0,n=h.clientX,i=h.clientY;const u=e.getBoundingClientRect();s=u.left,o=u.top,document.addEventListener("mousemove",c),document.addEventListener("mouseup",f),document.body.style.userSelect="none"},c=h=>{if(!a)return;const u=h.clientX-n,p=h.clientY-i,m=window.innerWidth,d=window.innerHeight,g=e.offsetWidth,x=e.offsetHeight;let w=s+u,v=o+p;w=Math.max(8,Math.min(m-g-8,w)),v=Math.max(8,Math.min(d-x-8,v)),e.style.left=`${w}px`,e.style.top=`${v}px`,r==null||r(w,v)},f=()=>{a=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f),document.body.style.userSelect=""};t.addEventListener("mousedown",l)},ta=t=>{if(!t)return null;let e=t.trim();return!e.startsWith("#")||(e=e.slice(1),e.length===3&&(e=e.split("").map(r=>r+r).join("")),!/^[0-9a-fA-F]{6}$/.test(e))?null:`#${e.toUpperCase()}`},Rn=(t,e,r)=>`#${[t,e,r].map(a=>Math.max(0,Math.min(255,a)).toString(16).padStart(2,"0")).join("")}`,Pt=t=>{const e=t.replace("#",""),r=e.length===3?e.split("").map(a=>a+a).join(""):e;return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}},ya=t=>{const{r:e,g:r,b:a}=Pt(t),n=e/255,i=r/255,s=a/255,o=Math.max(n,i,s),l=Math.min(n,i,s),c=o-l;let f=0;c!==0&&(o===n?f=(i-s)/c%6:o===i?f=(s-n)/c+2:f=(n-i)/c+4),f<0&&(f+=6);const h=o===0?0:c/o,u=o;return{h:f*60,s:h,v:u}},ka=(t,e,r)=>{const a=(t%360+360)%360,n=r*e,i=n*(1-Math.abs(a/60%2-1)),s=r-n;let o=0,l=0,c=0;return a<60?(o=n,l=i,c=0):a<120?(o=i,l=n,c=0):a<180?(o=0,l=n,c=i):a<240?(o=0,l=i,c=n):a<300?(o=i,l=0,c=n):(o=n,l=0,c=i),Rn(Math.round((o+s)*255),Math.round((l+s)*255),Math.round((c+s)*255))},m0=(t,e,r)=>{const a=r*(1-e/2),n=a===0||a===1?0:(r-a)/Math.min(a,1-a);return{hue:t,sat:n,lightness:a}},Oi=(t,e,r)=>{const a=(1-Math.abs(2*r-1))*e,n=a*(1-Math.abs(t/60%2-1)),i=r-a/2;let s=0,o=0,l=0;return t<60?(s=a,o=n,l=0):t<120?(s=n,o=a,l=0):t<180?(s=0,o=a,l=n):t<240?(s=0,o=n,l=a):t<300?(s=n,o=0,l=a):(s=a,o=0,l=n),{r:Math.round((s+i)*255),g:Math.round((o+i)*255),b:Math.round((l+i)*255)}},Pi=(t,e)=>{const r=Math.max(0,Math.min(100,e))/100;if(t.startsWith("#")){const{r:n,g:i,b:s}=Pt(t);return`rgba(${n}, ${i}, ${s}, ${r})`}if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${r})`);if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${r})`);if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}if(t.startsWith("hsla(")){const n=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}const a=ta(t);if(a){const{r:n,g:i,b:s}=Pt(a);return`rgba(${n}, ${i}, ${s}, ${r})`}return t},sf=t=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(t.toLowerCase()),g0=t=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(r=>r.test(t.trim())),of=t=>{if(typeof document>"u")return g0(t)||!!ta(t);const e=document.createElement("div");return e.style.color=t,e.style.color!==""},x0=t=>{const e=t.trim();if(/^#[0-9A-Fa-f]{8}$/.test(e)){const i=e.slice(1),s=parseInt(i.slice(0,2),16),o=parseInt(i.slice(2,4),16),l=parseInt(i.slice(4,6),16),c=parseInt(i.slice(6,8),16);return{color:Rn(s,o,l),position:0,opacity:Math.round(c/255*100)}}const r=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(r){const i=parseInt(r[1]),s=parseInt(r[2]),o=parseInt(r[3]),l=r[4]?parseFloat(r[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}const a=e.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(a){const{r:i,g:s,b:o}=Oi(parseFloat(a[1]),parseFloat(a[2])/100,parseFloat(a[3])/100),l=a[4]?parseFloat(a[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}return{color:ta(e)||e,position:0,opacity:100}},Js=t=>{const e=[];let r="",a=0;for(let n=0;n<t.length;n++){const i=t[n];if(i==="(")a++;else if(i===")")a--;else if(i===","&&a===0){e.push(r.trim()),r="";continue}r+=i}return r.trim()&&e.push(r.trim()),e},qs=(t,e)=>{const r=new RegExp(`${e}\\s*\\(`,"i"),a=t.match(r);if(!a)return null;const n=a.index+a[0].length;let i=1,s=n;for(let o=n;o<t.length&&i>0;o++)t[o]==="("?i++:t[o]===")"&&i--,s=o;return i===0?t.substring(n,s):null},lf=t=>{const e=t.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(e)?!1:/^#[0-9a-f]{3,8}$/i.test(e)||/^rgb/i.test(t)||/^hsl/i.test(t)||sf(e)},Zs=t=>{const e=[];return t.forEach((r,a)=>{const n=r.trim();if(!n)return;let i="",s=0;const o=n.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);o&&g0(o[1].trim())?(i=o[1].trim(),s=parseFloat(o[2])):(i=n,s=t.length===1?0:a/(t.length-1)*100);const l=x0(i);l.position=Math.max(0,Math.min(100,Math.round(s))),e.push(l)}),e},Cr=t=>{const e=t.stops&&t.stops.length?t.stops:[{color:"#000000",position:0,opacity:100}];return{type:t.type&&["linear","radial","solid"].includes(t.type)?t.type:"linear",angle:typeof t.angle=="number"?t.angle:90,stops:e.map((r,a)=>({color:r.color||"#000000",position:typeof r.position=="number"?r.position:e.length===1?0:Math.round(a/(e.length-1)*100),opacity:r.opacity===void 0||Number.isNaN(r.opacity)?100:r.opacity}))}},Nt=t=>{const e=t.replace(/;$/,"").trim();if(of(e)){const n=x0(e);return Cr({type:"solid",angle:0,stops:[n]})}const r=qs(e,"linear-gradient");if(r){const n=Js(r);let i=90,s=n;const o=n[0];if(o.includes("deg")){const c=o.match(/(-?\d+(?:\.\d+)?)deg/);c&&(i=parseFloat(c[1]),s=n.slice(1))}else o.includes("to ")&&(i={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[o]??90,s=n.slice(1));const l=Zs(s);return l.length?Cr({type:"linear",angle:i,stops:l}):null}const a=qs(e,"radial-gradient");if(a){const n=Js(a),i=n[0]&&!lf(n[0])?n.slice(1):n,s=Zs(i);return s.length?Cr({type:"radial",angle:0,stops:s}):null}return null},qt=t=>{if(t.type==="solid"){const r=t.stops[0],a=r.color;if(a.startsWith("var(--"))return a;const n=r.opacity??100,i=a.replace("#",""),s=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${s}`}const e=t.stops.map(r=>`${Pi(r.color,r.opacity??100)} ${r.position}%`).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`},cf=t=>Math.round(t/100*255).toString(16).toUpperCase().padStart(2,"0"),Bn=t=>{if(t.type==="solid"){const e=t.stops[0];if(e){const r=e.color;if(r.startsWith("var(--"))return r.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");r.toUpperCase();const a=e.opacity??100;if(a===100)return r;{const n=cf(a);return`${r}${n}`}}return"#000000"}return t.type==="linear"?`Linear ${t.angle}°`:"Radial Gradient"},Za=class Za{static defaults(){return{solid:[],gradient:[]}}static normalizeList(e){const r=new Set,a=[];return e.forEach(n=>{let i=ta(n);i||Nt(n)&&(i=n),i&&(r.has(i)||(r.add(i),a.push(i)))}),a.slice(0,this.MAX_COLORS)}static ensureLoaded(){var e;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const r=(e=window.sessionStorage)==null?void 0:e.getItem(this.STORAGE_KEY);if(!r)return;const a=JSON.parse(r);if(Array.isArray(a))this.colors.solid=this.normalizeList(a);else if(a&&typeof a=="object"){const n=a;n.solid&&(this.colors.solid=this.normalizeList(n.solid)),n.gradient&&(this.colors.gradient=this.normalizeList(n.gradient))}}catch{this.colors=this.defaults()}}static persist(){var e;if(!(typeof window>"u"))try{(e=window.sessionStorage)==null||e.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(e){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[e]}static getColors(e){if(e==="all"){const r=this.list("solid"),a=this.list("gradient"),n=[],i=Math.max(r.length,a.length);for(let s=0;s<i;s++)s<r.length&&n.push(r[s]),s<a.length&&n.push(a[s]);return this.normalizeList(n)}return[...this.list(e)]}static addColor(e,r){if(!e)return;let a=ta(e),n="solid";if(a)n="solid";else{const l=Nt(e);l&&(a=e,n=l.type==="solid"?"solid":"gradient")}if(!a)return;const i=r==="all"?n:r,s=this.list(i),o=s.indexOf(a);o!==-1&&s.splice(o,1),s.unshift(a),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};Za.STORAGE_KEY="settingsLib_recentColors",Za.MAX_COLORS=18,Za.colors=null;let ra=Za;const es=(t,e)=>{const r=document.createElement("div");r.className="color-picker-recent-section";const a=document.createElement("div");a.className="color-picker-recent-title",a.textContent="Recently Used";const n=document.createElement("div");n.className="color-picker-tooltip",n.style.display="none",r.appendChild(n);const i=()=>{n.style.display="none"},s=(f,h)=>{const u=f.getBoundingClientRect();n.textContent=h,n.style.left=`${u.left+u.width/2}px`,n.style.top=`${u.bottom+8}px`,n.style.display="block"},o=document.createElement("div");o.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",r.appendChild(a),r.appendChild(o),r.appendChild(l);const c=()=>{i(),o.innerHTML="";const f=ra.getColors(e);if(f.length===0){o.style.display="none",l.style.display="block";return}o.style.display="grid",l.style.display="none",f.forEach(h=>{const u=document.createElement("button");u.type="button",u.className="color-picker-recent-swatch";const p=ff(h);if(u.title=p,u.setAttribute("aria-label",`Use color: ${p}`),h.includes("gradient(")){u.style.backgroundImage=h,u.style.backgroundColor="transparent";const d=Nt(h);d&&d.stops&&d.stops.length>0&&(u.style.borderColor=d.stops[0].color)}else u.style.backgroundColor=h,u.style.borderColor=h;u.addEventListener("mouseenter",()=>s(u,p)),u.addEventListener("mouseleave",()=>{i(),u.style.boxShadow=""}),u.addEventListener("mousedown",()=>{u.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),u.addEventListener("mouseup",()=>{setTimeout(()=>{u.style.boxShadow=""},150)}),u.addEventListener("click",()=>{i(),t(h)}),o.appendChild(u)})};return c(),{container:r,refresh:c}},ff=t=>{const e=Nt(t);if(e)return Bn(e);const r=ta(t);if(r){const a=Pt(r);return`${r} (RGB: ${a.r}, ${a.g}, ${a.b})`}return t},v0=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path fill-rule="evenodd" clip-rule="evenodd"
3
3
  d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
4
4
  fill="#919EAB"/>
@@ -23,7 +23,7 @@
23
23
  `;class gf{constructor(e,r="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=a=>{if(!this.isOpen)return;const n=a.target;if(this.element.contains(n))return;if(this.backdrop.contains(n)){a.preventDefault(),a.stopPropagation(),this.close(!0);return}const i=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(i).some(l=>l.contains(n)))return;const o=document.querySelector(".gradient-popover");o&&o.contains(n)||(a.preventDefault(),a.stopPropagation(),this.close(!0))},this.keyDown=a=>{if(this.isOpen){if(a.key==="Escape")a.preventDefault(),this.close(!0);else if(a.key==="Enter"){const n=a.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"))return;a.preventDefault(),this.close(!0)}}},this.onChange=e,this.recentScope=r,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(e){const r=parseFloat(e);return isNaN(r)?0:r/100}build(){const e=document.createElement("div");e.className="custom-color-picker",e.style.display="none";const r=document.createElement("div");r.className="color-picker-header",r.style.cursor="move";const a=document.createElement("span");a.textContent="Color";const n=document.createElement("button");n.className="color-picker-close",n.innerHTML=v0,n.addEventListener("click",()=>this.close(!0)),r.appendChild(a),r.appendChild(n),Qi(r,e);const i=document.createElement("div");i.className="color-picker-area",this.colorArea=i;const s=document.createElement("div");s.className="color-picker-marker",this.colorMarker=s,i.appendChild(s);const o=document.createElement("div");o.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=E0;const c=document.createElement("div");c.className="color-picker-sliders-group";const f=document.createElement("div");f.className="color-picker-hue",this.hueSlider=f;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,f.appendChild(h);const u=document.createElement("div");u.className="color-picker-opacity",this.opacitySlider=u;const p=document.createElement("div");p.className="color-picker-opacity-marker",this.opacityMarker=p,u.appendChild(p),c.appendChild(f),c.appendChild(u),o.appendChild(l),o.appendChild(c);const m=es(y=>{var P;this.setColor(y),(P=this.onChange)==null||P.call(this,y,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=m.refresh;const d=document.createElement("div");d.className="color-picker-format-section";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const x=document.createElement("option");x.value="hex",x.textContent="HEX";const w=document.createElement("option");w.value="rgb",w.textContent="RGB";const v=document.createElement("option");v.value="hsl",v.textContent="HSL",g.appendChild(x),g.appendChild(w),g.appendChild(v);const F=document.createElement("input");F.type="text",F.className="color-picker-color-input",F.value=this.currentColor,this.input=F;const N=document.createElement("div");N.className="color-picker-input-container";const A=document.createElement("button");return A.className="color-picker-copy-inside",A.textContent="Copy",N.appendChild(F),N.appendChild(A),d.appendChild(g),d.appendChild(N),e.appendChild(r),e.appendChild(i),e.appendChild(o),e.appendChild(m.container),e.appendChild(d),e.addEventListener("click",y=>y.stopPropagation()),this.bind(i,f,u,F,g,A,l),e}createBackdrop(){const e=document.createElement("div");return e.className="color-picker-backdrop",e.style.display="none",e.style.pointerEvents="none",e}bind(e,r,a,n,i,s,o){const l=h=>{var w;const u=e.getBoundingClientRect(),p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width)),m=Math.max(0,Math.min(1,(h.clientY-u.top)/u.height));this.colorMarker.style.left=`${p*100}%`,this.colorMarker.style.top=`${m*100}%`;const g=this.parsePercentage(this.hueMarker.style.left||"0%")*360,x=ka(g,p,1-m);this.currentColor=x,this.syncInput(),this.updateOpacityBg(),(w=this.onChange)==null||w.call(this,x,this.currentOpacity)},c=h=>{var w;const u=r.getBoundingClientRect();let p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width));this.hueMarker.style.left=`${p*100}%`;const m=p*360,d=this.parsePercentage(this.colorMarker.style.left||"0%"),g=this.parsePercentage(this.colorMarker.style.top||"0%"),x=ka(m,d,1-g);this.currentColor=x,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${m}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(w=this.onChange)==null||w.call(this,x,this.currentOpacity)},f=h=>{var m;const u=a.getBoundingClientRect(),p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width));this.opacityMarker.style.left=`${p*100}%`,this.currentOpacity=Math.round(p*100),(m=this.onChange)==null||m.call(this,this.currentColor,this.currentOpacity)};e.addEventListener("mousedown",h=>{h.preventDefault(),l(h);const u=m=>l(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),r.addEventListener("mousedown",h=>{h.preventDefault(),c(h);const u=m=>c(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",h=>{h.preventDefault(),f(h);const u=m=>f(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),i.addEventListener("change",()=>this.syncInput()),n.addEventListener("input",()=>this.applyFromInput()),n.addEventListener("blur",()=>this.syncInput()),n.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),this.syncInput(),n.blur())}),s.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(n.value)}catch{n.select(),document.execCommand("copy")}}),o.addEventListener("click",async()=>{var h;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const u=new window.EyeDropper,{sRGBHex:p}=await u.open();this.setColor(p),(h=this.onChange)==null||h.call(this,p,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(e){var s;this.currentColor=e;const{h:r,s:a,v:n}=ya(e),i=r>=360?r%360:r;this.hueMarker.style.left=`${i/360*100}%`,this.colorMarker.style.left=`${a*100}%`,this.colorMarker.style.top=`${(1-n)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${i}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(s=this.onChange)==null||s.call(this,e,this.currentOpacity)}syncInput(){const e=this.select.value,{h:r,s:a,v:n}=ya(this.currentColor);if(e==="hex")this.input.value=this.currentColor;else if(e==="rgb"){const{r:i,g:s,b:o}=Pt(this.currentColor);this.input.value=`rgb(${i}, ${s}, ${o})`}else{const{hue:i,sat:s,lightness:o}=m0(r,a,n);this.input.value=`hsl(${Math.round(i)}, ${Math.round(s*100)}%, ${Math.round(o*100)}%)`}}applyFromInput(){const e=this.input.value.trim();let r="";if(/^#[0-9A-Fa-f]{6}$/.test(e))r=e;else{const a=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(a){const n=parseInt(a[1]),i=parseInt(a[2]),s=parseInt(a[3]);n<=255&&i<=255&&s<=255&&(r=`#${[n,i,s].map(o=>o.toString(16).padStart(2,"0")).join("")}`)}else{const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const i=parseInt(n[1]),s=parseInt(n[2])/100,o=parseInt(n[3])/100,l=o+s*Math.min(o,1-o),c=l===0?0:2*(1-o/l);r=ka(i,c,l)}}}r&&this.setColor(r)}updateOpacityBg(){const{r:e,g:r,b:a}=Pt(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${e}, ${r}, ${a})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${e}, ${r}, ${a}, 0)`)}open(e,r,a){var v;this.currentColor=e,this.currentOpacity=a??100,this.syncInput();const{h:n,s:i,v:s}=ya(e);this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(v=this.recentSectionRefresh)==null||v.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const o=this.element.offsetWidth,l=this.element.offsetHeight,c=r.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,u=16;let p=c.right+8,m=c.top;const d=f-c.right,g=c.left;d>=o+u?p=c.right+8:g>=o+u?p=c.left-o-8:p=Math.max(u,(f-o)/2);const x=h-c.bottom,w=c.top;x>=l+u?m=c.bottom+8:w>=l+u?m=c.top-l-8:x>w?(m=c.bottom+8,m+l>h-u&&(m=h-l-u)):(m=c.top-l-8,m<u&&(m=u)),this.element.style.left=`${p}px`,this.element.style.top=`${m}px`}close(e){var r;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),e&&this.onChange&&this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(r=this.recentSectionRefresh)==null||r.call(this)))}setOnChange(e){this.onChange=e}getIsOpen(){return this.isOpen}getElement(){return this.element}}class xf{constructor(e){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(e.initialColor),this.currentOpacity=this.clampOpacity(e.initialOpacity),this.onColorChange=e.onColorChange,this.recentScope=e.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(e){const r=parseFloat(e);return isNaN(r)?0:r/100}sanitizeColor(e){const r=this.currentColor||"#FFFFFF";return ta(e)??r}clampOpacity(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):100}build(){const e=document.createElement("div");e.className="embedded-color-picker";const r=document.createElement("div");r.className="color-picker-area embedded",this.colorArea=r;const a=document.createElement("div");a.className="color-picker-marker",this.colorMarker=a,r.appendChild(a);const n=document.createElement("div");n.className="color-picker-sliders-container embedded";const i=document.createElement("button");i.className="color-picker-eyedropper",i.type="button",i.innerHTML=E0;const s=document.createElement("div");s.className="color-picker-sliders-group";const o=document.createElement("div");o.className="color-picker-hue embedded",this.hueSlider=o;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,o.appendChild(l);const c=document.createElement("div");c.className="color-picker-opacity embedded",this.opacitySlider=c;const f=document.createElement("div");f.className="color-picker-opacity-marker",this.opacityMarker=f,c.appendChild(f),s.appendChild(o),s.appendChild(c),n.appendChild(i),n.appendChild(s);const h=es(F=>{const N=Nt(F);N&&N.type!=="solid"?this.onColorChange(F,this.currentOpacity):(this.setColor(F),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=h.refresh;const u=document.createElement("div");u.className="color-picker-format-section embedded";const p=document.createElement("select");p.className="color-picker-format-select",this.select=p;const m=document.createElement("option");m.value="hex",m.textContent="HEX";const d=document.createElement("option");d.value="rgb",d.textContent="RGB";const g=document.createElement("option");g.value="hsl",g.textContent="HSL",p.appendChild(m),p.appendChild(d),p.appendChild(g);const x=document.createElement("input");x.type="text",x.className="color-picker-color-input",this.input=x;const w=document.createElement("div");w.className="color-picker-input-container";const v=document.createElement("button");return v.className="color-picker-copy-inside",v.textContent="Copy",w.appendChild(x),w.appendChild(v),u.appendChild(p),u.appendChild(w),e.appendChild(r),e.appendChild(n),e.appendChild(u),e.appendChild(h.container),this.bind(r,o,c,x,p,v,i),e}bind(e,r,a,n,i,s,o){const l=(u,p)=>{const m=p||e.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width)),g=Math.max(0,Math.min(1,(u.clientY-m.top)/m.height));this.colorMarker.style.left=`${d*100}%`,this.colorMarker.style.top=`${g*100}%`;const w=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=ka(w,d,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),this.queueChange()},c=(u,p)=>{const m=p||r.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width));this.hueMarker.style.left=`${d*100}%`;const g=d*360,x=this.parsePercentage(this.colorMarker.style.left||"0%"),w=this.parsePercentage(this.colorMarker.style.top||"0%"),v=ka(g,x,1-w);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
24
24
  linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.queueChange()},f=(u,p)=>{const m=p||a.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width));this.opacityMarker.style.left=`${d*100}%`,this.currentOpacity=this.clampOpacity(d*100),this.queueChange()},h=(u,p,m)=>{u.preventDefault(),this.isDragging=!0,this.cachedRect=m.getBoundingClientRect(),p(u,this.cachedRect);let d=null,g;const x=()=>{this.dragRafId===void 0&&(this.dragRafId=window.requestAnimationFrame(()=>{this.dragRafId=void 0,d&&this.cachedRect&&p(d,this.cachedRect)}))},w=()=>{this.isDragging&&(this.isDragging=!1,this.dragRafId!==void 0&&(cancelAnimationFrame(this.dragRafId),this.dragRafId=void 0),this.cachedRect=void 0,d=null,this.flushChange(),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",w),window.removeEventListener("blur",w),this.applyPendingExternal())};g=v=>{if(!v.buttons){w();return}d=v,x()},document.addEventListener("mousemove",g),document.addEventListener("mouseup",w),window.addEventListener("blur",w)};e.addEventListener("mousedown",u=>{h(u,l,e)}),r.addEventListener("mousedown",u=>{h(u,c,r)}),a.addEventListener("mousedown",u=>{h(u,f,a)}),i.addEventListener("change",()=>{this.syncInput()}),n.addEventListener("input",()=>{this.applyFromInput()}),n.addEventListener("blur",()=>{this.syncInput()}),n.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),this.syncInput(),n.blur())}),s.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(n.value)}catch{n.select(),document.execCommand("copy")}}),o.addEventListener("click",async()=>{if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const u=new window.EyeDropper,{sRGBHex:p}=await u.open();this.setColor(p),this.onColorChange(this.currentColor,this.currentOpacity)}catch{}})}setColor(e){const r=this.sanitizeColor(e);this.currentColor=r;const{h:a,s:n,v:i}=ya(r),s=a>=360?a%360:a;this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-i)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
25
25
  linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const e=this.select.value,{h:r,s:a,v:n}=ya(this.currentColor);if(e==="hex")this.input.value=this.currentColor;else if(e==="rgb"){const{r:i,g:s,b:o}=Pt(this.currentColor);this.input.value=`rgb(${i}, ${s}, ${o})`}else{const{hue:i,sat:s,lightness:o}=m0(r,a,n);this.input.value=`hsl(${Math.round(i)}, ${Math.round(s*100)}%, ${Math.round(o*100)}%)`}}applyFromInput(){const e=this.input.value.trim();let r="";if(/^#[0-9A-Fa-f]{6}$/.test(e))r=e;else{const a=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(a){const n=parseInt(a[1],10),i=parseInt(a[2],10),s=parseInt(a[3],10);n<=255&&i<=255&&s<=255&&(r="#"+[n,i,s].map(o=>o.toString(16).padStart(2,"0")).join(""))}else{const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const i=parseInt(n[1],10),s=parseInt(n[2],10)/100,o=parseInt(n[3],10)/100,l=o+s*Math.min(o,1-o),c=l===0?0:2*(1-o/l);r=ka(i,c,l)}}}r&&(this.setColor(r),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:e,g:r,b:a}=Pt(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${e}, ${r}, ${a})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${e}, ${r}, ${a}, 0)`)}queueChange(){this.changeRafId===void 0&&(this.changeRafId=window.requestAnimationFrame(()=>{this.changeRafId=void 0,this.onColorChange(this.currentColor,this.currentOpacity)}))}flushChange(){this.changeRafId!==void 0&&(cancelAnimationFrame(this.changeRafId),this.changeRafId=void 0),this.onColorChange(this.currentColor,this.currentOpacity)}applyPendingExternal(){if(!this.pendingExternalUpdate)return;const{color:e,opacity:r}=this.pendingExternalUpdate;this.pendingExternalUpdate=void 0,this.initFromColor(e,r)}initFromColor(e,r){var l;const a=this.sanitizeColor(e);this.currentColor=a,this.currentOpacity=this.clampOpacity(r);const{h:n,s:i,v:s}=ya(a),o=n>=360?n%360:n;this.hueMarker.style.left=`${o/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
26
- linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var e;this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this))}getElement(){return this.element}updateColor(e,r){if(this.isDragging){this.pendingExternalUpdate={color:e,opacity:r};return}this.initFromColor(e,r)}}const Qt=class Qt extends Le{constructor(e={}){const r=typeof e.default=="string"?void 0:e.default;super({...e,title:e.title||"Color",default:r}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.sharedStopColorPicker=null,this.colorPickerStopIndex=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=a=>{var u;if(!this.popoverEl||!this.isPopoverOpen)return;const n=a.target,i=this.popoverEl.contains(n),s=(u=this.element)==null?void 0:u.contains(n),o=document.querySelectorAll(".custom-color-picker"),l=Array.from(o).some(p=>p.contains(n)),c=n.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),f=n.classList.contains("color-picker-backdrop"),h=n.classList.contains("gradient-popover-backdrop");!i&&!s&&!l&&!c&&!f&&!h&&this.closePopover()},this.handlePopoverKeydown=a=>{var n,i;if(this.isPopoverOpen){if(a.key==="Escape"){if(a.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(a.key==="Enter"){const s=a.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;if(a.preventDefault(),(i=this.sharedStopColorPicker)!=null&&i.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=e.detectChange,this.variant=e.variant??"default",this.originalDefault=e.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(e){if(e.startsWith("var(--")){const r=e.replace("var(--","").replace(")","");return(Le.GlobalVariables||{})[r]||e}return e}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new gf(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(e){var a,n;if(!e){this.linkedGlobalVariable=null;return}const r=typeof e=="string"?e:((n=(a=e.stops)==null?void 0:a[0])==null?void 0:n.color)??null;this.linkedGlobalVariable=r&&r.startsWith("var(--")?r:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var e,r;this.isBoundToGlobal()&&((r=(e=this.value)==null?void 0:e.stops)!=null&&r.length&&(this.value.stops=this.value.stops.map(a=>({...a,color:this.resolveGlobalVarColor(a.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var e;!this.isBoundToGlobal()||!this.value||((e=this.value.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const e=this.originalDefault;if(typeof e=="string"){if(e.startsWith("var(--"))return Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]});const a=Nt(e);if(a)return Cr(a)}return Cr(e&&typeof e=="object"?e:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(e){let r=null;typeof e=="string"?e.startsWith("var(--")?r=Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]}):r=Nt(e):e&&typeof e=="object"&&(r=Cr(e)),r||(r=this.defaultValue()),this.value=r,this.setLinkedGlobalVariableFrom(e??r),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const e=this.value.stops[0],r=e.opacity??100,a=this.resolveGlobalVarColor(e.color);this.previewEl.style.background=Pi(a,r)}else{const e=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=qt(e)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const r=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");this.inputEl.value=`Linked: ${r}`}else this.inputEl.value=Bn(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(e){return{...e,stops:e.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const e=this.isBoundToGlobal();e?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(e?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:qt(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const e=document.createElement("div");if(e.className="gradient-setting-wrapper",this.props.title){const a=document.createElement("div");a.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,a.appendChild(n),e.appendChild(a)}const r=document.createElement("div");return r.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?qt(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?Bn(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const a=this.value.stops[0];if(a){const i=this.resolveGlobalVarColor(a.color).toUpperCase(),s=a.opacity??100;if(s===100)this.inputEl.value=i;else{const l=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${i}${l}`}}}else this.inputEl.value=qt(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=Bn(this.value))}),this.inputEl.addEventListener("paste",a=>this.handlePaste(a)),this.inputEl.addEventListener("input",a=>this.handleTextInput(a)),this.inputEl.addEventListener("keydown",a=>{a.key==="Enter"&&(this.handleTextInput(a),this.inputEl.blur()),a.key==="Escape"&&(this.value&&(this.inputEl.value=qt(this.value)),this.inputEl.blur())}),r.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=mf,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.breakGlobalBinding()}),r.appendChild(this.unlinkButton),r.appendChild(this.inputEl),e.appendChild(r),this.createPopover(),this.element=e,this.updateUnlinkButtonVisibility(),e}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const e=document.createElement("div");e.className="gradient-popover-header",e.style.cursor="move";let r=null;if(this.variant!=="global"){r=document.createElement("div"),r.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const c=document.createElement("button");c.className="color-tab",c.textContent="Global",r.appendChild(l),r.appendChild(c),e.appendChild(r)}else{const l=document.createElement("div");e.appendChild(l)}const a=document.createElement("button");a.type="button",a.className="gradient-popover-close",a.innerHTML=v0,a.addEventListener("click",()=>this.closePopover()),e.appendChild(a),Qi(e,this.popoverEl,(l,c)=>{this.popoverPosition={left:l,top:c}});const n=document.createElement("div");n.className="gradient-editor";const i=document.createElement("div");i.className="type-tabs-wrapper";const s=this.createTypeTabs();i.appendChild(s),n.appendChild(i);const o=document.createElement("div");if(o.className="gradient-editor-content",this.updatePopoverContent(o),n.appendChild(o),this.variant!=="global"&&r){const l=r.children[0],c=r.children[1],f=h=>{this.currentMode=h,h==="custom"?(l.classList.add("active"),c.classList.remove("active"),i.style.display="block"):(c.classList.add("active"),l.classList.remove("active"),i.style.display="none"),this.updatePopoverContent(o)};l.addEventListener("click",()=>f("custom")),c.addEventListener("click",()=>f("global")),this.isBoundToGlobal()?(this.currentMode="global",f("global")):(this.currentMode="custom",f("custom"))}this.popoverEl.appendChild(e),this.popoverEl.appendChild(n),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var n,i;const e=document.createElement("div");e.className="gradient-type-tabs";const r=document.createElement("button");r.type="button",r.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)==="solid"?"active":""}`,r.innerHTML=df,r.addEventListener("click",()=>this.switchType("solid"));const a=document.createElement("button");return a.type="button",a.className=`gradient-type-tab ${((i=this.value)==null?void 0:i.type)!=="solid"?"active":""}`,a.innerHTML=pf,a.addEventListener("click",()=>{var o,l;const s=((o=this.value)==null?void 0:o.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(s)}),e.appendChild(r),e.appendChild(a),e}switchType(e,r=!1){var l,c;if(!this.value)return;const a=this.value.type,n=this.isBoundToGlobal(),i=this.linkedGlobalVariable;this.value.type=e;let s=!1;if(n&&i&&a==="solid"!=(e==="solid")){const f=this.resolveGlobalVarColor(i),h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100,u=Nt(f);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type,this.linkedGlobalVariable=null,s=!0):((l=this.value.stops)!=null&&l.length&&(this.value.stops=this.value.stops.map(p=>({...p,color:p.color.startsWith("var(--")?this.resolveGlobalVarColor(p.color):p.color}))),!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:f,position:0,opacity:h}]:this.value.stops[0]={...this.value.stops[0],color:f,opacity:h},this.linkedGlobalVariable=null,s=!0)}if(e!=="solid"&&(this.pendingSolidColor=null),e!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),e!=="solid"&&this.value.stops.length===1){const h=this.value.stops[0].color;if(h.startsWith("var(--")){const u=this.resolveGlobalVarColor(h),p=Nt(u);p&&p.type!=="solid"&&p.stops.length>=2?(this.value.stops=p.stops,this.value.angle=p.angle,this.value.type=p.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else if(h.startsWith("linear-gradient")||h.startsWith("radial-gradient")){const u=Nt(h);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type):(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}],this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(e!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(e==="solid"&&n&&i){const f=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:i,position:0,opacity:f}],this.value.angle=0}if(this.popoverEl){const f=this.popoverEl.querySelectorAll(".gradient-type-tab");f.forEach(p=>p.classList.remove("active"));const h=f[0],u=f[1];e==="solid"?h==null||h.classList.add("active"):u==null||u.classList.add("active")}const o=(c=this.popoverEl)==null?void 0:c.querySelector(".gradient-editor-content");o&&this.updatePopoverContent(o),this.updateUI(),(r||s||a!==e)&&this.triggerChange()}updatePopoverContent(e){if(e.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(e);return}this.value.type==="solid"?this.renderSolid(e):this.renderGradient(e)}}renderGlobalColors(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=h=>{h.innerHTML="";let u={};try{u=Le.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!u||Object.keys(u).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.fontSize="12px",g.style.color="#666",g.style.padding="8px",h.appendChild(g);return}const p=Le.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],m=this.globalSearchQuery.toLowerCase();let d;this.globalLayoutMode==="list"?(d=document.createElement("div"),d.className="global-colors-list"):(d=document.createElement("div"),d.className="global-colors-grid"),h.appendChild(d),p.forEach(g=>{const x=Object.entries(u).filter(([w])=>!g.keys.includes(w)&&g.title!=="Global Colors"?!1:g.keys.includes(w)&&w.toLowerCase().includes(m));x.length!==0&&x.forEach(([w,v])=>{if(this.globalLayoutMode==="list"){const F=document.createElement("div");F.className="global-color-row";const N=document.createElement("div");N.className="global-color-circle";const A=this.resolveGlobalVarColor(v);N.style.background=A,(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&N.classList.add("selected");const P=document.createElement("span");P.className="global-color-label",P.textContent=w.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),F.appendChild(N),F.appendChild(P),F.addEventListener("click",I=>{I.preventDefault();const z=`var(--${w})`;this.setValue(z),this.pendingSolidColor=z,a(h)}),d.appendChild(F)}else{const F=document.createElement("div");F.className="global-color-circle";const N=this.resolveGlobalVarColor(v);F.style.background=N,F.title=w.split("-").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&F.classList.add("selected"),F.addEventListener("click",y=>{y.preventDefault();const P=`var(--${w})`;this.setValue(P),this.pendingSolidColor=P,a(h)}),d.appendChild(F)}})})},n=document.createElement("div");n.className="global-controls-row";const i=document.createElement("div");i.className="global-search-container";const s=document.createElement("span");s.className="global-search-icon",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const o=document.createElement("input");o.type="text",o.className="global-search-input",o.placeholder="Search",o.value=this.globalSearchQuery;const l=document.createElement("div");o.addEventListener("input",h=>{this.globalSearchQuery=h.target.value,a(l)}),i.appendChild(s),i.appendChild(o);const c=document.createElement("button");c.className="global-layout-toggle",c.type="button";const f=()=>{c.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};f(),c.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",f(),a(l)}),n.appendChild(i),n.appendChild(c),e.appendChild(n),e.appendChild(l),a(l)}renderSolid(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=new xf({initialColor:r.color.startsWith("var(--")?this.resolveGlobalVarColor(r.color):r.color,initialOpacity:r.opacity??100,onColorChange:(n,i)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const s=Nt(n);if(s&&s.type!=="solid"){this.value=s,this.switchType(s.type,!0);return}this.value.stops[0].color=n,this.value.stops[0].opacity=i,this.updateUI(),this.triggerChange(),this.pendingSolidColor=n}}});this.solidPicker=a,e.appendChild(a.getElement())}renderGradient(e){this.solidPicker=null;let r=null;{const f=document.createElement("div");f.className="gradient-subtype-inline";const h=document.createElement("select");h.className="gradient-subtype-select";const u=document.createElement("option");u.value="linear",u.textContent="Linear";const p=document.createElement("option");p.value="radial",p.textContent="Radial",h.appendChild(u),h.appendChild(p),h.value=this.value.type==="radial"?"radial":"linear",r=document.createElement("input"),r.type="text",r.inputMode="numeric",r.className="gradient-degree-input",r.value=`${this.value.angle??90}°`,r.style.width="75px",r.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,r.value="90°");const m=document.createElement("button");m.type="button",m.className="gradient-flip-btn",m.innerHTML=hf,h.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(h.value==="radial"?"radial":"linear",!0),r&&this.updateDegreeVisibility(r)}),r.addEventListener("focus",d=>{const g=d.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),r.addEventListener("input",d=>{this.clearGlobalBindingForCustomChange();const g=parseInt(d.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),r.addEventListener("blur",d=>{var w;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=d.target;let x=parseInt(g.value);Number.isNaN(x)&&(x=((w=this.value)==null?void 0:w.angle)??0),x=Math.max(0,Math.min(360,x)),this.value&&(this.value.angle=x),g.value=`${x}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(d=>{d.position=100-d.position}),this.value.stops.sort((d,g)=>d.position-g.position),this.updateGradientPreview(a),this.createHandles(n,a),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),f.appendChild(h),f.appendChild(r),f.appendChild(m),e.appendChild(f),this.updateDegreeVisibility(r)}const a=document.createElement("div");a.className="gradient-preview",this.updateGradientPreview(a);const n=document.createElement("div");n.className="gradient-handles",a.appendChild(n),e.appendChild(a),this.createHandles(n,a),a.addEventListener("click",f=>{var d;const h=f.target;if(h.classList.contains("gstop-handle")||h.classList.contains("gstop-chip"))return;const u=a.getBoundingClientRect(),m=(f.clientX-u.left)/u.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(m),this.updateStopsList(),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((d=document.activeElement)==null?void 0:d.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const i=document.createElement("div");i.className="gradient-stops-header";const s=document.createElement("span");s.textContent="Stops";const o=document.createElement("button");o.type="button",o.className="gradient-add-stop",o.textContent="+",i.appendChild(s),i.appendChild(o);const l=document.createElement("div");l.className="gradient-stops",e.appendChild(i),e.appendChild(l),this.updateStopsList(l);const c=es(f=>{const h=Nt(f);h&&(this.clearGlobalBindingForCustomChange(),this.value=h,this.switchType(h.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=c.refresh,e.appendChild(c.container),o.addEventListener("click",()=>{var f;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(e){var r;e&&(((r=this.value)==null?void 0:r.type)==="radial"?(e.disabled=!0,e.style.opacity="0.5"):(e.disabled=!1,e.style.opacity="1"))}updateGradientPreview(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-preview"));if(r&&this.value)if(this.value.type==="solid")r.style.background=qt(this.value);else{const n=this.value.stops.map(i=>`${Pi(i.color,i.opacity??100)} ${i.position}%`).join(", ");r.style.background=`linear-gradient(90deg, ${n})`}}debouncedPreviewUpdate(e){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(e),this.previewUpdateTimeout=null},16)}createHandles(e,r){e.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((a,n)=>{const i=document.createElement("div");i.className="gstop-handle",i.style.left=`${Math.max(0,Math.min(100,a.position))}%`,i.style.top="0%";const s=document.createElement("div");s.className="gstop-chip";const o=this.resolveGlobalVarColor(a.color);s.style.backgroundColor=o,i.appendChild(s);let l=!1,c=!1,f=0,h=0;const u=d=>{l=!0,c=!1,f=d.clientX,h=this.value.stops[n].position,i.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),d.preventDefault(),d.stopPropagation()},p=d=>{if(!l||!this.value)return;const g=d.clientX-f;if(Math.abs(g)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const x=r.getBoundingClientRect();let w=h+g/x.width*100;w=Math.max(0,Math.min(100,w)),this.value.stops[n].position=Math.round(w),i.style.left=`${w}%`,this.updateGradientPreview()}},m=d=>{var g;if(l)if(l=!1,i.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((x,w)=>x.position-w.position),this.createHandles(e,r),this.updateStopsList()),this.updateUI(),this.triggerChange();else{d.stopPropagation();const x=(g=this.value)==null?void 0:g.stops[n];x&&setTimeout(()=>{const w=this.getSharedStopColorPicker();w.getIsOpen()&&w.close(!1),this.colorPickerStopIndex=n,w.setOnChange((F,N)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[n]&&(this.value.stops[n].color=F,N!==void 0&&(this.value.stops[n].opacity=N),s.style.backgroundColor=F,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const v=this.resolveGlobalVarColor(x.color);w.open(v,s,x.opacity??100)},0)}};i.addEventListener("mousedown",u),e.appendChild(i)})}updateStopsList(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-stops"));!r||!this.value||this.value.type==="solid"||!this.value.stops||(r.innerHTML="",this.value.stops.forEach((n,i)=>{var F,N;const s=document.createElement("div");s.className="gstop-row";const o=document.createElement("div");o.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${n.position}%`,l.style.width="60px",o.appendChild(l);const c=document.createElement("div");c.className="gstop-color-container";const f=this.resolveGlobalVarColor(n.color),h=document.createElement("div");h.className="gstop-color-preview",h.style.backgroundColor=f;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=f.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",c.appendChild(h),c.appendChild(u),c.appendChild(p);const m=document.createElement("button");m.type="button",m.className="gstop-del",m.innerHTML=uf,m.disabled=(((N=(F=this.value)==null?void 0:F.stops)==null?void 0:N.length)||0)<=2,s.appendChild(o),s.appendChild(c),s.appendChild(m),r.appendChild(s);const d=document.createElement("span");d.className="gstop-opacity-label",d.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const x=document.createElement("input");x.type="range",x.className="gstop-opacity-slider",x.min="0",x.max="100",x.value=String(n.opacity??100);const w=Pt(f);x.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${w.r}, ${w.g}, ${w.b}, 0)`);const v=document.createElement("span");v.className="gstop-opacity-value",v.textContent=`${n.opacity??100}%`,g.appendChild(x),g.appendChild(v),u.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const y=this.getSharedStopColorPicker();y.getIsOpen()&&y.close(!1),this.colorPickerStopIndex=i,y.setOnChange((I,z)=>{this.clearGlobalBindingForCustomChange(),u.value=I.replace("#","").toUpperCase(),h.style.backgroundColor=I,this.value.stops[i].color=I,z!==void 0&&(this.value.stops[i].opacity=z,x.value=String(z),v.textContent=`${z}%`);const V=Pt(I);x.style.setProperty("--slider-color",`rgb(${V.r}, ${V.g}, ${V.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${V.r}, ${V.g}, ${V.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const P=this.resolveGlobalVarColor(n.color);y.open(P,u,n.opacity??100)}),u.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=u.value.trim(),y=A.startsWith("#")?A:`#${A}`;if(/^#[0-9A-Fa-f]{6}$/.test(y)){this.value.stops[i].color=y,h.style.backgroundColor=y;const P=Pt(y);x.style.setProperty("--slider-color",`rgb(${P.r}, ${P.g}, ${P.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${P.r}, ${P.g}, ${P.b}, 0)`),this.debouncedPreviewUpdate()}}),u.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async A=>{A.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),l.addEventListener("focus",A=>{const y=A.target;y.value=y.value.replace("%",""),y.select()}),l.addEventListener("input",A=>{this.clearGlobalBindingForCustomChange();const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(P)){const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",A=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(Number.isNaN(P))y.value=`${this.value.stops[i].position}%`;else{const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{var A,y;(this.value.stops.length||0)<=2||((A=this.sharedStopColorPicker)!=null&&A.getIsOpen()&&this.colorPickerStopIndex===i?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>i&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(i,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),x.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=parseInt(x.value,10);this.value.stops[i].opacity=Math.max(0,Math.min(100,A)),v.textContent=`${this.value.stops[i].opacity}%`,this.debouncedPreviewUpdate()}),x.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=this.value.stops.map(n=>n.position).sort((n,i)=>n-i);let r=50,a=0;for(let n=0;n<e.length-1;n++){const i=e[n+1]-e[n];i>a&&(a=i,r=e[n]+i/2)}this.addStopAtPosition(r)}addStopAtPosition(e){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const r=Math.max(0,Math.min(100,e)),a=[...this.value.stops].sort((c,f)=>c.position-f.position);let n=a[0],i=a[a.length-1];for(let c=0;c<a.length-1;c++)if(a[c].position<=r&&a[c+1].position>=r){n=a[c],i=a[c+1];break}let s,o;if(n===i||n.position===i.position)s=n.color,o=n.opacity??100;else{const c=(r-n.position)/(i.position-n.position),f=Pt(n.color),h=Pt(i.color),u=Math.round(f.r+(h.r-f.r)*c),p=Math.round(f.g+(h.g-f.g)*c),m=Math.round(f.b+(h.b-f.b)*c);s=`#${u.toString(16).padStart(2,"0")}${p.toString(16).padStart(2,"0")}${m.toString(16).padStart(2,"0")}`.toUpperCase(),o=Math.round((n.opacity??100)+((i.opacity??100)-(n.opacity??100))*c)}const l={position:Math.round(r),color:s,opacity:o};this.value.stops.push(l),this.value.stops.sort((c,f)=>c.position-f.position)}openPopover(){if(this.popoverEl&&(Qt.openInstance&&Qt.openInstance!==this&&Qt.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,Qt.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const e=this.element.getBoundingClientRect(),r=306,a=window.innerWidth,n=window.innerHeight,i=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const s=this.popoverEl.offsetHeight;let o=e.right+8,l=e.top;const c=a-e.right,f=e.left,h=r+i;c<h&&f>c+100&&(o=e.left-r-8);const u=n-e.bottom,p=e.top;p>=s+i?l=e.top-s-8:u>=s+i?l=e.bottom+8:p>u?(l=e.top-s-8,l<i&&(l=i)):(l=e.bottom+8,l+s>n-i&&(l=n-s-i)),this.popoverEl.style.left=`${o}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:o,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var e;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((e=document.activeElement)==null?void 0:e.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const r=this.element.getBoundingClientRect(),a=306,n=window.innerWidth,i=window.innerHeight,s=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let l=r.right+8,c=r.top;const f=n-r.right,h=r.left,u=a+s;f<u&&h>f+100&&(l=r.left-a-8);const p=i-r.bottom,m=r.top;m>=o+s?c=r.top-o-8:p>=o+s?c=r.bottom+8:m>p?(c=r.top-o-8,c<s&&(c=s)):(c=r.bottom+8,c+o>i-s&&(c=i-o-s)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${c}px`})}}refreshPopoverContent(){var i,s;if(!this.popoverEl)return;const e=this.popoverEl.querySelectorAll(".gradient-type-tab");e.forEach(o=>o.classList.remove("active"));const r=e[0],a=e[1];((i=this.value)==null?void 0:i.type)==="solid"?r.classList.add("active"):(a.classList.add("active"),(s=this.recentGradientRefresh)==null||s.call(this)),this.popoverEl.offsetHeight;const n=this.popoverEl.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n)}closePopover(){var e,r;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(e=this.sharedStopColorPicker)!=null&&e.getIsOpen()&&(this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null),this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const a=qt(this.value);ra.addColor(a,"gradient"),(r=this.recentGradientRefresh)==null||r.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),Qt.openInstance===this&&(Qt.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():ra.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(e){var a;e.preventDefault();const r=((a=e.clipboardData)==null?void 0:a.getData("text"))||"";this.parseAndSet(r)}handleTextInput(e){const r=e.target;this.parseAndSet(r.value)}parseAndSet(e){let r=e.trim();r&&!r.startsWith("#")&&!r.startsWith("var(")&&!r.startsWith("rgb")&&!r.startsWith("hsl")&&!r.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(r)&&(r="#"+r,this.inputEl&&(this.inputEl.value=r));const a=Nt(r);a&&this.setValue(a)}getChangePayload(){var e;if(this.value)return this.isBoundToGlobal()?((e=this.value.stops)==null?void 0:e.some(a=>a.opacity!==void 0&&a.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const e=this.getChangePayload();e!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var r,a;(r=this.onChange)==null||r.call(this,e),(a=this.detectChange)==null||a.call(this,e),this.changeDebounceTimeout=null},Qt.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};Qt.openInstance=null,Qt.CHANGE_DEBOUNCE_DELAY=150;let aa=Qt;function zr(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=t[r];e(r,a)}}function Di(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>Di(e));if(typeof t=="object"){const e={};for(const[r,a]of Object.entries(t))r!=="$id"&&(e[r]=Di(a));return e}return t}const ni=class ni{constructor(e){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.isSettingValue=!1,this.suppressOnChange=!1,console.log("🔨 [SettingsGroup Created]",e.title||"Unnamed Group"),this.suppressOnChange=!0,this.id=e.id||Un(),this.title=e.title,this.settings=e.settings,this.isCollapsed=e.collapsed??!1,this.isMain=e.main??!1,this.custom=e.custom??!1,this.nestingLevel=0,this.includeGetJson=e.includeGetJson??!0,this.addItemCfg=e.addItem,this.deleteItemCfg=e.deleteItem,this.dataProps=e.dataProps,this.dataPropsPath=e.dataProps||"",this.hide=e.hide??!1,Object.assign(this,e.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath(),this.propagateComponentPaths(),this.suppressOnChange=!1}propagateNestingLevel(){const e=this.nestingLevel+1;zr(this.settings,(r,a)=>{$e(a)&&(a.nestingLevel=e,a.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(e){this.nestingLevel=e,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(e){if(this.title=e,this.elementRef){const r=this.elementRef.querySelector(".setting-group-title h3");r&&(r.textContent=e)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(e){this.dataPropsPath=e,this.propagateDataPropsPath()}propagateDataPropsPath(){zr(this.settings,(e,r)=>{const a=String(e),n=this.dataPropsPath?`${this.dataPropsPath}_${a}`:a;($e(r)||dr(r)&&typeof r.setDataPropsPath=="function")&&r.setDataPropsPath(n)})}propagateComponentPaths(e=""){zr(this.settings,(r,a)=>{var i;const n=String(r);if($e(a)){const s=e?`${e} > ${a.title}`:a.title;a.propagateComponentPaths(s)}else if(dr(a)&&typeof a.setComponentPath=="function"){const s=((i=a.props)==null?void 0:i.title)||n,o=e?`${e} > ${s}`:s;a.setComponentPath(o)}})}updateNestingStyles(){this.elementRef&&(Dn(this.elementRef,this.nestingLevel),Ni(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([e,r])=>{try{if($e(r)){const a=r.getValues();r.setValue(a)}else if(typeof r.setValue=="function"){const a=r.value;a!==void 0&&r.setValue(a)}}catch(a){console.warn(`Error refreshing UI for setting ${e}:`,a)}})}removeSetting(e){var n;const r=this.settings[e];if(!r)return;if(delete this.settings[e],this.elementRef){const i=this.elementRef.querySelector(".setting-group-content");if(i){const s=Array.from(i.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const o of s){const l=o.id,c=o.getAttribute("data-setting-id");if(l&&"id"in r&&typeof r.id=="string"&&l.includes(r.id)){o.remove();break}if(c&&"id"in r&&typeof r.id=="string"&&c===r.id){o.remove();break}}}}typeof r.cleanup=="function"&&r.cleanup(),this.updateNestingStyles();const a=this.getValues();this.initialValues=a,this.suppressOnChange||(n=this.onChange)==null||n.call(this,a)}updateVisibility(){this.elementRef}updateSettings(e,r){var l;const a=(r==null?void 0:r.preserveValues)??!0,n=new Set(Object.keys(this.settings)),i=Object.keys(e),s={};a&&i.forEach(c=>{const f=this.settings[c];f&&($e(f)?s[c]=f.getValues():dr(f)?s[c]=f.value:typeof f.getValues=="function"?s[c]=f.getValues():f.value!==void 0&&(s[c]=f.value))}),n.forEach(c=>{i.includes(c)||this.removeSetting(c)}),i.forEach(c=>{var u;const f=e[c],h=this.settings[c];if(h!==f&&(h&&this.removeSetting(c),this.addSetting(c,f),a&&c in s)){const p=s[c];try{$e(f)?f.setValue(p):dr(f)?(u=f.setValue)==null||u.call(f,p):f.setValue&&f.setValue(p)}catch(m){console.warn(`Could not preserve value for setting ${c}:`,m)}}}),this.settings=e,this.propagateNestingLevel(),this.propagateDataPropsPath();const o=this.getValues();this.initialValues=o,this.suppressOnChange||(l=this.onChange)==null||l.call(this,o)}clone(){const e={};zr(this.settings,(n,i)=>{const s=String(n);typeof i.clone=="function"?e[s]=i.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),e[s]=i)});const r={title:this.title,settings:e,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},a=w0(r);return a.suppressOnChange=!0,a.initialValues=this.getValues(),a.suppressOnChange=!1,a}resetDefault(){const e=this.originalDefaultValues;this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues())}setMobileValues(e){!e||typeof e!="object"||(Object.entries(e).forEach(([r,a])=>{const n=this.settings[r];n&&($e(n)||dr(n))&&typeof n.setMobileValue=="function"&&n.setMobileValue(a)}),this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues()))}getMobileValues(e){if(e===void 0){const r={};for(const a in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,a)){const n=this.settings[a];if($e(n))r[a]=n.getMobileValues();else{const i=n;r[a]=i.mobileValue!==void 0?i.mobileValue:i.value}}return r}else{const r=this.settings[e];if(!r)return;if($e(r))return r.getMobileValues();const a=r;return a.mobileValue!==void 0?a.mobileValue:a.value}}setOnChange(e){this.onChange=e;const r=()=>{this.isHandlingChange||this.suppressOnChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const a=this.getValues(),n=this.calculateChanges(this.initialValues,a);Object.keys(n).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=a,this.suppressOnChange||e(a),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),zr(this.settings,(a,n)=>{var i;if($e(n))n.setOnChange(()=>{if(this.suppressOnChange)return;const s=this.getValues();this.initialValues=s,e(s)}),this.changeHandlers.add(()=>e(this.getValues()));else if(dr(n)){const s=()=>r();this.changeHandlers.add(s),n.setOnChange(s)}else{const s=()=>r();this.changeHandlers.add(s),(i=n.setOnChange)==null||i.call(n,s)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear(),zr(this.settings,(e,r)=>{const a=r;try{typeof a.cleanup=="function"?a.cleanup():typeof a.destroy=="function"&&a.destroy()}catch{}})}setValue(e){if(!(!e||typeof e!="object")&&!this.isSettingValue){this.isSettingValue=!0;try{Object.entries(e).forEach(([a,n])=>{let i=this.settings[a];if(!i&&this.addItemCfg&&a.startsWith(this.addItemCfg.keyPrefix)){const s=a.slice(this.addItemCfg.keyPrefix.length),o=Number(s);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);Mi(l)&&(this.addSetting(a,l),i=l)}}i&&($e(i)||dr(i))&&typeof i.setValue=="function"&&i.setValue(n)});const r=this.getValues();this.initialValues=r,this.onChange&&!this.suppressOnChange&&this.onChange(r)}finally{this.isSettingValue=!1}}}wireChild(e){var a;const r=()=>{var i;if(this.suppressOnChange)return;const n=this.getValues();this.initialValues=n,(i=this.onChange)==null||i.call(this,n),this.updateVisibility()};$e(e)?e.setOnChange(()=>r()):dr(e)?e.setOnChange(()=>r()):(a=e.setOnChange)==null||a.call(e,()=>r())}addSetting(e,r){var n,i;if(this.settings[e]=r,this.wireChild(r),this.elementRef){const s=this.elementRef.querySelector(".setting-group-content");if(s){const o=s.querySelector(".setting-group-empty");o&&o.remove(),$e(r)&&typeof r.setNestingLevel=="function"&&r.setNestingLevel(this.nestingLevel+1);const l=r.draw(),c=this.deleteItemCfg??this.addItemCfg;if(c){const u=c.keyPrefix??((n=this.addItemCfg)==null?void 0:n.keyPrefix);u&&e.startsWith(u)&&this.addDeleteButtonToElement(l,e)}const f=s.querySelector(".sg-add-button-bottom");f?s.insertBefore(l,f):s.appendChild(l),Ys.trackElement(l),Dn(l,this.nestingLevel+1),Ni(l,this.nestingLevel+1);const h=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=h,this.updateNestingStyles()}}const a=this.getValues();this.initialValues=a,this.suppressOnChange||(i=this.onChange)==null||i.call(this,a)}addDeleteButtonToElement(e,r,a){let n=null;try{n=e.querySelector(":scope > .setting-group-title")}catch{n=null}if(!n){const c=Array.from(e.querySelectorAll(".setting-group-title"));for(const f of c)if(f.closest(".setting-group")===e){n=f;break}n||(n=c[0]??null)}if(!n)return;const i=n.querySelector(".actions-section");if(!i)return;const s=document.createElement("button");s.type="button",s.className="sg-delete-button",a?a.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,s.title="Delete",s.style.cssText=`
26
+ linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var e;this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this))}getElement(){return this.element}updateColor(e,r){if(this.isDragging){this.pendingExternalUpdate={color:e,opacity:r};return}this.initFromColor(e,r)}}const Qt=class Qt extends Le{constructor(e={}){const r=typeof e.default=="string"?void 0:e.default;super({...e,title:e.title||"Color",default:r}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.sharedStopColorPicker=null,this.colorPickerStopIndex=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=a=>{var u;if(!this.popoverEl||!this.isPopoverOpen)return;const n=a.target,i=this.popoverEl.contains(n),s=(u=this.element)==null?void 0:u.contains(n),o=document.querySelectorAll(".custom-color-picker"),l=Array.from(o).some(p=>p.contains(n)),c=n.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),f=n.classList.contains("color-picker-backdrop"),h=n.classList.contains("gradient-popover-backdrop");!i&&!s&&!l&&!c&&!f&&!h&&this.closePopover()},this.handlePopoverKeydown=a=>{var n,i;if(this.isPopoverOpen){if(a.key==="Escape"){if(a.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(a.key==="Enter"){const s=a.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;if(a.preventDefault(),(i=this.sharedStopColorPicker)!=null&&i.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=e.detectChange,this.variant=e.variant??"default",this.originalDefault=e.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(e){if(e.startsWith("var(--")){const r=e.replace("var(--","").replace(")","");return(Le.GlobalVariables||{})[r]||e}return e}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new gf(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(e){var a,n;if(!e){this.linkedGlobalVariable=null;return}const r=typeof e=="string"?e:((n=(a=e.stops)==null?void 0:a[0])==null?void 0:n.color)??null;this.linkedGlobalVariable=r&&r.startsWith("var(--")?r:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var e,r;this.isBoundToGlobal()&&((r=(e=this.value)==null?void 0:e.stops)!=null&&r.length&&(this.value.stops=this.value.stops.map(a=>({...a,color:this.resolveGlobalVarColor(a.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var e;!this.isBoundToGlobal()||!this.value||((e=this.value.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const e=this.originalDefault;if(typeof e=="string"){if(e.startsWith("var(--"))return Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]});const a=Nt(e);if(a)return Cr(a)}return Cr(e&&typeof e=="object"?e:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(e){let r=null;typeof e=="string"?e.startsWith("var(--")?r=Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]}):r=Nt(e):e&&typeof e=="object"&&(r=Cr(e)),r||(r=this.defaultValue()),this.value=r,this.setLinkedGlobalVariableFrom(e??r),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const e=this.value.stops[0],r=e.opacity??100,a=this.resolveGlobalVarColor(e.color);this.previewEl.style.background=Pi(a,r)}else{const e=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=qt(e)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const r=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");this.inputEl.value=`Linked: ${r}`}else this.inputEl.value=Bn(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(e){return{...e,stops:e.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const e=this.isBoundToGlobal();e?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(e?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:qt(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const e=document.createElement("div");if(e.className="gradient-setting-wrapper",this.props.title){const a=document.createElement("div");a.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,a.appendChild(n),e.appendChild(a)}const r=document.createElement("div");return r.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?qt(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?Bn(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const a=this.value.stops[0];if(a){const i=this.resolveGlobalVarColor(a.color).toUpperCase(),s=a.opacity??100;if(s===100)this.inputEl.value=i;else{const l=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${i}${l}`}}}else this.inputEl.value=qt(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=Bn(this.value))}),this.inputEl.addEventListener("paste",a=>this.handlePaste(a)),this.inputEl.addEventListener("input",a=>this.handleTextInput(a)),this.inputEl.addEventListener("keydown",a=>{a.key==="Enter"&&(this.handleTextInput(a),this.inputEl.blur()),a.key==="Escape"&&(this.value&&(this.inputEl.value=qt(this.value)),this.inputEl.blur())}),r.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=mf,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.breakGlobalBinding()}),r.appendChild(this.unlinkButton),r.appendChild(this.inputEl),e.appendChild(r),this.createPopover(),this.element=e,this.updateUnlinkButtonVisibility(),e}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const e=document.createElement("div");e.className="gradient-popover-header",e.style.cursor="move";let r=null;if(this.variant!=="global"){r=document.createElement("div"),r.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const c=document.createElement("button");c.className="color-tab",c.textContent="Global",r.appendChild(l),r.appendChild(c),e.appendChild(r)}else{const l=document.createElement("div");e.appendChild(l)}const a=document.createElement("button");a.type="button",a.className="gradient-popover-close",a.innerHTML=v0,a.addEventListener("click",()=>this.closePopover()),e.appendChild(a),Qi(e,this.popoverEl,(l,c)=>{this.popoverPosition={left:l,top:c}});const n=document.createElement("div");n.className="gradient-editor";const i=document.createElement("div");i.className="type-tabs-wrapper";const s=this.createTypeTabs();i.appendChild(s),n.appendChild(i);const o=document.createElement("div");if(o.className="gradient-editor-content",this.updatePopoverContent(o),n.appendChild(o),this.variant!=="global"&&r){const l=r.children[0],c=r.children[1],f=h=>{this.currentMode=h,h==="custom"?(l.classList.add("active"),c.classList.remove("active"),i.style.display="block"):(c.classList.add("active"),l.classList.remove("active"),i.style.display="none"),this.updatePopoverContent(o)};l.addEventListener("click",()=>f("custom")),c.addEventListener("click",()=>f("global")),this.isBoundToGlobal()?(this.currentMode="global",f("global")):(this.currentMode="custom",f("custom"))}this.popoverEl.appendChild(e),this.popoverEl.appendChild(n),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var n,i;const e=document.createElement("div");e.className="gradient-type-tabs";const r=document.createElement("button");r.type="button",r.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)==="solid"?"active":""}`,r.innerHTML=df,r.addEventListener("click",()=>this.switchType("solid"));const a=document.createElement("button");return a.type="button",a.className=`gradient-type-tab ${((i=this.value)==null?void 0:i.type)!=="solid"?"active":""}`,a.innerHTML=pf,a.addEventListener("click",()=>{var o,l;const s=((o=this.value)==null?void 0:o.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(s)}),e.appendChild(r),e.appendChild(a),e}switchType(e,r=!1){var l,c;if(!this.value)return;const a=this.value.type,n=this.isBoundToGlobal(),i=this.linkedGlobalVariable;this.value.type=e;let s=!1;if(n&&i&&a==="solid"!=(e==="solid")){const f=this.resolveGlobalVarColor(i),h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100,u=Nt(f);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type,this.linkedGlobalVariable=null,s=!0):((l=this.value.stops)!=null&&l.length&&(this.value.stops=this.value.stops.map(p=>({...p,color:p.color.startsWith("var(--")?this.resolveGlobalVarColor(p.color):p.color}))),!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:f,position:0,opacity:h}]:this.value.stops[0]={...this.value.stops[0],color:f,opacity:h},this.linkedGlobalVariable=null,s=!0)}if(e!=="solid"&&(this.pendingSolidColor=null),e!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),e!=="solid"&&this.value.stops.length===1){const h=this.value.stops[0].color;if(h.startsWith("var(--")){const u=this.resolveGlobalVarColor(h),p=Nt(u);p&&p.type!=="solid"&&p.stops.length>=2?(this.value.stops=p.stops,this.value.angle=p.angle,this.value.type=p.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else if(h.startsWith("linear-gradient")||h.startsWith("radial-gradient")){const u=Nt(h);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type):(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}],this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(e!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(e==="solid"&&n&&i){const f=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:i,position:0,opacity:f}],this.value.angle=0}if(this.popoverEl){const f=this.popoverEl.querySelectorAll(".gradient-type-tab");f.forEach(p=>p.classList.remove("active"));const h=f[0],u=f[1];e==="solid"?h==null||h.classList.add("active"):u==null||u.classList.add("active")}const o=(c=this.popoverEl)==null?void 0:c.querySelector(".gradient-editor-content");o&&this.updatePopoverContent(o),this.updateUI(),(r||s||a!==e)&&this.triggerChange()}updatePopoverContent(e){if(e.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(e);return}this.value.type==="solid"?this.renderSolid(e):this.renderGradient(e)}}renderGlobalColors(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=h=>{h.innerHTML="";let u={};try{u=Le.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!u||Object.keys(u).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.fontSize="12px",g.style.color="#666",g.style.padding="8px",h.appendChild(g);return}const p=Le.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],m=this.globalSearchQuery.toLowerCase();let d;this.globalLayoutMode==="list"?(d=document.createElement("div"),d.className="global-colors-list"):(d=document.createElement("div"),d.className="global-colors-grid"),h.appendChild(d),p.forEach(g=>{const x=Object.entries(u).filter(([w])=>!g.keys.includes(w)&&g.title!=="Global Colors"?!1:g.keys.includes(w)&&w.toLowerCase().includes(m));x.length!==0&&x.forEach(([w,v])=>{if(this.globalLayoutMode==="list"){const F=document.createElement("div");F.className="global-color-row";const N=document.createElement("div");N.className="global-color-circle";const A=this.resolveGlobalVarColor(v);N.style.background=A,(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&N.classList.add("selected");const P=document.createElement("span");P.className="global-color-label",P.textContent=w.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),F.appendChild(N),F.appendChild(P),F.addEventListener("click",I=>{I.preventDefault();const z=`var(--${w})`;this.setValue(z),this.pendingSolidColor=z,a(h)}),d.appendChild(F)}else{const F=document.createElement("div");F.className="global-color-circle";const N=this.resolveGlobalVarColor(v);F.style.background=N,F.title=w.split("-").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&F.classList.add("selected"),F.addEventListener("click",y=>{y.preventDefault();const P=`var(--${w})`;this.setValue(P),this.pendingSolidColor=P,a(h)}),d.appendChild(F)}})})},n=document.createElement("div");n.className="global-controls-row";const i=document.createElement("div");i.className="global-search-container";const s=document.createElement("span");s.className="global-search-icon",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const o=document.createElement("input");o.type="text",o.className="global-search-input",o.placeholder="Search",o.value=this.globalSearchQuery;const l=document.createElement("div");o.addEventListener("input",h=>{this.globalSearchQuery=h.target.value,a(l)}),i.appendChild(s),i.appendChild(o);const c=document.createElement("button");c.className="global-layout-toggle",c.type="button";const f=()=>{c.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};f(),c.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",f(),a(l)}),n.appendChild(i),n.appendChild(c),e.appendChild(n),e.appendChild(l),a(l)}renderSolid(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=new xf({initialColor:r.color.startsWith("var(--")?this.resolveGlobalVarColor(r.color):r.color,initialOpacity:r.opacity??100,onColorChange:(n,i)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const s=Nt(n);if(s&&s.type!=="solid"){this.value=s,this.switchType(s.type,!0);return}this.value.stops[0].color=n,this.value.stops[0].opacity=i,this.updateUI(),this.triggerChange(),this.pendingSolidColor=n}}});this.solidPicker=a,e.appendChild(a.getElement())}renderGradient(e){this.solidPicker=null;let r=null;{const f=document.createElement("div");f.className="gradient-subtype-inline";const h=document.createElement("select");h.className="gradient-subtype-select";const u=document.createElement("option");u.value="linear",u.textContent="Linear";const p=document.createElement("option");p.value="radial",p.textContent="Radial",h.appendChild(u),h.appendChild(p),h.value=this.value.type==="radial"?"radial":"linear",r=document.createElement("input"),r.type="text",r.inputMode="numeric",r.className="gradient-degree-input",r.value=`${this.value.angle??90}°`,r.style.width="75px",r.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,r.value="90°");const m=document.createElement("button");m.type="button",m.className="gradient-flip-btn",m.innerHTML=hf,h.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(h.value==="radial"?"radial":"linear",!0),r&&this.updateDegreeVisibility(r)}),r.addEventListener("focus",d=>{const g=d.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),r.addEventListener("input",d=>{this.clearGlobalBindingForCustomChange();const g=parseInt(d.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),r.addEventListener("blur",d=>{var w;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=d.target;let x=parseInt(g.value);Number.isNaN(x)&&(x=((w=this.value)==null?void 0:w.angle)??0),x=Math.max(0,Math.min(360,x)),this.value&&(this.value.angle=x),g.value=`${x}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(d=>{d.position=100-d.position}),this.value.stops.sort((d,g)=>d.position-g.position),this.updateGradientPreview(a),this.createHandles(n,a),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),f.appendChild(h),f.appendChild(r),f.appendChild(m),e.appendChild(f),this.updateDegreeVisibility(r)}const a=document.createElement("div");a.className="gradient-preview",this.updateGradientPreview(a);const n=document.createElement("div");n.className="gradient-handles",a.appendChild(n),e.appendChild(a),this.createHandles(n,a),a.addEventListener("click",f=>{var d;const h=f.target;if(h.classList.contains("gstop-handle")||h.classList.contains("gstop-chip"))return;const u=a.getBoundingClientRect(),m=(f.clientX-u.left)/u.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(m),this.updateStopsList(),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((d=document.activeElement)==null?void 0:d.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const i=document.createElement("div");i.className="gradient-stops-header";const s=document.createElement("span");s.textContent="Stops";const o=document.createElement("button");o.type="button",o.className="gradient-add-stop",o.textContent="+",i.appendChild(s),i.appendChild(o);const l=document.createElement("div");l.className="gradient-stops",e.appendChild(i),e.appendChild(l),this.updateStopsList(l);const c=es(f=>{const h=Nt(f);h&&(this.clearGlobalBindingForCustomChange(),this.value=h,this.switchType(h.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=c.refresh,e.appendChild(c.container),o.addEventListener("click",()=>{var f;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(e){var r;e&&(((r=this.value)==null?void 0:r.type)==="radial"?(e.disabled=!0,e.style.opacity="0.5"):(e.disabled=!1,e.style.opacity="1"))}updateGradientPreview(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-preview"));if(r&&this.value)if(this.value.type==="solid")r.style.background=qt(this.value);else{const n=this.value.stops.map(i=>`${Pi(i.color,i.opacity??100)} ${i.position}%`).join(", ");r.style.background=`linear-gradient(90deg, ${n})`}}debouncedPreviewUpdate(e){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(e),this.previewUpdateTimeout=null},16)}createHandles(e,r){e.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((a,n)=>{const i=document.createElement("div");i.className="gstop-handle",i.style.left=`${Math.max(0,Math.min(100,a.position))}%`,i.style.top="0%";const s=document.createElement("div");s.className="gstop-chip";const o=this.resolveGlobalVarColor(a.color);s.style.backgroundColor=o,i.appendChild(s);let l=!1,c=!1,f=0,h=0;const u=d=>{l=!0,c=!1,f=d.clientX,h=this.value.stops[n].position,i.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),d.preventDefault(),d.stopPropagation()},p=d=>{if(!l||!this.value)return;const g=d.clientX-f;if(Math.abs(g)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const x=r.getBoundingClientRect();let w=h+g/x.width*100;w=Math.max(0,Math.min(100,w)),this.value.stops[n].position=Math.round(w),i.style.left=`${w}%`,this.updateGradientPreview()}},m=d=>{var g;if(l)if(l=!1,i.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((x,w)=>x.position-w.position),this.createHandles(e,r),this.updateStopsList()),this.updateUI(),this.triggerChange();else{d.stopPropagation();const x=(g=this.value)==null?void 0:g.stops[n];x&&setTimeout(()=>{const w=this.getSharedStopColorPicker();w.getIsOpen()&&w.close(!1),this.colorPickerStopIndex=n,w.setOnChange((F,N)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[n]&&(this.value.stops[n].color=F,N!==void 0&&(this.value.stops[n].opacity=N),s.style.backgroundColor=F,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const v=this.resolveGlobalVarColor(x.color);w.open(v,s,x.opacity??100)},0)}};i.addEventListener("mousedown",u),e.appendChild(i)})}updateStopsList(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-stops"));!r||!this.value||this.value.type==="solid"||!this.value.stops||(r.innerHTML="",this.value.stops.forEach((n,i)=>{var F,N;const s=document.createElement("div");s.className="gstop-row";const o=document.createElement("div");o.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${n.position}%`,l.style.width="60px",o.appendChild(l);const c=document.createElement("div");c.className="gstop-color-container";const f=this.resolveGlobalVarColor(n.color),h=document.createElement("div");h.className="gstop-color-preview",h.style.backgroundColor=f;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=f.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",c.appendChild(h),c.appendChild(u),c.appendChild(p);const m=document.createElement("button");m.type="button",m.className="gstop-del",m.innerHTML=uf,m.disabled=(((N=(F=this.value)==null?void 0:F.stops)==null?void 0:N.length)||0)<=2,s.appendChild(o),s.appendChild(c),s.appendChild(m),r.appendChild(s);const d=document.createElement("span");d.className="gstop-opacity-label",d.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const x=document.createElement("input");x.type="range",x.className="gstop-opacity-slider",x.min="0",x.max="100",x.value=String(n.opacity??100);const w=Pt(f);x.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${w.r}, ${w.g}, ${w.b}, 0)`);const v=document.createElement("span");v.className="gstop-opacity-value",v.textContent=`${n.opacity??100}%`,g.appendChild(x),g.appendChild(v),u.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const y=this.getSharedStopColorPicker();y.getIsOpen()&&y.close(!1),this.colorPickerStopIndex=i,y.setOnChange((I,z)=>{this.clearGlobalBindingForCustomChange(),u.value=I.replace("#","").toUpperCase(),h.style.backgroundColor=I,this.value.stops[i].color=I,z!==void 0&&(this.value.stops[i].opacity=z,x.value=String(z),v.textContent=`${z}%`);const V=Pt(I);x.style.setProperty("--slider-color",`rgb(${V.r}, ${V.g}, ${V.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${V.r}, ${V.g}, ${V.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const P=this.resolveGlobalVarColor(n.color);y.open(P,u,n.opacity??100)}),u.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=u.value.trim(),y=A.startsWith("#")?A:`#${A}`;if(/^#[0-9A-Fa-f]{6}$/.test(y)){this.value.stops[i].color=y,h.style.backgroundColor=y;const P=Pt(y);x.style.setProperty("--slider-color",`rgb(${P.r}, ${P.g}, ${P.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${P.r}, ${P.g}, ${P.b}, 0)`),this.debouncedPreviewUpdate()}}),u.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async A=>{A.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),l.addEventListener("focus",A=>{const y=A.target;y.value=y.value.replace("%",""),y.select()}),l.addEventListener("input",A=>{this.clearGlobalBindingForCustomChange();const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(P)){const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",A=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(Number.isNaN(P))y.value=`${this.value.stops[i].position}%`;else{const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{var A,y;(this.value.stops.length||0)<=2||((A=this.sharedStopColorPicker)!=null&&A.getIsOpen()&&this.colorPickerStopIndex===i?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>i&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(i,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),x.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=parseInt(x.value,10);this.value.stops[i].opacity=Math.max(0,Math.min(100,A)),v.textContent=`${this.value.stops[i].opacity}%`,this.debouncedPreviewUpdate()}),x.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=this.value.stops.map(n=>n.position).sort((n,i)=>n-i);let r=50,a=0;for(let n=0;n<e.length-1;n++){const i=e[n+1]-e[n];i>a&&(a=i,r=e[n]+i/2)}this.addStopAtPosition(r)}addStopAtPosition(e){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const r=Math.max(0,Math.min(100,e)),a=[...this.value.stops].sort((c,f)=>c.position-f.position);let n=a[0],i=a[a.length-1];for(let c=0;c<a.length-1;c++)if(a[c].position<=r&&a[c+1].position>=r){n=a[c],i=a[c+1];break}let s,o;if(n===i||n.position===i.position)s=n.color,o=n.opacity??100;else{const c=(r-n.position)/(i.position-n.position),f=Pt(n.color),h=Pt(i.color),u=Math.round(f.r+(h.r-f.r)*c),p=Math.round(f.g+(h.g-f.g)*c),m=Math.round(f.b+(h.b-f.b)*c);s=`#${u.toString(16).padStart(2,"0")}${p.toString(16).padStart(2,"0")}${m.toString(16).padStart(2,"0")}`.toUpperCase(),o=Math.round((n.opacity??100)+((i.opacity??100)-(n.opacity??100))*c)}const l={position:Math.round(r),color:s,opacity:o};this.value.stops.push(l),this.value.stops.sort((c,f)=>c.position-f.position)}openPopover(){if(this.popoverEl&&(Qt.openInstance&&Qt.openInstance!==this&&Qt.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,Qt.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const e=this.element.getBoundingClientRect(),r=306,a=window.innerWidth,n=window.innerHeight,i=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const s=this.popoverEl.offsetHeight;let o=e.right+8,l=e.top;const c=a-e.right,f=e.left,h=r+i;c<h&&f>c+100&&(o=e.left-r-8);const u=n-e.bottom,p=e.top;p>=s+i?l=e.top-s-8:u>=s+i?l=e.bottom+8:p>u?(l=e.top-s-8,l<i&&(l=i)):(l=e.bottom+8,l+s>n-i&&(l=n-s-i)),this.popoverEl.style.left=`${o}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:o,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var e;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((e=document.activeElement)==null?void 0:e.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const r=this.element.getBoundingClientRect(),a=306,n=window.innerWidth,i=window.innerHeight,s=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let l=r.right+8,c=r.top;const f=n-r.right,h=r.left,u=a+s;f<u&&h>f+100&&(l=r.left-a-8);const p=i-r.bottom,m=r.top;m>=o+s?c=r.top-o-8:p>=o+s?c=r.bottom+8:m>p?(c=r.top-o-8,c<s&&(c=s)):(c=r.bottom+8,c+o>i-s&&(c=i-o-s)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${c}px`})}}refreshPopoverContent(){var i,s;if(!this.popoverEl)return;const e=this.popoverEl.querySelectorAll(".gradient-type-tab");e.forEach(o=>o.classList.remove("active"));const r=e[0],a=e[1];((i=this.value)==null?void 0:i.type)==="solid"?r.classList.add("active"):(a.classList.add("active"),(s=this.recentGradientRefresh)==null||s.call(this)),this.popoverEl.offsetHeight;const n=this.popoverEl.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n)}closePopover(){var e,r;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(e=this.sharedStopColorPicker)!=null&&e.getIsOpen()&&(this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null),this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const a=qt(this.value);ra.addColor(a,"gradient"),(r=this.recentGradientRefresh)==null||r.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),Qt.openInstance===this&&(Qt.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():ra.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(e){var a;e.preventDefault();const r=((a=e.clipboardData)==null?void 0:a.getData("text"))||"";this.parseAndSet(r)}handleTextInput(e){const r=e.target;this.parseAndSet(r.value)}parseAndSet(e){let r=e.trim();r&&!r.startsWith("#")&&!r.startsWith("var(")&&!r.startsWith("rgb")&&!r.startsWith("hsl")&&!r.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(r)&&(r="#"+r,this.inputEl&&(this.inputEl.value=r));const a=Nt(r);a&&this.setValue(a)}getChangePayload(){var e;if(this.value)return this.isBoundToGlobal()?((e=this.value.stops)==null?void 0:e.some(a=>a.opacity!==void 0&&a.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const e=this.getChangePayload();e!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var r,a;(r=this.onChange)==null||r.call(this,e),(a=this.detectChange)==null||a.call(this,e),this.changeDebounceTimeout=null},Qt.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};Qt.openInstance=null,Qt.CHANGE_DEBOUNCE_DELAY=150;let aa=Qt;function zr(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=t[r];e(r,a)}}function Di(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>Di(e));if(typeof t=="object"){const e={};for(const[r,a]of Object.entries(t))r!=="$id"&&(e[r]=Di(a));return e}return t}const ni=class ni{constructor(e){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.isSettingValue=!1,this.suppressOnChange=!1,this.suppressOnChange=!0,this.id=e.id||Un(),this.title=e.title,this.settings=e.settings,this.isCollapsed=e.collapsed??!1,this.isMain=e.main??!1,this.custom=e.custom??!1,this.nestingLevel=0,this.includeGetJson=e.includeGetJson??!0,this.addItemCfg=e.addItem,this.deleteItemCfg=e.deleteItem,this.dataProps=e.dataProps,this.dataPropsPath=e.dataProps||"",this.hide=e.hide??!1,Object.assign(this,e.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath(),this.propagateComponentPaths(),this.suppressOnChange=!1}propagateNestingLevel(){const e=this.nestingLevel+1;zr(this.settings,(r,a)=>{$e(a)&&(a.nestingLevel=e,a.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(e){this.nestingLevel=e,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(e){if(this.title=e,this.elementRef){const r=this.elementRef.querySelector(".setting-group-title h3");r&&(r.textContent=e)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(e){this.dataPropsPath=e,this.propagateDataPropsPath()}propagateDataPropsPath(){zr(this.settings,(e,r)=>{const a=String(e),n=this.dataPropsPath?`${this.dataPropsPath}_${a}`:a;($e(r)||dr(r)&&typeof r.setDataPropsPath=="function")&&r.setDataPropsPath(n)})}propagateComponentPaths(e=""){zr(this.settings,(r,a)=>{var i;const n=String(r);if($e(a)){const s=e?`${e} > ${a.title}`:a.title;a.propagateComponentPaths(s)}else if(dr(a)&&typeof a.setComponentPath=="function"){const s=((i=a.props)==null?void 0:i.title)||n,o=e?`${e} > ${s}`:s;a.setComponentPath(o)}})}updateNestingStyles(){this.elementRef&&(Dn(this.elementRef,this.nestingLevel),Ni(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([e,r])=>{try{if($e(r)){const a=r.getValues();r.setValue(a)}else if(typeof r.setValue=="function"){const a=r.value;a!==void 0&&r.setValue(a)}}catch(a){console.warn(`Error refreshing UI for setting ${e}:`,a)}})}removeSetting(e){var n;const r=this.settings[e];if(!r)return;if(delete this.settings[e],this.elementRef){const i=this.elementRef.querySelector(".setting-group-content");if(i){const s=Array.from(i.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const o of s){const l=o.id,c=o.getAttribute("data-setting-id");if(l&&"id"in r&&typeof r.id=="string"&&l.includes(r.id)){o.remove();break}if(c&&"id"in r&&typeof r.id=="string"&&c===r.id){o.remove();break}}}}typeof r.cleanup=="function"&&r.cleanup(),this.updateNestingStyles();const a=this.getValues();this.initialValues=a,this.suppressOnChange||(n=this.onChange)==null||n.call(this,a)}updateVisibility(){this.elementRef}updateSettings(e,r){var l;const a=(r==null?void 0:r.preserveValues)??!0,n=new Set(Object.keys(this.settings)),i=Object.keys(e),s={};a&&i.forEach(c=>{const f=this.settings[c];f&&($e(f)?s[c]=f.getValues():dr(f)?s[c]=f.value:typeof f.getValues=="function"?s[c]=f.getValues():f.value!==void 0&&(s[c]=f.value))}),n.forEach(c=>{i.includes(c)||this.removeSetting(c)}),i.forEach(c=>{var u;const f=e[c],h=this.settings[c];if(h!==f&&(h&&this.removeSetting(c),this.addSetting(c,f),a&&c in s)){const p=s[c];try{$e(f)?f.setValue(p):dr(f)?(u=f.setValue)==null||u.call(f,p):f.setValue&&f.setValue(p)}catch(m){console.warn(`Could not preserve value for setting ${c}:`,m)}}}),this.settings=e,this.propagateNestingLevel(),this.propagateDataPropsPath();const o=this.getValues();this.initialValues=o,this.suppressOnChange||(l=this.onChange)==null||l.call(this,o)}clone(){const e={};zr(this.settings,(n,i)=>{const s=String(n);typeof i.clone=="function"?e[s]=i.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),e[s]=i)});const r={title:this.title,settings:e,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},a=w0(r);return a.suppressOnChange=!0,a.initialValues=this.getValues(),a.suppressOnChange=!1,a}resetDefault(){const e=this.originalDefaultValues;this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues())}setMobileValues(e){!e||typeof e!="object"||(Object.entries(e).forEach(([r,a])=>{const n=this.settings[r];n&&($e(n)||dr(n))&&typeof n.setMobileValue=="function"&&n.setMobileValue(a)}),this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues()))}getMobileValues(e){if(e===void 0){const r={};for(const a in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,a)){const n=this.settings[a];if($e(n))r[a]=n.getMobileValues();else{const i=n;r[a]=i.mobileValue!==void 0?i.mobileValue:i.value}}return r}else{const r=this.settings[e];if(!r)return;if($e(r))return r.getMobileValues();const a=r;return a.mobileValue!==void 0?a.mobileValue:a.value}}setOnChange(e){this.onChange=e;const r=()=>{this.isHandlingChange||this.suppressOnChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const a=this.getValues(),n=this.calculateChanges(this.initialValues,a);Object.keys(n).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=a,this.suppressOnChange||e(a),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),zr(this.settings,(a,n)=>{var i;if($e(n))n.setOnChange(()=>{if(this.suppressOnChange)return;const s=this.getValues();this.initialValues=s,e(s)}),this.changeHandlers.add(()=>e(this.getValues()));else if(dr(n)){const s=()=>r();this.changeHandlers.add(s),n.setOnChange(s)}else{const s=()=>r();this.changeHandlers.add(s),(i=n.setOnChange)==null||i.call(n,s)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear(),zr(this.settings,(e,r)=>{const a=r;try{typeof a.cleanup=="function"?a.cleanup():typeof a.destroy=="function"&&a.destroy()}catch{}})}setValue(e){if(!(!e||typeof e!="object")&&!this.isSettingValue){this.isSettingValue=!0;try{Object.entries(e).forEach(([a,n])=>{let i=this.settings[a];if(!i&&this.addItemCfg&&a.startsWith(this.addItemCfg.keyPrefix)){const s=a.slice(this.addItemCfg.keyPrefix.length),o=Number(s);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);Mi(l)&&(this.addSetting(a,l),i=l)}}i&&($e(i)||dr(i))&&typeof i.setValue=="function"&&i.setValue(n)});const r=this.getValues();this.initialValues=r,this.onChange&&!this.suppressOnChange&&this.onChange(r)}finally{this.isSettingValue=!1}}}wireChild(e){var a;const r=()=>{var i;if(this.suppressOnChange)return;const n=this.getValues();this.initialValues=n,(i=this.onChange)==null||i.call(this,n),this.updateVisibility()};$e(e)?e.setOnChange(()=>r()):dr(e)?e.setOnChange(()=>r()):(a=e.setOnChange)==null||a.call(e,()=>r())}addSetting(e,r){var n,i;if(this.settings[e]=r,this.wireChild(r),this.elementRef){const s=this.elementRef.querySelector(".setting-group-content");if(s){const o=s.querySelector(".setting-group-empty");o&&o.remove(),$e(r)&&typeof r.setNestingLevel=="function"&&r.setNestingLevel(this.nestingLevel+1);const l=r.draw(),c=this.deleteItemCfg??this.addItemCfg;if(c){const u=c.keyPrefix??((n=this.addItemCfg)==null?void 0:n.keyPrefix);u&&e.startsWith(u)&&this.addDeleteButtonToElement(l,e)}const f=s.querySelector(".sg-add-button-bottom");f?s.insertBefore(l,f):s.appendChild(l),Ys.trackElement(l),Dn(l,this.nestingLevel+1),Ni(l,this.nestingLevel+1);const h=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=h,this.updateNestingStyles()}}const a=this.getValues();this.initialValues=a,this.suppressOnChange||(i=this.onChange)==null||i.call(this,a)}addDeleteButtonToElement(e,r,a){let n=null;try{n=e.querySelector(":scope > .setting-group-title")}catch{n=null}if(!n){const c=Array.from(e.querySelectorAll(".setting-group-title"));for(const f of c)if(f.closest(".setting-group")===e){n=f;break}n||(n=c[0]??null)}if(!n)return;const i=n.querySelector(".actions-section");if(!i)return;const s=document.createElement("button");s.type="button",s.className="sg-delete-button",a?a.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,s.title="Delete",s.style.cssText=`
27
27
  background: none;
28
28
  border: none;
29
29
  cursor: pointer;
@@ -104,7 +104,7 @@
104
104
  xmlns="http://www.w3.org/2000/svg">
105
105
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
106
106
  strokeWidth="1.5" strokeLinecap="round"/>
107
- </svg>`;f.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,f.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const p=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),m=this.addItemCfg.createItem(p);if(Mi(m)){const d=`${this.addItemCfg.keyPrefix}${p}`;this.addSetting(d,m)}}),o.appendChild(f)}return r.appendChild(a),r.appendChild(i),e.appendChild(r),e.appendChild(o),this.elementRef=e,Ys.trackElement(e),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),e}collapse(){if(!this.elementRef||this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!0,e.classList.add("collapsed"),r.classList.add("rotated"),a.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!1,e.classList.remove("collapsed"),r.classList.remove("rotated"),a.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(e){try{const r=JSON.parse(e);let a=r;const n=Object.keys(this.settings),i=Object.keys(r);if(!n.some(o=>i.includes(o))&&i.length===1){const o=i[0];a=r[o]}this.setValue(a)}catch(r){throw console.error("Invalid JSON provided to setJson:",r),new Error("Invalid JSON format")}}};ni.hiddenElements=new Set;let ir=ni;function vf(t){return new ts(t)}class ts extends ir{constructor(e){super(e);const r=Object.keys(this.settings)[0];this.activeTabId=r||""}getActiveTabId(){return this.activeTabId}switchToTab(e){if(!this.settings[e]||this.activeTabId===e)return;this.activeTabId=e,this.updateTabUI();const r=this.getValues();this.initialValues=r}getValues(e){return e!==void 0?super.getValues(e):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(r=>{r.getAttribute("data-tab-id")===this.activeTabId?r.classList.add("active"):r.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([r,a])=>{r===this.activeTabId?a.classList.add("active"):a.classList.remove("active")})}draw(){const e=super.draw();e.classList.add("tabs-settings-container");const r=e.querySelector(".setting-group-content");if(!r)return e;r.innerHTML="";const a=document.createElement("div");a.className="tabs-title";const n=document.createElement("h3");n.textContent=this.title,a.appendChild(n);const i=document.createElement("div");i.className="tabs-header",this.tabsContainer=i;const s=document.createElement("div");if(s.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const c=document.createElement("button");c.className="tab-button",c.type="button",c.setAttribute("data-tab-id",o),c.textContent=o,c.addEventListener("click",()=>this.switchToTab(o)),i.appendChild(c);const f=document.createElement("div");f.className="tab-panel",this.contentContainers[o]=f;const h=this.settings[o];h&&($e(h)&&typeof h.setNestingLevel=="function"&&h.setNestingLevel(this.getNestingLevel()+1),f.appendChild(h.draw())),s.appendChild(f),l===0&&!this.activeTabId&&(this.activeTabId=o)}),r.appendChild(a),r.appendChild(i),r.appendChild(s),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),e}}function w0(t){return new ir(t)}function Ef(t){return t}class C0 extends Le{constructor(e={}){super(e),this.inputType="text",e.onChange&&this.setOnChange(e.onChange)}draw(){const e=r=>{this.props.maxLength!==void 0&&(r.maxLength=this.props.maxLength),this.props.className&&r.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e})}}const wf="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' strokeLinecap='round' strokeLinejoin='round'/></svg>";class Zt extends C0{constructor(e){super({...e,icon:e.icon||wf,title:e.title||"Color",default:e.default?Zt.normalizeColorValue(e.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=e.detectChange}static normalizeColorValue(e){return e.startsWith("var(--")?e:e.startsWith("#")?Zt.normalizeHexValue(e):e.includes(",")?Zt.rgbToHexStatic(e):Zt.normalizeHexValue(e)}static normalizeHexValue(e){return e=e.replace("#",""),e.length===3&&(e=e.split("").map(r=>r+r).join("")),e.length!==6?(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(e)?`#${e.toLowerCase()}`:(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000")}static rgbToHexStatic(e){const r=e.split(",").map(f=>parseInt(f.trim()));if(r.length!==3||r.some(isNaN))return console.warn(`Invalid RGB value "${e}", using default "#000000"`),"#000000";const[a,n,i]=r,s=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,i)),c=f=>{const h=f.toString(16);return h.length===1?"0"+h:h};return`#${c(s)}${c(o)}${c(l)}`}setValue(e){if(e===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof e=="string"){const r=Zt.normalizeColorValue(e);this.value=r,this.colorInputEl&&(this.colorInputEl.value=r),this.textInputEl&&(this.textInputEl.value=r),this.onChange&&this.onChange(r),this.props.detectChange&&this.props.detectChange(r)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(e){e=e.replace("#","");const r=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return`${r}, ${a}, ${n}`}draw(){const e=document.createElement("div");if(e.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const d=document.createElement("div");if(d.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,d.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,d.appendChild(g)}e.appendChild(d)}const r=document.createElement("div");r.className="color-input-wrapper";const a=document.createElement("div");a.className="color-setting-tabs",a.style.display="flex",a.style.marginBottom="8px",a.style.gap="4px";const n=document.createElement("button");n.className="color-tab active",n.textContent="Solid";const i=document.createElement("button");i.className="color-tab",i.textContent="Global",a.appendChild(n),a.appendChild(i);const s=document.createElement("div");s.className="color-content-solid";const o=document.createElement("div");o.className="color-content-global",o.style.display="none",o.style.display="grid",o.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",o.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),o.innerHTML="",!Le){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",o.appendChild(g);return}const d=Le.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",d),!d||Object.keys(d).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.gridColumn="1 / -1",g.style.fontSize="12px",g.style.color="#666",o.appendChild(g);return}Object.entries(d).forEach(([g,x])=>{const w=document.createElement("button");w.className="global-color-btn",w.title=g,w.style.width="30px",w.style.height="30px",w.style.borderRadius="50%",w.style.border="1px solid #ddd",w.style.backgroundColor=x,w.style.cursor="pointer",this.value===`var(--${g})`&&(w.style.border="2px solid #2196f3"),w.addEventListener("click",v=>{var N,A;v.preventDefault();const F=`var(--${g})`;this.value=F,(N=this.onChange)==null||N.call(this,F),(A=this.detectChange)==null||A.call(this,F),Array.from(o.children).forEach(y=>{y.style.border="1px solid #ddd"}),w.style.border="2px solid #2196f3",h.style.backgroundColor=x}),o.appendChild(w)})}catch(d){console.error("ColorSetting: Error in renderGlobalOptions",d),o.innerHTML="Error loading global options"}};l(),n.addEventListener("click",d=>{d.preventDefault(),n.classList.add("active"),i.classList.remove("active"),s.style.display="flex",o.style.display="none",this.value&&this.value.startsWith("var(--")}),i.addEventListener("click",d=>{d.preventDefault(),i.classList.add("active"),n.classList.remove("active"),s.style.display="none",o.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?i.click():n.click();const c=d=>{const g=d.value.trim();if(!g)return r.classList.remove("error"),!0;const w=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return w?r.classList.remove("error"):r.classList.add("error"),w},f=document.createElement("input");f.type="color",f.className="color-picker",f.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",f.setAttribute("aria-label","Choose color"),f.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&f.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=f;const h=document.createElement("div");h.className="color-preview";let u=this.value||"#000000";if(u.startsWith("var(--")){const d=u.replace("var(--","").replace(")","");u=(Le.GlobalVariables||{})[d]||"#000000"}h.style.backgroundColor=u;const p=document.createElement("input");p.type="text",p.className="color-text-input",p.value=this.value||"",p.placeholder="#000000",p.setAttribute("pattern","#[0-9A-Fa-f]{6}"),p.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),p.setAttribute("aria-label","Hex color value"),p.setAttribute("maxlength","7"),this.getDataPropsPath()&&p.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=p;const m=d=>{var x,w;let g=d.trim();if(g&&!g.startsWith("#")&&!g.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(g)&&(g="#"+g,this.textInputEl&&(this.textInputEl.value=g)),this.textInputEl&&c(this.textInputEl)){const v=Zt.normalizeColorValue(g);this.value=v,(x=this.onChange)==null||x.call(this,v),(w=this.detectChange)==null||w.call(this,v),this.colorInputEl&&(this.colorInputEl.value=v),h.style.backgroundColor=v}};return this.textInputEl.addEventListener("input",d=>{const g=d.target.value;m(g)}),this.textInputEl.addEventListener("paste",d=>{var x;d.preventDefault();const g=((x=d.clipboardData)==null?void 0:x.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),m(g))}),this.textInputEl.addEventListener("keydown",d=>{var g,x,w;d.key==="Enter"&&(d.preventDefault(),m(((g=this.textInputEl)==null?void 0:g.value)||""),(x=this.textInputEl)==null||x.blur()),d.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(w=this.textInputEl)==null||w.blur(),r.classList.remove("error"))}),this.colorInputEl.addEventListener("input",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x,r.classList.remove("error")}),this.colorInputEl.addEventListener("change",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x}),s.appendChild(f),s.appendChild(h),s.appendChild(p),r.appendChild(a),r.appendChild(s),r.appendChild(o),e.appendChild(r),this.element=e,e}getElement(){return this.element}getNormalizedValue(){return this.value?Zt.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Cf=`
107
+ </svg>`;f.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,f.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const p=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),m=this.addItemCfg.createItem(p);if(Mi(m)){const d=`${this.addItemCfg.keyPrefix}${p}`;this.addSetting(d,m)}}),o.appendChild(f)}return r.appendChild(a),r.appendChild(i),e.appendChild(r),e.appendChild(o),this.elementRef=e,Ys.trackElement(e),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),e}collapse(){if(!this.elementRef||this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!0,e.classList.add("collapsed"),r.classList.add("rotated"),a.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!1,e.classList.remove("collapsed"),r.classList.remove("rotated"),a.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(e){try{const r=JSON.parse(e);let a=r;const n=Object.keys(this.settings),i=Object.keys(r);if(!n.some(o=>i.includes(o))&&i.length===1){const o=i[0];a=r[o]}this.setValue(a)}catch(r){throw console.error("Invalid JSON provided to setJson:",r),new Error("Invalid JSON format")}}};ni.hiddenElements=new Set;let ir=ni;function vf(t){return new ts(t)}class ts extends ir{constructor(e){super(e);const r=Object.keys(this.settings)[0];this.activeTabId=r||""}getActiveTabId(){return this.activeTabId}switchToTab(e){if(!this.settings[e]||this.activeTabId===e)return;this.activeTabId=e,this.updateTabUI();const r=this.getValues();this.initialValues=r}getValues(e){return e!==void 0?super.getValues(e):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(r=>{r.getAttribute("data-tab-id")===this.activeTabId?r.classList.add("active"):r.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([r,a])=>{r===this.activeTabId?a.classList.add("active"):a.classList.remove("active")})}draw(){const e=super.draw();e.classList.add("tabs-settings-container");const r=e.querySelector(".setting-group-content");if(!r)return e;r.innerHTML="";const a=document.createElement("div");a.className="tabs-title";const n=document.createElement("h3");n.textContent=this.title,a.appendChild(n);const i=document.createElement("div");i.className="tabs-header",this.tabsContainer=i;const s=document.createElement("div");if(s.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const c=document.createElement("button");c.className="tab-button",c.type="button",c.setAttribute("data-tab-id",o),c.textContent=o,c.addEventListener("click",()=>this.switchToTab(o)),i.appendChild(c);const f=document.createElement("div");f.className="tab-panel",this.contentContainers[o]=f;const h=this.settings[o];h&&($e(h)&&typeof h.setNestingLevel=="function"&&h.setNestingLevel(this.getNestingLevel()+1),f.appendChild(h.draw())),s.appendChild(f),l===0&&!this.activeTabId&&(this.activeTabId=o)}),r.appendChild(a),r.appendChild(i),r.appendChild(s),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),e}}function w0(t){return new ir(t)}function Ef(t){return t}class C0 extends Le{constructor(e={}){super(e),this.inputType="text",e.onChange&&this.setOnChange(e.onChange)}draw(){const e=r=>{this.props.maxLength!==void 0&&(r.maxLength=this.props.maxLength),this.props.className&&r.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e})}}const wf="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' strokeLinecap='round' strokeLinejoin='round'/></svg>";class Zt extends C0{constructor(e){super({...e,icon:e.icon||wf,title:e.title||"Color",default:e.default?Zt.normalizeColorValue(e.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=e.detectChange}static normalizeColorValue(e){return e.startsWith("var(--")?e:e.startsWith("#")?Zt.normalizeHexValue(e):e.includes(",")?Zt.rgbToHexStatic(e):Zt.normalizeHexValue(e)}static normalizeHexValue(e){return e=e.replace("#",""),e.length===3&&(e=e.split("").map(r=>r+r).join("")),e.length!==6?(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(e)?`#${e.toLowerCase()}`:(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000")}static rgbToHexStatic(e){const r=e.split(",").map(f=>parseInt(f.trim()));if(r.length!==3||r.some(isNaN))return console.warn(`Invalid RGB value "${e}", using default "#000000"`),"#000000";const[a,n,i]=r,s=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,i)),c=f=>{const h=f.toString(16);return h.length===1?"0"+h:h};return`#${c(s)}${c(o)}${c(l)}`}setValue(e){if(e===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof e=="string"){const r=Zt.normalizeColorValue(e);this.value=r,this.colorInputEl&&(this.colorInputEl.value=r),this.textInputEl&&(this.textInputEl.value=r),this.onChange&&this.onChange(r),this.props.detectChange&&this.props.detectChange(r)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(e){e=e.replace("#","");const r=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return`${r}, ${a}, ${n}`}draw(){const e=document.createElement("div");if(e.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const d=document.createElement("div");if(d.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,d.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,d.appendChild(g)}e.appendChild(d)}const r=document.createElement("div");r.className="color-input-wrapper";const a=document.createElement("div");a.className="color-setting-tabs",a.style.display="flex",a.style.marginBottom="8px",a.style.gap="4px";const n=document.createElement("button");n.className="color-tab active",n.textContent="Solid";const i=document.createElement("button");i.className="color-tab",i.textContent="Global",a.appendChild(n),a.appendChild(i);const s=document.createElement("div");s.className="color-content-solid";const o=document.createElement("div");o.className="color-content-global",o.style.display="none",o.style.display="grid",o.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",o.style.gap="8px";const l=()=>{try{if(o.innerHTML="",!Le){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",o.appendChild(g);return}const d=Le.GlobalVariables||{};if(!d||Object.keys(d).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.gridColumn="1 / -1",g.style.fontSize="12px",g.style.color="#666",o.appendChild(g);return}Object.entries(d).forEach(([g,x])=>{const w=document.createElement("button");w.className="global-color-btn",w.title=g,w.style.width="30px",w.style.height="30px",w.style.borderRadius="50%",w.style.border="1px solid #ddd",w.style.backgroundColor=x,w.style.cursor="pointer",this.value===`var(--${g})`&&(w.style.border="2px solid #2196f3"),w.addEventListener("click",v=>{var N,A;v.preventDefault();const F=`var(--${g})`;this.value=F,(N=this.onChange)==null||N.call(this,F),(A=this.detectChange)==null||A.call(this,F),Array.from(o.children).forEach(y=>{y.style.border="1px solid #ddd"}),w.style.border="2px solid #2196f3",h.style.backgroundColor=x}),o.appendChild(w)})}catch(d){console.error("ColorSetting: Error in renderGlobalOptions",d),o.innerHTML="Error loading global options"}};l(),n.addEventListener("click",d=>{d.preventDefault(),n.classList.add("active"),i.classList.remove("active"),s.style.display="flex",o.style.display="none",this.value&&this.value.startsWith("var(--")}),i.addEventListener("click",d=>{d.preventDefault(),i.classList.add("active"),n.classList.remove("active"),s.style.display="none",o.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?i.click():n.click();const c=d=>{const g=d.value.trim();if(!g)return r.classList.remove("error"),!0;const w=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return w?r.classList.remove("error"):r.classList.add("error"),w},f=document.createElement("input");f.type="color",f.className="color-picker",f.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",f.setAttribute("aria-label","Choose color"),f.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&f.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=f;const h=document.createElement("div");h.className="color-preview";let u=this.value||"#000000";if(u.startsWith("var(--")){const d=u.replace("var(--","").replace(")","");u=(Le.GlobalVariables||{})[d]||"#000000"}h.style.backgroundColor=u;const p=document.createElement("input");p.type="text",p.className="color-text-input",p.value=this.value||"",p.placeholder="#000000",p.setAttribute("pattern","#[0-9A-Fa-f]{6}"),p.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),p.setAttribute("aria-label","Hex color value"),p.setAttribute("maxlength","7"),this.getDataPropsPath()&&p.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=p;const m=d=>{var x,w;let g=d.trim();if(g&&!g.startsWith("#")&&!g.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(g)&&(g="#"+g,this.textInputEl&&(this.textInputEl.value=g)),this.textInputEl&&c(this.textInputEl)){const v=Zt.normalizeColorValue(g);this.value=v,(x=this.onChange)==null||x.call(this,v),(w=this.detectChange)==null||w.call(this,v),this.colorInputEl&&(this.colorInputEl.value=v),h.style.backgroundColor=v}};return this.textInputEl.addEventListener("input",d=>{const g=d.target.value;m(g)}),this.textInputEl.addEventListener("paste",d=>{var x;d.preventDefault();const g=((x=d.clipboardData)==null?void 0:x.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),m(g))}),this.textInputEl.addEventListener("keydown",d=>{var g,x,w;d.key==="Enter"&&(d.preventDefault(),m(((g=this.textInputEl)==null?void 0:g.value)||""),(x=this.textInputEl)==null||x.blur()),d.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(w=this.textInputEl)==null||w.blur(),r.classList.remove("error"))}),this.colorInputEl.addEventListener("input",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x,r.classList.remove("error")}),this.colorInputEl.addEventListener("change",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x}),s.appendChild(f),s.appendChild(h),s.appendChild(p),r.appendChild(a),r.appendChild(s),r.appendChild(o),e.appendChild(r),this.element=e,e}getElement(){return this.element}getNormalizedValue(){return this.value?Zt.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Cf=`
108
108
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
109
109
  <path d="M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z" stroke="#667085" strokeLinecap="round" strokeLinejoin="round"/>
110
110
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" strokeWidth="0.5" strokeLinecap="round" strokeLinejoin="round" opacity="0.5"/>
@@ -138,7 +138,7 @@
138
138
  <path d="M13.5 15C14.1989 15 14.5484 15 14.824 14.8858C15.1916 14.7336 15.4836 14.4416 15.6358 14.074C15.75 13.7984 15.75 13.4489 15.75 12.75C15.75 12.0511 15.75 11.7016 15.6358 11.426C15.4836 11.0584 15.1916 10.7664 14.824 10.6142C14.5484 10.5 14.1989 10.5 13.5 10.5H4.5C3.80109 10.5 3.45163 10.5 3.17598 10.6142C2.80843 10.7664 2.51642 11.0584 2.36418 11.426C2.25 11.7016 2.25 12.0511 2.25 12.75C2.25 13.4489 2.25 13.7984 2.36418 14.074C2.51642 14.4416 2.80843 14.7336 3.17597 14.8858C3.45163 15 3.80109 15 4.5 15L13.5 15Z"
139
139
  stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
140
140
  </svg>
141
- `}].forEach(i=>{const s=document.createElement("button");s.className="align-option-button",s.innerHTML=i.icon,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${i.name}`),this.value===i.name&&s.classList.add("selected"),s.addEventListener("click",()=>{var o;a.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),s.classList.add("selected"),this.value=i.name,(o=this.onChange)==null||o.call(this,this.value)}),a.appendChild(s)}),e.appendChild(a),e}}class Tf extends Le{constructor(e){super(e),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const e=document.createElement("button");e.className="button-setting "+(this.props.className||""),e.textContent=this.props.label,e.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)",this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath());const r=this.props.backgroundColor||"rgba(0,0,0,0)",a=this.props.textColor||"black";e.style.backgroundColor=r,e.style.color=a;let n=r;const i=r.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(i){let o=+i[1],l=+i[2],c=+i[3],f=+i[4];f>=1?(o=Math.round(o*.9),l=Math.round(l*.9),c=Math.round(c*.9)):f=Math.min(1,f+.12),n=`rgba(${o},${l},${c},${f})`}e.addEventListener("mouseenter",()=>{console.log("hoverBg",n),e.style.setProperty("background-color",n,"important")}),e.addEventListener("mouseleave",()=>{e.style.setProperty("background-color",r,"important")}),e.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const s=document.createElement("div");return s.className="button-setting-wrapper "+(this.props.wrapperClassName||""),s.appendChild(e),s}}class Sf extends Le{constructor(e={}){super(e),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const r=e.width||0,a=e.height||0;this.value||(this.value={width:r,height:a}),this.minWidth=e.minWidth??0,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight??0,this.maxHeight=e.maxHeight,this.locked=e.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new sr({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:bf}),this.heightSetting=new sr({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:Ff}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minWidth,e),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth),this.isUpdating=!0;try{let r=e,a=this.value.height;this.locked&&this.aspectRatio>0&&(a=Math.round(r/this.aspectRatio),this.maxHeight&&a>this.maxHeight&&(a=this.maxHeight,r=Math.round(a*this.aspectRatio),this.maxWidth&&r>this.maxWidth&&(r=this.maxWidth,a>0&&(this.aspectRatio=r/a)))),this.value={width:r,height:a},this.widthSetting.setValue(r),this.locked&&this.heightSetting.setValue(a),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minHeight,e),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.isUpdating=!0;try{let r=e,a=this.value.width;this.locked&&this.aspectRatio>0&&(a=Math.round(r*this.aspectRatio),this.maxWidth&&a>this.maxWidth&&(a=this.maxWidth,r=Math.round(a/this.aspectRatio),this.maxHeight&&r>this.maxHeight&&(r=this.maxHeight,r>0&&(this.aspectRatio=a/r)))),this.value={width:a,height:r},this.locked&&this.widthSetting.setValue(a),this.heightSetting.setValue(r),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(e){if(this.locked=!this.locked,this.locked&&this.value){const{width:a,height:n}=this.value;n>0&&(this.aspectRatio=a/n)}e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const r=e.closest(".dimension-setting-container");r&&(this.locked?r.classList.add("aspect-locked"):r.classList.remove("aspect-locked")),e.style.transform="scale(0.9)",setTimeout(()=>{e.style.transform="scale(1)"},100)}getLockSVG(e){return e?`
141
+ `}].forEach(i=>{const s=document.createElement("button");s.className="align-option-button",s.innerHTML=i.icon,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${i.name}`),this.value===i.name&&s.classList.add("selected"),s.addEventListener("click",()=>{var o;a.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),s.classList.add("selected"),this.value=i.name,(o=this.onChange)==null||o.call(this,this.value)}),a.appendChild(s)}),e.appendChild(a),e}}class Tf extends Le{constructor(e){super(e),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const e=document.createElement("button");e.className="button-setting "+(this.props.className||""),e.textContent=this.props.label,e.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)",this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath());const r=this.props.backgroundColor||"rgba(0,0,0,0)",a=this.props.textColor||"black";e.style.backgroundColor=r,e.style.color=a;let n=r;const i=r.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(i){let o=+i[1],l=+i[2],c=+i[3],f=+i[4];f>=1?(o=Math.round(o*.9),l=Math.round(l*.9),c=Math.round(c*.9)):f=Math.min(1,f+.12),n=`rgba(${o},${l},${c},${f})`}e.addEventListener("mouseenter",()=>{e.style.setProperty("background-color",n,"important")}),e.addEventListener("mouseleave",()=>{e.style.setProperty("background-color",r,"important")}),e.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const s=document.createElement("div");return s.className="button-setting-wrapper "+(this.props.wrapperClassName||""),s.appendChild(e),s}}class Sf extends Le{constructor(e={}){super(e),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const r=e.width||0,a=e.height||0;this.value||(this.value={width:r,height:a}),this.minWidth=e.minWidth??0,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight??0,this.maxHeight=e.maxHeight,this.locked=e.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new sr({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:bf}),this.heightSetting=new sr({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:Ff}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minWidth,e),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth),this.isUpdating=!0;try{let r=e,a=this.value.height;this.locked&&this.aspectRatio>0&&(a=Math.round(r/this.aspectRatio),this.maxHeight&&a>this.maxHeight&&(a=this.maxHeight,r=Math.round(a*this.aspectRatio),this.maxWidth&&r>this.maxWidth&&(r=this.maxWidth,a>0&&(this.aspectRatio=r/a)))),this.value={width:r,height:a},this.widthSetting.setValue(r),this.locked&&this.heightSetting.setValue(a),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minHeight,e),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.isUpdating=!0;try{let r=e,a=this.value.width;this.locked&&this.aspectRatio>0&&(a=Math.round(r*this.aspectRatio),this.maxWidth&&a>this.maxWidth&&(a=this.maxWidth,r=Math.round(a/this.aspectRatio),this.maxHeight&&r>this.maxHeight&&(r=this.maxHeight,r>0&&(this.aspectRatio=a/r)))),this.value={width:a,height:r},this.locked&&this.widthSetting.setValue(a),this.heightSetting.setValue(r),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(e){if(this.locked=!this.locked,this.locked&&this.value){const{width:a,height:n}=this.value;n>0&&(this.aspectRatio=a/n)}e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const r=e.closest(".dimension-setting-container");r&&(this.locked?r.classList.add("aspect-locked"):r.classList.remove("aspect-locked")),e.style.transform="scale(0.9)",setTimeout(()=>{e.style.transform="scale(1)"},100)}getLockSVG(e){return e?`
142
142
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
143
143
  <path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25C6.00786 1.25 6.84859 1.96573 7.04162 2.91667M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
144
144
  </svg>`:`
@@ -189,14 +189,7 @@ const lt = class lt {
189
189
  setComponentPath(e) {
190
190
  }
191
191
  setValue(e) {
192
- console.log(
193
- "📤 [setValue]",
194
- this.title || this.id,
195
- ":",
196
- this.value,
197
- "→",
198
- e
199
- ), this.value = e, this.inputEl && (this.inputEl.value = String(e)), this.onChange && this.onChange(e), this.props.detectChange && this.props.detectChange(e);
192
+ this.value = e, this.inputEl && (this.inputEl.value = String(e)), this.onChange && this.onChange(e), this.props.detectChange && this.props.detectChange(e);
200
193
  }
201
194
  clone() {
202
195
  const e = this.constructor, r = Un(this.props), a = new e(r);
@@ -1955,10 +1948,7 @@ function Oi(t) {
1955
1948
  const ai = class ai {
1956
1949
  constructor(e) {
1957
1950
  this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastChangeTime = 0, this.handleBlur = () => {
1958
- }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.isSettingValue = !1, this.suppressOnChange = !1, console.log(
1959
- "🔨 [SettingsGroup Created]",
1960
- e.title || "Unnamed Group"
1961
- ), this.suppressOnChange = !0, this.id = e.id || Vn(), this.title = e.title, this.settings = e.settings, this.isCollapsed = e.collapsed ?? !1, this.isMain = e.main ?? !1, this.custom = e.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = e.includeGetJson ?? !0, this.addItemCfg = e.addItem, this.deleteItemCfg = e.deleteItem, this.dataProps = e.dataProps, this.dataPropsPath = e.dataProps || "", this.hide = e.hide ?? !1, Object.assign(this, e.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath(), this.propagateComponentPaths(), this.suppressOnChange = !1;
1951
+ }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.isSettingValue = !1, this.suppressOnChange = !1, this.suppressOnChange = !0, this.id = e.id || Vn(), this.title = e.title, this.settings = e.settings, this.isCollapsed = e.collapsed ?? !1, this.isMain = e.main ?? !1, this.custom = e.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = e.includeGetJson ?? !0, this.addItemCfg = e.addItem, this.deleteItemCfg = e.deleteItem, this.dataProps = e.dataProps, this.dataPropsPath = e.dataProps || "", this.hide = e.hide ?? !1, Object.assign(this, e.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath(), this.propagateComponentPaths(), this.suppressOnChange = !1;
1962
1952
  }
1963
1953
  propagateNestingLevel() {
1964
1954
  const e = this.nestingLevel + 1;
@@ -2758,14 +2748,14 @@ class lr extends df {
2758
2748
  o.className = "color-content-global", o.style.display = "none", o.style.display = "grid", o.style.gridTemplateColumns = "repeat(auto-fill, minmax(30px, 1fr))", o.style.gap = "8px";
2759
2749
  const l = () => {
2760
2750
  try {
2761
- if (console.log("ColorSetting: renderGlobalOptions called"), o.innerHTML = "", !Le) {
2751
+ if (o.innerHTML = "", !Le) {
2762
2752
  console.error("ColorSetting: Setting class is undefined");
2763
2753
  const g = document.createElement("div");
2764
2754
  g.textContent = "Error: System error (Setting undefined)", o.appendChild(g);
2765
2755
  return;
2766
2756
  }
2767
2757
  const d = Le.GlobalVariables || {};
2768
- if (console.log("ColorSetting: GlobalVariables:", d), !d || Object.keys(d).length === 0) {
2758
+ if (!d || Object.keys(d).length === 0) {
2769
2759
  const g = document.createElement("div");
2770
2760
  g.textContent = "No global colors defined", g.style.gridColumn = "1 / -1", g.style.fontSize = "12px", g.style.color = "#666", o.appendChild(g);
2771
2761
  return;
@@ -3299,7 +3289,7 @@ class O3 extends Le {
3299
3289
  f >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), c = Math.round(c * 0.9)) : f = Math.min(1, f + 0.12), n = `rgba(${o},${l},${c},${f})`;
3300
3290
  }
3301
3291
  e.addEventListener("mouseenter", () => {
3302
- console.log("hoverBg", n), e.style.setProperty("background-color", n, "important");
3292
+ e.style.setProperty("background-color", n, "important");
3303
3293
  }), e.addEventListener("mouseleave", () => {
3304
3294
  e.style.setProperty("background-color", r, "important");
3305
3295
  }), e.addEventListener("click", () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "builder-settings-types",
3
3
  "description": "builder settings",
4
- "version": "0.0.406",
4
+ "version": "0.0.407",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",