builder-settings-types 0.0.379 → 0.0.380

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 Rt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let St=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=Rt[e[c]&63];return t};function Ft(c){let t=0,e=c.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==c&&t++,e=e.parentElement;return t}function Q(c,t){const e=Math.min(Math.max(t,0),5);c.setAttribute("data-nesting-level",e.toString()),e>0?c.style.setProperty("--visual-indent",`${e*2}px`):(c.style.removeProperty("--visual-indent"),c.style.marginLeft="")}function ct(c,t=0){c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Q(s,n),ct(s,n)})}const Ut={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class zt{constructor(t={}){this.observedElements=new Set,this.config={...Ut,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=Ft(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const Ct=new zt;function it(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(c instanceof Array)return c.map(t=>it(t));if(typeof c=="object"){const t={};for(const e in c)Object.prototype.hasOwnProperty.call(c,e)&&(t[e]=it(c[e]));return t}return c}function Wt(c){switch(c){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 S=class S{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||St(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,S.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,S.DefaultLanguage=t}static CurrentLanguage(t){return t!==void 0&&(S.currentLanguage=t,S.currentLanguageExplicitlySet=!0,S.DefaultLanguage||S.SetDefaultLanguage(t),S.languageChangeCallbacks.forEach(e=>e(t))),S.currentLanguage||S.DefaultLanguage}static HasExplicitCurrentLanguage(){return S.currentLanguageExplicitlySet}static onLanguageChange(t){return S.languageChangeCallbacks.add(t),()=>{S.languageChangeCallbacks.delete(t)}}static SetGlobalVariables(t){S.GlobalVariables={...S.GlobalVariables,...t}}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=it(this.props),i=new t(e);return i.value=it(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||Wt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}};S.currentLanguageExplicitlySet=!1,S.languageChangeCallbacks=new Set,S.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},S.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let w=S;function A(c){return c instanceof w}function M(c){return c instanceof H}function ht(c){return A(c)||M(c)}const gt=(c,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=d=>{if(d.target.closest("button"))return;i=!0,s=d.clientX,n=d.clientY;const p=t.getBoundingClientRect();o=p.left,a=p.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",h),document.body.style.userSelect="none"},r=d=>{if(!i)return;const p=d.clientX-s,u=d.clientY-n,C=window.innerWidth,m=window.innerHeight,g=t.offsetWidth,f=t.offsetHeight;let v=o+p,y=a+u;v=Math.max(8,Math.min(C-g-8,v)),y=Math.max(8,Math.min(m-f-8,y)),t.style.left=`${v}px`,t.style.top=`${y}px`,e==null||e(v,y)},h=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",h),document.body.style.userSelect=""};c.addEventListener("mousedown",l)},z=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},tt=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,N=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},Z=c=>{const{r:t,g:e,b:i}=N(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let h=0;r!==0&&(a===s?h=(n-o)/r%6:a===n?h=(o-s)/r+2:h=(s-n)/r+4),h<0&&(h+=6);const d=a===0?0:r/a,p=a;return{h:h*60,s:d,v:p}},J=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),tt(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},It=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},dt=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},pt=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=N(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=dt(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=dt(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=z(c);if(i){const{r:s,g:n,b:o}=N(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},jt=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),Nt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),_t=c=>{if(typeof document>"u")return Nt(c)||!!z(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Tt=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:tt(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:tt(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=dt(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:tt(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:z(t)||t,position:0,opacity:100}},yt=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},Et=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},qt=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||jt(t)},bt=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&Nt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Tt(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},G=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},O=c=>{const t=c.replace(/;$/,"").trim();if(_t(t)){const s=Tt(t);return G({type:"solid",angle:0,stops:[s]})}const e=Et(t,"linear-gradient");if(e){const s=yt(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"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}[a]??90,o=s.slice(1));const l=bt(o);return l.length?G({type:"linear",angle:n,stops:l}):null}const i=Et(t,"radial-gradient");if(i){const s=yt(i),n=s[0]&&!qt(s[0])?s.slice(1):s,o=bt(n);return o.length?G({type:"radial",angle:0,stops:o}):null}return null},T=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.color;if(i.startsWith("var(--"))return i;const s=e.opacity??100,n=i.replace("#",""),o=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${n}${o}`}const t=c.stops.map(e=>`${pt(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},Zt=c=>Math.round(c/100*255).toString(16).toUpperCase().padStart(2,"0"),et=c=>{if(c.type==="solid"){const t=c.stops[0];if(t){const e=t.color;if(e.startsWith("var(--"))return e.replace("var(--","").replace(")","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");e.toUpperCase();const i=t.opacity??100;if(i===100)return e;{const s=Zt(i);return`${e}${s}`}}return"#000000"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},Y=class Y{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=z(s);n||O(s)&&(n=s),n&&(e.has(n)||(e.add(n),i.push(n)))}),i.slice(0,this.MAX_COLORS)}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);if(Array.isArray(i))this.colors.solid=this.normalizeList(i);else if(i&&typeof i=="object"){const s=i;s.solid&&(this.colors.solid=this.normalizeList(s.solid)),s.gradient&&(this.colors.gradient=this.normalizeList(s.gradient))}}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){if(t==="all"){const e=this.list("solid"),i=this.list("gradient"),s=[],n=Math.max(e.length,i.length);for(let o=0;o<n;o++)o<e.length&&s.push(e[o]),o<i.length&&s.push(i[o]);return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=z(t),s="solid";if(i)s="solid";else{const l=O(t);l&&(i=t,s=l.type==="solid"?"solid":"gradient")}if(!i)return;const n=e==="all"?s:e,o=this.list(n),a=o.indexOf(i);a!==-1&&o.splice(a,1),o.unshift(i),o.length>this.MAX_COLORS&&(o.length=this.MAX_COLORS),this.persist()}};Y.STORAGE_KEY="settingsLib_recentColors",Y.MAX_COLORS=18,Y.colors=null;let W=Y;const mt=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used";const s=document.createElement("div");s.className="color-picker-tooltip",s.style.display="none",e.appendChild(s);const n=()=>{s.style.display="none"},o=(h,d)=>{const p=h.getBoundingClientRect();s.textContent=d,s.style.left=`${p.left+p.width/2}px`,s.style.top=`${p.bottom+8}px`,s.style.display="block"},a=document.createElement("div");a.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",e.appendChild(i),e.appendChild(a),e.appendChild(l);const r=()=>{n(),a.innerHTML="";const h=W.getColors(t);if(h.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",h.forEach(d=>{const p=document.createElement("button");p.type="button",p.className="color-picker-recent-swatch";const u=Jt(d);if(p.title=u,p.setAttribute("aria-label",`Use color: ${u}`),d.includes("gradient(")){p.style.backgroundImage=d,p.style.backgroundColor="transparent";const m=O(d);m&&m.stops&&m.stops.length>0&&(p.style.borderColor=m.stops[0].color)}else p.style.backgroundColor=d,p.style.borderColor=d;p.addEventListener("mouseenter",()=>o(p,u)),p.addEventListener("mouseleave",()=>{n(),p.style.boxShadow=""}),p.addEventListener("mousedown",()=>{p.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),p.addEventListener("mouseup",()=>{setTimeout(()=>{p.style.boxShadow=""},150)}),p.addEventListener("click",()=>{n(),c(d)}),a.appendChild(p)})};return r(),{container:e,refresh:r}},Jt=c=>{const t=O(c);if(t)return et(t);const e=z(c);if(e){const i=N(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return c},Pt=`<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 Rt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let gt=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=Rt[e[c]&63];return t};function Ft(c){let t=0,e=c.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==c&&t++,e=e.parentElement;return t}function Q(c,t){const e=Math.min(Math.max(t,0),5);c.setAttribute("data-nesting-level",e.toString()),e>0?c.style.setProperty("--visual-indent",`${e*2}px`):(c.style.removeProperty("--visual-indent"),c.style.marginLeft="")}function ct(c,t=0){c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Q(s,n),ct(s,n)})}const Ut={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class zt{constructor(t={}){this.observedElements=new Set,this.config={...Ut,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=Ft(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const yt=new zt;function it(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(c instanceof Array)return c.map(t=>it(t));if(typeof c=="object"){const t={};for(const e in c)Object.prototype.hasOwnProperty.call(c,e)&&(t[e]=it(c[e]));return t}return c}function Wt(c){switch(c){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 S=class S{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||gt(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,S.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,S.DefaultLanguage=t}static CurrentLanguage(t){return t!==void 0&&(S.currentLanguage=t,S.currentLanguageExplicitlySet=!0,S.DefaultLanguage||S.SetDefaultLanguage(t),S.languageChangeCallbacks.forEach(e=>e(t))),S.currentLanguage||S.DefaultLanguage}static HasExplicitCurrentLanguage(){return S.currentLanguageExplicitlySet}static onLanguageChange(t){return S.languageChangeCallbacks.add(t),()=>{S.languageChangeCallbacks.delete(t)}}static SetGlobalVariables(t){S.GlobalVariables={...S.GlobalVariables,...t}}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=it(this.props),i=new t(e);return i.value=it(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||Wt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}};S.currentLanguageExplicitlySet=!1,S.languageChangeCallbacks=new Set,S.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},S.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let w=S;function A(c){return c instanceof w}function M(c){return c instanceof H}function ht(c){return A(c)||M(c)}const mt=(c,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=d=>{if(d.target.closest("button"))return;i=!0,s=d.clientX,n=d.clientY;const p=t.getBoundingClientRect();o=p.left,a=p.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",h),document.body.style.userSelect="none"},r=d=>{if(!i)return;const p=d.clientX-s,u=d.clientY-n,C=window.innerWidth,m=window.innerHeight,g=t.offsetWidth,f=t.offsetHeight;let v=o+p,y=a+u;v=Math.max(8,Math.min(C-g-8,v)),y=Math.max(8,Math.min(m-f-8,y)),t.style.left=`${v}px`,t.style.top=`${y}px`,e==null||e(v,y)},h=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",h),document.body.style.userSelect=""};c.addEventListener("mousedown",l)},z=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},tt=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,N=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},Z=c=>{const{r:t,g:e,b:i}=N(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let h=0;r!==0&&(a===s?h=(n-o)/r%6:a===n?h=(o-s)/r+2:h=(s-n)/r+4),h<0&&(h+=6);const d=a===0?0:r/a,p=a;return{h:h*60,s:d,v:p}},J=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),tt(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},It=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},dt=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},pt=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=N(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=dt(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=dt(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=z(c);if(i){const{r:s,g:n,b:o}=N(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},jt=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),Nt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),_t=c=>{if(typeof document>"u")return Nt(c)||!!z(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Tt=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:tt(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:tt(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=dt(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:tt(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:z(t)||t,position:0,opacity:100}},Et=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},bt=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},qt=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||jt(t)},wt=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&Nt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Tt(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},G=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},O=c=>{const t=c.replace(/;$/,"").trim();if(_t(t)){const s=Tt(t);return G({type:"solid",angle:0,stops:[s]})}const e=bt(t,"linear-gradient");if(e){const s=Et(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"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}[a]??90,o=s.slice(1));const l=wt(o);return l.length?G({type:"linear",angle:n,stops:l}):null}const i=bt(t,"radial-gradient");if(i){const s=Et(i),n=s[0]&&!qt(s[0])?s.slice(1):s,o=wt(n);return o.length?G({type:"radial",angle:0,stops:o}):null}return null},T=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.color;if(i.startsWith("var(--"))return i;const s=e.opacity??100,n=i.replace("#",""),o=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${n}${o}`}const t=c.stops.map(e=>`${pt(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},Zt=c=>Math.round(c/100*255).toString(16).toUpperCase().padStart(2,"0"),et=c=>{if(c.type==="solid"){const t=c.stops[0];if(t){const e=t.color;if(e.startsWith("var(--"))return e.replace("var(--","").replace(")","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");e.toUpperCase();const i=t.opacity??100;if(i===100)return e;{const s=Zt(i);return`${e}${s}`}}return"#000000"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},Y=class Y{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=z(s);n||O(s)&&(n=s),n&&(e.has(n)||(e.add(n),i.push(n)))}),i.slice(0,this.MAX_COLORS)}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);if(Array.isArray(i))this.colors.solid=this.normalizeList(i);else if(i&&typeof i=="object"){const s=i;s.solid&&(this.colors.solid=this.normalizeList(s.solid)),s.gradient&&(this.colors.gradient=this.normalizeList(s.gradient))}}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){if(t==="all"){const e=this.list("solid"),i=this.list("gradient"),s=[],n=Math.max(e.length,i.length);for(let o=0;o<n;o++)o<e.length&&s.push(e[o]),o<i.length&&s.push(i[o]);return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=z(t),s="solid";if(i)s="solid";else{const l=O(t);l&&(i=t,s=l.type==="solid"?"solid":"gradient")}if(!i)return;const n=e==="all"?s:e,o=this.list(n),a=o.indexOf(i);a!==-1&&o.splice(a,1),o.unshift(i),o.length>this.MAX_COLORS&&(o.length=this.MAX_COLORS),this.persist()}};Y.STORAGE_KEY="settingsLib_recentColors",Y.MAX_COLORS=18,Y.colors=null;let W=Y;const vt=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used";const s=document.createElement("div");s.className="color-picker-tooltip",s.style.display="none",e.appendChild(s);const n=()=>{s.style.display="none"},o=(h,d)=>{const p=h.getBoundingClientRect();s.textContent=d,s.style.left=`${p.left+p.width/2}px`,s.style.top=`${p.bottom+8}px`,s.style.display="block"},a=document.createElement("div");a.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",e.appendChild(i),e.appendChild(a),e.appendChild(l);const r=()=>{n(),a.innerHTML="";const h=W.getColors(t);if(h.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",h.forEach(d=>{const p=document.createElement("button");p.type="button",p.className="color-picker-recent-swatch";const u=Jt(d);if(p.title=u,p.setAttribute("aria-label",`Use color: ${u}`),d.includes("gradient(")){p.style.backgroundImage=d,p.style.backgroundColor="transparent";const m=O(d);m&&m.stops&&m.stops.length>0&&(p.style.borderColor=m.stops[0].color)}else p.style.backgroundColor=d,p.style.borderColor=d;p.addEventListener("mouseenter",()=>o(p,u)),p.addEventListener("mouseleave",()=>{n(),p.style.boxShadow=""}),p.addEventListener("mousedown",()=>{p.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),p.addEventListener("mouseup",()=>{setTimeout(()=>{p.style.boxShadow=""},150)}),p.addEventListener("click",()=>{n(),c(d)}),a.appendChild(p)})};return r(),{container:e,refresh:r}},Jt=c=>{const t=O(c);if(t)return et(t);const e=z(c);if(e){const i=N(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return c},Pt=`<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"/>
@@ -22,10 +22,10 @@
22
22
  <path d="M20.6106 19.5062C20.6887 19.5843 20.6887 19.711 20.6106 19.7891L19.7896 20.6101C19.7115 20.6882 19.5848 20.6882 19.5067 20.6101L5.98957 7.09298C5.91146 7.01488 5.91146 6.88825 5.98957 6.81014L6.81063 5.98908C6.88873 5.91097 7.01537 5.91097 7.09347 5.98908L20.6106 19.5062Z" fill="#46525C"/>
23
23
  <path d="M9.69583 12.2146C9.81298 12.3318 9.81298 12.5217 9.69583 12.6389L7.80151 14.5332C6.72071 15.614 6.6062 17.4365 7.80151 18.6318C8.99473 19.8267 10.8184 19.7123 11.8992 18.6318L13.7935 16.7366C13.9106 16.6194 14.1006 16.6194 14.2178 16.7366L14.816 17.3348C14.9331 17.4519 14.9332 17.6418 14.816 17.759L12.9216 19.6543C11.2241 21.3536 8.47364 21.3518 6.77417 19.6543C5.07483 17.9568 5.0749 15.2064 6.77417 13.5068L8.66848 11.6116C8.78563 11.4944 8.97562 11.4944 9.0928 11.6116L9.69583 12.2146ZM13.5085 6.77441C15.2061 5.07514 17.9565 5.07509 19.656 6.77441C21.3535 8.47388 21.3533 11.2243 19.656 12.9238L17.7607 14.8182C17.6436 14.9354 17.4536 14.9353 17.3365 14.8182L16.7344 14.2161C16.6172 14.0989 16.6172 13.9089 16.7344 13.7918L18.6296 11.8975C19.7101 10.8167 19.8245 8.99503 18.6296 7.7998C17.4363 6.60449 15.6118 6.719 14.531 7.7998L12.6367 9.69412C12.5195 9.81128 12.3296 9.81128 12.2124 9.69412L11.6123 9.09402C11.4952 8.97684 11.4952 8.78685 11.6124 8.6697L13.5085 6.77441Z" fill="#46525C"/>
24
24
  </svg>
25
- `;class ee{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;if(this.backdrop.contains(s)){i.preventDefault(),i.stopPropagation(),this.close(!0);return}const n=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(n).some(l=>l.contains(s)))return;const a=document.querySelector(".gradient-popover");a&&a.contains(s)||(i.preventDefault(),i.stopPropagation(),this.close(!0))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=Pt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),gt(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=Vt;const r=document.createElement("div");r.className="color-picker-sliders-group";const h=document.createElement("div");h.className="color-picker-hue",this.hueSlider=h;const d=document.createElement("div");d.className="color-picker-hue-marker",this.hueMarker=d,h.appendChild(d);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const u=document.createElement("div");u.className="color-picker-opacity-marker",this.opacityMarker=u,p.appendChild(u),r.appendChild(h),r.appendChild(p),a.appendChild(l),a.appendChild(r);const C=mt(E=>{var L;this.setColor(E),(L=this.onChange)==null||L.call(this,E,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=C.refresh;const m=document.createElement("div");m.className="color-picker-format-section";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const f=document.createElement("option");f.value="hex",f.textContent="HEX";const v=document.createElement("option");v.value="rgb",v.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",g.appendChild(f),g.appendChild(v),g.appendChild(y);const b=document.createElement("input");b.type="text",b.className="color-picker-color-input",b.value=this.currentColor,this.input=b;const k=document.createElement("div");k.className="color-picker-input-container";const x=document.createElement("button");return x.className="color-picker-copy-inside",x.textContent="Copy",k.appendChild(b),k.appendChild(x),m.appendChild(g),m.appendChild(k),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(C.container),t.appendChild(m),t.addEventListener("click",E=>E.stopPropagation()),this.bind(n,h,p,b,g,x,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.style.pointerEvents="none",t}bind(t,e,i,s,n,o,a){const l=d=>{var v;const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width)),C=Math.max(0,Math.min(1,(d.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${C*100}%`;const g=this.parsePercentage(this.hueMarker.style.left||"0%")*360,f=J(g,u,1-C);this.currentColor=f,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},r=d=>{var v;const p=e.getBoundingClientRect();let u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const C=u*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),g=this.parsePercentage(this.colorMarker.style.top||"0%"),f=J(C,m,1-g);this.currentColor=f,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},h=d=>{var C;const p=i.getBoundingClientRect(),u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width));this.opacityMarker.style.left=`${u*100}%`,this.currentOpacity=Math.round(u*100),(C=this.onChange)==null||C.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",d=>{d.preventDefault(),l(d);const p=C=>l(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),e.addEventListener("mousedown",d=>{d.preventDefault(),r(d);const p=C=>r(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),i.addEventListener("mousedown",d=>{d.preventDefault(),h(d);const p=C=>h(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var d;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const p=new window.EyeDropper,{sRGBHex:u}=await p.open();this.setColor(u),(d=this.onChange)==null||d.call(this,u,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=Z(t),n=e>=360?e%360: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.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=Z(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=N(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=It(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=J(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=N(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${t}, ${e}, ${i}, 0)`)}open(t,e,i){var y;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=Z(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(y=this.recentSectionRefresh)==null||y.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 a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),h=window.innerWidth,d=window.innerHeight,p=16;let u=r.right+8,C=r.top;const m=h-r.right,g=r.left;m>=a+p?u=r.right+8:g>=a+p?u=r.left-a-8:u=Math.max(p,(h-a)/2);const f=d-r.bottom,v=r.top;f>=l+p?C=r.bottom+8:v>=l+p?C=r.top-l-8:f>v?(C=r.bottom+8,C+l>d-p&&(C=d-l-p)):(C=r.top-l-8,C<p&&(C=p)),this.element.style.left=`${u}px`,this.element.style.top=`${C}px`}close(t){var e;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),t&&this.onChange&&this.recentScope==="solid"&&(W.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}setOnChange(t){this.onChange=t}getIsOpen(){return this.isOpen}getElement(){return this.element}}class ie{constructor(t){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(t.initialColor),this.currentOpacity=this.clampOpacity(t.initialOpacity),this.onColorChange=t.onColorChange,this.recentScope=t.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}sanitizeColor(t){const e=this.currentColor||"#FFFFFF";return z(t)??e}clampOpacity(t){return Number.isFinite(t)?Math.min(100,Math.max(0,Math.round(t))):100}build(){const t=document.createElement("div");t.className="embedded-color-picker";const e=document.createElement("div");e.className="color-picker-area embedded",this.colorArea=e;const i=document.createElement("div");i.className="color-picker-marker",this.colorMarker=i,e.appendChild(i);const s=document.createElement("div");s.className="color-picker-sliders-container embedded";const n=document.createElement("button");n.className="color-picker-eyedropper",n.type="button",n.innerHTML=Vt;const o=document.createElement("div");o.className="color-picker-sliders-group";const a=document.createElement("div");a.className="color-picker-hue embedded",this.hueSlider=a;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,a.appendChild(l);const r=document.createElement("div");r.className="color-picker-opacity embedded",this.opacitySlider=r;const h=document.createElement("div");h.className="color-picker-opacity-marker",this.opacityMarker=h,r.appendChild(h),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const d=mt(b=>{const k=O(b);k&&k.type!=="solid"?this.onColorChange(b,this.currentOpacity):(this.setColor(b),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=d.refresh;const p=document.createElement("div");p.className="color-picker-format-section embedded";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const g=document.createElement("option");g.value="hsl",g.textContent="HSL",u.appendChild(C),u.appendChild(m),u.appendChild(g);const f=document.createElement("input");f.type="text",f.className="color-picker-color-input",this.input=f;const v=document.createElement("div");v.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",v.appendChild(f),v.appendChild(y),p.appendChild(u),p.appendChild(v),t.appendChild(e),t.appendChild(s),t.appendChild(p),t.appendChild(d.container),this.bind(e,a,r,f,u,y,n),t}bind(t,e,i,s,n,o,a){const l=(p,u)=>{const C=u||t.getBoundingClientRect(),m=Math.max(0,Math.min(1,(p.clientX-C.left)/C.width)),g=Math.max(0,Math.min(1,(p.clientY-C.top)/C.height));this.colorMarker.style.left=`${m*100}%`,this.colorMarker.style.top=`${g*100}%`;const v=this.parsePercentage(this.hueMarker.style.left||"0%")*360,y=J(v,m,1-g);this.currentColor=y,this.syncInput(),this.updateOpacityBg(),this.queueChange()},r=(p,u)=>{const C=u||e.getBoundingClientRect(),m=Math.max(0,Math.min(1,(p.clientX-C.left)/C.width));this.hueMarker.style.left=`${m*100}%`;const g=m*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),v=this.parsePercentage(this.colorMarker.style.top||"0%"),y=J(g,f,1-v);this.currentColor=y,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
25
+ `;class ee{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;if(this.backdrop.contains(s)){i.preventDefault(),i.stopPropagation(),this.close(!0);return}const n=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(n).some(l=>l.contains(s)))return;const a=document.querySelector(".gradient-popover");a&&a.contains(s)||(i.preventDefault(),i.stopPropagation(),this.close(!0))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=Pt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),mt(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=Vt;const r=document.createElement("div");r.className="color-picker-sliders-group";const h=document.createElement("div");h.className="color-picker-hue",this.hueSlider=h;const d=document.createElement("div");d.className="color-picker-hue-marker",this.hueMarker=d,h.appendChild(d);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const u=document.createElement("div");u.className="color-picker-opacity-marker",this.opacityMarker=u,p.appendChild(u),r.appendChild(h),r.appendChild(p),a.appendChild(l),a.appendChild(r);const C=vt(E=>{var L;this.setColor(E),(L=this.onChange)==null||L.call(this,E,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=C.refresh;const m=document.createElement("div");m.className="color-picker-format-section";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const f=document.createElement("option");f.value="hex",f.textContent="HEX";const v=document.createElement("option");v.value="rgb",v.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",g.appendChild(f),g.appendChild(v),g.appendChild(y);const b=document.createElement("input");b.type="text",b.className="color-picker-color-input",b.value=this.currentColor,this.input=b;const k=document.createElement("div");k.className="color-picker-input-container";const x=document.createElement("button");return x.className="color-picker-copy-inside",x.textContent="Copy",k.appendChild(b),k.appendChild(x),m.appendChild(g),m.appendChild(k),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(C.container),t.appendChild(m),t.addEventListener("click",E=>E.stopPropagation()),this.bind(n,h,p,b,g,x,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.style.pointerEvents="none",t}bind(t,e,i,s,n,o,a){const l=d=>{var v;const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width)),C=Math.max(0,Math.min(1,(d.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${C*100}%`;const g=this.parsePercentage(this.hueMarker.style.left||"0%")*360,f=J(g,u,1-C);this.currentColor=f,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},r=d=>{var v;const p=e.getBoundingClientRect();let u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const C=u*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),g=this.parsePercentage(this.colorMarker.style.top||"0%"),f=J(C,m,1-g);this.currentColor=f,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},h=d=>{var C;const p=i.getBoundingClientRect(),u=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width));this.opacityMarker.style.left=`${u*100}%`,this.currentOpacity=Math.round(u*100),(C=this.onChange)==null||C.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",d=>{d.preventDefault(),l(d);const p=C=>l(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),e.addEventListener("mousedown",d=>{d.preventDefault(),r(d);const p=C=>r(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),i.addEventListener("mousedown",d=>{d.preventDefault(),h(d);const p=C=>h(C),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var d;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const p=new window.EyeDropper,{sRGBHex:u}=await p.open();this.setColor(u),(d=this.onChange)==null||d.call(this,u,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=Z(t),n=e>=360?e%360: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.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=Z(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=N(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=It(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=J(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=N(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${t}, ${e}, ${i}, 0)`)}open(t,e,i){var y;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=Z(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(y=this.recentSectionRefresh)==null||y.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 a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),h=window.innerWidth,d=window.innerHeight,p=16;let u=r.right+8,C=r.top;const m=h-r.right,g=r.left;m>=a+p?u=r.right+8:g>=a+p?u=r.left-a-8:u=Math.max(p,(h-a)/2);const f=d-r.bottom,v=r.top;f>=l+p?C=r.bottom+8:v>=l+p?C=r.top-l-8:f>v?(C=r.bottom+8,C+l>d-p&&(C=d-l-p)):(C=r.top-l-8,C<p&&(C=p)),this.element.style.left=`${u}px`,this.element.style.top=`${C}px`}close(t){var e;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),t&&this.onChange&&this.recentScope==="solid"&&(W.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}setOnChange(t){this.onChange=t}getIsOpen(){return this.isOpen}getElement(){return this.element}}class ie{constructor(t){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(t.initialColor),this.currentOpacity=this.clampOpacity(t.initialOpacity),this.onColorChange=t.onColorChange,this.recentScope=t.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}sanitizeColor(t){const e=this.currentColor||"#FFFFFF";return z(t)??e}clampOpacity(t){return Number.isFinite(t)?Math.min(100,Math.max(0,Math.round(t))):100}build(){const t=document.createElement("div");t.className="embedded-color-picker";const e=document.createElement("div");e.className="color-picker-area embedded",this.colorArea=e;const i=document.createElement("div");i.className="color-picker-marker",this.colorMarker=i,e.appendChild(i);const s=document.createElement("div");s.className="color-picker-sliders-container embedded";const n=document.createElement("button");n.className="color-picker-eyedropper",n.type="button",n.innerHTML=Vt;const o=document.createElement("div");o.className="color-picker-sliders-group";const a=document.createElement("div");a.className="color-picker-hue embedded",this.hueSlider=a;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,a.appendChild(l);const r=document.createElement("div");r.className="color-picker-opacity embedded",this.opacitySlider=r;const h=document.createElement("div");h.className="color-picker-opacity-marker",this.opacityMarker=h,r.appendChild(h),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const d=vt(b=>{const k=O(b);k&&k.type!=="solid"?this.onColorChange(b,this.currentOpacity):(this.setColor(b),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=d.refresh;const p=document.createElement("div");p.className="color-picker-format-section embedded";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const g=document.createElement("option");g.value="hsl",g.textContent="HSL",u.appendChild(C),u.appendChild(m),u.appendChild(g);const f=document.createElement("input");f.type="text",f.className="color-picker-color-input",this.input=f;const v=document.createElement("div");v.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",v.appendChild(f),v.appendChild(y),p.appendChild(u),p.appendChild(v),t.appendChild(e),t.appendChild(s),t.appendChild(p),t.appendChild(d.container),this.bind(e,a,r,f,u,y,n),t}bind(t,e,i,s,n,o,a){const l=(p,u)=>{const C=u||t.getBoundingClientRect(),m=Math.max(0,Math.min(1,(p.clientX-C.left)/C.width)),g=Math.max(0,Math.min(1,(p.clientY-C.top)/C.height));this.colorMarker.style.left=`${m*100}%`,this.colorMarker.style.top=`${g*100}%`;const v=this.parsePercentage(this.hueMarker.style.left||"0%")*360,y=J(v,m,1-g);this.currentColor=y,this.syncInput(),this.updateOpacityBg(),this.queueChange()},r=(p,u)=>{const C=u||e.getBoundingClientRect(),m=Math.max(0,Math.min(1,(p.clientX-C.left)/C.width));this.hueMarker.style.left=`${m*100}%`;const g=m*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),v=this.parsePercentage(this.colorMarker.style.top||"0%"),y=J(g,f,1-v);this.currentColor=y,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
26
26
  linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.queueChange()},h=(p,u)=>{const C=u||i.getBoundingClientRect(),m=Math.max(0,Math.min(1,(p.clientX-C.left)/C.width));this.opacityMarker.style.left=`${m*100}%`,this.currentOpacity=this.clampOpacity(m*100),this.queueChange()},d=(p,u,C)=>{p.preventDefault(),this.isDragging=!0,this.cachedRect=C.getBoundingClientRect(),u(p,this.cachedRect);let m=null,g;const f=()=>{this.dragRafId===void 0&&(this.dragRafId=window.requestAnimationFrame(()=>{this.dragRafId=void 0,m&&this.cachedRect&&u(m,this.cachedRect)}))},v=()=>{this.isDragging&&(this.isDragging=!1,this.dragRafId!==void 0&&(cancelAnimationFrame(this.dragRafId),this.dragRafId=void 0),this.cachedRect=void 0,m=null,this.flushChange(),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",v),window.removeEventListener("blur",v),this.applyPendingExternal())};g=y=>{if(!y.buttons){v();return}m=y,f()},document.addEventListener("mousemove",g),document.addEventListener("mouseup",v),window.addEventListener("blur",v)};t.addEventListener("mousedown",p=>{d(p,l,t)}),e.addEventListener("mousedown",p=>{d(p,r,e)}),i.addEventListener("mousedown",p=>{d(p,h,i)}),n.addEventListener("change",()=>{this.syncInput()}),s.addEventListener("input",()=>{this.applyFromInput()}),s.addEventListener("blur",()=>{this.syncInput()}),s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const p=new window.EyeDropper,{sRGBHex:u}=await p.open();this.setColor(u),this.onColorChange(this.currentColor,this.currentOpacity)}catch{}})}setColor(t){const e=this.sanitizeColor(t);this.currentColor=e;const{h:i,s,v:n}=Z(e),o=i>=360?i%360:i;this.hueMarker.style.left=`${o/360*100}%`,this.colorMarker.style.left=`${s*100}%`,this.colorMarker.style.top=`${(1-n)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
27
27
  linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=Z(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=N(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=It(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1],10),n=parseInt(i[2],10),o=parseInt(i[3],10);s<=255&&n<=255&&o<=255&&(e="#"+[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join(""))}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1],10),o=parseInt(s[2],10)/100,a=parseInt(s[3],10)/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=J(n,r,l)}}}e&&(this.setColor(e),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:t,g:e,b:i}=N(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${t}, ${e}, ${i}, 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:t,opacity:e}=this.pendingExternalUpdate;this.pendingExternalUpdate=void 0,this.initFromColor(t,e)}initFromColor(t,e){var l;const i=this.sanitizeColor(t);this.currentColor=i,this.currentOpacity=this.clampOpacity(e);const{h:s,s:n,v:o}=Z(i),a=s>=360?s%360:s;this.hueMarker.style.left=`${a/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
28
- linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(W.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this))}getElement(){return this.element}updateColor(t,e){if(this.isDragging){this.pendingExternalUpdate={color:t,opacity:e};return}this.initFromColor(t,e)}}const V=class V extends w{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),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=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop"),d=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!h&&!d&&this.closePopover()},this.handlePopoverKeydown=i=>{var s,n;if(this.isPopoverOpen){if(i.key==="Escape"){if(i.preventDefault(),(s=this.sharedStopColorPicker)!=null&&s.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(i.key==="Enter"){const o=i.target;if(o&&(o.tagName==="INPUT"||o.tagName==="TEXTAREA"))return;if(i.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=t.detectChange,this.variant=t.variant??"default",this.originalDefault=t.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(t){if(t.startsWith("var(--")){const e=t.replace("var(--","").replace(")","");return(w.GlobalVariables||{})[e]||t}return t}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new ee(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(t){var i,s;if(!t){this.linkedGlobalVariable=null;return}const e=typeof t=="string"?t:((s=(i=t.stops)==null?void 0:i[0])==null?void 0:s.color)??null;this.linkedGlobalVariable=e&&e.startsWith("var(--")?e:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var t,e;this.isBoundToGlobal()&&((e=(t=this.value)==null?void 0:t.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(i=>({...i,color:this.resolveGlobalVarColor(i.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var t;!this.isBoundToGlobal()||!this.value||((t=this.value.stops)!=null&&t.length&&(this.value.stops=this.value.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){if(t.startsWith("var(--"))return G({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]});const i=O(t);if(i)return G(i)}return G(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){let e=null;typeof t=="string"?t.startsWith("var(--")?e=G({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]}):e=O(t):t&&typeof t=="object"&&(e=G(t)),e||(e=this.defaultValue()),this.value=e,this.setLinkedGlobalVariableFrom(t??e),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 t=this.value.stops[0],e=t.opacity??100,i=this.resolveGlobalVarColor(t.color);this.previewEl.style.background=pt(i,e)}else{const t=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=T(t)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const e=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");this.inputEl.value=`Linked: ${e}`}else this.inputEl.value=et(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(t){return{...t,stops:t.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const t=this.isBoundToGlobal();t?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(t?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:T(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?T(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",i=>{i.preventDefault(),i.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?et(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const n=this.resolveGlobalVarColor(i.color).toUpperCase(),o=i.opacity??100;if(o===100)this.inputEl.value=n;else{const l=Math.round(o/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${n}${l}`}}}else this.inputEl.value=T(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=et(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=T(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=te,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.breakGlobalBinding()}),e.appendChild(this.unlinkButton),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,this.updateUnlinkButtonVisibility(),t}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 t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";let e=null;if(this.variant!=="global"){e=document.createElement("div"),e.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const r=document.createElement("button");r.className="color-tab",r.textContent="Global",e.appendChild(l),e.appendChild(r),t.appendChild(e)}else{const l=document.createElement("div");t.appendChild(l)}const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=Pt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(i),gt(t,this.popoverEl,(l,r)=>{this.popoverPosition={left:l,top:r}});const s=document.createElement("div");s.className="gradient-editor";const n=document.createElement("div");n.className="type-tabs-wrapper";const o=this.createTypeTabs();n.appendChild(o),s.appendChild(n);const a=document.createElement("div");if(a.className="gradient-editor-content",this.updatePopoverContent(a),s.appendChild(a),this.variant!=="global"&&e){const l=e.children[0],r=e.children[1],h=d=>{this.currentMode=d,d==="custom"?(l.classList.add("active"),r.classList.remove("active"),n.style.display="block"):(r.classList.add("active"),l.classList.remove("active"),n.style.display="none"),this.updatePopoverContent(a)};l.addEventListener("click",()=>h("custom")),r.addEventListener("click",()=>h("global")),this.isBoundToGlobal()?(this.currentMode="global",h("global")):(this.currentMode="custom",h("custom"))}this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.innerHTML=Kt,e.style.minWidth="32px",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.innerHTML=Qt,i.style.minWidth="32px",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t,e=!1){var l,r;if(!this.value)return;const i=this.value.type,s=this.isBoundToGlobal(),n=this.linkedGlobalVariable;this.value.type=t;let o=!1;if(s&&n&&i==="solid"!=(t==="solid")){const h=this.resolveGlobalVarColor(n),d=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;(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:h,position:0,opacity:d}]:this.value.stops[0]={...this.value.stops[0],color:h,opacity:d},this.linkedGlobalVariable=null,o=!0}if(t!=="solid"&&(this.pendingSolidColor=null),t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),t!=="solid"&&this.value.stops.length===1){const d=this.value.stops[0].color;if(d.startsWith("var(--")){const p=this.resolveGlobalVarColor(d),u=O(p);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.push({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(t!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(t==="solid"&&s&&n){const h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:n,position:0,opacity:h}],this.value.angle=0}if(this.popoverEl){const h=this.popoverEl.querySelectorAll(".gradient-type-tab");h.forEach(u=>u.classList.remove("active"));const d=h[0],p=h[1];t==="solid"?d==null||d.classList.add("active"):p==null||p.classList.add("active")}const a=(r=this.popoverEl)==null?void 0:r.querySelector(".gradient-editor-content");a&&this.updatePopoverContent(a),this.updateUI(),(e||o||i!==t)&&this.triggerChange()}updatePopoverContent(t){if(t.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(t);return}this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t)}}renderGlobalColors(t){(!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 e=this.value.stops[0],i=d=>{d.innerHTML="";let p={};try{p=w.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!p||Object.keys(p).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",d.appendChild(g);return}const u=w.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],C=this.globalSearchQuery.toLowerCase();let m;this.globalLayoutMode==="list"?(m=document.createElement("div"),m.className="global-colors-list"):(m=document.createElement("div"),m.className="global-colors-grid"),d.appendChild(m),u.forEach(g=>{const f=Object.entries(p).filter(([v])=>!g.keys.includes(v)&&g.title!=="Global Colors"?!1:g.keys.includes(v)&&v.toLowerCase().includes(C));f.length!==0&&f.forEach(([v,y])=>{if(this.globalLayoutMode==="list"){const b=document.createElement("div");b.className="global-color-row";const k=document.createElement("div");k.className="global-color-circle";const x=this.resolveGlobalVarColor(y);k.style.background=x,(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&k.classList.add("selected");const L=document.createElement("span");L.className="global-color-label",L.textContent=v.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),b.appendChild(k),b.appendChild(L),b.addEventListener("click",I=>{I.preventDefault();const R=`var(--${v})`;this.setValue(R),this.pendingSolidColor=R,i(d)}),m.appendChild(b)}else{const b=document.createElement("div");b.className="global-color-circle";const k=this.resolveGlobalVarColor(y);b.style.background=k,b.title=v.split("-").map(E=>E.charAt(0).toUpperCase()+E.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&b.classList.add("selected"),b.addEventListener("click",E=>{E.preventDefault();const L=`var(--${v})`;this.setValue(L),this.pendingSolidColor=L,i(d)}),m.appendChild(b)}})})},s=document.createElement("div");s.className="global-controls-row";const n=document.createElement("div");n.className="global-search-container";const o=document.createElement("span");o.className="global-search-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const a=document.createElement("input");a.type="text",a.className="global-search-input",a.placeholder="Search",a.value=this.globalSearchQuery;const l=document.createElement("div");a.addEventListener("input",d=>{this.globalSearchQuery=d.target.value,i(l)}),n.appendChild(o),n.appendChild(a);const r=document.createElement("button");r.className="global-layout-toggle",r.type="button";const h=()=>{r.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" stroke-width="2" stroke-linecap="round" stroke-linejoin="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" stroke-width="2" stroke-linecap="round" stroke-linejoin="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>'};h(),r.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",h(),i(l)}),s.appendChild(n),s.appendChild(r),t.appendChild(s),t.appendChild(l),i(l)}renderSolid(t){(!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 e=this.value.stops[0],i=new ie({initialColor:e.color.startsWith("var(--")?this.resolveGlobalVarColor(e.color):e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const o=O(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type,!0);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;let e=null;{const h=document.createElement("div");h.className="gradient-subtype-inline";const d=document.createElement("select");d.className="gradient-subtype-select";const p=document.createElement("option");p.value="linear",p.textContent="Linear";const u=document.createElement("option");u.value="radial",u.textContent="Radial",d.appendChild(p),d.appendChild(u),d.value=this.value.type==="radial"?"radial":"linear",e=document.createElement("input"),e.type="text",e.inputMode="numeric",e.className="gradient-degree-input",e.value=`${this.value.angle??90}°`,e.style.width="75px",e.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,e.value="90°");const C=document.createElement("button");C.type="button",C.className="gradient-flip-btn",C.innerHTML=Xt,d.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(d.value==="radial"?"radial":"linear",!0),e&&this.updateDegreeVisibility(e)}),e.addEventListener("focus",m=>{const g=m.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),e.addEventListener("input",m=>{this.clearGlobalBindingForCustomChange();const g=parseInt(m.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),e.addEventListener("blur",m=>{var v;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=m.target;let f=parseInt(g.value);Number.isNaN(f)&&(f=((v=this.value)==null?void 0:v.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),g.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,g)=>m.position-g.position),this.updateGradientPreview(i),this.createHandles(s,i),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),h.appendChild(d),h.appendChild(e),h.appendChild(C),t.appendChild(h),this.updateDegreeVisibility(e)}const i=document.createElement("div");i.className="gradient-preview",this.updateGradientPreview(i);const s=document.createElement("div");s.className="gradient-handles",i.appendChild(s),t.appendChild(i),this.createHandles(s,i),i.addEventListener("click",h=>{var m;const d=h.target;if(d.classList.contains("gstop-handle")||d.classList.contains("gstop-chip"))return;const p=i.getBoundingClientRect(),C=(h.clientX-p.left)/p.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(C),this.updateStopsList(),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((m=document.activeElement)==null?void 0:m.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const n=document.createElement("div");n.className="gradient-stops-header";const o=document.createElement("span");o.textContent="Stops";const a=document.createElement("button");a.type="button",a.className="gradient-add-stop",a.textContent="+",n.appendChild(o),n.appendChild(a);const l=document.createElement("div");l.className="gradient-stops",t.appendChild(n),t.appendChild(l),this.updateStopsList(l);const r=mt(h=>{const d=O(h);d&&(this.clearGlobalBindingForCustomChange(),this.value=d,this.switchType(d.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=r.refresh,t.appendChild(r.container),a.addEventListener("click",()=>{var h;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((h=document.activeElement)==null?void 0:h.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;t&&(((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1"))}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));if(e&&this.value)if(this.value.type==="solid")e.style.background=T(this.value);else{const s=this.value.stops.map(n=>`${pt(n.color,n.opacity??100)} ${n.position}%`).join(", ");e.style.background=`linear-gradient(90deg, ${s})`}}debouncedPreviewUpdate(t){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(t),this.previewUpdateTimeout=null},16)}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip";const a=this.resolveGlobalVarColor(i.color);o.style.backgroundColor=a,n.appendChild(o);let l=!1,r=!1,h=0,d=0;const p=m=>{l=!0,r=!1,h=m.clientX,d=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",u),document.addEventListener("mouseup",C),m.preventDefault(),m.stopPropagation()},u=m=>{if(!l||!this.value)return;const g=m.clientX-h;if(Math.abs(g)>3&&(r=!0),r){this.clearGlobalBindingForCustomChange();const f=e.getBoundingClientRect();let v=d+g/f.width*100;v=Math.max(0,Math.min(100,v)),this.value.stops[s].position=Math.round(v),n.style.left=`${v}%`,this.updateGradientPreview()}},C=m=>{var g;if(l)if(l=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",C),r)this.value&&(this.value.stops.sort((f,v)=>f.position-v.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange();else{m.stopPropagation();const f=(g=this.value)==null?void 0:g.stops[s];f&&setTimeout(()=>{const v=this.getSharedStopColorPicker();v.getIsOpen()&&v.close(!1),this.colorPickerStopIndex=s,v.setOnChange((b,k)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[s]&&(this.value.stops[s].color=b,k!==void 0&&(this.value.stops[s].opacity=k),o.style.backgroundColor=b,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const y=this.resolveGlobalVarColor(f.color);v.open(y,o,f.opacity??100)},0)}};n.addEventListener("mousedown",p),t.appendChild(n)})}updateStopsList(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-stops"));!e||!this.value||this.value.type==="solid"||!this.value.stops||(e.innerHTML="",this.value.stops.forEach((s,n)=>{var b,k;const o=document.createElement("div");o.className="gstop-row";const a=document.createElement("div");a.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${s.position}%`,l.style.width="60px",a.appendChild(l);const r=document.createElement("div");r.className="gstop-color-container";const h=this.resolveGlobalVarColor(s.color),d=document.createElement("div");d.className="gstop-color-preview",d.style.backgroundColor=h;const p=document.createElement("input");p.type="text",p.className="gstop-color-input",p.value=h.replace("#","").toUpperCase();const u=document.createElement("button");u.type="button",u.className="gstop-color-copy",u.textContent="Copy",r.appendChild(d),r.appendChild(p),r.appendChild(u);const C=document.createElement("button");C.type="button",C.className="gstop-del",C.innerHTML=Yt,C.disabled=(((k=(b=this.value)==null?void 0:b.stops)==null?void 0:k.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(C),e.appendChild(o);const m=document.createElement("span");m.className="gstop-opacity-label",m.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const f=document.createElement("input");f.type="range",f.className="gstop-opacity-slider",f.min="0",f.max="100",f.value=String(s.opacity??100);const v=N(h);f.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${v.r}, ${v.g}, ${v.b}, 0)`);const y=document.createElement("span");y.className="gstop-opacity-value",y.textContent=`${s.opacity??100}%`,g.appendChild(f),g.appendChild(y),p.addEventListener("click",x=>{x.preventDefault(),x.stopPropagation();const E=this.getSharedStopColorPicker();E.getIsOpen()&&E.close(!1),this.colorPickerStopIndex=n,E.setOnChange((I,R)=>{this.clearGlobalBindingForCustomChange(),p.value=I.replace("#","").toUpperCase(),d.style.backgroundColor=I,this.value.stops[n].color=I,R!==void 0&&(this.value.stops[n].opacity=R,f.value=String(R),y.textContent=`${R}%`);const _=N(I);f.style.setProperty("--slider-color",`rgb(${_.r}, ${_.g}, ${_.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${_.r}, ${_.g}, ${_.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const L=this.resolveGlobalVarColor(s.color);E.open(L,p,s.opacity??100)}),p.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const x=p.value.trim(),E=x.startsWith("#")?x:`#${x}`;if(/^#[0-9A-Fa-f]{6}$/.test(E)){this.value.stops[n].color=E,d.style.backgroundColor=E;const L=N(E);f.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${L.r}, ${L.g}, ${L.b}, 0)`),this.debouncedPreviewUpdate()}}),p.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),u.addEventListener("click",async x=>{x.stopPropagation();try{await navigator.clipboard.writeText(`#${p.value}`)}catch{}}),l.addEventListener("focus",x=>{const E=x.target;E.value=E.value.replace("%",""),E.select()}),l.addEventListener("input",x=>{this.clearGlobalBindingForCustomChange();const E=x.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(L)){const I=Math.max(0,Math.min(100,L));this.value.stops[n].position=I,E.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",x=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const E=x.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(Number.isNaN(L))E.value=`${this.value.stops[n].position}%`;else{const I=Math.max(0,Math.min(100,L));this.value.stops[n].position=I,E.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{var x,E;(this.value.stops.length||0)<=2||((x=this.sharedStopColorPicker)!=null&&x.getIsOpen()&&this.colorPickerStopIndex===n?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>n&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((E=document.activeElement)==null?void 0:E.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),f.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const x=parseInt(f.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,x)),y.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),f.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 t=this.value.stops.map(s=>s.position).sort((s,n)=>s-n);let e=50,i=0;for(let s=0;s<t.length-1;s++){const n=t[s+1]-t[s];n>i&&(i=n,e=t[s]+n/2)}this.addStopAtPosition(e)}addStopAtPosition(t){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=Math.max(0,Math.min(100,t)),i=[...this.value.stops].sort((r,h)=>r.position-h.position);let s=i[0],n=i[i.length-1];for(let r=0;r<i.length-1;r++)if(i[r].position<=e&&i[r+1].position>=e){s=i[r],n=i[r+1];break}let o,a;if(s===n||s.position===n.position)o=s.color,a=s.opacity??100;else{const r=(e-s.position)/(n.position-s.position),h=N(s.color),d=N(n.color),p=Math.round(h.r+(d.r-h.r)*r),u=Math.round(h.g+(d.g-h.g)*r),C=Math.round(h.b+(d.b-h.b)*r);o=`#${p.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}${C.toString(16).padStart(2,"0")}`.toUpperCase(),a=Math.round((s.opacity??100)+((n.opacity??100)-(s.opacity??100))*r)}const l={position:Math.round(e),color:o,opacity:a};this.value.stops.push(l),this.value.stops.sort((r,h)=>r.position-h.position)}openPopover(){if(this.popoverEl&&(V.openInstance&&V.openInstance!==this&&V.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,V.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 t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,h=t.left,d=e+n;r<d&&h>r+100&&(a=t.left-e-8);const p=s-t.bottom,u=t.top;u>=o+n?l=t.top-o-8:p>=o+n?l=t.bottom+8:u>p?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:a,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((t=document.activeElement)==null?void 0:t.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 e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const h=s-e.right,d=e.left,p=i+o;h<p&&d>h+100&&(l=e.left-i-8);const u=n-e.bottom,C=e.top;C>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:C>u?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}}refreshPopoverContent(){var n,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):(i.classList.add("active"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){var t,e;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(t=this.sharedStopColorPicker)!=null&&t.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 i=T(this.value);W.addColor(i,"gradient"),(e=this.recentGradientRefresh)==null||e.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),V.openInstance===this&&(V.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():W.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){let e=t.trim();e&&!e.startsWith("#")&&!e.startsWith("var(")&&!e.startsWith("rgb")&&!e.startsWith("hsl")&&!e.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(e)&&(e="#"+e,this.inputEl&&(this.inputEl.value=e));const i=O(e);i&&this.setValue(i)}getChangePayload(){var t;if(this.value)return this.isBoundToGlobal()?((t=this.value.stops)==null?void 0:t.some(i=>i.opacity!==void 0&&i.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const t=this.getChangePayload();t!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var e,i;(e=this.onChange)==null||e.call(this,t),(i=this.detectChange)==null||i.call(this,t),this.changeDebounceTimeout=null},V.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:T(t):""}getCSSValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:T(t):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};V.openInstance=null,V.CHANGE_DEBOUNCE_DELAY=150;let j=V;function X(c,t){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)){const i=c[e];t(e,i)}}const at=class at{constructor(t){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.id=t.id||St(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",this.hide=t.hide??!1,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;X(this.settings,(e,i)=>{M(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(t){if(this.title=t,this.elementRef){const e=this.elementRef.querySelector(".setting-group-title h3");e&&(e.textContent=t)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){X(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(M(e)||A(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Q(this.elementRef,this.nestingLevel),ct(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(M(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const a of o){const l=a.id,r=a.getAttribute("data-setting-id");if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}if(r&&"id"in e&&typeof e.id=="string"&&r===e.id){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}updateSettings(t,e){var l;const i=(e==null?void 0:e.preserveValues)??!0,s=new Set(Object.keys(this.settings)),n=Object.keys(t),o={};i&&n.forEach(r=>{const h=this.settings[r];h&&(M(h)?o[r]=h.getValues():A(h)?o[r]=h.value:typeof h.getValues=="function"?o[r]=h.getValues():h.value!==void 0&&(o[r]=h.value))}),s.forEach(r=>{n.includes(r)||this.removeSetting(r)}),n.forEach(r=>{var p;const h=t[r],d=this.settings[r];if(d!==h&&(d&&this.removeSetting(r),this.addSetting(r,h),i&&r in o)){const u=o[r];try{M(h)?h.setValue(u):A(h)?(p=h.setValue)==null||p.call(h,u):h.setValue&&h.setValue(u)}catch(C){console.warn(`Could not preserve value for setting ${r}:`,C)}}}),this.settings=t,this.propagateNestingLevel(),this.propagateDataPropsPath();const a=this.getValues();this.initialValues=a,(l=this.onChange)==null||l.call(this,a)}clone(){const t={};X(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},i=Ot(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(M(s)||A(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(M(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(M(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),X(this.settings,(i,s)=>{var n;if(M(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(A(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),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()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);ht(l)&&(this.addSetting(i,l),n=l)}}n&&(M(n)||A(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};M(t)?t.setOnChange(()=>e()):A(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){const a=o.querySelector(".setting-group-empty");a&&a.remove(),M(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const l=e.draw(),r=this.deleteItemCfg??this.addItemCfg;if(r){const p=r.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);p&&t.startsWith(p)&&this.addDeleteButtonToElement(l,t)}const h=o.querySelector(".sg-add-button-bottom");h?o.insertBefore(l,h):o.appendChild(l),Ct.trackElement(l),Q(l,this.nestingLevel+1),ct(l,this.nestingLevel+1);const d=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=d,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const h of r)if(h.closest(".setting-group")===t){s=h;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
28
+ linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(W.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this))}getElement(){return this.element}updateColor(t,e){if(this.isDragging){this.pendingExternalUpdate={color:t,opacity:e};return}this.initFromColor(t,e)}}const V=class V extends w{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),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=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop"),d=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!h&&!d&&this.closePopover()},this.handlePopoverKeydown=i=>{var s,n;if(this.isPopoverOpen){if(i.key==="Escape"){if(i.preventDefault(),(s=this.sharedStopColorPicker)!=null&&s.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(i.key==="Enter"){const o=i.target;if(o&&(o.tagName==="INPUT"||o.tagName==="TEXTAREA"))return;if(i.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=t.detectChange,this.variant=t.variant??"default",this.originalDefault=t.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(t){if(t.startsWith("var(--")){const e=t.replace("var(--","").replace(")","");return(w.GlobalVariables||{})[e]||t}return t}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new ee(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(t){var i,s;if(!t){this.linkedGlobalVariable=null;return}const e=typeof t=="string"?t:((s=(i=t.stops)==null?void 0:i[0])==null?void 0:s.color)??null;this.linkedGlobalVariable=e&&e.startsWith("var(--")?e:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var t,e;this.isBoundToGlobal()&&((e=(t=this.value)==null?void 0:t.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(i=>({...i,color:this.resolveGlobalVarColor(i.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var t;!this.isBoundToGlobal()||!this.value||((t=this.value.stops)!=null&&t.length&&(this.value.stops=this.value.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){if(t.startsWith("var(--"))return G({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]});const i=O(t);if(i)return G(i)}return G(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){let e=null;typeof t=="string"?t.startsWith("var(--")?e=G({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]}):e=O(t):t&&typeof t=="object"&&(e=G(t)),e||(e=this.defaultValue()),this.value=e,this.setLinkedGlobalVariableFrom(t??e),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 t=this.value.stops[0],e=t.opacity??100,i=this.resolveGlobalVarColor(t.color);this.previewEl.style.background=pt(i,e)}else{const t=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=T(t)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const e=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");this.inputEl.value=`Linked: ${e}`}else this.inputEl.value=et(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(t){return{...t,stops:t.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const t=this.isBoundToGlobal();t?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(t?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:T(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?T(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",i=>{i.preventDefault(),i.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?et(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const n=this.resolveGlobalVarColor(i.color).toUpperCase(),o=i.opacity??100;if(o===100)this.inputEl.value=n;else{const l=Math.round(o/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${n}${l}`}}}else this.inputEl.value=T(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=et(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=T(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=te,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.breakGlobalBinding()}),e.appendChild(this.unlinkButton),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,this.updateUnlinkButtonVisibility(),t}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 t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";let e=null;if(this.variant!=="global"){e=document.createElement("div"),e.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const r=document.createElement("button");r.className="color-tab",r.textContent="Global",e.appendChild(l),e.appendChild(r),t.appendChild(e)}else{const l=document.createElement("div");t.appendChild(l)}const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=Pt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(i),mt(t,this.popoverEl,(l,r)=>{this.popoverPosition={left:l,top:r}});const s=document.createElement("div");s.className="gradient-editor";const n=document.createElement("div");n.className="type-tabs-wrapper";const o=this.createTypeTabs();n.appendChild(o),s.appendChild(n);const a=document.createElement("div");if(a.className="gradient-editor-content",this.updatePopoverContent(a),s.appendChild(a),this.variant!=="global"&&e){const l=e.children[0],r=e.children[1],h=d=>{this.currentMode=d,d==="custom"?(l.classList.add("active"),r.classList.remove("active"),n.style.display="block"):(r.classList.add("active"),l.classList.remove("active"),n.style.display="none"),this.updatePopoverContent(a)};l.addEventListener("click",()=>h("custom")),r.addEventListener("click",()=>h("global")),this.isBoundToGlobal()?(this.currentMode="global",h("global")):(this.currentMode="custom",h("custom"))}this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.innerHTML=Kt,e.style.minWidth="32px",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.innerHTML=Qt,i.style.minWidth="32px",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t,e=!1){var l,r;if(!this.value)return;const i=this.value.type,s=this.isBoundToGlobal(),n=this.linkedGlobalVariable;this.value.type=t;let o=!1;if(s&&n&&i==="solid"!=(t==="solid")){const h=this.resolveGlobalVarColor(n),d=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;(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:h,position:0,opacity:d}]:this.value.stops[0]={...this.value.stops[0],color:h,opacity:d},this.linkedGlobalVariable=null,o=!0}if(t!=="solid"&&(this.pendingSolidColor=null),t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),t!=="solid"&&this.value.stops.length===1){const d=this.value.stops[0].color;if(d.startsWith("var(--")){const p=this.resolveGlobalVarColor(d),u=O(p);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.push({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(t!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(t==="solid"&&s&&n){const h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:n,position:0,opacity:h}],this.value.angle=0}if(this.popoverEl){const h=this.popoverEl.querySelectorAll(".gradient-type-tab");h.forEach(u=>u.classList.remove("active"));const d=h[0],p=h[1];t==="solid"?d==null||d.classList.add("active"):p==null||p.classList.add("active")}const a=(r=this.popoverEl)==null?void 0:r.querySelector(".gradient-editor-content");a&&this.updatePopoverContent(a),this.updateUI(),(e||o||i!==t)&&this.triggerChange()}updatePopoverContent(t){if(t.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(t);return}this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t)}}renderGlobalColors(t){(!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 e=this.value.stops[0],i=d=>{d.innerHTML="";let p={};try{p=w.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!p||Object.keys(p).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",d.appendChild(g);return}const u=w.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],C=this.globalSearchQuery.toLowerCase();let m;this.globalLayoutMode==="list"?(m=document.createElement("div"),m.className="global-colors-list"):(m=document.createElement("div"),m.className="global-colors-grid"),d.appendChild(m),u.forEach(g=>{const f=Object.entries(p).filter(([v])=>!g.keys.includes(v)&&g.title!=="Global Colors"?!1:g.keys.includes(v)&&v.toLowerCase().includes(C));f.length!==0&&f.forEach(([v,y])=>{if(this.globalLayoutMode==="list"){const b=document.createElement("div");b.className="global-color-row";const k=document.createElement("div");k.className="global-color-circle";const x=this.resolveGlobalVarColor(y);k.style.background=x,(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&k.classList.add("selected");const L=document.createElement("span");L.className="global-color-label",L.textContent=v.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),b.appendChild(k),b.appendChild(L),b.addEventListener("click",I=>{I.preventDefault();const R=`var(--${v})`;this.setValue(R),this.pendingSolidColor=R,i(d)}),m.appendChild(b)}else{const b=document.createElement("div");b.className="global-color-circle";const k=this.resolveGlobalVarColor(y);b.style.background=k,b.title=v.split("-").map(E=>E.charAt(0).toUpperCase()+E.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&b.classList.add("selected"),b.addEventListener("click",E=>{E.preventDefault();const L=`var(--${v})`;this.setValue(L),this.pendingSolidColor=L,i(d)}),m.appendChild(b)}})})},s=document.createElement("div");s.className="global-controls-row";const n=document.createElement("div");n.className="global-search-container";const o=document.createElement("span");o.className="global-search-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const a=document.createElement("input");a.type="text",a.className="global-search-input",a.placeholder="Search",a.value=this.globalSearchQuery;const l=document.createElement("div");a.addEventListener("input",d=>{this.globalSearchQuery=d.target.value,i(l)}),n.appendChild(o),n.appendChild(a);const r=document.createElement("button");r.className="global-layout-toggle",r.type="button";const h=()=>{r.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" stroke-width="2" stroke-linecap="round" stroke-linejoin="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" stroke-width="2" stroke-linecap="round" stroke-linejoin="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>'};h(),r.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",h(),i(l)}),s.appendChild(n),s.appendChild(r),t.appendChild(s),t.appendChild(l),i(l)}renderSolid(t){(!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 e=this.value.stops[0],i=new ie({initialColor:e.color.startsWith("var(--")?this.resolveGlobalVarColor(e.color):e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const o=O(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type,!0);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;let e=null;{const h=document.createElement("div");h.className="gradient-subtype-inline";const d=document.createElement("select");d.className="gradient-subtype-select";const p=document.createElement("option");p.value="linear",p.textContent="Linear";const u=document.createElement("option");u.value="radial",u.textContent="Radial",d.appendChild(p),d.appendChild(u),d.value=this.value.type==="radial"?"radial":"linear",e=document.createElement("input"),e.type="text",e.inputMode="numeric",e.className="gradient-degree-input",e.value=`${this.value.angle??90}°`,e.style.width="75px",e.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,e.value="90°");const C=document.createElement("button");C.type="button",C.className="gradient-flip-btn",C.innerHTML=Xt,d.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(d.value==="radial"?"radial":"linear",!0),e&&this.updateDegreeVisibility(e)}),e.addEventListener("focus",m=>{const g=m.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),e.addEventListener("input",m=>{this.clearGlobalBindingForCustomChange();const g=parseInt(m.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),e.addEventListener("blur",m=>{var v;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=m.target;let f=parseInt(g.value);Number.isNaN(f)&&(f=((v=this.value)==null?void 0:v.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),g.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,g)=>m.position-g.position),this.updateGradientPreview(i),this.createHandles(s,i),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),h.appendChild(d),h.appendChild(e),h.appendChild(C),t.appendChild(h),this.updateDegreeVisibility(e)}const i=document.createElement("div");i.className="gradient-preview",this.updateGradientPreview(i);const s=document.createElement("div");s.className="gradient-handles",i.appendChild(s),t.appendChild(i),this.createHandles(s,i),i.addEventListener("click",h=>{var m;const d=h.target;if(d.classList.contains("gstop-handle")||d.classList.contains("gstop-chip"))return;const p=i.getBoundingClientRect(),C=(h.clientX-p.left)/p.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(C),this.updateStopsList(),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((m=document.activeElement)==null?void 0:m.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const n=document.createElement("div");n.className="gradient-stops-header";const o=document.createElement("span");o.textContent="Stops";const a=document.createElement("button");a.type="button",a.className="gradient-add-stop",a.textContent="+",n.appendChild(o),n.appendChild(a);const l=document.createElement("div");l.className="gradient-stops",t.appendChild(n),t.appendChild(l),this.updateStopsList(l);const r=vt(h=>{const d=O(h);d&&(this.clearGlobalBindingForCustomChange(),this.value=d,this.switchType(d.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=r.refresh,t.appendChild(r.container),a.addEventListener("click",()=>{var h;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((h=document.activeElement)==null?void 0:h.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;t&&(((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1"))}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));if(e&&this.value)if(this.value.type==="solid")e.style.background=T(this.value);else{const s=this.value.stops.map(n=>`${pt(n.color,n.opacity??100)} ${n.position}%`).join(", ");e.style.background=`linear-gradient(90deg, ${s})`}}debouncedPreviewUpdate(t){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(t),this.previewUpdateTimeout=null},16)}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip";const a=this.resolveGlobalVarColor(i.color);o.style.backgroundColor=a,n.appendChild(o);let l=!1,r=!1,h=0,d=0;const p=m=>{l=!0,r=!1,h=m.clientX,d=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",u),document.addEventListener("mouseup",C),m.preventDefault(),m.stopPropagation()},u=m=>{if(!l||!this.value)return;const g=m.clientX-h;if(Math.abs(g)>3&&(r=!0),r){this.clearGlobalBindingForCustomChange();const f=e.getBoundingClientRect();let v=d+g/f.width*100;v=Math.max(0,Math.min(100,v)),this.value.stops[s].position=Math.round(v),n.style.left=`${v}%`,this.updateGradientPreview()}},C=m=>{var g;if(l)if(l=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",C),r)this.value&&(this.value.stops.sort((f,v)=>f.position-v.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange();else{m.stopPropagation();const f=(g=this.value)==null?void 0:g.stops[s];f&&setTimeout(()=>{const v=this.getSharedStopColorPicker();v.getIsOpen()&&v.close(!1),this.colorPickerStopIndex=s,v.setOnChange((b,k)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[s]&&(this.value.stops[s].color=b,k!==void 0&&(this.value.stops[s].opacity=k),o.style.backgroundColor=b,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const y=this.resolveGlobalVarColor(f.color);v.open(y,o,f.opacity??100)},0)}};n.addEventListener("mousedown",p),t.appendChild(n)})}updateStopsList(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-stops"));!e||!this.value||this.value.type==="solid"||!this.value.stops||(e.innerHTML="",this.value.stops.forEach((s,n)=>{var b,k;const o=document.createElement("div");o.className="gstop-row";const a=document.createElement("div");a.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${s.position}%`,l.style.width="60px",a.appendChild(l);const r=document.createElement("div");r.className="gstop-color-container";const h=this.resolveGlobalVarColor(s.color),d=document.createElement("div");d.className="gstop-color-preview",d.style.backgroundColor=h;const p=document.createElement("input");p.type="text",p.className="gstop-color-input",p.value=h.replace("#","").toUpperCase();const u=document.createElement("button");u.type="button",u.className="gstop-color-copy",u.textContent="Copy",r.appendChild(d),r.appendChild(p),r.appendChild(u);const C=document.createElement("button");C.type="button",C.className="gstop-del",C.innerHTML=Yt,C.disabled=(((k=(b=this.value)==null?void 0:b.stops)==null?void 0:k.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(C),e.appendChild(o);const m=document.createElement("span");m.className="gstop-opacity-label",m.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const f=document.createElement("input");f.type="range",f.className="gstop-opacity-slider",f.min="0",f.max="100",f.value=String(s.opacity??100);const v=N(h);f.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${v.r}, ${v.g}, ${v.b}, 0)`);const y=document.createElement("span");y.className="gstop-opacity-value",y.textContent=`${s.opacity??100}%`,g.appendChild(f),g.appendChild(y),p.addEventListener("click",x=>{x.preventDefault(),x.stopPropagation();const E=this.getSharedStopColorPicker();E.getIsOpen()&&E.close(!1),this.colorPickerStopIndex=n,E.setOnChange((I,R)=>{this.clearGlobalBindingForCustomChange(),p.value=I.replace("#","").toUpperCase(),d.style.backgroundColor=I,this.value.stops[n].color=I,R!==void 0&&(this.value.stops[n].opacity=R,f.value=String(R),y.textContent=`${R}%`);const _=N(I);f.style.setProperty("--slider-color",`rgb(${_.r}, ${_.g}, ${_.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${_.r}, ${_.g}, ${_.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const L=this.resolveGlobalVarColor(s.color);E.open(L,p,s.opacity??100)}),p.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const x=p.value.trim(),E=x.startsWith("#")?x:`#${x}`;if(/^#[0-9A-Fa-f]{6}$/.test(E)){this.value.stops[n].color=E,d.style.backgroundColor=E;const L=N(E);f.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),f.style.setProperty("--slider-color-transparent",`rgba(${L.r}, ${L.g}, ${L.b}, 0)`),this.debouncedPreviewUpdate()}}),p.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),u.addEventListener("click",async x=>{x.stopPropagation();try{await navigator.clipboard.writeText(`#${p.value}`)}catch{}}),l.addEventListener("focus",x=>{const E=x.target;E.value=E.value.replace("%",""),E.select()}),l.addEventListener("input",x=>{this.clearGlobalBindingForCustomChange();const E=x.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(L)){const I=Math.max(0,Math.min(100,L));this.value.stops[n].position=I,E.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",x=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const E=x.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(Number.isNaN(L))E.value=`${this.value.stops[n].position}%`;else{const I=Math.max(0,Math.min(100,L));this.value.stops[n].position=I,E.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{var x,E;(this.value.stops.length||0)<=2||((x=this.sharedStopColorPicker)!=null&&x.getIsOpen()&&this.colorPickerStopIndex===n?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>n&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((E=document.activeElement)==null?void 0:E.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),f.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const x=parseInt(f.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,x)),y.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),f.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 t=this.value.stops.map(s=>s.position).sort((s,n)=>s-n);let e=50,i=0;for(let s=0;s<t.length-1;s++){const n=t[s+1]-t[s];n>i&&(i=n,e=t[s]+n/2)}this.addStopAtPosition(e)}addStopAtPosition(t){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=Math.max(0,Math.min(100,t)),i=[...this.value.stops].sort((r,h)=>r.position-h.position);let s=i[0],n=i[i.length-1];for(let r=0;r<i.length-1;r++)if(i[r].position<=e&&i[r+1].position>=e){s=i[r],n=i[r+1];break}let o,a;if(s===n||s.position===n.position)o=s.color,a=s.opacity??100;else{const r=(e-s.position)/(n.position-s.position),h=N(s.color),d=N(n.color),p=Math.round(h.r+(d.r-h.r)*r),u=Math.round(h.g+(d.g-h.g)*r),C=Math.round(h.b+(d.b-h.b)*r);o=`#${p.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}${C.toString(16).padStart(2,"0")}`.toUpperCase(),a=Math.round((s.opacity??100)+((n.opacity??100)-(s.opacity??100))*r)}const l={position:Math.round(e),color:o,opacity:a};this.value.stops.push(l),this.value.stops.sort((r,h)=>r.position-h.position)}openPopover(){if(this.popoverEl&&(V.openInstance&&V.openInstance!==this&&V.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,V.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 t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,h=t.left,d=e+n;r<d&&h>r+100&&(a=t.left-e-8);const p=s-t.bottom,u=t.top;u>=o+n?l=t.top-o-8:p>=o+n?l=t.bottom+8:u>p?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:a,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((t=document.activeElement)==null?void 0:t.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 e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const h=s-e.right,d=e.left,p=i+o;h<p&&d>h+100&&(l=e.left-i-8);const u=n-e.bottom,C=e.top;C>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:C>u?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}}refreshPopoverContent(){var n,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):(i.classList.add("active"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){var t,e;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(t=this.sharedStopColorPicker)!=null&&t.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 i=T(this.value);W.addColor(i,"gradient"),(e=this.recentGradientRefresh)==null||e.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),V.openInstance===this&&(V.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():W.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){let e=t.trim();e&&!e.startsWith("#")&&!e.startsWith("var(")&&!e.startsWith("rgb")&&!e.startsWith("hsl")&&!e.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(e)&&(e="#"+e,this.inputEl&&(this.inputEl.value=e));const i=O(e);i&&this.setValue(i)}getChangePayload(){var t;if(this.value)return this.isBoundToGlobal()?((t=this.value.stops)==null?void 0:t.some(i=>i.opacity!==void 0&&i.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const t=this.getChangePayload();t!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var e,i;(e=this.onChange)==null||e.call(this,t),(i=this.detectChange)==null||i.call(this,t),this.changeDebounceTimeout=null},V.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:T(t):""}getCSSValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:T(t):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};V.openInstance=null,V.CHANGE_DEBOUNCE_DELAY=150;let j=V;function X(c,t){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)){const i=c[e];t(e,i)}}const at=class at{constructor(t){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.id=t.id||gt(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",this.hide=t.hide??!1,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;X(this.settings,(e,i)=>{M(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(t){if(this.title=t,this.elementRef){const e=this.elementRef.querySelector(".setting-group-title h3");e&&(e.textContent=t)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){X(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(M(e)||A(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Q(this.elementRef,this.nestingLevel),ct(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(M(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const a of o){const l=a.id,r=a.getAttribute("data-setting-id");if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}if(r&&"id"in e&&typeof e.id=="string"&&r===e.id){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}updateSettings(t,e){var l;const i=(e==null?void 0:e.preserveValues)??!0,s=new Set(Object.keys(this.settings)),n=Object.keys(t),o={};i&&n.forEach(r=>{const h=this.settings[r];h&&(M(h)?o[r]=h.getValues():A(h)?o[r]=h.value:typeof h.getValues=="function"?o[r]=h.getValues():h.value!==void 0&&(o[r]=h.value))}),s.forEach(r=>{n.includes(r)||this.removeSetting(r)}),n.forEach(r=>{var p;const h=t[r],d=this.settings[r];if(d!==h&&(d&&this.removeSetting(r),this.addSetting(r,h),i&&r in o)){const u=o[r];try{M(h)?h.setValue(u):A(h)?(p=h.setValue)==null||p.call(h,u):h.setValue&&h.setValue(u)}catch(C){console.warn(`Could not preserve value for setting ${r}:`,C)}}}),this.settings=t,this.propagateNestingLevel(),this.propagateDataPropsPath();const a=this.getValues();this.initialValues=a,(l=this.onChange)==null||l.call(this,a)}clone(){const t={};X(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},i=Ot(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(M(s)||A(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(M(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(M(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),X(this.settings,(i,s)=>{var n;if(M(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(A(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),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()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);ht(l)&&(this.addSetting(i,l),n=l)}}n&&(M(n)||A(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};M(t)?t.setOnChange(()=>e()):A(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){const a=o.querySelector(".setting-group-empty");a&&a.remove(),M(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const l=e.draw(),r=this.deleteItemCfg??this.addItemCfg;if(r){const p=r.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);p&&t.startsWith(p)&&this.addDeleteButtonToElement(l,t)}const h=o.querySelector(".sg-add-button-bottom");h?o.insertBefore(l,h):o.appendChild(l),yt.trackElement(l),Q(l,this.nestingLevel+1),ct(l,this.nestingLevel+1);const d=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=d,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const h of r)if(h.closest(".setting-group")===t){s=h;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
29
29
  background: none;
30
30
  border: none;
31
31
  cursor: pointer;
@@ -106,7 +106,7 @@
106
106
  xmlns="http://www.w3.org/2000/svg">
107
107
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
108
108
  stroke-width="1.5" stroke-linecap="round"/>
109
- </svg>`;h.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,h.addEventListener("click",p=>{p.stopPropagation(),p.preventDefault();const u=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),C=this.addItemCfg.createItem(u);if(ht(C)){const m=`${this.addItemCfg.keyPrefix}${u}`;this.addSetting(m,C)}}),a.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(a),this.elementRef=t,Ct.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(a=>n.includes(a))&&n.length===1){const a=n[0];i=e[a]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};at.hiddenElements=new Set;let H=at;function se(c){return new vt(c)}class vt extends H{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){var i;if(!this.settings[t]||this.activeTabId===t)return;this.activeTabId=t,this.updateTabUI();const e=this.getValues();this.initialValues=e,(i=this.onChange)==null||i.call(this,e)}getValues(t){return t!==void 0?super.getValues(t):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const o=document.createElement("div");if(o.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((a,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",a),r.textContent=a,r.addEventListener("click",()=>this.switchToTab(a)),n.appendChild(r);const h=document.createElement("div");h.className="tab-panel",this.contentContainers[a]=h;const d=this.settings[a];d&&(M(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),h.appendChild(d.draw())),o.appendChild(h),l===0&&!this.activeTabId&&(this.activeTabId=a)}),e.appendChild(i),e.appendChild(n),e.appendChild(o),!this.activeTabId){const a=Object.keys(this.settings)[0];this.activeTabId=a||""}return this.updateTabUI(),t}}function Ot(c){return new H(c)}function ne(c){return c}class Ht extends w{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.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:t})}}const oe="<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' stroke-linecap='round' stroke-linejoin='round'/></svg>";class P extends Ht{constructor(t){super({...t,icon:t.icon||oe,title:t.title||"Color",default:t.default?P.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("var(--")?t:t.startsWith("#")?P.normalizeHexValue(t):t.includes(",")?P.rgbToHexStatic(t):P.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,o=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const d=h.toString(16);return d.length===1?"0"+d:d};return`#${r(o)}${r(a)}${r(l)}`}setValue(t){if(t===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 t=="string"){const e=P.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}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(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const m=document.createElement("div");if(m.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,m.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,m.appendChild(g)}t.appendChild(m)}const e=document.createElement("div");e.className="color-input-wrapper";const i=document.createElement("div");i.className="color-setting-tabs",i.style.display="flex",i.style.marginBottom="8px",i.style.gap="4px";const s=document.createElement("button");s.className="color-tab active",s.textContent="Solid";const n=document.createElement("button");n.className="color-tab",n.textContent="Global",i.appendChild(s),i.appendChild(n);const o=document.createElement("div");o.className="color-content-solid";const a=document.createElement("div");a.className="color-content-global",a.style.display="none",a.style.display="grid",a.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",a.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),a.innerHTML="",!w){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",a.appendChild(g);return}const m=w.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",m),!m||Object.keys(m).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",a.appendChild(g);return}Object.entries(m).forEach(([g,f])=>{const v=document.createElement("button");v.className="global-color-btn",v.title=g,v.style.width="30px",v.style.height="30px",v.style.borderRadius="50%",v.style.border="1px solid #ddd",v.style.backgroundColor=f,v.style.cursor="pointer",this.value===`var(--${g})`&&(v.style.border="2px solid #2196f3"),v.addEventListener("click",y=>{var k,x;y.preventDefault();const b=`var(--${g})`;this.value=b,(k=this.onChange)==null||k.call(this,b),(x=this.detectChange)==null||x.call(this,b),Array.from(a.children).forEach(E=>{E.style.border="1px solid #ddd"}),v.style.border="2px solid #2196f3",d.style.backgroundColor=f}),a.appendChild(v)})}catch(m){console.error("ColorSetting: Error in renderGlobalOptions",m),a.innerHTML="Error loading global options"}};l(),s.addEventListener("click",m=>{m.preventDefault(),s.classList.add("active"),n.classList.remove("active"),o.style.display="flex",a.style.display="none",this.value&&this.value.startsWith("var(--")}),n.addEventListener("click",m=>{m.preventDefault(),n.classList.add("active"),s.classList.remove("active"),o.style.display="none",a.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?n.click():s.click();const r=m=>{const g=m.value.trim();if(!g)return e.classList.remove("error"),!0;const v=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return v?e.classList.remove("error"):e.classList.add("error"),v},h=document.createElement("input");h.type="color",h.className="color-picker",h.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",h.setAttribute("aria-label","Choose color"),h.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&h.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=h;const d=document.createElement("div");d.className="color-preview";let p=this.value||"#000000";if(p.startsWith("var(--")){const m=p.replace("var(--","").replace(")","");p=(w.GlobalVariables||{})[m]||"#000000"}d.style.backgroundColor=p;const u=document.createElement("input");u.type="text",u.className="color-text-input",u.value=this.value||"",u.placeholder="#000000",u.setAttribute("pattern","#[0-9A-Fa-f]{6}"),u.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),u.setAttribute("aria-label","Hex color value"),u.setAttribute("maxlength","7"),this.getDataPropsPath()&&u.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=u;const C=m=>{var f,v;let g=m.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&&r(this.textInputEl)){const y=P.normalizeColorValue(g);this.value=y,(f=this.onChange)==null||f.call(this,y),(v=this.detectChange)==null||v.call(this,y),this.colorInputEl&&(this.colorInputEl.value=y),d.style.backgroundColor=y}};return this.textInputEl.addEventListener("input",m=>{const g=m.target.value;C(g)}),this.textInputEl.addEventListener("paste",m=>{var f;m.preventDefault();const g=((f=m.clipboardData)==null?void 0:f.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),C(g))}),this.textInputEl.addEventListener("keydown",m=>{var g,f,v;m.key==="Enter"&&(m.preventDefault(),C(((g=this.textInputEl)==null?void 0:g.value)||""),(f=this.textInputEl)==null||f.blur()),m.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(v=this.textInputEl)==null||v.blur(),e.classList.remove("error"))}),this.colorInputEl.addEventListener("input",m=>{var v,y;const g=m.target.value,f=P.normalizeColorValue(g);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),d.style.backgroundColor=f,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",m=>{var v,y;const g=m.target.value,f=P.normalizeColorValue(g);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),d.style.backgroundColor=f}),o.appendChild(h),o.appendChild(d),o.appendChild(u),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?P.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 ae=`
109
+ </svg>`;h.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,h.addEventListener("click",p=>{p.stopPropagation(),p.preventDefault();const u=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),C=this.addItemCfg.createItem(u);if(ht(C)){const m=`${this.addItemCfg.keyPrefix}${u}`;this.addSetting(m,C)}}),a.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(a),this.elementRef=t,yt.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(a=>n.includes(a))&&n.length===1){const a=n[0];i=e[a]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};at.hiddenElements=new Set;let H=at;function se(c){return new ft(c)}class ft extends H{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){var i;if(!this.settings[t]||this.activeTabId===t)return;this.activeTabId=t,this.updateTabUI();const e=this.getValues();this.initialValues=e,(i=this.onChange)==null||i.call(this,e)}getValues(t){return t!==void 0?super.getValues(t):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const o=document.createElement("div");if(o.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((a,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",a),r.textContent=a,r.addEventListener("click",()=>this.switchToTab(a)),n.appendChild(r);const h=document.createElement("div");h.className="tab-panel",this.contentContainers[a]=h;const d=this.settings[a];d&&(M(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),h.appendChild(d.draw())),o.appendChild(h),l===0&&!this.activeTabId&&(this.activeTabId=a)}),e.appendChild(i),e.appendChild(n),e.appendChild(o),!this.activeTabId){const a=Object.keys(this.settings)[0];this.activeTabId=a||""}return this.updateTabUI(),t}}function Ot(c){return new H(c)}function ne(c){return c}class Ht extends w{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.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:t})}}const oe="<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' stroke-linecap='round' stroke-linejoin='round'/></svg>";class P extends Ht{constructor(t){super({...t,icon:t.icon||oe,title:t.title||"Color",default:t.default?P.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("var(--")?t:t.startsWith("#")?P.normalizeHexValue(t):t.includes(",")?P.rgbToHexStatic(t):P.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,o=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const d=h.toString(16);return d.length===1?"0"+d:d};return`#${r(o)}${r(a)}${r(l)}`}setValue(t){if(t===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 t=="string"){const e=P.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}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(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const m=document.createElement("div");if(m.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,m.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,m.appendChild(g)}t.appendChild(m)}const e=document.createElement("div");e.className="color-input-wrapper";const i=document.createElement("div");i.className="color-setting-tabs",i.style.display="flex",i.style.marginBottom="8px",i.style.gap="4px";const s=document.createElement("button");s.className="color-tab active",s.textContent="Solid";const n=document.createElement("button");n.className="color-tab",n.textContent="Global",i.appendChild(s),i.appendChild(n);const o=document.createElement("div");o.className="color-content-solid";const a=document.createElement("div");a.className="color-content-global",a.style.display="none",a.style.display="grid",a.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",a.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),a.innerHTML="",!w){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",a.appendChild(g);return}const m=w.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",m),!m||Object.keys(m).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",a.appendChild(g);return}Object.entries(m).forEach(([g,f])=>{const v=document.createElement("button");v.className="global-color-btn",v.title=g,v.style.width="30px",v.style.height="30px",v.style.borderRadius="50%",v.style.border="1px solid #ddd",v.style.backgroundColor=f,v.style.cursor="pointer",this.value===`var(--${g})`&&(v.style.border="2px solid #2196f3"),v.addEventListener("click",y=>{var k,x;y.preventDefault();const b=`var(--${g})`;this.value=b,(k=this.onChange)==null||k.call(this,b),(x=this.detectChange)==null||x.call(this,b),Array.from(a.children).forEach(E=>{E.style.border="1px solid #ddd"}),v.style.border="2px solid #2196f3",d.style.backgroundColor=f}),a.appendChild(v)})}catch(m){console.error("ColorSetting: Error in renderGlobalOptions",m),a.innerHTML="Error loading global options"}};l(),s.addEventListener("click",m=>{m.preventDefault(),s.classList.add("active"),n.classList.remove("active"),o.style.display="flex",a.style.display="none",this.value&&this.value.startsWith("var(--")}),n.addEventListener("click",m=>{m.preventDefault(),n.classList.add("active"),s.classList.remove("active"),o.style.display="none",a.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?n.click():s.click();const r=m=>{const g=m.value.trim();if(!g)return e.classList.remove("error"),!0;const v=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return v?e.classList.remove("error"):e.classList.add("error"),v},h=document.createElement("input");h.type="color",h.className="color-picker",h.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",h.setAttribute("aria-label","Choose color"),h.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&h.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=h;const d=document.createElement("div");d.className="color-preview";let p=this.value||"#000000";if(p.startsWith("var(--")){const m=p.replace("var(--","").replace(")","");p=(w.GlobalVariables||{})[m]||"#000000"}d.style.backgroundColor=p;const u=document.createElement("input");u.type="text",u.className="color-text-input",u.value=this.value||"",u.placeholder="#000000",u.setAttribute("pattern","#[0-9A-Fa-f]{6}"),u.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),u.setAttribute("aria-label","Hex color value"),u.setAttribute("maxlength","7"),this.getDataPropsPath()&&u.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=u;const C=m=>{var f,v;let g=m.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&&r(this.textInputEl)){const y=P.normalizeColorValue(g);this.value=y,(f=this.onChange)==null||f.call(this,y),(v=this.detectChange)==null||v.call(this,y),this.colorInputEl&&(this.colorInputEl.value=y),d.style.backgroundColor=y}};return this.textInputEl.addEventListener("input",m=>{const g=m.target.value;C(g)}),this.textInputEl.addEventListener("paste",m=>{var f;m.preventDefault();const g=((f=m.clipboardData)==null?void 0:f.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),C(g))}),this.textInputEl.addEventListener("keydown",m=>{var g,f,v;m.key==="Enter"&&(m.preventDefault(),C(((g=this.textInputEl)==null?void 0:g.value)||""),(f=this.textInputEl)==null||f.blur()),m.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(v=this.textInputEl)==null||v.blur(),e.classList.remove("error"))}),this.colorInputEl.addEventListener("input",m=>{var v,y;const g=m.target.value,f=P.normalizeColorValue(g);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),d.style.backgroundColor=f,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",m=>{var v,y;const g=m.target.value,f=P.normalizeColorValue(g);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),d.style.backgroundColor=f}),o.appendChild(h),o.appendChild(d),o.appendChild(u),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?P.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 ae=`
110
110
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
111
111
  <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" stroke-linecap="round" stroke-linejoin="round"/>
112
112
  <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" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
@@ -195,7 +195,7 @@
195
195
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
196
196
  <path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
197
197
  </svg>
198
- `,wt=`
198
+ `,xt=`
199
199
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
200
200
  <path d="M1.5 7.5C1.5 7.5 3.00374 5.45116 4.22538 4.22868C5.44702 3.0062 7.1352 2.25 9 2.25C12.7279 2.25 15.75 5.27208 15.75 9C15.75 12.7279 12.7279 15.75 9 15.75C5.92268 15.75 3.32633 13.6907 2.51382 10.875M1.5 7.5V3M1.5 7.5H6" stroke="#637381" stroke-linecap="round" stroke-linejoin="round"/>
201
201
  </svg>
@@ -246,7 +246,7 @@
246
246
  <svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox="0 0 8 4" fill="none">
247
247
  <path fill-rule="evenodd" clip-rule="evenodd" d="M0 0L2.58579 2.58579C3.36684 3.36684 4.63317 3.36683 5.41421 2.58579L8 0L0 0Z" fill="#1C252E"/>
248
248
  </svg>
249
- `,F=10,xt=5,Se=24,Ie=50,Ne=5e3,Te=800,Pe=.8,Ve=700,Oe=["image/jpeg","image/jpg","image/png","image/gif","image/webp"];function He(c,t){if(!Oe.includes(c.type))return{valid:!1,error:"Invalid file type. Please upload a JPEG, PNG, GIF, or WebP image."};const e=t*1024*1024;return c.size>e?{valid:!1,error:`File size (${(c.size/1048576).toFixed(1)}MB) exceeds ${t}MB limit.`}:{valid:!0}}function Lt(c,t,e){if(!c.length)return[];const i=t&&t.width&&t.height&&t||e&&e.width&&e.height&&e||null;return c.map(s=>{const n={...s};return i&&n.x>100&&(n.x=n.x/i.width*100),i&&n.y>100&&(n.y=n.y/i.height*100),n.x=ot(n.x),n.y=ot(n.y),n})}function ot(c){return Number.isFinite(c)?Math.max(0,Math.min(100,c)):0}function kt(c,t,e){const i=(c-e.left)/e.width*100,s=(t-e.top)/e.height*100;return{x:ot(i),y:ot(s)}}function At(c){const t=c.map(i=>i.index).sort((i,s)=>i-s);let e=1;for(const i of t)if(i===e)e++;else break;return e}function $e(c,t){const e=At(c);let i=`Prize ${e}`;if(t&&t.length>0){const s=t[e-1];s&&(i=s)}return{index:e,name:i}}const ft=class ft{static show(t,e=Ne){this.injectStyles();const i=document.createElement("div");i.className="image-map-error-toast",i.textContent=t,i.style.cssText=`
249
+ `,F=10,Lt=5,Se=24,Ie=50,Ne=5e3,Te=800,Pe=.8,Ve=700,Oe=["image/jpeg","image/jpg","image/png","image/gif","image/webp"];function He(c,t){if(!Oe.includes(c.type))return{valid:!1,error:"Invalid file type. Please upload a JPEG, PNG, GIF, or WebP image."};const e=t*1024*1024;return c.size>e?{valid:!1,error:`File size (${(c.size/1048576).toFixed(1)}MB) exceeds ${t}MB limit.`}:{valid:!0}}function kt(c,t,e){if(!c.length)return[];const i=t&&t.width&&t.height&&t||e&&e.width&&e.height&&e||null;return c.map(s=>{const n={...s};return i&&n.x>100&&(n.x=n.x/i.width*100),i&&n.y>100&&(n.y=n.y/i.height*100),n.x=ot(n.x),n.y=ot(n.y),n})}function ot(c){return Number.isFinite(c)?Math.max(0,Math.min(100,c)):0}function Mt(c,t,e){const i=(c-e.left)/e.width*100,s=(t-e.top)/e.height*100;return{x:ot(i),y:ot(s)}}function At(c){const t=c.map(i=>i.index).sort((i,s)=>i-s);let e=1;for(const i of t)if(i===e)e++;else break;return e}function $e(c,t){const e=At(c);let i=`Prize ${e}`;if(t&&t.length>0){const s=t[e-1];s&&(i=s)}return{index:e,name:i}}const Ct=class Ct{static show(t,e=Ne){this.injectStyles();const i=document.createElement("div");i.className="image-map-error-toast",i.textContent=t,i.style.cssText=`
250
250
  position: fixed;
251
251
  top: 20px;
252
252
  right: 20px;
@@ -280,17 +280,17 @@
280
280
  opacity: 0;
281
281
  }
282
282
  }
283
- `,document.head.appendChild(t)}this.styleInjected=!0}}};ft.styleInjected=!1;let q=ft;class Be{constructor(){this.overlayElement=null,this.activePromise=null}show(t){return this.activePromise?this.activePromise:(this.activePromise=new Promise(e=>{this.cleanup();const i=document.createElement("div");i.className="image-map-confirm-overlay",this.overlayElement=i;const s=document.createElement("div");s.className="image-map-confirm-modal";const n=document.createElement("div");n.className="confirm-header",n.textContent=t.title;const o=document.createElement("div");o.className="confirm-body",o.textContent=t.description;const a=document.createElement("div");a.className="confirm-actions";const l=document.createElement("button");l.type="button",l.className="confirm-btn ghost",l.textContent=t.cancelText||"Cancel";const r=document.createElement("button");r.type="button",r.className="confirm-btn danger",r.textContent=t.confirmText||"Discard";const h=d=>{i.remove(),this.overlayElement=null,this.activePromise=null,e(d)};l.addEventListener("click",()=>h(!1)),r.addEventListener("click",()=>h(!0)),i.addEventListener("click",d=>{d.target===i&&h(!1)}),a.appendChild(l),a.appendChild(r),s.appendChild(n),s.appendChild(o),s.appendChild(a),i.appendChild(s),document.body.appendChild(i),setTimeout(()=>{s.classList.add("visible")},10)}),this.activePromise)}cleanup(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null),this.activePromise=null}}class Ae{constructor(){this.element=document.createElement("div"),this.element.className="marker-cursor-tooltip"}getElement(){return this.element}show(){this.element.classList.add("visible")}hide(){this.element.classList.remove("visible")}updateContent(t){this.element.textContent=t}updatePosition(t,e){const i=e.getBoundingClientRect(),s=t.clientX-i.left,n=t.clientY-i.top;this.element.style.left=`${s}px`,this.element.style.top=`${n}px`}shouldShow(t,e){return t<e}}class De{constructor(){this.history=[],this.historyIndex=-1}initialize(t){this.history=[JSON.parse(JSON.stringify(t))],this.historyIndex=0}saveState(t){const e=JSON.parse(JSON.stringify(t));if(this.historyIndex>=0&&this.history.length>0){const i=this.history[this.historyIndex];if(JSON.stringify(i)===JSON.stringify(e))return}this.history=this.history.slice(0,this.historyIndex+1),this.history.push(e),this.historyIndex++,this.history.length>Ie&&(this.history.shift(),this.historyIndex--)}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}undo(){return this.canUndo()?(this.historyIndex--,JSON.parse(JSON.stringify(this.history[this.historyIndex]))):null}redo(){return this.canRedo()?(this.historyIndex++,JSON.parse(JSON.stringify(this.history[this.historyIndex]))):null}reset(){this.history=[],this.historyIndex=-1}}class Ge{constructor(){this.messageListener=null,this.handlers=new Map}registerHandler(t,e){this.handlers.set(t,e),this.messageListener||this.setupMessageListener()}unregisterHandler(t){this.handlers.delete(t),this.handlers.size===0&&this.cleanupMessageListener()}openFileManager(t){window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:t},"*")}setupMessageListener(){this.messageListener=t=>{if(t.data&&t.data.type==="FILE_MANAGER_IMAGE_SELECTED"){const e=t.data.settingId,i=t.data.imageUrl;if(e&&i&&typeof i=="string"){const s=this.handlers.get(e);s&&s(i)}}},window.addEventListener("message",this.messageListener)}cleanupMessageListener(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null)}cleanup(){this.handlers.clear(),this.cleanupMessageListener()}}const Mt=new Ge;function Re(c,t){const e=document.createElement("div");e.className="marker-container",e.style.left=`${c.x}%`,e.style.top=`${c.y}%`,e.setAttribute("data-marker-id",String(c.id));const i=document.createElement("div");i.className="image-map-marker",i.innerHTML=Le;const s=document.createElement("span");s.className="marker-number",s.textContent=String(c.index),i.appendChild(s),e.appendChild(i);const n=document.createElement("button");return n.type="button",n.className="marker-delete-btn",n.innerHTML=Ce,n.addEventListener("click",o=>{o.stopPropagation(),t.onDelete(c.id)}),e.appendChild(n),e.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),t.onDragStart(c.id),e.classList.add("dragging")}),e}function Fe(c,t,e){const i=new Map;c.forEach(n=>i.set(n.index,n));const s=document.createElement("div");s.className="simple-prize-list";for(let n=t;n>=1;n--){const o=i.get(n),a=!!o,l=(o==null?void 0:o.prizeName)||e&&e[n-1]||"Prize Name",r=document.createElement("div");r.className=`simple-prize-item ${a?"placed":""}`;const h=document.createElement("div");h.className="simple-prize-number",h.textContent=`#${n}`,r.appendChild(h);const d=document.createElement("div");if(d.className="simple-prize-text",d.textContent=`${l}`,r.appendChild(d),a){const p=document.createElement("div");p.className="simple-prize-check",p.innerHTML=we,r.appendChild(p)}s.appendChild(r)}return s}function Ue(c,t){const e=document.createElement("div");e.className="controls-row";const i=document.createElement("div");i.className="place-prize-text",i.textContent="Place Prize",e.appendChild(i);const s=document.createElement("div");s.className="undo-redo-group";const n=document.createElement("button");n.type="button",n.className="undo-btn action-btn",n.innerHTML=Ee,n.title="Undo (Ctrl+Z)",n.disabled=!c.canUndo,n.addEventListener("click",()=>t.onUndo()),s.appendChild(n);const o=document.createElement("button");o.type="button",o.className="redo-btn action-btn",o.innerHTML=be,o.title="Redo (Ctrl+Y)",o.disabled=!c.canRedo,o.addEventListener("click",()=>t.onRedo()),s.appendChild(o),e.appendChild(s);const a=c.markerCount===c.maxMarkers,l=document.createElement("div");return l.className="prize-counter-inline",l.textContent=`${c.markerCount}/${c.maxMarkers}`,a&&l.classList.add("complete"),e.appendChild(l),e}function ze(c){const t=document.createElement("div");{t.className="upload-section-wrapper";{const s=document.createElement("h4");s.className="upload-section-title",s.textContent="Upload/Replace Map Image",t.appendChild(s)}const e=document.createElement("div");e.className="upload-section";const i=We(c);e.appendChild(i),t.appendChild(e)}return t}function We(c){if(c.uploadMethod==="input"){const t=document.createElement("label");t.className="upload-label",t.innerHTML=`<div class="upload-placeholder">${nt}<span>Click to upload image</span></div>`;const e=document.createElement("input");return e.type="file",e.accept="image/jpeg,image/jpg,image/png,image/gif,image/webp",e.style.display="none",e.addEventListener("change",i=>{var n;const s=(n=i.target.files)==null?void 0:n[0];s&&c.onFileSelected(s)}),t.appendChild(e),t}else{const t=document.createElement("button");return t.type="button",t.className="upload-label",t.innerHTML=`<div class="upload-placeholder">${nt}<span>Open File Manager</span></div>`,t.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:c.settingId},"*")}),t}}function je(){const c=document.createElement("img");c.className="image-map-thumbnail-main";const t=document.createElement("span");t.className="image-map-icon",t.innerHTML=xe;const e=document.createElement("span");e.className="image-map-marker-count";const i=document.createElement("button");return i.type="button",i.className="image-map-button",i.appendChild(t),i.appendChild(e),{thumbnailEl:c,configureButtonTextEl:e,mapIconEl:t,configureButton:i,uploadBox:document.createElement("div")}}function B(c,t){const e=t&&t.imageUrl&&t.imageUrl!=="",i=c.thumbnailEl.parentElement,s=i==null?void 0:i.parentElement;s&&(e?(s.classList.add("has-image"),c.thumbnailEl.src=t.imageUrl):(s.classList.remove("has-image"),c.thumbnailEl.src="")),c.configureButtonTextEl.textContent="Configure Map",c.configureButton&&(c.configureButton.disabled=!e)}function _e(c,t){const e=document.createElement("div");e.className="image-map-upload-box";const i=document.createElement("div");i.className="image-map-thumbnail-wrapper",i.appendChild(c);const s=document.createElement("button");return s.type="button",s.className="image-map-delete-btn",s.innerHTML=ye,s.addEventListener("click",n=>{n.stopPropagation(),t()}),i.appendChild(s),e.appendChild(i),e}function qe(c,t,e){if(c==="input"){const i=document.createElement("label");i.className="image-map-upload-label",i.innerHTML=`
283
+ `,document.head.appendChild(t)}this.styleInjected=!0}}};Ct.styleInjected=!1;let q=Ct;class Be{constructor(){this.overlayElement=null,this.activePromise=null}show(t){return this.activePromise?this.activePromise:(this.activePromise=new Promise(e=>{this.cleanup();const i=document.createElement("div");i.className="image-map-confirm-overlay",this.overlayElement=i;const s=document.createElement("div");s.className="image-map-confirm-modal";const n=document.createElement("div");n.className="confirm-header",n.textContent=t.title;const o=document.createElement("div");o.className="confirm-body",o.textContent=t.description;const a=document.createElement("div");a.className="confirm-actions";const l=document.createElement("button");l.type="button",l.className="confirm-btn ghost",l.textContent=t.cancelText||"Cancel";const r=document.createElement("button");r.type="button",r.className="confirm-btn danger",r.textContent=t.confirmText||"Discard";const h=d=>{i.remove(),this.overlayElement=null,this.activePromise=null,e(d)};l.addEventListener("click",()=>h(!1)),r.addEventListener("click",()=>h(!0)),i.addEventListener("click",d=>{d.target===i&&h(!1)}),a.appendChild(l),a.appendChild(r),s.appendChild(n),s.appendChild(o),s.appendChild(a),i.appendChild(s),document.body.appendChild(i),setTimeout(()=>{s.classList.add("visible")},10)}),this.activePromise)}cleanup(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null),this.activePromise=null}}class Ae{constructor(){this.element=document.createElement("div"),this.element.className="marker-cursor-tooltip"}getElement(){return this.element}show(){this.element.classList.add("visible")}hide(){this.element.classList.remove("visible")}updateContent(t){this.element.textContent=t}updatePosition(t,e){const i=e.getBoundingClientRect(),s=t.clientX-i.left,n=t.clientY-i.top;this.element.style.left=`${s}px`,this.element.style.top=`${n}px`}shouldShow(t,e){return t<e}}class De{constructor(){this.history=[],this.historyIndex=-1}initialize(t){this.history=[JSON.parse(JSON.stringify(t))],this.historyIndex=0}saveState(t){const e=JSON.parse(JSON.stringify(t));if(this.historyIndex>=0&&this.history.length>0){const i=this.history[this.historyIndex];if(JSON.stringify(i)===JSON.stringify(e))return}this.history=this.history.slice(0,this.historyIndex+1),this.history.push(e),this.historyIndex++,this.history.length>Ie&&(this.history.shift(),this.historyIndex--)}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}undo(){return this.canUndo()?(this.historyIndex--,JSON.parse(JSON.stringify(this.history[this.historyIndex]))):null}redo(){return this.canRedo()?(this.historyIndex++,JSON.parse(JSON.stringify(this.history[this.historyIndex]))):null}reset(){this.history=[],this.historyIndex=-1}}class Ge{constructor(){this.messageListener=null,this.handlers=new Map}registerHandler(t,e){this.handlers.set(t,e),this.messageListener||this.setupMessageListener()}unregisterHandler(t){this.handlers.delete(t),this.handlers.size===0&&this.cleanupMessageListener()}openFileManager(t){window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:t},"*")}setupMessageListener(){this.messageListener=t=>{if(t.data&&t.data.type==="FILE_MANAGER_IMAGE_SELECTED"){const e=t.data.settingId,i=t.data.imageUrl;if(e&&i&&typeof i=="string"){const s=this.handlers.get(e);s&&s(i)}}},window.addEventListener("message",this.messageListener)}cleanupMessageListener(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null)}cleanup(){this.handlers.clear(),this.cleanupMessageListener()}}const St=new Ge;function Re(c,t){const e=document.createElement("div");e.className="marker-container",e.style.left=`${c.x}%`,e.style.top=`${c.y}%`,e.setAttribute("data-marker-id",String(c.id));const i=document.createElement("div");i.className="image-map-marker",i.innerHTML=Le;const s=document.createElement("span");s.className="marker-number",s.textContent=String(c.index),i.appendChild(s),e.appendChild(i);const n=document.createElement("button");return n.type="button",n.className="marker-delete-btn",n.innerHTML=Ce,n.addEventListener("click",o=>{o.stopPropagation(),t.onDelete(c.id)}),e.appendChild(n),e.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),t.onDragStart(c.id),e.classList.add("dragging")}),e}function Fe(c,t,e){const i=new Map;c.forEach(n=>i.set(n.index,n));const s=document.createElement("div");s.className="simple-prize-list";for(let n=t;n>=1;n--){const o=i.get(n),a=!!o,l=(o==null?void 0:o.prizeName)||e&&e[n-1]||"Prize Name",r=document.createElement("div");r.className=`simple-prize-item ${a?"placed":""}`;const h=document.createElement("div");h.className="simple-prize-number",h.textContent=`#${n}`,r.appendChild(h);const d=document.createElement("div");if(d.className="simple-prize-text",d.textContent=`${l}`,r.appendChild(d),a){const p=document.createElement("div");p.className="simple-prize-check",p.innerHTML=we,r.appendChild(p)}s.appendChild(r)}return s}function Ue(c,t){const e=document.createElement("div");e.className="controls-row";const i=document.createElement("div");i.className="place-prize-text",i.textContent="Place Prize",e.appendChild(i);const s=document.createElement("div");s.className="undo-redo-group";const n=document.createElement("button");n.type="button",n.className="undo-btn action-btn",n.innerHTML=Ee,n.title="Undo (Ctrl+Z)",n.disabled=!c.canUndo,n.addEventListener("click",()=>t.onUndo()),s.appendChild(n);const o=document.createElement("button");o.type="button",o.className="redo-btn action-btn",o.innerHTML=be,o.title="Redo (Ctrl+Y)",o.disabled=!c.canRedo,o.addEventListener("click",()=>t.onRedo()),s.appendChild(o),e.appendChild(s);const a=c.markerCount===c.maxMarkers,l=document.createElement("div");return l.className="prize-counter-inline",l.textContent=`${c.markerCount}/${c.maxMarkers}`,a&&l.classList.add("complete"),e.appendChild(l),e}function ze(c){const t=document.createElement("div");{t.className="upload-section-wrapper";{const s=document.createElement("h4");s.className="upload-section-title",s.textContent="Upload/Replace Map Image",t.appendChild(s)}const e=document.createElement("div");e.className="upload-section";const i=We(c);e.appendChild(i),t.appendChild(e)}return t}function We(c){if(c.uploadMethod==="input"){const t=document.createElement("label");t.className="upload-label",t.innerHTML=`<div class="upload-placeholder">${nt}<span>Click to upload image</span></div>`;const e=document.createElement("input");return e.type="file",e.accept="image/jpeg,image/jpg,image/png,image/gif,image/webp",e.style.display="none",e.addEventListener("change",i=>{var n;const s=(n=i.target.files)==null?void 0:n[0];s&&c.onFileSelected(s)}),t.appendChild(e),t}else{const t=document.createElement("button");return t.type="button",t.className="upload-label",t.innerHTML=`<div class="upload-placeholder">${nt}<span>Open File Manager</span></div>`,t.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:c.settingId},"*")}),t}}function je(){const c=document.createElement("img");c.className="image-map-thumbnail-main";const t=document.createElement("span");t.className="image-map-icon",t.innerHTML=xe;const e=document.createElement("span");e.className="image-map-marker-count";const i=document.createElement("button");return i.type="button",i.className="image-map-button",i.appendChild(t),i.appendChild(e),{thumbnailEl:c,configureButtonTextEl:e,mapIconEl:t,configureButton:i,uploadBox:document.createElement("div")}}function B(c,t){const e=t&&t.imageUrl&&t.imageUrl!=="",i=c.thumbnailEl.parentElement,s=i==null?void 0:i.parentElement;s&&(e?(s.classList.add("has-image"),c.thumbnailEl.src=t.imageUrl):(s.classList.remove("has-image"),c.thumbnailEl.src="")),c.configureButtonTextEl.textContent="Configure Map",c.configureButton&&(c.configureButton.disabled=!e)}function _e(c,t){const e=document.createElement("div");e.className="image-map-upload-box";const i=document.createElement("div");i.className="image-map-thumbnail-wrapper",i.appendChild(c);const s=document.createElement("button");return s.type="button",s.className="image-map-delete-btn",s.innerHTML=ye,s.addEventListener("click",n=>{n.stopPropagation(),t()}),i.appendChild(s),e.appendChild(i),e}function qe(c,t,e){if(c==="input"){const i=document.createElement("label");i.className="image-map-upload-label",i.innerHTML=`
284
284
  <div class="upload-icon upload-icon-default">${nt}</div>
285
- <div class="upload-icon upload-icon-replace">${wt}</div>
285
+ <div class="upload-icon upload-icon-replace">${xt}</div>
286
286
  <span class="upload-text">Upload Image</span>
287
287
  `;const s=document.createElement("input");return s.type="file",s.accept="image/jpeg,image/jpg,image/png,image/gif,image/webp",s.style.display="none",s.addEventListener("change",n=>{var a;const o=(a=n.target.files)==null?void 0:a[0];o&&t&&t(o)}),i.appendChild(s),i}else{const i=document.createElement("button");return i.type="button",i.className="image-map-upload-label",i.innerHTML=`
288
288
  <div class="upload-icon upload-icon-default">${nt}</div>
289
- <div class="upload-icon upload-icon-replace">${wt}</div>
289
+ <div class="upload-icon upload-icon-replace">${xt}</div>
290
290
  <span class="upload-text">Upload Image</span>
291
- `,i.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:e},"*")}),i}}function Ze(c,t,e,i){const s=document.createElement("div");s.className="image-map-container",s.addEventListener("scroll",e.onScroll);const n=document.createElement("div");n.className="image-map-wrapper",n.addEventListener("mousemove",e.onMarkerDrag),n.addEventListener("mouseup",e.onStopDragging),n.addEventListener("mouseleave",e.onStopDragging);const o=document.createElement("img");o.className="image-map-image",o.src=c,o.addEventListener("load",e.onImageLoad),o.addEventListener("click",e.onImageClick),n.appendChild(o);const a=i.getElement();return n.appendChild(a),o.addEventListener("mouseenter",()=>i.show()),o.addEventListener("mouseleave",()=>i.hide()),o.addEventListener("mousemove",l=>{i.updatePosition(l,o),e.onMouseMove&&e.onMouseMove(l)}),t.forEach(l=>{const r=Re(l,{onDelete:e.onDelete,onDragStart:e.onDragStart});n.appendChild(r)}),s.appendChild(n),{container:s,imageElement:o}}function Je(c,t){const e=document.createElement("div");e.className="image-map-backdrop",e.style.display="none";const i=document.createElement("div");i.className="image-map-popover",i.style.display="none";const s=document.createElement("div");s.className="image-map-header",s.style.cursor="move";const n=document.createElement("h3");n.className="image-map-title",n.textContent="Prize Map",s.appendChild(n);const o=document.createElement("button");o.type="button",o.className="image-map-close-btn",o.innerHTML=fe,o.addEventListener("click",()=>void c()),s.appendChild(o),gt(s,i,(l,r)=>{t(l,r)}),i.appendChild(s);const a=document.createElement("div");return a.className="image-map-content",i.appendChild(a),document.body.appendChild(e),document.body.appendChild(i),{backdrop:e,popover:i,content:a}}function Xe(c,t){const e=t.getBoundingClientRect(),i=Te,s=Math.min(window.innerHeight*Pe,Ve);let n=e.right+8,o=e.top;const a=window.innerWidth-e.right;return a<i+16&&e.left>a+100&&(n=e.left-i-8),n=Math.max(8,Math.min(n,window.innerWidth-i-8)),o=Math.max(8,Math.min(o,window.innerHeight-s-8)),c.style.left=`${n}px`,c.style.top=`${o}px`,{left:n,top:o}}function Ye(c,t,e){const i=document.createElement("div");i.className="bottom-buttons";const s=document.createElement("button");s.type="button",s.className="clear-all-btn",s.innerHTML=ke+"<span>Remove All</span>",s.addEventListener("click",t),i.appendChild(s);const n=document.createElement("div");n.className="done-btn-wrapper";const o=document.createElement("button");if(o.type="button",o.className="done-btn",o.textContent="Done",c||(o.disabled=!0,n.classList.add("has-tooltip")),o.addEventListener("click",()=>{c&&e()}),n.appendChild(o),!c){const a=document.createElement("div");a.className="done-btn-tooltip";const l=document.createElement("div");l.className="done-btn-tooltip-content",l.textContent="Map all prizes";const r=document.createElement("div");r.className="done-btn-tooltip-tail",r.innerHTML=Me,a.appendChild(l),a.appendChild(r),n.appendChild(a)}return i.appendChild(n),i}const Ke=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox="0 0 8 4" fill="none">
291
+ `,i.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:e},"*")}),i}}function Ze(c,t,e,i){const s=document.createElement("div");s.className="image-map-container",s.addEventListener("scroll",e.onScroll);const n=document.createElement("div");n.className="image-map-wrapper",n.addEventListener("mousemove",e.onMarkerDrag),n.addEventListener("mouseup",e.onStopDragging),n.addEventListener("mouseleave",e.onStopDragging);const o=document.createElement("img");o.className="image-map-image",o.src=c,o.addEventListener("load",e.onImageLoad),o.addEventListener("click",e.onImageClick),n.appendChild(o);const a=i.getElement();return n.appendChild(a),o.addEventListener("mouseenter",()=>i.show()),o.addEventListener("mouseleave",()=>i.hide()),o.addEventListener("mousemove",l=>{i.updatePosition(l,o),e.onMouseMove&&e.onMouseMove(l)}),t.forEach(l=>{const r=Re(l,{onDelete:e.onDelete,onDragStart:e.onDragStart});n.appendChild(r)}),s.appendChild(n),{container:s,imageElement:o}}function Je(c,t){const e=document.createElement("div");e.className="image-map-backdrop",e.style.display="none";const i=document.createElement("div");i.className="image-map-popover",i.style.display="none";const s=document.createElement("div");s.className="image-map-header",s.style.cursor="move";const n=document.createElement("h3");n.className="image-map-title",n.textContent="Prize Map",s.appendChild(n);const o=document.createElement("button");o.type="button",o.className="image-map-close-btn",o.innerHTML=fe,o.addEventListener("click",()=>void c()),s.appendChild(o),mt(s,i,(l,r)=>{t(l,r)}),i.appendChild(s);const a=document.createElement("div");return a.className="image-map-content",i.appendChild(a),document.body.appendChild(e),document.body.appendChild(i),{backdrop:e,popover:i,content:a}}function Xe(c,t){const e=t.getBoundingClientRect(),i=Te,s=Math.min(window.innerHeight*Pe,Ve);let n=e.right+8,o=e.top;const a=window.innerWidth-e.right;return a<i+16&&e.left>a+100&&(n=e.left-i-8),n=Math.max(8,Math.min(n,window.innerWidth-i-8)),o=Math.max(8,Math.min(o,window.innerHeight-s-8)),c.style.left=`${n}px`,c.style.top=`${o}px`,{left:n,top:o}}function Ye(c,t,e){const i=document.createElement("div");i.className="bottom-buttons";const s=document.createElement("button");s.type="button",s.className="clear-all-btn",s.innerHTML=ke+"<span>Remove All</span>",s.addEventListener("click",t),i.appendChild(s);const n=document.createElement("div");n.className="done-btn-wrapper";const o=document.createElement("button");if(o.type="button",o.className="done-btn",o.textContent="Done",c||(o.disabled=!0,n.classList.add("has-tooltip")),o.addEventListener("click",()=>{c&&e()}),n.appendChild(o),!c){const a=document.createElement("div");a.className="done-btn-tooltip";const l=document.createElement("div");l.className="done-btn-tooltip-content",l.textContent="Map all prizes";const r=document.createElement("div");r.className="done-btn-tooltip-tail",r.innerHTML=Me,a.appendChild(l),a.appendChild(r),n.appendChild(a)}return i.appendChild(n),i}const Ke=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox="0 0 8 4" fill="none">
292
292
  <path fill-rule="evenodd" clip-rule="evenodd" d="M0 0L2.58579 2.58579C3.36684 3.36684 4.63317 3.36683 5.41421 2.58579L8 0L0 0Z" fill="#FF5630"/>
293
- </svg>`,D=class D extends w{constructor(t={}){var e;super(t),this.inputType={imageUrl:"text",markers:"text"},this.mainDisplayElements=null,this.popoverElements=null,this.imageElement=null,this.cursorTooltip=null,this.popoverPosition=null,this.isPopoverOpen=!1,this.confirmModal=new Be,this.previousImageDimensions=null,this.draggingMarkerId=null,this.historyManager=new De,this.isUndoRedoOperation=!1,this.initialValue=null,this.lastMouseX=0,this.lastMouseY=0,this.errorTooltipEl=null,this.errorTooltipTimeoutId=null,this.props.maxMarkers=this.props.maxMarkers??((e=this.props.prizeMap)==null?void 0:e.length)??F,this.props.maxFileSizeMB=this.props.maxFileSizeMB??xt,this.props.markerSize=this.props.markerSize??Se,this.value||(this.value={imageUrl:"",markers:[]}),Mt.registerHandler(this.id,i=>{this.handleFileManagerImageSelected(i)}),this.onBackgroundClick=i=>{if(this.isPopoverOpen&&this.popoverElements&&!this.popoverElements.popover.contains(i.target)){if(i.target.closest('[class*="modal"], [class*="Modal"], [class*="dialog"], [class*="Dialog"], [class*="overlay"], [class*="Overlay"]'))return;this.closePopover()}},this.handlePopoverKeydown=i=>{this.isPopoverOpen&&(i.key==="Escape"?this.closePopover():(i.ctrlKey||i.metaKey)&&(i.key==="z"||i.key==="Z"?i.shiftKey?(i.preventDefault(),this.redo()):(i.preventDefault(),this.undo()):(i.key==="y"||i.key==="Y")&&(i.preventDefault(),this.redo())))},this.boundHandleMarkerDrag=this.handleMarkerDrag.bind(this),this.boundStopDragging=this.stopDragging.bind(this),this.boundHandleScroll=this.handleScroll.bind(this)}draw(){const t=document.createElement("div");if(t.className="image-map-setting-wrapper",this.props.title||this.props.icon){const h=document.createElement("div");if(h.className="icon-container",this.props.icon){const d=this.createIcon(this.props.icon);h.appendChild(d)}if(this.props.title){const d=this.createLabel(this.props.title);h.appendChild(d)}t.appendChild(h)}const e=document.createElement("div");e.className="image-map-sections-container";const i=document.createElement("div");i.className="image-map-section";const s=document.createElement("h4");s.className="image-map-section-title",s.textContent="Upload/Replace Map Image",i.appendChild(s),this.mainDisplayElements=je();const n=_e(this.mainDisplayElements.thumbnailEl,()=>{this.value={imageUrl:"",markers:[]},this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}),o=this.props.upload||"file-manager",a=qe(o,h=>this.handleImageUpload(h),this.id);n.appendChild(a),i.appendChild(n),e.appendChild(i);const l=document.createElement("div");l.className="image-map-section";const r=document.createElement("h4");return r.className="image-map-section-title",r.textContent="Map Setup",l.appendChild(r),this.mainDisplayElements.configureButton.addEventListener("click",()=>{var h;(h=this.mainDisplayElements)!=null&&h.configureButton.disabled||this.openPopover()}),l.appendChild(this.mainDisplayElements.configureButton),e.appendChild(l),t.appendChild(e),this.createPopoverElements(),B(this.mainDisplayElements,this.value),t}createPopoverElements(){this.popoverElements=Je(()=>void this.closePopover(),(t,e)=>{this.popoverPosition={left:t,top:e}})}openPopover(){D.openInstance&&D.openInstance!==this&&D.openInstance.closePopover(),this.isPopoverOpen=!0,D.openInstance=this,this.value?this.initialValue=JSON.parse(JSON.stringify(this.value)):this.initialValue={imageUrl:"",markers:[]},this.value&&this.historyManager.initialize(this.value.markers),this.popoverElements&&(this.popoverElements.backdrop.style.display="block",this.popoverElements.popover.style.display="flex"),this.positionPopoverElement(),this.refreshPopoverContentAndScrollToBottom(),setTimeout(()=>{document.addEventListener("click",this.onBackgroundClick,!0)},200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}hasAllMarkers(){if(!this.value)return!1;const t=this.props.maxMarkers||F;return this.value.markers.length===t}hasChanges(){return!this.initialValue||!this.value?!1:JSON.stringify(this.initialValue.markers)!==JSON.stringify(this.value.markers)}async closePopover(t=!1){if(!(!this.isPopoverOpen&&!t)){if(!t&&this.hasChanges()&&!this.hasAllMarkers()){if(!await this.confirmModal.show({title:"Discard changes?",description:"You haven't placed all markers. Closing will discard your changes."}))return;this.initialValue&&(this.value=JSON.parse(JSON.stringify(this.initialValue)),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange())}this.isPopoverOpen=!1,this.draggingMarkerId=null,this.clearErrorTooltip(),this.popoverElements&&(this.popoverElements.backdrop.style.display="none",this.popoverElements.popover.style.display="none"),document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),D.openInstance===this&&(D.openInstance=null)}}positionPopoverElement(){!this.popoverElements||!this.mainDisplayElements||(this.popoverPosition=Xe(this.popoverElements.popover,this.mainDisplayElements.configureButton))}refreshPopoverContent(){var a;if(!this.popoverElements)return;this.clearErrorTooltip();const t=this.popoverElements.content,e=t.querySelector(".image-map-container"),i=t.querySelector(".simple-prize-list"),s=(e==null?void 0:e.scrollTop)||0,n=(i==null?void 0:i.scrollTop)||0;if(t.innerHTML="",this.value&&this.value.imageUrl&&this.value.imageUrl!==""){const l=Ue({canUndo:this.historyManager.canUndo(),canRedo:this.historyManager.canRedo(),markerCount:((a=this.value)==null?void 0:a.markers.length)||0,maxMarkers:this.props.maxMarkers||F},{onUndo:()=>this.undo(),onRedo:()=>this.redo()});t.appendChild(l);const r=document.createElement("div");r.className="image-map-main-layout";const h=document.createElement("div");h.className="image-map-image-section",this.cursorTooltip=new Ae;const{container:d,imageElement:p}=Ze(this.value.imageUrl,this.value.markers,{onImageClick:v=>this.handleImageClick(v),onMarkerDrag:this.boundHandleMarkerDrag,onStopDragging:this.boundStopDragging,onImageLoad:()=>this.recordImageNaturalSize(),onDelete:v=>this.handleDeleteMarker(v),onDragStart:v=>{this.draggingMarkerId=v},onScroll:this.boundHandleScroll,onMouseMove:v=>this.trackMousePosition(v)},this.cursorTooltip);this.imageElement=p,h.appendChild(d);const u=document.createElement("div");u.className="prize-list-section";const C=Fe(this.value.markers,this.props.maxMarkers||F,this.props.prizeMap);u.appendChild(C),r.appendChild(h),r.appendChild(u),t.appendChild(r);const m=Ye(this.hasAllMarkers(),()=>this.handleClearAllMarkers(),()=>{this.triggerChange(),this.closePopover(!0)});t.appendChild(m);const g=h.querySelector(".image-map-container"),f=u.querySelector(".simple-prize-list");g&&(g.scrollTop=s),f&&(f.scrollTop=n),this.updateCursorTooltipContent()}else{const l=ze({uploadMethod:this.props.upload||"file-manager",settingId:this.id,onFileSelected:r=>this.handleImageUpload(r),includeTitle:!0,variant:"popover"});t.appendChild(l)}}refreshPopoverContentAndScrollToBottom(){this.refreshPopoverContent(),requestAnimationFrame(()=>{this.scrollPrizeListToBottom()})}scrollPrizeListToBottom(){if(!this.popoverElements)return;const t=this.popoverElements.popover.querySelector(".simple-prize-list");t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleFileManagerImageSelected(t){const e=this.previousImageDimensions,i=new Image;i.onload=()=>{var o;const s={width:i.naturalWidth||0,height:i.naturalHeight||0},n=Lt(((o=this.value)==null?void 0:o.markers)||[],e,s);this.value={imageUrl:t,markers:n},this.previousImageDimensions=s,this.historyManager.initialize(n),this.updateUndoRedoButtons(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange()},i.onerror=()=>{q.show("Failed to load image from file manager.")},i.src=t}handleImageUpload(t){const e=this.previousImageDimensions,i=He(t,this.props.maxFileSizeMB||xt);if(!i.valid){q.show(i.error);return}const s=new FileReader;s.onload=n=>{var a;const o=(a=n.target)==null?void 0:a.result;if(typeof o=="string"){const l=new Image;l.onload=()=>{var d;const r={width:l.naturalWidth||0,height:l.naturalHeight||0},h=Lt(((d=this.value)==null?void 0:d.markers)||[],e,r);this.value={imageUrl:o,markers:h},this.previousImageDimensions=r,this.historyManager.initialize(h),this.updateUndoRedoButtons(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange()},l.onerror=()=>{q.show("Failed to read image file.")},l.src=o}},s.onerror=()=>{q.show("Failed to read image file.")},s.readAsDataURL(t)}handleImageClick(t){if(this.draggingMarkerId!==null||!this.value||!this.imageElement)return;if(this.value.markers.length>=(this.props.maxMarkers||F)){const r=`Maximum of ${this.props.maxMarkers||F} markers allowed.`;this.showErrorTooltip(r,t.clientX,t.clientY);return}const e=this.imageElement.getBoundingClientRect(),{x:i,y:s}=kt(t.clientX,t.clientY,e),n=At(this.value.markers);let o;this.props.prizeMap&&this.props.prizeMap.length>0&&(o=this.props.prizeMap[n-1]);const a={id:Date.now(),index:n,x:i,y:s,prizeName:o},l=[...this.value.markers,a];this.setMarkers(l),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}handleMarkerDrag(t){var a;if(this.draggingMarkerId===null||!this.imageElement||!this.value)return;const e=this.imageElement.getBoundingClientRect(),{x:i,y:s}=kt(t.clientX,t.clientY,e),n=this.value.markers.map(l=>l.id===this.draggingMarkerId?{...l,x:i,y:s}:l),o=(a=this.popoverElements)==null?void 0:a.popover.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);o&&(o.style.left=`${i}%`,o.style.top=`${s}%`),this.setMarkers(n)}stopDragging(){var t;if(this.draggingMarkerId!==null){const e=(t=this.popoverElements)==null?void 0:t.popover.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);e==null||e.classList.remove("dragging"),this.draggingMarkerId=null,this.saveState(),this.triggerChange()}}handleScroll(t){if(this.cursorTooltip&&this.lastMouseX&&this.lastMouseY&&this.imageElement){this.imageElement.getBoundingClientRect();const e=new MouseEvent("mousemove",{clientX:this.lastMouseX,clientY:this.lastMouseY});this.cursorTooltip.updatePosition(e,this.imageElement)}}trackMousePosition(t){this.lastMouseX=t.clientX,this.lastMouseY=t.clientY}handleDeleteMarker(t){if(!this.value)return;const e=this.value.markers.filter(i=>i.id!==t);this.setMarkers(e),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}handleClearAllMarkers(){this.value&&(this.setMarkers([]),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange())}updateCursorTooltipContent(){if(!this.cursorTooltip||!this.value)return;const t=this.props.maxMarkers||F;if(this.cursorTooltip.shouldShow(this.value.markers.length,t)){const e=$e(this.value.markers,this.props.prizeMap);this.cursorTooltip.updateContent(String(e.index))}}saveState(){this.isUndoRedoOperation||!this.value||(this.historyManager.saveState(this.value.markers),this.updateUndoRedoButtons())}undo(){if(!this.value)return;const t=this.historyManager.undo();t!==null&&(this.isUndoRedoOperation=!0,this.setMarkers(t),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons())}redo(){if(!this.value)return;const t=this.historyManager.redo();t!==null&&(this.isUndoRedoOperation=!0,this.setMarkers(t),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons())}updateUndoRedoButtons(){if(!this.popoverElements)return;const t=this.popoverElements.popover.querySelector(".undo-btn"),e=this.popoverElements.popover.querySelector(".redo-btn");t&&(t.disabled=!this.historyManager.canUndo()),e&&(e.disabled=!this.historyManager.canRedo())}setMarkers(t){const e=t.map(i=>({...i}));this.value={...this.value||{imageUrl:"",markers:[]},markers:e}}recordImageNaturalSize(){if(!this.imageElement)return;const{naturalWidth:t,naturalHeight:e}=this.imageElement;t&&e&&(this.previousImageDimensions={width:t,height:e})}triggerChange(){this.value&&(this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value))}showErrorTooltip(t,e,i){if(!this.imageElement||!this.isPopoverOpen)return;const s=this.imageElement.parentElement;if(!s)return;const n=this.imageElement.getBoundingClientRect();if(!this.errorTooltipEl||!s.contains(this.errorTooltipEl)){this.errorTooltipEl=document.createElement("div"),this.errorTooltipEl.className="image-map-error-tooltip";const p=document.createElement("div");p.className="image-map-error-tooltip-content",this.errorTooltipEl.appendChild(p);const u=document.createElement("div");u.className="image-map-error-tooltip-tail",u.innerHTML=Ke,this.errorTooltipEl.appendChild(u),s.appendChild(this.errorTooltipEl)}const o=this.errorTooltipEl.querySelector(".image-map-error-tooltip-content");o&&(o.textContent=t);const a=s.getBoundingClientRect(),l=e-a.left,r=i-a.top,h=Math.min(Math.max(l,n.left-a.left),n.right-a.left),d=Math.min(Math.max(r,n.top-a.top),n.bottom-a.top);this.errorTooltipEl.style.left=`${h}px`,this.errorTooltipEl.style.top=`${d}px`,this.errorTooltipEl.classList.remove("visible"),this.errorTooltipEl.offsetWidth,this.errorTooltipEl.classList.add("visible"),this.errorTooltipTimeoutId!==null&&window.clearTimeout(this.errorTooltipTimeoutId),this.errorTooltipTimeoutId=window.setTimeout(()=>{this.hideErrorTooltip()},2e3)}hideErrorTooltip(){this.errorTooltipEl&&(this.errorTooltipEl.classList.remove("visible"),this.errorTooltipTimeoutId=null)}clearErrorTooltip(){var t;this.errorTooltipTimeoutId!==null&&(window.clearTimeout(this.errorTooltipTimeoutId),this.errorTooltipTimeoutId=null),(t=this.errorTooltipEl)!=null&&t.parentElement&&this.errorTooltipEl.parentElement.removeChild(this.errorTooltipEl),this.errorTooltipEl=null}destroy(){this.closePopover(),this.clearErrorTooltip(),this.popoverElements&&(this.popoverElements.backdrop.parentElement&&this.popoverElements.backdrop.parentElement.removeChild(this.popoverElements.backdrop),this.popoverElements.popover.parentElement&&this.popoverElements.popover.parentElement.removeChild(this.popoverElements.popover)),document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),Mt.unregisterHandler(this.id),this.confirmModal.cleanup()}};D.openInstance=null;let ut=D;class Dt extends ${constructor(t={}){super({...t,title:t.title||"Height",suffix:t.suffix||"px",minValue:t.minValue??0,icon:t.icon||Qe,default:t.default??100}),this.inputType="number",this.mobileValue=t.mobile,this.suffix=t.suffix||"px"}getValue(){const t=this.value??0;return this.suffix==="%"?t+this.suffix:t}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const Qe=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
293
+ </svg>`,D=class D extends w{constructor(t={}){var e;super(t),this.inputType={imageUrl:"text",markers:"text"},this.mainDisplayElements=null,this.popoverElements=null,this.imageElement=null,this.cursorTooltip=null,this.popoverPosition=null,this.isPopoverOpen=!1,this.confirmModal=new Be,this.previousImageDimensions=null,this.draggingMarkerId=null,this.historyManager=new De,this.isUndoRedoOperation=!1,this.initialValue=null,this.lastMouseX=0,this.lastMouseY=0,this.errorTooltipEl=null,this.errorTooltipTimeoutId=null,this.props.maxMarkers=this.props.maxMarkers??((e=this.props.prizeMap)==null?void 0:e.length)??F,this.props.maxFileSizeMB=this.props.maxFileSizeMB??Lt,this.props.markerSize=this.props.markerSize??Se,this.value||(this.value={imageUrl:"",markers:[]}),St.registerHandler(this.id,i=>{this.handleFileManagerImageSelected(i)}),this.onBackgroundClick=i=>{if(this.isPopoverOpen&&this.popoverElements&&!this.popoverElements.popover.contains(i.target)){if(i.target.closest('[class*="modal"], [class*="Modal"], [class*="dialog"], [class*="Dialog"], [class*="overlay"], [class*="Overlay"]'))return;this.closePopover()}},this.handlePopoverKeydown=i=>{this.isPopoverOpen&&(i.key==="Escape"?this.closePopover():(i.ctrlKey||i.metaKey)&&(i.key==="z"||i.key==="Z"?i.shiftKey?(i.preventDefault(),this.redo()):(i.preventDefault(),this.undo()):(i.key==="y"||i.key==="Y")&&(i.preventDefault(),this.redo())))},this.boundHandleMarkerDrag=this.handleMarkerDrag.bind(this),this.boundStopDragging=this.stopDragging.bind(this),this.boundHandleScroll=this.handleScroll.bind(this)}draw(){const t=document.createElement("div");if(t.className="image-map-setting-wrapper",this.props.title||this.props.icon){const h=document.createElement("div");if(h.className="icon-container",this.props.icon){const d=this.createIcon(this.props.icon);h.appendChild(d)}if(this.props.title){const d=this.createLabel(this.props.title);h.appendChild(d)}t.appendChild(h)}const e=document.createElement("div");e.className="image-map-sections-container";const i=document.createElement("div");i.className="image-map-section";const s=document.createElement("h4");s.className="image-map-section-title",s.textContent="Upload/Replace Map Image",i.appendChild(s),this.mainDisplayElements=je();const n=_e(this.mainDisplayElements.thumbnailEl,()=>{this.value={imageUrl:"",markers:[]},this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}),o=this.props.upload||"file-manager",a=qe(o,h=>this.handleImageUpload(h),this.id);n.appendChild(a),i.appendChild(n),e.appendChild(i);const l=document.createElement("div");l.className="image-map-section";const r=document.createElement("h4");return r.className="image-map-section-title",r.textContent="Map Setup",l.appendChild(r),this.mainDisplayElements.configureButton.addEventListener("click",()=>{var h;(h=this.mainDisplayElements)!=null&&h.configureButton.disabled||this.openPopover()}),l.appendChild(this.mainDisplayElements.configureButton),e.appendChild(l),t.appendChild(e),this.createPopoverElements(),B(this.mainDisplayElements,this.value),t}createPopoverElements(){this.popoverElements=Je(()=>void this.closePopover(),(t,e)=>{this.popoverPosition={left:t,top:e}})}openPopover(){D.openInstance&&D.openInstance!==this&&D.openInstance.closePopover(),this.isPopoverOpen=!0,D.openInstance=this,this.value?this.initialValue=JSON.parse(JSON.stringify(this.value)):this.initialValue={imageUrl:"",markers:[]},this.value&&this.historyManager.initialize(this.value.markers),this.popoverElements&&(this.popoverElements.backdrop.style.display="block",this.popoverElements.popover.style.display="flex"),this.positionPopoverElement(),this.refreshPopoverContentAndScrollToBottom(),setTimeout(()=>{document.addEventListener("click",this.onBackgroundClick,!0)},200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}hasAllMarkers(){if(!this.value)return!1;const t=this.props.maxMarkers||F;return this.value.markers.length===t}hasChanges(){return!this.initialValue||!this.value?!1:JSON.stringify(this.initialValue.markers)!==JSON.stringify(this.value.markers)}async closePopover(t=!1){if(!(!this.isPopoverOpen&&!t)){if(!t&&this.hasChanges()&&!this.hasAllMarkers()){if(!await this.confirmModal.show({title:"Discard changes?",description:"You haven't placed all markers. Closing will discard your changes."}))return;this.initialValue&&(this.value=JSON.parse(JSON.stringify(this.initialValue)),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange())}this.isPopoverOpen=!1,this.draggingMarkerId=null,this.clearErrorTooltip(),this.popoverElements&&(this.popoverElements.backdrop.style.display="none",this.popoverElements.popover.style.display="none"),document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),D.openInstance===this&&(D.openInstance=null)}}positionPopoverElement(){!this.popoverElements||!this.mainDisplayElements||(this.popoverPosition=Xe(this.popoverElements.popover,this.mainDisplayElements.configureButton))}refreshPopoverContent(){var a;if(!this.popoverElements)return;this.clearErrorTooltip();const t=this.popoverElements.content,e=t.querySelector(".image-map-container"),i=t.querySelector(".simple-prize-list"),s=(e==null?void 0:e.scrollTop)||0,n=(i==null?void 0:i.scrollTop)||0;if(t.innerHTML="",this.value&&this.value.imageUrl&&this.value.imageUrl!==""){const l=Ue({canUndo:this.historyManager.canUndo(),canRedo:this.historyManager.canRedo(),markerCount:((a=this.value)==null?void 0:a.markers.length)||0,maxMarkers:this.props.maxMarkers||F},{onUndo:()=>this.undo(),onRedo:()=>this.redo()});t.appendChild(l);const r=document.createElement("div");r.className="image-map-main-layout";const h=document.createElement("div");h.className="image-map-image-section",this.cursorTooltip=new Ae;const{container:d,imageElement:p}=Ze(this.value.imageUrl,this.value.markers,{onImageClick:v=>this.handleImageClick(v),onMarkerDrag:this.boundHandleMarkerDrag,onStopDragging:this.boundStopDragging,onImageLoad:()=>this.recordImageNaturalSize(),onDelete:v=>this.handleDeleteMarker(v),onDragStart:v=>{this.draggingMarkerId=v},onScroll:this.boundHandleScroll,onMouseMove:v=>this.trackMousePosition(v)},this.cursorTooltip);this.imageElement=p,h.appendChild(d);const u=document.createElement("div");u.className="prize-list-section";const C=Fe(this.value.markers,this.props.maxMarkers||F,this.props.prizeMap);u.appendChild(C),r.appendChild(h),r.appendChild(u),t.appendChild(r);const m=Ye(this.hasAllMarkers(),()=>this.handleClearAllMarkers(),()=>{this.triggerChange(),this.closePopover(!0)});t.appendChild(m);const g=h.querySelector(".image-map-container"),f=u.querySelector(".simple-prize-list");g&&(g.scrollTop=s),f&&(f.scrollTop=n),this.updateCursorTooltipContent()}else{const l=ze({uploadMethod:this.props.upload||"file-manager",settingId:this.id,onFileSelected:r=>this.handleImageUpload(r),includeTitle:!0,variant:"popover"});t.appendChild(l)}}refreshPopoverContentAndScrollToBottom(){this.refreshPopoverContent(),requestAnimationFrame(()=>{this.scrollPrizeListToBottom()})}scrollPrizeListToBottom(){if(!this.popoverElements)return;const t=this.popoverElements.popover.querySelector(".simple-prize-list");t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleFileManagerImageSelected(t){const e=this.previousImageDimensions,i=new Image;i.onload=()=>{var o;const s={width:i.naturalWidth||0,height:i.naturalHeight||0},n=kt(((o=this.value)==null?void 0:o.markers)||[],e,s);this.value={imageUrl:t,markers:n},this.previousImageDimensions=s,this.historyManager.initialize(n),this.updateUndoRedoButtons(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange()},i.onerror=()=>{q.show("Failed to load image from file manager.")},i.src=t}handleImageUpload(t){const e=this.previousImageDimensions,i=He(t,this.props.maxFileSizeMB||Lt);if(!i.valid){q.show(i.error);return}const s=new FileReader;s.onload=n=>{var a;const o=(a=n.target)==null?void 0:a.result;if(typeof o=="string"){const l=new Image;l.onload=()=>{var d;const r={width:l.naturalWidth||0,height:l.naturalHeight||0},h=kt(((d=this.value)==null?void 0:d.markers)||[],e,r);this.value={imageUrl:o,markers:h},this.previousImageDimensions=r,this.historyManager.initialize(h),this.updateUndoRedoButtons(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange()},l.onerror=()=>{q.show("Failed to read image file.")},l.src=o}},s.onerror=()=>{q.show("Failed to read image file.")},s.readAsDataURL(t)}handleImageClick(t){if(this.draggingMarkerId!==null||!this.value||!this.imageElement)return;if(this.value.markers.length>=(this.props.maxMarkers||F)){const r=`Maximum of ${this.props.maxMarkers||F} markers allowed.`;this.showErrorTooltip(r,t.clientX,t.clientY);return}const e=this.imageElement.getBoundingClientRect(),{x:i,y:s}=Mt(t.clientX,t.clientY,e),n=At(this.value.markers);let o;this.props.prizeMap&&this.props.prizeMap.length>0&&(o=this.props.prizeMap[n-1]);const a={id:Date.now(),index:n,x:i,y:s,prizeName:o},l=[...this.value.markers,a];this.setMarkers(l),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}handleMarkerDrag(t){var a;if(this.draggingMarkerId===null||!this.imageElement||!this.value)return;const e=this.imageElement.getBoundingClientRect(),{x:i,y:s}=Mt(t.clientX,t.clientY,e),n=this.value.markers.map(l=>l.id===this.draggingMarkerId?{...l,x:i,y:s}:l),o=(a=this.popoverElements)==null?void 0:a.popover.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);o&&(o.style.left=`${i}%`,o.style.top=`${s}%`),this.setMarkers(n)}stopDragging(){var t;if(this.draggingMarkerId!==null){const e=(t=this.popoverElements)==null?void 0:t.popover.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);e==null||e.classList.remove("dragging"),this.draggingMarkerId=null,this.saveState(),this.triggerChange()}}handleScroll(t){if(this.cursorTooltip&&this.lastMouseX&&this.lastMouseY&&this.imageElement){this.imageElement.getBoundingClientRect();const e=new MouseEvent("mousemove",{clientX:this.lastMouseX,clientY:this.lastMouseY});this.cursorTooltip.updatePosition(e,this.imageElement)}}trackMousePosition(t){this.lastMouseX=t.clientX,this.lastMouseY=t.clientY}handleDeleteMarker(t){if(!this.value)return;const e=this.value.markers.filter(i=>i.id!==t);this.setMarkers(e),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange()}handleClearAllMarkers(){this.value&&(this.setMarkers([]),this.saveState(),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange())}updateCursorTooltipContent(){if(!this.cursorTooltip||!this.value)return;const t=this.props.maxMarkers||F;if(this.cursorTooltip.shouldShow(this.value.markers.length,t)){const e=$e(this.value.markers,this.props.prizeMap);this.cursorTooltip.updateContent(String(e.index))}}saveState(){this.isUndoRedoOperation||!this.value||(this.historyManager.saveState(this.value.markers),this.updateUndoRedoButtons())}undo(){if(!this.value)return;const t=this.historyManager.undo();t!==null&&(this.isUndoRedoOperation=!0,this.setMarkers(t),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons())}redo(){if(!this.value)return;const t=this.historyManager.redo();t!==null&&(this.isUndoRedoOperation=!0,this.setMarkers(t),this.refreshPopoverContent(),this.mainDisplayElements&&B(this.mainDisplayElements,this.value),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons())}updateUndoRedoButtons(){if(!this.popoverElements)return;const t=this.popoverElements.popover.querySelector(".undo-btn"),e=this.popoverElements.popover.querySelector(".redo-btn");t&&(t.disabled=!this.historyManager.canUndo()),e&&(e.disabled=!this.historyManager.canRedo())}setMarkers(t){const e=t.map(i=>({...i}));this.value={...this.value||{imageUrl:"",markers:[]},markers:e}}recordImageNaturalSize(){if(!this.imageElement)return;const{naturalWidth:t,naturalHeight:e}=this.imageElement;t&&e&&(this.previousImageDimensions={width:t,height:e})}triggerChange(){this.value&&(this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value))}showErrorTooltip(t,e,i){if(!this.imageElement||!this.isPopoverOpen)return;const s=this.imageElement.parentElement;if(!s)return;const n=this.imageElement.getBoundingClientRect();if(!this.errorTooltipEl||!s.contains(this.errorTooltipEl)){this.errorTooltipEl=document.createElement("div"),this.errorTooltipEl.className="image-map-error-tooltip";const p=document.createElement("div");p.className="image-map-error-tooltip-content",this.errorTooltipEl.appendChild(p);const u=document.createElement("div");u.className="image-map-error-tooltip-tail",u.innerHTML=Ke,this.errorTooltipEl.appendChild(u),s.appendChild(this.errorTooltipEl)}const o=this.errorTooltipEl.querySelector(".image-map-error-tooltip-content");o&&(o.textContent=t);const a=s.getBoundingClientRect(),l=e-a.left,r=i-a.top,h=Math.min(Math.max(l,n.left-a.left),n.right-a.left),d=Math.min(Math.max(r,n.top-a.top),n.bottom-a.top);this.errorTooltipEl.style.left=`${h}px`,this.errorTooltipEl.style.top=`${d}px`,this.errorTooltipEl.classList.remove("visible"),this.errorTooltipEl.offsetWidth,this.errorTooltipEl.classList.add("visible"),this.errorTooltipTimeoutId!==null&&window.clearTimeout(this.errorTooltipTimeoutId),this.errorTooltipTimeoutId=window.setTimeout(()=>{this.hideErrorTooltip()},2e3)}hideErrorTooltip(){this.errorTooltipEl&&(this.errorTooltipEl.classList.remove("visible"),this.errorTooltipTimeoutId=null)}clearErrorTooltip(){var t;this.errorTooltipTimeoutId!==null&&(window.clearTimeout(this.errorTooltipTimeoutId),this.errorTooltipTimeoutId=null),(t=this.errorTooltipEl)!=null&&t.parentElement&&this.errorTooltipEl.parentElement.removeChild(this.errorTooltipEl),this.errorTooltipEl=null}destroy(){this.closePopover(),this.clearErrorTooltip(),this.popoverElements&&(this.popoverElements.backdrop.parentElement&&this.popoverElements.backdrop.parentElement.removeChild(this.popoverElements.backdrop),this.popoverElements.popover.parentElement&&this.popoverElements.popover.parentElement.removeChild(this.popoverElements.popover)),document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),St.unregisterHandler(this.id),this.confirmModal.cleanup()}};D.openInstance=null;let ut=D;class Dt extends ${constructor(t={}){super({...t,title:t.title||"Height",suffix:t.suffix||"px",minValue:t.minValue??0,icon:t.icon||Qe,default:t.default??100}),this.inputType="number",this.mobileValue=t.mobile,this.suffix=t.suffix||"px"}getValue(){const t=this.value??0;return this.suffix==="%"?t+this.suffix:t}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const Qe=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
294
294
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
295
295
  </svg>`;class Gt extends ${constructor(t={}){super({...t,title:t.title||"Width",suffix:t.suffix||"px",minValue:t.minValue??0,icon:t.icon||ti,default:t.default??100}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const ti=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
296
296
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
@@ -312,7 +312,7 @@
312
312
  </svg>`;class li extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ai,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const ri=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
313
313
  <path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
314
314
  stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
315
- </svg>`;class ci extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ri,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class hi extends w{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,t.default?this.value=t.default:this.value||(this.value={});const e=w.HasExplicitCurrentLanguage(),i=e?w.CurrentLanguage():"",s=w.DefaultLanguage;this.defaultLanguage=e&&i&&t.languages.includes(i)?i:s&&t.languages.includes(s)?s:t.languages[0];const n=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(o=>{var a,l;o in(this.value||{})||(this.value||(this.value={}),o===this.defaultLanguage&&n?this.value[o]=((a=t.default)==null?void 0:a[o])||n:this.value[o]=((l=t.default)==null?void 0:l[o])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const h="...";let d=0,p=e.length,u=0;for(;d<=p;){const m=Math.floor((d+p)/2),g=e.slice(0,m).trimEnd()+h;this.measureTextWidth(g,i)<=l?(u=m,d=m+1):p=m-1}const C=e.slice(0,u).trimEnd()+h;t.placeholder=C}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new lt({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}renderContent(t){var n;const e=t.querySelector(".simple-multi-language-content");if(!e)return;e.innerHTML="";const i=w.HasExplicitCurrentLanguage(),s=w.CurrentLanguage();if(!i||!s||!this.props.languages.includes(s))this.props.languages.forEach(o=>{var r;const a=((r=this.value)==null?void 0:r[o])||"",l=this.createTextareaRow(o,a);e.appendChild(l)});else{const o=((n=this.value)==null?void 0:n[s])||"",a=this.createTextareaRow(s,o);e.appendChild(a);const l=e.querySelector(".simple-language-textarea");if(l){const r=l.getAttribute("data-full-placeholder")||"";r&&this.adaptPlaceholderToSingleLine(l,r)}}}createPopup(){const t=document.createElement("div");t.classList.add("multi-language-popup-overlay"),t.style.cssText=`
315
+ </svg>`;class ci extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ri,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class hi extends w{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,t.default?this.value=t.default:this.value||(this.value={}),this.value.$id=gt();const e=w.HasExplicitCurrentLanguage(),i=e?w.CurrentLanguage():"",s=w.DefaultLanguage;this.defaultLanguage=e&&i&&t.languages.includes(i)?i:s&&t.languages.includes(s)?s:t.languages[0];const n=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(o=>{var a,l;o in(this.value||{})||(this.value||(this.value={}),o===this.defaultLanguage&&n?this.value[o]=((a=t.default)==null?void 0:a[o])||n:this.value[o]=((l=t.default)==null?void 0:l[o])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const h="...";let d=0,p=e.length,u=0;for(;d<=p;){const m=Math.floor((d+p)/2),g=e.slice(0,m).trimEnd()+h;this.measureTextWidth(g,i)<=l?(u=m,d=m+1):p=m-1}const C=e.slice(0,u).trimEnd()+h;t.placeholder=C}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new lt({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}renderContent(t){var n;const e=t.querySelector(".simple-multi-language-content");if(!e)return;e.innerHTML="";const i=w.HasExplicitCurrentLanguage(),s=w.CurrentLanguage();if(!i||!s||!this.props.languages.includes(s))this.props.languages.forEach(o=>{var r;const a=((r=this.value)==null?void 0:r[o])||"",l=this.createTextareaRow(o,a);e.appendChild(l)});else{const o=((n=this.value)==null?void 0:n[s])||"",a=this.createTextareaRow(s,o);e.appendChild(a);const l=e.querySelector(".simple-language-textarea");if(l){const r=l.getAttribute("data-full-placeholder")||"";r&&this.adaptPlaceholderToSingleLine(l,r)}}}createPopup(){const t=document.createElement("div");t.classList.add("multi-language-popup-overlay"),t.style.cssText=`
316
316
  position: fixed;
317
317
  top: 0;
318
318
  left: 0;
@@ -431,4 +431,4 @@
431
431
  opacity: ${e/100};
432
432
  `:`
433
433
  background-color: ${i};
434
- `}}class ki extends H{constructor(t){super({title:(t==null?void 0:t.title)??"Image",collapsed:t==null?void 0:t.collapsed,settings:{image:new lt({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.image)??""}),width:new Gt({default:(t==null?void 0:t.width)??1e3,mobile:t==null?void 0:t.widthMobile}),height:new Dt({default:(t==null?void 0:t.height)??300,mobile:t==null?void 0:t.heightMobile})}})}}exports.AlignSetting=Bt;exports.AnimationSetting=di;exports.BackgroundSettingSet=Li;exports.BorderSettingSet=gi;exports.ButtonSetting=he;exports.ColorSetting=P;exports.ColorWithOpacitySetting=U;exports.DimensionSetting=de;exports.GapSetting=oi;exports.GradientSetting=j;exports.HeaderTypographySettingSet=Ci;exports.HeightSetting=Dt;exports.HtmlSetting=le;exports.ImageMapSetting=ut;exports.ImageSettingSet=ki;exports.MarginBottomSetting=li;exports.MarginSettingGroup=yi;exports.MarginTopSetting=ci;exports.MultiLanguageSetting=hi;exports.NumberSetting=$;exports.OpacitySetting=$t;exports.SelectApiSettings=ii;exports.SelectSetting=st;exports.Setting=w;exports.SettingGroup=H;exports.StringSetting=Ht;exports.TabSettingGroup=vt;exports.TabsSettingGroup=vt;exports.Toggle=si;exports.UploadSetting=lt;exports.WidthSetting=Gt;exports.asSettingGroupWithSettings=ne;exports.createSettingGroup=Ot;exports.createTabSettingGroup=se;exports.isSetting=A;exports.isSettingChild=ht;exports.isSettingGroup=M;exports.iterateSettings=X;
434
+ `}}class ki extends H{constructor(t){super({title:(t==null?void 0:t.title)??"Image",collapsed:t==null?void 0:t.collapsed,settings:{image:new lt({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.image)??""}),width:new Gt({default:(t==null?void 0:t.width)??1e3,mobile:t==null?void 0:t.widthMobile}),height:new Dt({default:(t==null?void 0:t.height)??300,mobile:t==null?void 0:t.heightMobile})}})}}exports.AlignSetting=Bt;exports.AnimationSetting=di;exports.BackgroundSettingSet=Li;exports.BorderSettingSet=gi;exports.ButtonSetting=he;exports.ColorSetting=P;exports.ColorWithOpacitySetting=U;exports.DimensionSetting=de;exports.GapSetting=oi;exports.GradientSetting=j;exports.HeaderTypographySettingSet=Ci;exports.HeightSetting=Dt;exports.HtmlSetting=le;exports.ImageMapSetting=ut;exports.ImageSettingSet=ki;exports.MarginBottomSetting=li;exports.MarginSettingGroup=yi;exports.MarginTopSetting=ci;exports.MultiLanguageSetting=hi;exports.NumberSetting=$;exports.OpacitySetting=$t;exports.SelectApiSettings=ii;exports.SelectSetting=st;exports.Setting=w;exports.SettingGroup=H;exports.StringSetting=Ht;exports.TabSettingGroup=ft;exports.TabsSettingGroup=ft;exports.Toggle=si;exports.UploadSetting=lt;exports.WidthSetting=Gt;exports.asSettingGroupWithSettings=ne;exports.createSettingGroup=Ot;exports.createTabSettingGroup=se;exports.isSetting=A;exports.isSettingChild=ht;exports.isSettingGroup=M;exports.iterateSettings=X;
@@ -1,5 +1,5 @@
1
1
  const Ot = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
- let Mt = (c = 21) => {
2
+ let dt = (c = 21) => {
3
3
  let t = "", e = crypto.getRandomValues(new Uint8Array(c |= 0));
4
4
  for (; c--; )
5
5
  t += Ot[e[c] & 63];
@@ -111,7 +111,7 @@ class Bt {
111
111
  this.observer && (this.observer.disconnect(), this.observer = void 0), this.observedElements.clear();
112
112
  }
113
113
  }
114
- const mt = new Bt();
114
+ const vt = new Bt();
115
115
  function it(c) {
116
116
  if (c === null || typeof c != "object") return c;
117
117
  if (c instanceof Date) return new Date(c.getTime());
@@ -144,7 +144,7 @@ function At(c) {
144
144
  }
145
145
  const I = class I {
146
146
  constructor(t = {}) {
147
- this.props = t, this.dataPropsPath = "", this.id = t.id || Mt(), this.value = this.props.default, this.desktop = this.props.default, this.title = t.title || "", this.includeGetJson = t.includeGetJson !== void 0 ? t.includeGetJson : !0;
147
+ this.props = t, this.dataPropsPath = "", this.id = t.id || dt(), this.value = this.props.default, this.desktop = this.props.default, this.title = t.title || "", this.includeGetJson = t.includeGetJson !== void 0 ? t.includeGetJson : !0;
148
148
  }
149
149
  static SetUploadUrl(t) {
150
150
  globalThis.DefaultUploadUrl = t, I.DefaultUploadUrl = t;
@@ -268,10 +268,10 @@ function R(c) {
268
268
  function M(c) {
269
269
  return c instanceof $;
270
270
  }
271
- function vt(c) {
271
+ function ft(c) {
272
272
  return R(c) || M(c);
273
273
  }
274
- const dt = (c, t, e) => {
274
+ const pt = (c, t, e) => {
275
275
  let i = !1, s = 0, n = 0, o = 0, a = 0;
276
276
  const l = (d) => {
277
277
  if (d.target.closest("button")) return;
@@ -432,7 +432,7 @@ const dt = (c, t, e) => {
432
432
  };
433
433
  }
434
434
  return { color: U(t) || t, position: 0, opacity: 100 };
435
- }, ft = (c) => {
435
+ }, Ct = (c) => {
436
436
  const t = [];
437
437
  let e = "", i = 0;
438
438
  for (let s = 0; s < c.length; s++) {
@@ -446,7 +446,7 @@ const dt = (c, t, e) => {
446
446
  e += n;
447
447
  }
448
448
  return e.trim() && t.push(e.trim()), t;
449
- }, Ct = (c, t) => {
449
+ }, yt = (c, t) => {
450
450
  const e = new RegExp(`${t}\\s*\\(`, "i"), i = c.match(e);
451
451
  if (!i) return null;
452
452
  const s = i.index + i[0].length;
@@ -467,7 +467,7 @@ const dt = (c, t, e) => {
467
467
  "contain",
468
468
  "cover"
469
469
  ].includes(t) ? !1 : /^#[0-9a-f]{3,8}$/i.test(t) || /^rgb/i.test(c) || /^hsl/i.test(c) || Dt(t);
470
- }, yt = (c) => {
470
+ }, Et = (c) => {
471
471
  const t = [];
472
472
  return c.forEach((e, i) => {
473
473
  const s = e.trim();
@@ -495,9 +495,9 @@ const dt = (c, t, e) => {
495
495
  const s = Nt(t);
496
496
  return D({ type: "solid", angle: 0, stops: [s] });
497
497
  }
498
- const e = Ct(t, "linear-gradient");
498
+ const e = yt(t, "linear-gradient");
499
499
  if (e) {
500
- const s = ft(e);
500
+ const s = Ct(e);
501
501
  let n = 90, o = s;
502
502
  const a = s[0];
503
503
  if (a.includes("deg")) {
@@ -513,12 +513,12 @@ const dt = (c, t, e) => {
513
513
  "to top right": 45,
514
514
  "to top left": 315
515
515
  }[a] ?? 90, o = s.slice(1));
516
- const l = yt(o);
516
+ const l = Et(o);
517
517
  return l.length ? D({ type: "linear", angle: n, stops: l }) : null;
518
518
  }
519
- const i = Ct(t, "radial-gradient");
519
+ const i = yt(t, "radial-gradient");
520
520
  if (i) {
521
- const s = ft(i), n = s[0] && !Gt(s[0]) ? s.slice(1) : s, o = yt(n);
521
+ const s = Ct(i), n = s[0] && !Gt(s[0]) ? s.slice(1) : s, o = Et(n);
522
522
  return o.length ? D({ type: "radial", angle: 0, stops: o }) : null;
523
523
  }
524
524
  return null;
@@ -623,7 +623,7 @@ const dt = (c, t, e) => {
623
623
  };
624
624
  X.STORAGE_KEY = "settingsLib_recentColors", X.MAX_COLORS = 18, X.colors = null;
625
625
  let z = X;
626
- const pt = (c, t) => {
626
+ const ut = (c, t) => {
627
627
  const e = document.createElement("div");
628
628
  e.className = "color-picker-recent-section";
629
629
  const i = document.createElement("div");
@@ -747,7 +747,7 @@ class Zt {
747
747
  const i = document.createElement("span");
748
748
  i.textContent = "Color";
749
749
  const s = document.createElement("button");
750
- s.className = "color-picker-close", s.innerHTML = Tt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), dt(e, t);
750
+ s.className = "color-picker-close", s.innerHTML = Tt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), pt(e, t);
751
751
  const n = document.createElement("div");
752
752
  n.className = "color-picker-area", this.colorArea = n;
753
753
  const o = document.createElement("div");
@@ -766,7 +766,7 @@ class Zt {
766
766
  p.className = "color-picker-opacity", this.opacitySlider = p;
767
767
  const u = document.createElement("div");
768
768
  u.className = "color-picker-opacity-marker", this.opacityMarker = u, p.appendChild(u), r.appendChild(h), r.appendChild(p), a.appendChild(l), a.appendChild(r);
769
- const C = pt((E) => {
769
+ const C = ut((E) => {
770
770
  var L;
771
771
  this.setColor(E), (L = this.onChange) == null || L.call(this, E, this.currentOpacity);
772
772
  }, this.recentScope);
@@ -963,7 +963,7 @@ class Jt {
963
963
  r.className = "color-picker-opacity embedded", this.opacitySlider = r;
964
964
  const h = document.createElement("div");
965
965
  h.className = "color-picker-opacity-marker", this.opacityMarker = h, r.appendChild(h), o.appendChild(a), o.appendChild(r), s.appendChild(n), s.appendChild(o);
966
- const d = pt((b) => {
966
+ const d = ut((b) => {
967
967
  const k = V(b);
968
968
  k && k.type !== "solid" ? this.onColorChange(b, this.currentOpacity) : (this.setColor(b), this.onColorChange(this.currentColor, this.currentOpacity));
969
969
  }, "all");
@@ -1335,7 +1335,7 @@ const P = class P extends w {
1335
1335
  t.appendChild(l);
1336
1336
  }
1337
1337
  const i = document.createElement("button");
1338
- i.type = "button", i.className = "gradient-popover-close", i.innerHTML = Tt, i.addEventListener("click", () => this.closePopover()), t.appendChild(i), dt(t, this.popoverEl, (l, r) => {
1338
+ i.type = "button", i.className = "gradient-popover-close", i.innerHTML = Tt, i.addEventListener("click", () => this.closePopover()), t.appendChild(i), pt(t, this.popoverEl, (l, r) => {
1339
1339
  this.popoverPosition = { left: l, top: r };
1340
1340
  });
1341
1341
  const s = document.createElement("div");
@@ -1565,7 +1565,7 @@ const P = class P extends w {
1565
1565
  a.type = "button", a.className = "gradient-add-stop", a.textContent = "+", n.appendChild(o), n.appendChild(a);
1566
1566
  const l = document.createElement("div");
1567
1567
  l.className = "gradient-stops", t.appendChild(n), t.appendChild(l), this.updateStopsList(l);
1568
- const r = pt((h) => {
1568
+ const r = ut((h) => {
1569
1569
  const d = V(h);
1570
1570
  d && (this.clearGlobalBindingForCustomChange(), this.value = d, this.switchType(d.type, !0), this.updateUI(), this.triggerChange());
1571
1571
  }, "all");
@@ -1881,7 +1881,7 @@ function Y(c, t) {
1881
1881
  const ot = class ot {
1882
1882
  constructor(t) {
1883
1883
  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 = () => {
1884
- }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.id = t.id || Mt(), this.title = t.title, this.settings = t.settings, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = t.includeGetJson ?? !0, this.addItemCfg = t.addItem, this.deleteItemCfg = t.deleteItem, this.dataProps = t.dataProps, this.dataPropsPath = t.dataProps || "", this.hide = t.hide ?? !1, Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath();
1884
+ }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.id = t.id || dt(), this.title = t.title, this.settings = t.settings, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = t.includeGetJson ?? !0, this.addItemCfg = t.addItem, this.deleteItemCfg = t.deleteItem, this.dataProps = t.dataProps, this.dataPropsPath = t.dataProps || "", this.hide = t.hide ?? !1, Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath();
1885
1885
  }
1886
1886
  propagateNestingLevel() {
1887
1887
  const t = this.nestingLevel + 1;
@@ -2091,7 +2091,7 @@ const ot = class ot {
2091
2091
  const o = i.slice(this.addItemCfg.keyPrefix.length), a = Number(o);
2092
2092
  if (Number.isFinite(a)) {
2093
2093
  const l = this.addItemCfg.createItem(a);
2094
- vt(l) && (this.addSetting(i, l), n = l);
2094
+ ft(l) && (this.addSetting(i, l), n = l);
2095
2095
  }
2096
2096
  }
2097
2097
  n && (M(n) || R(n)) && typeof n.setValue == "function" && n.setValue(s);
@@ -2125,7 +2125,7 @@ const ot = class ot {
2125
2125
  p && t.startsWith(p) && this.addDeleteButtonToElement(l, t);
2126
2126
  }
2127
2127
  const h = o.querySelector(".sg-add-button-bottom");
2128
- h ? o.insertBefore(l, h) : o.appendChild(l), mt.trackElement(l), Q(l, this.nestingLevel + 1), lt(l, this.nestingLevel + 1);
2128
+ h ? o.insertBefore(l, h) : o.appendChild(l), vt.trackElement(l), Q(l, this.nestingLevel + 1), lt(l, this.nestingLevel + 1);
2129
2129
  const d = l.style.display;
2130
2130
  l.style.display = "none", l.offsetHeight, l.style.display = d, this.updateNestingStyles();
2131
2131
  }
@@ -2447,13 +2447,13 @@ const ot = class ot {
2447
2447
  h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (p) => {
2448
2448
  p.stopPropagation(), p.preventDefault();
2449
2449
  const u = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), C = this.addItemCfg.createItem(u);
2450
- if (vt(C)) {
2450
+ if (ft(C)) {
2451
2451
  const m = `${this.addItemCfg.keyPrefix}${u}`;
2452
2452
  this.addSetting(m, C);
2453
2453
  }
2454
2454
  }), a.appendChild(h);
2455
2455
  }
2456
- return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(a), this.elementRef = t, mt.trackElement(t), setTimeout(() => {
2456
+ return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(a), this.elementRef = t, vt.trackElement(t), setTimeout(() => {
2457
2457
  this.updateNestingStyles();
2458
2458
  }, 0), this.pendingBlurHandler && (this.pendingBlurHandler = null), t;
2459
2459
  }
@@ -3360,7 +3360,7 @@ const oe = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
3360
3360
  <circle cx="6.7" cy="6.7" r="1.5" fill="#02CC59" opacity="0.3"/>
3361
3361
  </svg>
3362
3362
  `;
3363
- class ut extends w {
3363
+ class gt extends w {
3364
3364
  constructor(t = {}) {
3365
3365
  super(t), this.inputType = "button", this.previewWrapper = null, this.previewEl = null, this.emptyStateEl = null, this.errorContainer = null, this.messageListener = null, this.loadingSpinner = null, this.props.delete === void 0 && (this.props.delete = !0), this.props.maxFileSizeMB === void 0 && (this.props.maxFileSizeMB = 5), !this.value && t.defaultUrl && t.defaultUrl !== "" && (this.value = t.defaultUrl), this.setupMessageListener();
3366
3366
  }
@@ -3484,7 +3484,7 @@ const st = `
3484
3484
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
3485
3485
  <path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
3486
3486
  </svg>
3487
- `, Et = `
3487
+ `, bt = `
3488
3488
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
3489
3489
  <path d="M1.5 7.5C1.5 7.5 3.00374 5.45116 4.22538 4.22868C5.44702 3.0062 7.1352 2.25 9 2.25C12.7279 2.25 15.75 5.27208 15.75 9C15.75 12.7279 12.7279 15.75 9 15.75C5.92268 15.75 3.32633 13.6907 2.51382 10.875M1.5 7.5V3M1.5 7.5H6" stroke="#637381" stroke-linecap="round" stroke-linejoin="round"/>
3490
3490
  </svg>
@@ -3535,7 +3535,7 @@ const st = `
3535
3535
  <svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox="0 0 8 4" fill="none">
3536
3536
  <path fill-rule="evenodd" clip-rule="evenodd" d="M0 0L2.58579 2.58579C3.36684 3.36684 4.63317 3.36683 5.41421 2.58579L8 0L0 0Z" fill="#1C252E"/>
3537
3537
  </svg>
3538
- `, F = 10, bt = 5, Ee = 24, be = 50, we = 5e3, xe = 800, Le = 0.8, ke = 700, Me = [
3538
+ `, F = 10, wt = 5, Ee = 24, be = 50, we = 5e3, xe = 800, Le = 0.8, ke = 700, Me = [
3539
3539
  "image/jpeg",
3540
3540
  "image/jpg",
3541
3541
  "image/png",
@@ -3554,7 +3554,7 @@ function Ie(c, t) {
3554
3554
  error: `File size (${(c.size / 1048576).toFixed(1)}MB) exceeds ${t}MB limit.`
3555
3555
  } : { valid: !0 };
3556
3556
  }
3557
- function wt(c, t, e) {
3557
+ function xt(c, t, e) {
3558
3558
  if (!c.length) return [];
3559
3559
  const i = t && t.width && t.height && t || e && e.width && e.height && e || null;
3560
3560
  return c.map((s) => {
@@ -3565,7 +3565,7 @@ function wt(c, t, e) {
3565
3565
  function nt(c) {
3566
3566
  return Number.isFinite(c) ? Math.max(0, Math.min(100, c)) : 0;
3567
3567
  }
3568
- function xt(c, t, e) {
3568
+ function Lt(c, t, e) {
3569
3569
  const i = (c - e.left) / e.width * 100, s = (t - e.top) / e.height * 100;
3570
3570
  return {
3571
3571
  x: nt(i),
@@ -3591,7 +3591,7 @@ function Se(c, t) {
3591
3591
  }
3592
3592
  return { index: e, name: i };
3593
3593
  }
3594
- const gt = class gt {
3594
+ const mt = class mt {
3595
3595
  static show(t, e = we) {
3596
3596
  this.injectStyles();
3597
3597
  const i = document.createElement("div");
@@ -3645,8 +3645,8 @@ const gt = class gt {
3645
3645
  }
3646
3646
  }
3647
3647
  };
3648
- gt.styleInjected = !1;
3649
- let _ = gt;
3648
+ mt.styleInjected = !1;
3649
+ let _ = mt;
3650
3650
  class Ne {
3651
3651
  constructor() {
3652
3652
  this.overlayElement = null, this.activePromise = null;
@@ -3781,7 +3781,7 @@ class Ve {
3781
3781
  this.handlers.clear(), this.cleanupMessageListener();
3782
3782
  }
3783
3783
  }
3784
- const Lt = new Ve();
3784
+ const kt = new Ve();
3785
3785
  function Oe(c, t) {
3786
3786
  const e = document.createElement("div");
3787
3787
  e.className = "marker-container", e.style.left = `${c.x}%`, e.style.top = `${c.y}%`, e.setAttribute("data-marker-id", String(c.id));
@@ -3902,7 +3902,7 @@ function Ge(c, t, e) {
3902
3902
  const i = document.createElement("label");
3903
3903
  i.className = "image-map-upload-label", i.innerHTML = `
3904
3904
  <div class="upload-icon upload-icon-default">${st}</div>
3905
- <div class="upload-icon upload-icon-replace">${Et}</div>
3905
+ <div class="upload-icon upload-icon-replace">${bt}</div>
3906
3906
  <span class="upload-text">Upload Image</span>
3907
3907
  `;
3908
3908
  const s = document.createElement("input");
@@ -3915,7 +3915,7 @@ function Ge(c, t, e) {
3915
3915
  const i = document.createElement("button");
3916
3916
  return i.type = "button", i.className = "image-map-upload-label", i.innerHTML = `
3917
3917
  <div class="upload-icon upload-icon-default">${st}</div>
3918
- <div class="upload-icon upload-icon-replace">${Et}</div>
3918
+ <div class="upload-icon upload-icon-replace">${bt}</div>
3919
3919
  <span class="upload-text">Upload Image</span>
3920
3920
  `, i.addEventListener("click", () => {
3921
3921
  window.postMessage(
@@ -3959,7 +3959,7 @@ function Ue(c, t) {
3959
3959
  const n = document.createElement("h3");
3960
3960
  n.className = "image-map-title", n.textContent = "Prize Map", s.appendChild(n);
3961
3961
  const o = document.createElement("button");
3962
- o.type = "button", o.className = "image-map-close-btn", o.innerHTML = he, o.addEventListener("click", () => void c()), s.appendChild(o), dt(s, i, (l, r) => {
3962
+ o.type = "button", o.className = "image-map-close-btn", o.innerHTML = he, o.addEventListener("click", () => void c()), s.appendChild(o), pt(s, i, (l, r) => {
3963
3963
  t(l, r);
3964
3964
  }), i.appendChild(s);
3965
3965
  const a = document.createElement("div");
@@ -3999,7 +3999,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
3999
3999
  super(t), this.inputType = {
4000
4000
  imageUrl: "text",
4001
4001
  markers: "text"
4002
- }, this.mainDisplayElements = null, this.popoverElements = null, this.imageElement = null, this.cursorTooltip = null, this.popoverPosition = null, this.isPopoverOpen = !1, this.confirmModal = new Ne(), this.previousImageDimensions = null, this.draggingMarkerId = null, this.historyManager = new Pe(), this.isUndoRedoOperation = !1, this.initialValue = null, this.lastMouseX = 0, this.lastMouseY = 0, this.errorTooltipEl = null, this.errorTooltipTimeoutId = null, this.props.maxMarkers = this.props.maxMarkers ?? ((e = this.props.prizeMap) == null ? void 0 : e.length) ?? F, this.props.maxFileSizeMB = this.props.maxFileSizeMB ?? bt, this.props.markerSize = this.props.markerSize ?? Ee, this.value || (this.value = { imageUrl: "", markers: [] }), Lt.registerHandler(this.id, (i) => {
4002
+ }, this.mainDisplayElements = null, this.popoverElements = null, this.imageElement = null, this.cursorTooltip = null, this.popoverPosition = null, this.isPopoverOpen = !1, this.confirmModal = new Ne(), this.previousImageDimensions = null, this.draggingMarkerId = null, this.historyManager = new Pe(), this.isUndoRedoOperation = !1, this.initialValue = null, this.lastMouseX = 0, this.lastMouseY = 0, this.errorTooltipEl = null, this.errorTooltipTimeoutId = null, this.props.maxMarkers = this.props.maxMarkers ?? ((e = this.props.prizeMap) == null ? void 0 : e.length) ?? F, this.props.maxFileSizeMB = this.props.maxFileSizeMB ?? wt, this.props.markerSize = this.props.markerSize ?? Ee, this.value || (this.value = { imageUrl: "", markers: [] }), kt.registerHandler(this.id, (i) => {
4003
4003
  this.handleFileManagerImageSelected(i);
4004
4004
  }), this.onBackgroundClick = (i) => {
4005
4005
  if (this.isPopoverOpen && this.popoverElements && !this.popoverElements.popover.contains(i.target)) {
@@ -4195,7 +4195,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4195
4195
  const s = {
4196
4196
  width: i.naturalWidth || 0,
4197
4197
  height: i.naturalHeight || 0
4198
- }, n = wt(
4198
+ }, n = xt(
4199
4199
  ((o = this.value) == null ? void 0 : o.markers) || [],
4200
4200
  e,
4201
4201
  s
@@ -4211,7 +4211,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4211
4211
  handleImageUpload(t) {
4212
4212
  const e = this.previousImageDimensions, i = Ie(
4213
4213
  t,
4214
- this.props.maxFileSizeMB || bt
4214
+ this.props.maxFileSizeMB || wt
4215
4215
  );
4216
4216
  if (!i.valid) {
4217
4217
  _.show(i.error);
@@ -4228,7 +4228,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4228
4228
  const r = {
4229
4229
  width: l.naturalWidth || 0,
4230
4230
  height: l.naturalHeight || 0
4231
- }, h = wt(
4231
+ }, h = xt(
4232
4232
  ((d = this.value) == null ? void 0 : d.markers) || [],
4233
4233
  e,
4234
4234
  r
@@ -4252,7 +4252,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4252
4252
  this.showErrorTooltip(r, t.clientX, t.clientY);
4253
4253
  return;
4254
4254
  }
4255
- const e = this.imageElement.getBoundingClientRect(), { x: i, y: s } = xt(t.clientX, t.clientY, e), n = Vt(this.value.markers);
4255
+ const e = this.imageElement.getBoundingClientRect(), { x: i, y: s } = Lt(t.clientX, t.clientY, e), n = Vt(this.value.markers);
4256
4256
  let o;
4257
4257
  this.props.prizeMap && this.props.prizeMap.length > 0 && (o = this.props.prizeMap[n - 1]);
4258
4258
  const a = {
@@ -4268,7 +4268,7 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4268
4268
  var a;
4269
4269
  if (this.draggingMarkerId === null || !this.imageElement || !this.value)
4270
4270
  return;
4271
- const e = this.imageElement.getBoundingClientRect(), { x: i, y: s } = xt(t.clientX, t.clientY, e), n = this.value.markers.map(
4271
+ const e = this.imageElement.getBoundingClientRect(), { x: i, y: s } = Lt(t.clientX, t.clientY, e), n = this.value.markers.map(
4272
4272
  (l) => l.id === this.draggingMarkerId ? { ...l, x: i, y: s } : l
4273
4273
  ), o = (a = this.popoverElements) == null ? void 0 : a.popover.querySelector(
4274
4274
  `[data-marker-id="${this.draggingMarkerId}"]`
@@ -4395,11 +4395,11 @@ const je = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox
4395
4395
  this.popoverElements.backdrop
4396
4396
  ), this.popoverElements.popover.parentElement && this.popoverElements.popover.parentElement.removeChild(
4397
4397
  this.popoverElements.popover
4398
- )), document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), Lt.unregisterHandler(this.id), this.confirmModal.cleanup();
4398
+ )), document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), kt.unregisterHandler(this.id), this.confirmModal.cleanup();
4399
4399
  }
4400
4400
  };
4401
4401
  A.openInstance = null;
4402
- let kt = A;
4402
+ let Mt = A;
4403
4403
  class _e extends B {
4404
4404
  constructor(t = {}) {
4405
4405
  super({
@@ -4743,7 +4743,7 @@ class Ci extends B {
4743
4743
  }
4744
4744
  class yi extends w {
4745
4745
  constructor(t) {
4746
- super(t), this.inputType = {}, this.container = null, this.defaultLanguage = "", this.uploadSettings = /* @__PURE__ */ new Map(), this.popup = null, t.default ? this.value = t.default : this.value || (this.value = {});
4746
+ super(t), this.inputType = {}, this.container = null, this.defaultLanguage = "", this.uploadSettings = /* @__PURE__ */ new Map(), this.popup = null, t.default ? this.value = t.default : this.value || (this.value = {}), this.value.$id = dt();
4747
4747
  const e = w.HasExplicitCurrentLanguage(), i = e ? w.CurrentLanguage() : "", s = w.DefaultLanguage;
4748
4748
  this.defaultLanguage = e && i && t.languages.includes(i) ? i : s && t.languages.includes(s) ? s : t.languages[0];
4749
4749
  const n = t.defaultValue || `Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;
@@ -4794,7 +4794,7 @@ class yi extends w {
4794
4794
  i.classList.add("simple-multi-language-row");
4795
4795
  const s = document.createElement("label");
4796
4796
  if (s.classList.add("simple-language-label"), s.textContent = t.toUpperCase(), s.setAttribute("for", `textarea-${t}`), i.appendChild(s), this.props.multiImg) {
4797
- const n = new ut({
4797
+ const n = new gt({
4798
4798
  defaultUrl: e || "",
4799
4799
  title: "",
4800
4800
  id: `${this.id}_upload_${t}`
@@ -5296,7 +5296,7 @@ class Li extends $ {
5296
5296
  title: "Background Image",
5297
5297
  collapsed: t == null ? void 0 : t.collapsed,
5298
5298
  settings: {
5299
- backgroundImage: new ut({
5299
+ backgroundImage: new gt({
5300
5300
  ...t == null ? void 0 : t.uploadProps,
5301
5301
  default: (t == null ? void 0 : t.backgroundImage) ?? ""
5302
5302
  }),
@@ -5335,7 +5335,7 @@ class ki extends $ {
5335
5335
  title: (t == null ? void 0 : t.title) ?? "Image",
5336
5336
  collapsed: t == null ? void 0 : t.collapsed,
5337
5337
  settings: {
5338
- image: new ut({
5338
+ image: new gt({
5339
5339
  ...t == null ? void 0 : t.uploadProps,
5340
5340
  default: (t == null ? void 0 : t.image) ?? ""
5341
5341
  }),
@@ -5365,7 +5365,7 @@ export {
5365
5365
  wi as HeaderTypographySettingSet,
5366
5366
  _e as HeightSetting,
5367
5367
  di as HtmlSetting,
5368
- kt as ImageMapSetting,
5368
+ Mt as ImageMapSetting,
5369
5369
  ki as ImageSettingSet,
5370
5370
  fi as MarginBottomSetting,
5371
5371
  xi as MarginSettingGroup,
@@ -5381,13 +5381,13 @@ export {
5381
5381
  Xt as TabSettingGroup,
5382
5382
  Xt as TabsSettingGroup,
5383
5383
  mi as Toggle,
5384
- ut as UploadSetting,
5384
+ gt as UploadSetting,
5385
5385
  Ze as WidthSetting,
5386
5386
  hi as asSettingGroupWithSettings,
5387
5387
  Yt as createSettingGroup,
5388
5388
  ci as createTabSettingGroup,
5389
5389
  R as isSetting,
5390
- vt as isSettingChild,
5390
+ ft as isSettingChild,
5391
5391
  M as isSettingGroup,
5392
5392
  Y as iterateSettings
5393
5393
  };
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.379",
4
+ "version": "0.0.380",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",