builder-settings-types 0.0.406 → 0.0.408

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ef="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Un=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ef[r[t]&63];return e};function tf(t){let e=0,r=t.parentElement;for(;r;)r.classList.contains("setting-group")&&r!==t&&e++,r=r.parentElement;return e}function Dn(t,e){const r=Math.min(Math.max(e,0),5);t.setAttribute("data-nesting-level",r.toString()),r>0?t.style.setProperty("--visual-indent",`${r*2}px`):(t.style.removeProperty("--visual-indent"),t.style.marginLeft="")}function Ni(t,e=0){t.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(a=>{const n=a,i=e+1;Dn(n,i),Ni(n,i)})}const rf={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class af{constructor(e={}){this.observedElements=new Set,this.config={...rf,...e},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(e=>{let r=!1;e.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("setting-group")?[n]:Array.from(n.querySelectorAll(".setting-group"))).length>0&&(r=!0)})}),r&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(e){this.observedElements.add(e),this.updateElementNesting(e)}untrackElement(e){this.observedElements.delete(e)}updateElementNesting(e){const r=tf(e);this.applyNestingWithConfig(e,r)}updateAllNesting(){this.observedElements.forEach(e=>{e.isConnected?this.updateElementNesting(e):this.observedElements.delete(e)})}applyNestingWithConfig(e,r){const a=Math.min(Math.max(r,0),this.config.maxLevel);if(e.setAttribute("data-nesting-level",a.toString()),a>0){const n=a*this.config.visualIndentMultiplier;e.style.setProperty("--visual-indent",`${n}px`)}else e.style.removeProperty("--visual-indent"),e.style.marginLeft=""}recalculateNesting(e=document.body){e.querySelectorAll(".setting-group").forEach(a=>{const n=a;this.updateElementNesting(n),this.trackElement(n)})}getNestingStats(){const e={};return this.observedElements.forEach(r=>{const a=parseInt(r.getAttribute("data-nesting-level")||"0",10);e[a]=(e[a]||0)+1}),e}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const Ys=new af;function Hn(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array)return t.map(e=>Hn(e));if(typeof t=="object"){const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Hn(t[r]));return e}return t}function nf(t){switch(t){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const lt=class lt{constructor(e={}){this.props=e,this.dataPropsPath="",this.id=e.id||Un(),this.value=this.props.default,this.desktop=this.props.default,this.title=e.title||"",this.includeGetJson=e.includeGetJson!==void 0?e.includeGetJson:!0}static SetUploadUrl(e){globalThis.DefaultUploadUrl=e,lt.DefaultUploadUrl=e}static SetDefaultLanguage(e){globalThis.DefaultLanguage=e,lt.DefaultLanguage=e}static CurrentLanguage(e){return e!==void 0&&(lt.currentLanguage=e,lt.currentLanguageExplicitlySet=!0,lt.languageChangeCallbacks.forEach(r=>r(e))),lt.currentLanguage||lt.DefaultLanguage}static HasExplicitCurrentLanguage(){return lt.currentLanguageExplicitlySet}static onLanguageChange(e){return lt.languageChangeCallbacks.add(e),()=>{lt.languageChangeCallbacks.delete(e)}}static SetGlobalVariables(e){lt.GlobalVariables={...lt.GlobalVariables,...e}}destroy(){throw new Error("Method not implemented.")}setOnChange(e){return this.onChange=e,this}setOnBlur(e){return this.onBlur=e,this}setDataPropsPath(e){this.dataPropsPath=e}getDataPropsPath(){return this.dataPropsPath}setComponentPath(e){}setValue(e){console.log("📤 [setValue]",this.title||this.id,":",this.value,"→",e),this.value=e,this.inputEl&&(this.inputEl.value=String(e)),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}clone(){const e=this.constructor,r=Hn(this.props),a=new e(r);return a.value=Hn(this.value),a}createInput(e){e={...this.props.inputProps,...e};const r=document.createElement("div");if(r.className=e.wrapperClassName||"",e.title||e.icon){const o=document.createElement("div");if(o.className="icon-container",e.icon){const l=this.createIcon(e.icon,e.iconClassName);o.appendChild(l)}if(e.title){const l=this.createLabel(e.title,e.labelClassName);o.appendChild(l)}r.appendChild(o)}const a=document.createElement("div");a.className=e.wrapperClassName||"";const n=document.createElement("input");this.inputEl=n,n.value=String(e.value||nf(e.inputType)),n.type=e.inputType,n.placeholder=e.placeholder||"",n.className=e.inputClassName||"",this.dataPropsPath&&n.setAttribute("data-test-id",this.dataPropsPath);const i=o=>{const l=o.target;let c=l.value;switch(e.inputType){case"number":c=Number(l.value);break;case"color":c=l.value;break;case"date":c=l.value;break;case"select":c=l.value;break;case"text":c=l.value;break;case"button":c=l.value;break;default:c=l.value}this.value=c,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return n.addEventListener("input",i),n.addEventListener("change",i),n.addEventListener("blur",s),e.inputCustomizer&&e.inputCustomizer(n),a.appendChild(n),r.appendChild(a),r}createLabel(e,r){const a=document.createElement("span");return a.textContent=e,a.className="input-label "+(r||""),a}createIcon(e,r){const a=document.createElement("span");return a.className="input-icon "+(r||""),a.innerHTML=e,a}};lt.currentLanguageExplicitlySet=!1,lt.languageChangeCallbacks=new Set,lt.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},lt.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let Le=lt;function dr(t){return t instanceof Le}function $e(t){return t instanceof ir}function Mi(t){return dr(t)||$e(t)}const Qi=(t,e,r)=>{let a=!1,n=0,i=0,s=0,o=0;const l=h=>{if(h.target.closest("button"))return;a=!0,n=h.clientX,i=h.clientY;const u=e.getBoundingClientRect();s=u.left,o=u.top,document.addEventListener("mousemove",c),document.addEventListener("mouseup",f),document.body.style.userSelect="none"},c=h=>{if(!a)return;const u=h.clientX-n,p=h.clientY-i,m=window.innerWidth,d=window.innerHeight,g=e.offsetWidth,x=e.offsetHeight;let w=s+u,v=o+p;w=Math.max(8,Math.min(m-g-8,w)),v=Math.max(8,Math.min(d-x-8,v)),e.style.left=`${w}px`,e.style.top=`${v}px`,r==null||r(w,v)},f=()=>{a=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f),document.body.style.userSelect=""};t.addEventListener("mousedown",l)},ta=t=>{if(!t)return null;let e=t.trim();return!e.startsWith("#")||(e=e.slice(1),e.length===3&&(e=e.split("").map(r=>r+r).join("")),!/^[0-9a-fA-F]{6}$/.test(e))?null:`#${e.toUpperCase()}`},Rn=(t,e,r)=>`#${[t,e,r].map(a=>Math.max(0,Math.min(255,a)).toString(16).padStart(2,"0")).join("")}`,Pt=t=>{const e=t.replace("#",""),r=e.length===3?e.split("").map(a=>a+a).join(""):e;return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}},ya=t=>{const{r:e,g:r,b:a}=Pt(t),n=e/255,i=r/255,s=a/255,o=Math.max(n,i,s),l=Math.min(n,i,s),c=o-l;let f=0;c!==0&&(o===n?f=(i-s)/c%6:o===i?f=(s-n)/c+2:f=(n-i)/c+4),f<0&&(f+=6);const h=o===0?0:c/o,u=o;return{h:f*60,s:h,v:u}},ka=(t,e,r)=>{const a=(t%360+360)%360,n=r*e,i=n*(1-Math.abs(a/60%2-1)),s=r-n;let o=0,l=0,c=0;return a<60?(o=n,l=i,c=0):a<120?(o=i,l=n,c=0):a<180?(o=0,l=n,c=i):a<240?(o=0,l=i,c=n):a<300?(o=i,l=0,c=n):(o=n,l=0,c=i),Rn(Math.round((o+s)*255),Math.round((l+s)*255),Math.round((c+s)*255))},m0=(t,e,r)=>{const a=r*(1-e/2),n=a===0||a===1?0:(r-a)/Math.min(a,1-a);return{hue:t,sat:n,lightness:a}},Oi=(t,e,r)=>{const a=(1-Math.abs(2*r-1))*e,n=a*(1-Math.abs(t/60%2-1)),i=r-a/2;let s=0,o=0,l=0;return t<60?(s=a,o=n,l=0):t<120?(s=n,o=a,l=0):t<180?(s=0,o=a,l=n):t<240?(s=0,o=n,l=a):t<300?(s=n,o=0,l=a):(s=a,o=0,l=n),{r:Math.round((s+i)*255),g:Math.round((o+i)*255),b:Math.round((l+i)*255)}},Pi=(t,e)=>{const r=Math.max(0,Math.min(100,e))/100;if(t.startsWith("#")){const{r:n,g:i,b:s}=Pt(t);return`rgba(${n}, ${i}, ${s}, ${r})`}if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${r})`);if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${r})`);if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}if(t.startsWith("hsla(")){const n=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}const a=ta(t);if(a){const{r:n,g:i,b:s}=Pt(a);return`rgba(${n}, ${i}, ${s}, ${r})`}return t},sf=t=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(t.toLowerCase()),g0=t=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(r=>r.test(t.trim())),of=t=>{if(typeof document>"u")return g0(t)||!!ta(t);const e=document.createElement("div");return e.style.color=t,e.style.color!==""},x0=t=>{const e=t.trim();if(/^#[0-9A-Fa-f]{8}$/.test(e)){const i=e.slice(1),s=parseInt(i.slice(0,2),16),o=parseInt(i.slice(2,4),16),l=parseInt(i.slice(4,6),16),c=parseInt(i.slice(6,8),16);return{color:Rn(s,o,l),position:0,opacity:Math.round(c/255*100)}}const r=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(r){const i=parseInt(r[1]),s=parseInt(r[2]),o=parseInt(r[3]),l=r[4]?parseFloat(r[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}const a=e.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(a){const{r:i,g:s,b:o}=Oi(parseFloat(a[1]),parseFloat(a[2])/100,parseFloat(a[3])/100),l=a[4]?parseFloat(a[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}return{color:ta(e)||e,position:0,opacity:100}},Js=t=>{const e=[];let r="",a=0;for(let n=0;n<t.length;n++){const i=t[n];if(i==="(")a++;else if(i===")")a--;else if(i===","&&a===0){e.push(r.trim()),r="";continue}r+=i}return r.trim()&&e.push(r.trim()),e},qs=(t,e)=>{const r=new RegExp(`${e}\\s*\\(`,"i"),a=t.match(r);if(!a)return null;const n=a.index+a[0].length;let i=1,s=n;for(let o=n;o<t.length&&i>0;o++)t[o]==="("?i++:t[o]===")"&&i--,s=o;return i===0?t.substring(n,s):null},lf=t=>{const e=t.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(e)?!1:/^#[0-9a-f]{3,8}$/i.test(e)||/^rgb/i.test(t)||/^hsl/i.test(t)||sf(e)},Zs=t=>{const e=[];return t.forEach((r,a)=>{const n=r.trim();if(!n)return;let i="",s=0;const o=n.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);o&&g0(o[1].trim())?(i=o[1].trim(),s=parseFloat(o[2])):(i=n,s=t.length===1?0:a/(t.length-1)*100);const l=x0(i);l.position=Math.max(0,Math.min(100,Math.round(s))),e.push(l)}),e},Cr=t=>{const e=t.stops&&t.stops.length?t.stops:[{color:"#000000",position:0,opacity:100}];return{type:t.type&&["linear","radial","solid"].includes(t.type)?t.type:"linear",angle:typeof t.angle=="number"?t.angle:90,stops:e.map((r,a)=>({color:r.color||"#000000",position:typeof r.position=="number"?r.position:e.length===1?0:Math.round(a/(e.length-1)*100),opacity:r.opacity===void 0||Number.isNaN(r.opacity)?100:r.opacity}))}},Nt=t=>{const e=t.replace(/;$/,"").trim();if(of(e)){const n=x0(e);return Cr({type:"solid",angle:0,stops:[n]})}const r=qs(e,"linear-gradient");if(r){const n=Js(r);let i=90,s=n;const o=n[0];if(o.includes("deg")){const c=o.match(/(-?\d+(?:\.\d+)?)deg/);c&&(i=parseFloat(c[1]),s=n.slice(1))}else o.includes("to ")&&(i={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[o]??90,s=n.slice(1));const l=Zs(s);return l.length?Cr({type:"linear",angle:i,stops:l}):null}const a=qs(e,"radial-gradient");if(a){const n=Js(a),i=n[0]&&!lf(n[0])?n.slice(1):n,s=Zs(i);return s.length?Cr({type:"radial",angle:0,stops:s}):null}return null},qt=t=>{if(t.type==="solid"){const r=t.stops[0],a=r.color;if(a.startsWith("var(--"))return a;const n=r.opacity??100,i=a.replace("#",""),s=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${s}`}const e=t.stops.map(r=>`${Pi(r.color,r.opacity??100)} ${r.position}%`).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`},cf=t=>Math.round(t/100*255).toString(16).toUpperCase().padStart(2,"0"),Bn=t=>{if(t.type==="solid"){const e=t.stops[0];if(e){const r=e.color;if(r.startsWith("var(--"))return r.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");r.toUpperCase();const a=e.opacity??100;if(a===100)return r;{const n=cf(a);return`${r}${n}`}}return"#000000"}return t.type==="linear"?`Linear ${t.angle}°`:"Radial Gradient"},Za=class Za{static defaults(){return{solid:[],gradient:[]}}static normalizeList(e){const r=new Set,a=[];return e.forEach(n=>{let i=ta(n);i||Nt(n)&&(i=n),i&&(r.has(i)||(r.add(i),a.push(i)))}),a.slice(0,this.MAX_COLORS)}static ensureLoaded(){var e;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const r=(e=window.sessionStorage)==null?void 0:e.getItem(this.STORAGE_KEY);if(!r)return;const a=JSON.parse(r);if(Array.isArray(a))this.colors.solid=this.normalizeList(a);else if(a&&typeof a=="object"){const n=a;n.solid&&(this.colors.solid=this.normalizeList(n.solid)),n.gradient&&(this.colors.gradient=this.normalizeList(n.gradient))}}catch{this.colors=this.defaults()}}static persist(){var e;if(!(typeof window>"u"))try{(e=window.sessionStorage)==null||e.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(e){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[e]}static getColors(e){if(e==="all"){const r=this.list("solid"),a=this.list("gradient"),n=[],i=Math.max(r.length,a.length);for(let s=0;s<i;s++)s<r.length&&n.push(r[s]),s<a.length&&n.push(a[s]);return this.normalizeList(n)}return[...this.list(e)]}static addColor(e,r){if(!e)return;let a=ta(e),n="solid";if(a)n="solid";else{const l=Nt(e);l&&(a=e,n=l.type==="solid"?"solid":"gradient")}if(!a)return;const i=r==="all"?n:r,s=this.list(i),o=s.indexOf(a);o!==-1&&s.splice(o,1),s.unshift(a),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};Za.STORAGE_KEY="settingsLib_recentColors",Za.MAX_COLORS=18,Za.colors=null;let ra=Za;const es=(t,e)=>{const r=document.createElement("div");r.className="color-picker-recent-section";const a=document.createElement("div");a.className="color-picker-recent-title",a.textContent="Recently Used";const n=document.createElement("div");n.className="color-picker-tooltip",n.style.display="none",r.appendChild(n);const i=()=>{n.style.display="none"},s=(f,h)=>{const u=f.getBoundingClientRect();n.textContent=h,n.style.left=`${u.left+u.width/2}px`,n.style.top=`${u.bottom+8}px`,n.style.display="block"},o=document.createElement("div");o.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",r.appendChild(a),r.appendChild(o),r.appendChild(l);const c=()=>{i(),o.innerHTML="";const f=ra.getColors(e);if(f.length===0){o.style.display="none",l.style.display="block";return}o.style.display="grid",l.style.display="none",f.forEach(h=>{const u=document.createElement("button");u.type="button",u.className="color-picker-recent-swatch";const p=ff(h);if(u.title=p,u.setAttribute("aria-label",`Use color: ${p}`),h.includes("gradient(")){u.style.backgroundImage=h,u.style.backgroundColor="transparent";const d=Nt(h);d&&d.stops&&d.stops.length>0&&(u.style.borderColor=d.stops[0].color)}else u.style.backgroundColor=h,u.style.borderColor=h;u.addEventListener("mouseenter",()=>s(u,p)),u.addEventListener("mouseleave",()=>{i(),u.style.boxShadow=""}),u.addEventListener("mousedown",()=>{u.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),u.addEventListener("mouseup",()=>{setTimeout(()=>{u.style.boxShadow=""},150)}),u.addEventListener("click",()=>{i(),t(h)}),o.appendChild(u)})};return c(),{container:r,refresh:c}},ff=t=>{const e=Nt(t);if(e)return Bn(e);const r=ta(t);if(r){const a=Pt(r);return`${r} (RGB: ${a.r}, ${a.g}, ${a.b})`}return t},v0=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ef="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Un=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ef[r[t]&63];return e};function tf(t){let e=0,r=t.parentElement;for(;r;)r.classList.contains("setting-group")&&r!==t&&e++,r=r.parentElement;return e}function Dn(t,e){const r=Math.min(Math.max(e,0),5);t.setAttribute("data-nesting-level",r.toString()),r>0?t.style.setProperty("--visual-indent",`${r*2}px`):(t.style.removeProperty("--visual-indent"),t.style.marginLeft="")}function Ni(t,e=0){t.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(a=>{const n=a,i=e+1;Dn(n,i),Ni(n,i)})}const rf={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class af{constructor(e={}){this.observedElements=new Set,this.config={...rf,...e},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(e=>{let r=!1;e.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("setting-group")?[n]:Array.from(n.querySelectorAll(".setting-group"))).length>0&&(r=!0)})}),r&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(e){this.observedElements.add(e),this.updateElementNesting(e)}untrackElement(e){this.observedElements.delete(e)}updateElementNesting(e){const r=tf(e);this.applyNestingWithConfig(e,r)}updateAllNesting(){this.observedElements.forEach(e=>{e.isConnected?this.updateElementNesting(e):this.observedElements.delete(e)})}applyNestingWithConfig(e,r){const a=Math.min(Math.max(r,0),this.config.maxLevel);if(e.setAttribute("data-nesting-level",a.toString()),a>0){const n=a*this.config.visualIndentMultiplier;e.style.setProperty("--visual-indent",`${n}px`)}else e.style.removeProperty("--visual-indent"),e.style.marginLeft=""}recalculateNesting(e=document.body){e.querySelectorAll(".setting-group").forEach(a=>{const n=a;this.updateElementNesting(n),this.trackElement(n)})}getNestingStats(){const e={};return this.observedElements.forEach(r=>{const a=parseInt(r.getAttribute("data-nesting-level")||"0",10);e[a]=(e[a]||0)+1}),e}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const Ys=new af;function Hn(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array)return t.map(e=>Hn(e));if(typeof t=="object"){const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Hn(t[r]));return e}return t}function nf(t){switch(t){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const lt=class lt{constructor(e={}){this.props=e,this.dataPropsPath="",this.id=e.id||Un(),this.value=this.props.default,this.desktop=this.props.default,this.title=e.title||"",this.includeGetJson=e.includeGetJson!==void 0?e.includeGetJson:!0}static SetUploadUrl(e){globalThis.DefaultUploadUrl=e,lt.DefaultUploadUrl=e}static SetDefaultLanguage(e){globalThis.DefaultLanguage=e,lt.DefaultLanguage=e}static CurrentLanguage(e){return e!==void 0&&(lt.currentLanguage=e,lt.currentLanguageExplicitlySet=!0,lt.languageChangeCallbacks.forEach(r=>r(e))),lt.currentLanguage||lt.DefaultLanguage}static HasExplicitCurrentLanguage(){return lt.currentLanguageExplicitlySet}static onLanguageChange(e){return lt.languageChangeCallbacks.add(e),()=>{lt.languageChangeCallbacks.delete(e)}}static SetGlobalVariables(e){lt.GlobalVariables={...lt.GlobalVariables,...e}}destroy(){throw new Error("Method not implemented.")}setOnChange(e){return this.onChange=e,this}setOnBlur(e){return this.onBlur=e,this}setDataPropsPath(e){this.dataPropsPath=e}getDataPropsPath(){return this.dataPropsPath}setComponentPath(e){}setValue(e){this.value=e,this.inputEl&&(this.inputEl.value=String(e)),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}clone(){const e=this.constructor,r=Hn(this.props),a=new e(r);return a.value=Hn(this.value),a}createInput(e){e={...this.props.inputProps,...e};const r=document.createElement("div");if(r.className=e.wrapperClassName||"",e.title||e.icon){const o=document.createElement("div");if(o.className="icon-container",e.icon){const l=this.createIcon(e.icon,e.iconClassName);o.appendChild(l)}if(e.title){const l=this.createLabel(e.title,e.labelClassName);o.appendChild(l)}r.appendChild(o)}const a=document.createElement("div");a.className=e.wrapperClassName||"";const n=document.createElement("input");this.inputEl=n,n.value=String(e.value||nf(e.inputType)),n.type=e.inputType,n.placeholder=e.placeholder||"",n.className=e.inputClassName||"",this.dataPropsPath&&n.setAttribute("data-test-id",this.dataPropsPath);const i=o=>{const l=o.target;let c=l.value;switch(e.inputType){case"number":c=Number(l.value);break;case"color":c=l.value;break;case"date":c=l.value;break;case"select":c=l.value;break;case"text":c=l.value;break;case"button":c=l.value;break;default:c=l.value}this.value=c,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return n.addEventListener("input",i),n.addEventListener("change",i),n.addEventListener("blur",s),e.inputCustomizer&&e.inputCustomizer(n),a.appendChild(n),r.appendChild(a),r}createLabel(e,r){const a=document.createElement("span");return a.textContent=e,a.className="input-label "+(r||""),a}createIcon(e,r){const a=document.createElement("span");return a.className="input-icon "+(r||""),a.innerHTML=e,a}};lt.currentLanguageExplicitlySet=!1,lt.languageChangeCallbacks=new Set,lt.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},lt.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let Le=lt;function dr(t){return t instanceof Le}function $e(t){return t instanceof ir}function Mi(t){return dr(t)||$e(t)}const Qi=(t,e,r)=>{let a=!1,n=0,i=0,s=0,o=0;const l=h=>{if(h.target.closest("button"))return;a=!0,n=h.clientX,i=h.clientY;const u=e.getBoundingClientRect();s=u.left,o=u.top,document.addEventListener("mousemove",c),document.addEventListener("mouseup",f),document.body.style.userSelect="none"},c=h=>{if(!a)return;const u=h.clientX-n,p=h.clientY-i,m=window.innerWidth,d=window.innerHeight,g=e.offsetWidth,x=e.offsetHeight;let w=s+u,v=o+p;w=Math.max(8,Math.min(m-g-8,w)),v=Math.max(8,Math.min(d-x-8,v)),e.style.left=`${w}px`,e.style.top=`${v}px`,r==null||r(w,v)},f=()=>{a=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f),document.body.style.userSelect=""};t.addEventListener("mousedown",l)},ta=t=>{if(!t)return null;let e=t.trim();return!e.startsWith("#")||(e=e.slice(1),e.length===3&&(e=e.split("").map(r=>r+r).join("")),!/^[0-9a-fA-F]{6}$/.test(e))?null:`#${e.toUpperCase()}`},Rn=(t,e,r)=>`#${[t,e,r].map(a=>Math.max(0,Math.min(255,a)).toString(16).padStart(2,"0")).join("")}`,Pt=t=>{const e=t.replace("#",""),r=e.length===3?e.split("").map(a=>a+a).join(""):e;return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}},ya=t=>{const{r:e,g:r,b:a}=Pt(t),n=e/255,i=r/255,s=a/255,o=Math.max(n,i,s),l=Math.min(n,i,s),c=o-l;let f=0;c!==0&&(o===n?f=(i-s)/c%6:o===i?f=(s-n)/c+2:f=(n-i)/c+4),f<0&&(f+=6);const h=o===0?0:c/o,u=o;return{h:f*60,s:h,v:u}},ka=(t,e,r)=>{const a=(t%360+360)%360,n=r*e,i=n*(1-Math.abs(a/60%2-1)),s=r-n;let o=0,l=0,c=0;return a<60?(o=n,l=i,c=0):a<120?(o=i,l=n,c=0):a<180?(o=0,l=n,c=i):a<240?(o=0,l=i,c=n):a<300?(o=i,l=0,c=n):(o=n,l=0,c=i),Rn(Math.round((o+s)*255),Math.round((l+s)*255),Math.round((c+s)*255))},m0=(t,e,r)=>{const a=r*(1-e/2),n=a===0||a===1?0:(r-a)/Math.min(a,1-a);return{hue:t,sat:n,lightness:a}},Oi=(t,e,r)=>{const a=(1-Math.abs(2*r-1))*e,n=a*(1-Math.abs(t/60%2-1)),i=r-a/2;let s=0,o=0,l=0;return t<60?(s=a,o=n,l=0):t<120?(s=n,o=a,l=0):t<180?(s=0,o=a,l=n):t<240?(s=0,o=n,l=a):t<300?(s=n,o=0,l=a):(s=a,o=0,l=n),{r:Math.round((s+i)*255),g:Math.round((o+i)*255),b:Math.round((l+i)*255)}},Pi=(t,e)=>{const r=Math.max(0,Math.min(100,e))/100;if(t.startsWith("#")){const{r:n,g:i,b:s}=Pt(t);return`rgba(${n}, ${i}, ${s}, ${r})`}if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${r})`);if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${r})`);if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}if(t.startsWith("hsla(")){const n=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(n){const{r:i,g:s,b:o}=Oi(parseInt(n[1]),parseInt(n[2])/100,parseInt(n[3])/100);return`rgba(${i}, ${s}, ${o}, ${r})`}}const a=ta(t);if(a){const{r:n,g:i,b:s}=Pt(a);return`rgba(${n}, ${i}, ${s}, ${r})`}return t},sf=t=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(t.toLowerCase()),g0=t=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(r=>r.test(t.trim())),of=t=>{if(typeof document>"u")return g0(t)||!!ta(t);const e=document.createElement("div");return e.style.color=t,e.style.color!==""},x0=t=>{const e=t.trim();if(/^#[0-9A-Fa-f]{8}$/.test(e)){const i=e.slice(1),s=parseInt(i.slice(0,2),16),o=parseInt(i.slice(2,4),16),l=parseInt(i.slice(4,6),16),c=parseInt(i.slice(6,8),16);return{color:Rn(s,o,l),position:0,opacity:Math.round(c/255*100)}}const r=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(r){const i=parseInt(r[1]),s=parseInt(r[2]),o=parseInt(r[3]),l=r[4]?parseFloat(r[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}const a=e.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(a){const{r:i,g:s,b:o}=Oi(parseFloat(a[1]),parseFloat(a[2])/100,parseFloat(a[3])/100),l=a[4]?parseFloat(a[4]):1;return{color:Rn(i,s,o),position:0,opacity:Math.round(l*100)}}return{color:ta(e)||e,position:0,opacity:100}},Js=t=>{const e=[];let r="",a=0;for(let n=0;n<t.length;n++){const i=t[n];if(i==="(")a++;else if(i===")")a--;else if(i===","&&a===0){e.push(r.trim()),r="";continue}r+=i}return r.trim()&&e.push(r.trim()),e},qs=(t,e)=>{const r=new RegExp(`${e}\\s*\\(`,"i"),a=t.match(r);if(!a)return null;const n=a.index+a[0].length;let i=1,s=n;for(let o=n;o<t.length&&i>0;o++)t[o]==="("?i++:t[o]===")"&&i--,s=o;return i===0?t.substring(n,s):null},lf=t=>{const e=t.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(e)?!1:/^#[0-9a-f]{3,8}$/i.test(e)||/^rgb/i.test(t)||/^hsl/i.test(t)||sf(e)},Zs=t=>{const e=[];return t.forEach((r,a)=>{const n=r.trim();if(!n)return;let i="",s=0;const o=n.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);o&&g0(o[1].trim())?(i=o[1].trim(),s=parseFloat(o[2])):(i=n,s=t.length===1?0:a/(t.length-1)*100);const l=x0(i);l.position=Math.max(0,Math.min(100,Math.round(s))),e.push(l)}),e},Cr=t=>{const e=t.stops&&t.stops.length?t.stops:[{color:"#000000",position:0,opacity:100}];return{type:t.type&&["linear","radial","solid"].includes(t.type)?t.type:"linear",angle:typeof t.angle=="number"?t.angle:90,stops:e.map((r,a)=>({color:r.color||"#000000",position:typeof r.position=="number"?r.position:e.length===1?0:Math.round(a/(e.length-1)*100),opacity:r.opacity===void 0||Number.isNaN(r.opacity)?100:r.opacity}))}},Nt=t=>{const e=t.replace(/;$/,"").trim();if(of(e)){const n=x0(e);return Cr({type:"solid",angle:0,stops:[n]})}const r=qs(e,"linear-gradient");if(r){const n=Js(r);let i=90,s=n;const o=n[0];if(o.includes("deg")){const c=o.match(/(-?\d+(?:\.\d+)?)deg/);c&&(i=parseFloat(c[1]),s=n.slice(1))}else o.includes("to ")&&(i={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[o]??90,s=n.slice(1));const l=Zs(s);return l.length?Cr({type:"linear",angle:i,stops:l}):null}const a=qs(e,"radial-gradient");if(a){const n=Js(a),i=n[0]&&!lf(n[0])?n.slice(1):n,s=Zs(i);return s.length?Cr({type:"radial",angle:0,stops:s}):null}return null},qt=t=>{if(t.type==="solid"){const r=t.stops[0],a=r.color;if(a.startsWith("var(--"))return a;const n=r.opacity??100,i=a.replace("#",""),s=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${s}`}const e=t.stops.map(r=>`${Pi(r.color,r.opacity??100)} ${r.position}%`).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`},cf=t=>Math.round(t/100*255).toString(16).toUpperCase().padStart(2,"0"),Bn=t=>{if(t.type==="solid"){const e=t.stops[0];if(e){const r=e.color;if(r.startsWith("var(--"))return r.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");r.toUpperCase();const a=e.opacity??100;if(a===100)return r;{const n=cf(a);return`${r}${n}`}}return"#000000"}return t.type==="linear"?`Linear ${t.angle}°`:"Radial Gradient"},Za=class Za{static defaults(){return{solid:[],gradient:[]}}static normalizeList(e){const r=new Set,a=[];return e.forEach(n=>{let i=ta(n);i||Nt(n)&&(i=n),i&&(r.has(i)||(r.add(i),a.push(i)))}),a.slice(0,this.MAX_COLORS)}static ensureLoaded(){var e;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const r=(e=window.sessionStorage)==null?void 0:e.getItem(this.STORAGE_KEY);if(!r)return;const a=JSON.parse(r);if(Array.isArray(a))this.colors.solid=this.normalizeList(a);else if(a&&typeof a=="object"){const n=a;n.solid&&(this.colors.solid=this.normalizeList(n.solid)),n.gradient&&(this.colors.gradient=this.normalizeList(n.gradient))}}catch{this.colors=this.defaults()}}static persist(){var e;if(!(typeof window>"u"))try{(e=window.sessionStorage)==null||e.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(e){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[e]}static getColors(e){if(e==="all"){const r=this.list("solid"),a=this.list("gradient"),n=[],i=Math.max(r.length,a.length);for(let s=0;s<i;s++)s<r.length&&n.push(r[s]),s<a.length&&n.push(a[s]);return this.normalizeList(n)}return[...this.list(e)]}static addColor(e,r){if(!e)return;let a=ta(e),n="solid";if(a)n="solid";else{const l=Nt(e);l&&(a=e,n=l.type==="solid"?"solid":"gradient")}if(!a)return;const i=r==="all"?n:r,s=this.list(i),o=s.indexOf(a);o!==-1&&s.splice(o,1),s.unshift(a),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};Za.STORAGE_KEY="settingsLib_recentColors",Za.MAX_COLORS=18,Za.colors=null;let ra=Za;const es=(t,e)=>{const r=document.createElement("div");r.className="color-picker-recent-section";const a=document.createElement("div");a.className="color-picker-recent-title",a.textContent="Recently Used";const n=document.createElement("div");n.className="color-picker-tooltip",n.style.display="none",r.appendChild(n);const i=()=>{n.style.display="none"},s=(f,h)=>{const u=f.getBoundingClientRect();n.textContent=h,n.style.left=`${u.left+u.width/2}px`,n.style.top=`${u.bottom+8}px`,n.style.display="block"},o=document.createElement("div");o.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",r.appendChild(a),r.appendChild(o),r.appendChild(l);const c=()=>{i(),o.innerHTML="";const f=ra.getColors(e);if(f.length===0){o.style.display="none",l.style.display="block";return}o.style.display="grid",l.style.display="none",f.forEach(h=>{const u=document.createElement("button");u.type="button",u.className="color-picker-recent-swatch";const p=ff(h);if(u.title=p,u.setAttribute("aria-label",`Use color: ${p}`),h.includes("gradient(")){u.style.backgroundImage=h,u.style.backgroundColor="transparent";const d=Nt(h);d&&d.stops&&d.stops.length>0&&(u.style.borderColor=d.stops[0].color)}else u.style.backgroundColor=h,u.style.borderColor=h;u.addEventListener("mouseenter",()=>s(u,p)),u.addEventListener("mouseleave",()=>{i(),u.style.boxShadow=""}),u.addEventListener("mousedown",()=>{u.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),u.addEventListener("mouseup",()=>{setTimeout(()=>{u.style.boxShadow=""},150)}),u.addEventListener("click",()=>{i(),t(h)}),o.appendChild(u)})};return c(),{container:r,refresh:c}},ff=t=>{const e=Nt(t);if(e)return Bn(e);const r=ta(t);if(r){const a=Pt(r);return`${r} (RGB: ${a.r}, ${a.g}, ${a.b})`}return t},v0=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path fill-rule="evenodd" clip-rule="evenodd"
3
3
  d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
4
4
  fill="#919EAB"/>
@@ -23,7 +23,7 @@
23
23
  `;class gf{constructor(e,r="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=a=>{if(!this.isOpen)return;const n=a.target;if(this.element.contains(n))return;if(this.backdrop.contains(n)){a.preventDefault(),a.stopPropagation(),this.close(!0);return}const i=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(i).some(l=>l.contains(n)))return;const o=document.querySelector(".gradient-popover");o&&o.contains(n)||(a.preventDefault(),a.stopPropagation(),this.close(!0))},this.keyDown=a=>{if(this.isOpen){if(a.key==="Escape")a.preventDefault(),this.close(!0);else if(a.key==="Enter"){const n=a.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"))return;a.preventDefault(),this.close(!0)}}},this.onChange=e,this.recentScope=r,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(e){const r=parseFloat(e);return isNaN(r)?0:r/100}build(){const e=document.createElement("div");e.className="custom-color-picker",e.style.display="none";const r=document.createElement("div");r.className="color-picker-header",r.style.cursor="move";const a=document.createElement("span");a.textContent="Color";const n=document.createElement("button");n.className="color-picker-close",n.innerHTML=v0,n.addEventListener("click",()=>this.close(!0)),r.appendChild(a),r.appendChild(n),Qi(r,e);const i=document.createElement("div");i.className="color-picker-area",this.colorArea=i;const s=document.createElement("div");s.className="color-picker-marker",this.colorMarker=s,i.appendChild(s);const o=document.createElement("div");o.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=E0;const c=document.createElement("div");c.className="color-picker-sliders-group";const f=document.createElement("div");f.className="color-picker-hue",this.hueSlider=f;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,f.appendChild(h);const u=document.createElement("div");u.className="color-picker-opacity",this.opacitySlider=u;const p=document.createElement("div");p.className="color-picker-opacity-marker",this.opacityMarker=p,u.appendChild(p),c.appendChild(f),c.appendChild(u),o.appendChild(l),o.appendChild(c);const m=es(y=>{var P;this.setColor(y),(P=this.onChange)==null||P.call(this,y,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=m.refresh;const d=document.createElement("div");d.className="color-picker-format-section";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const x=document.createElement("option");x.value="hex",x.textContent="HEX";const w=document.createElement("option");w.value="rgb",w.textContent="RGB";const v=document.createElement("option");v.value="hsl",v.textContent="HSL",g.appendChild(x),g.appendChild(w),g.appendChild(v);const F=document.createElement("input");F.type="text",F.className="color-picker-color-input",F.value=this.currentColor,this.input=F;const N=document.createElement("div");N.className="color-picker-input-container";const A=document.createElement("button");return A.className="color-picker-copy-inside",A.textContent="Copy",N.appendChild(F),N.appendChild(A),d.appendChild(g),d.appendChild(N),e.appendChild(r),e.appendChild(i),e.appendChild(o),e.appendChild(m.container),e.appendChild(d),e.addEventListener("click",y=>y.stopPropagation()),this.bind(i,f,u,F,g,A,l),e}createBackdrop(){const e=document.createElement("div");return e.className="color-picker-backdrop",e.style.display="none",e.style.pointerEvents="none",e}bind(e,r,a,n,i,s,o){const l=h=>{var w;const u=e.getBoundingClientRect(),p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width)),m=Math.max(0,Math.min(1,(h.clientY-u.top)/u.height));this.colorMarker.style.left=`${p*100}%`,this.colorMarker.style.top=`${m*100}%`;const g=this.parsePercentage(this.hueMarker.style.left||"0%")*360,x=ka(g,p,1-m);this.currentColor=x,this.syncInput(),this.updateOpacityBg(),(w=this.onChange)==null||w.call(this,x,this.currentOpacity)},c=h=>{var w;const u=r.getBoundingClientRect();let p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width));this.hueMarker.style.left=`${p*100}%`;const m=p*360,d=this.parsePercentage(this.colorMarker.style.left||"0%"),g=this.parsePercentage(this.colorMarker.style.top||"0%"),x=ka(m,d,1-g);this.currentColor=x,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${m}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(w=this.onChange)==null||w.call(this,x,this.currentOpacity)},f=h=>{var m;const u=a.getBoundingClientRect(),p=Math.max(0,Math.min(1,(h.clientX-u.left)/u.width));this.opacityMarker.style.left=`${p*100}%`,this.currentOpacity=Math.round(p*100),(m=this.onChange)==null||m.call(this,this.currentColor,this.currentOpacity)};e.addEventListener("mousedown",h=>{h.preventDefault(),l(h);const u=m=>l(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),r.addEventListener("mousedown",h=>{h.preventDefault(),c(h);const u=m=>c(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",h=>{h.preventDefault(),f(h);const u=m=>f(m),p=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",p)}),i.addEventListener("change",()=>this.syncInput()),n.addEventListener("input",()=>this.applyFromInput()),n.addEventListener("blur",()=>this.syncInput()),n.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),this.syncInput(),n.blur())}),s.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(n.value)}catch{n.select(),document.execCommand("copy")}}),o.addEventListener("click",async()=>{var h;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const u=new window.EyeDropper,{sRGBHex:p}=await u.open();this.setColor(p),(h=this.onChange)==null||h.call(this,p,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(e){var s;this.currentColor=e;const{h:r,s:a,v:n}=ya(e),i=r>=360?r%360:r;this.hueMarker.style.left=`${i/360*100}%`,this.colorMarker.style.left=`${a*100}%`,this.colorMarker.style.top=`${(1-n)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${i}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(s=this.onChange)==null||s.call(this,e,this.currentOpacity)}syncInput(){const e=this.select.value,{h:r,s:a,v:n}=ya(this.currentColor);if(e==="hex")this.input.value=this.currentColor;else if(e==="rgb"){const{r:i,g:s,b:o}=Pt(this.currentColor);this.input.value=`rgb(${i}, ${s}, ${o})`}else{const{hue:i,sat:s,lightness:o}=m0(r,a,n);this.input.value=`hsl(${Math.round(i)}, ${Math.round(s*100)}%, ${Math.round(o*100)}%)`}}applyFromInput(){const e=this.input.value.trim();let r="";if(/^#[0-9A-Fa-f]{6}$/.test(e))r=e;else{const a=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(a){const n=parseInt(a[1]),i=parseInt(a[2]),s=parseInt(a[3]);n<=255&&i<=255&&s<=255&&(r=`#${[n,i,s].map(o=>o.toString(16).padStart(2,"0")).join("")}`)}else{const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const i=parseInt(n[1]),s=parseInt(n[2])/100,o=parseInt(n[3])/100,l=o+s*Math.min(o,1-o),c=l===0?0:2*(1-o/l);r=ka(i,c,l)}}}r&&this.setColor(r)}updateOpacityBg(){const{r:e,g:r,b:a}=Pt(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${e}, ${r}, ${a})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${e}, ${r}, ${a}, 0)`)}open(e,r,a){var v;this.currentColor=e,this.currentOpacity=a??100,this.syncInput();const{h:n,s:i,v:s}=ya(e);this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(v=this.recentSectionRefresh)==null||v.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const o=this.element.offsetWidth,l=this.element.offsetHeight,c=r.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,u=16;let p=c.right+8,m=c.top;const d=f-c.right,g=c.left;d>=o+u?p=c.right+8:g>=o+u?p=c.left-o-8:p=Math.max(u,(f-o)/2);const x=h-c.bottom,w=c.top;x>=l+u?m=c.bottom+8:w>=l+u?m=c.top-l-8:x>w?(m=c.bottom+8,m+l>h-u&&(m=h-l-u)):(m=c.top-l-8,m<u&&(m=u)),this.element.style.left=`${p}px`,this.element.style.top=`${m}px`}close(e){var r;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),e&&this.onChange&&this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(r=this.recentSectionRefresh)==null||r.call(this)))}setOnChange(e){this.onChange=e}getIsOpen(){return this.isOpen}getElement(){return this.element}}class xf{constructor(e){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(e.initialColor),this.currentOpacity=this.clampOpacity(e.initialOpacity),this.onColorChange=e.onColorChange,this.recentScope=e.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(e){const r=parseFloat(e);return isNaN(r)?0:r/100}sanitizeColor(e){const r=this.currentColor||"#FFFFFF";return ta(e)??r}clampOpacity(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):100}build(){const e=document.createElement("div");e.className="embedded-color-picker";const r=document.createElement("div");r.className="color-picker-area embedded",this.colorArea=r;const a=document.createElement("div");a.className="color-picker-marker",this.colorMarker=a,r.appendChild(a);const n=document.createElement("div");n.className="color-picker-sliders-container embedded";const i=document.createElement("button");i.className="color-picker-eyedropper",i.type="button",i.innerHTML=E0;const s=document.createElement("div");s.className="color-picker-sliders-group";const o=document.createElement("div");o.className="color-picker-hue embedded",this.hueSlider=o;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,o.appendChild(l);const c=document.createElement("div");c.className="color-picker-opacity embedded",this.opacitySlider=c;const f=document.createElement("div");f.className="color-picker-opacity-marker",this.opacityMarker=f,c.appendChild(f),s.appendChild(o),s.appendChild(c),n.appendChild(i),n.appendChild(s);const h=es(F=>{const N=Nt(F);N&&N.type!=="solid"?this.onColorChange(F,this.currentOpacity):(this.setColor(F),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=h.refresh;const u=document.createElement("div");u.className="color-picker-format-section embedded";const p=document.createElement("select");p.className="color-picker-format-select",this.select=p;const m=document.createElement("option");m.value="hex",m.textContent="HEX";const d=document.createElement("option");d.value="rgb",d.textContent="RGB";const g=document.createElement("option");g.value="hsl",g.textContent="HSL",p.appendChild(m),p.appendChild(d),p.appendChild(g);const x=document.createElement("input");x.type="text",x.className="color-picker-color-input",this.input=x;const w=document.createElement("div");w.className="color-picker-input-container";const v=document.createElement("button");return v.className="color-picker-copy-inside",v.textContent="Copy",w.appendChild(x),w.appendChild(v),u.appendChild(p),u.appendChild(w),e.appendChild(r),e.appendChild(n),e.appendChild(u),e.appendChild(h.container),this.bind(r,o,c,x,p,v,i),e}bind(e,r,a,n,i,s,o){const l=(u,p)=>{const m=p||e.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width)),g=Math.max(0,Math.min(1,(u.clientY-m.top)/m.height));this.colorMarker.style.left=`${d*100}%`,this.colorMarker.style.top=`${g*100}%`;const w=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=ka(w,d,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),this.queueChange()},c=(u,p)=>{const m=p||r.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width));this.hueMarker.style.left=`${d*100}%`;const g=d*360,x=this.parsePercentage(this.colorMarker.style.left||"0%"),w=this.parsePercentage(this.colorMarker.style.top||"0%"),v=ka(g,x,1-w);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
24
24
  linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.queueChange()},f=(u,p)=>{const m=p||a.getBoundingClientRect(),d=Math.max(0,Math.min(1,(u.clientX-m.left)/m.width));this.opacityMarker.style.left=`${d*100}%`,this.currentOpacity=this.clampOpacity(d*100),this.queueChange()},h=(u,p,m)=>{u.preventDefault(),this.isDragging=!0,this.cachedRect=m.getBoundingClientRect(),p(u,this.cachedRect);let d=null,g;const x=()=>{this.dragRafId===void 0&&(this.dragRafId=window.requestAnimationFrame(()=>{this.dragRafId=void 0,d&&this.cachedRect&&p(d,this.cachedRect)}))},w=()=>{this.isDragging&&(this.isDragging=!1,this.dragRafId!==void 0&&(cancelAnimationFrame(this.dragRafId),this.dragRafId=void 0),this.cachedRect=void 0,d=null,this.flushChange(),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",w),window.removeEventListener("blur",w),this.applyPendingExternal())};g=v=>{if(!v.buttons){w();return}d=v,x()},document.addEventListener("mousemove",g),document.addEventListener("mouseup",w),window.addEventListener("blur",w)};e.addEventListener("mousedown",u=>{h(u,l,e)}),r.addEventListener("mousedown",u=>{h(u,c,r)}),a.addEventListener("mousedown",u=>{h(u,f,a)}),i.addEventListener("change",()=>{this.syncInput()}),n.addEventListener("input",()=>{this.applyFromInput()}),n.addEventListener("blur",()=>{this.syncInput()}),n.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),this.syncInput(),n.blur())}),s.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(n.value)}catch{n.select(),document.execCommand("copy")}}),o.addEventListener("click",async()=>{if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const u=new window.EyeDropper,{sRGBHex:p}=await u.open();this.setColor(p),this.onColorChange(this.currentColor,this.currentOpacity)}catch{}})}setColor(e){const r=this.sanitizeColor(e);this.currentColor=r;const{h:a,s:n,v:i}=ya(r),s=a>=360?a%360:a;this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-i)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
25
25
  linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const e=this.select.value,{h:r,s:a,v:n}=ya(this.currentColor);if(e==="hex")this.input.value=this.currentColor;else if(e==="rgb"){const{r:i,g:s,b:o}=Pt(this.currentColor);this.input.value=`rgb(${i}, ${s}, ${o})`}else{const{hue:i,sat:s,lightness:o}=m0(r,a,n);this.input.value=`hsl(${Math.round(i)}, ${Math.round(s*100)}%, ${Math.round(o*100)}%)`}}applyFromInput(){const e=this.input.value.trim();let r="";if(/^#[0-9A-Fa-f]{6}$/.test(e))r=e;else{const a=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(a){const n=parseInt(a[1],10),i=parseInt(a[2],10),s=parseInt(a[3],10);n<=255&&i<=255&&s<=255&&(r="#"+[n,i,s].map(o=>o.toString(16).padStart(2,"0")).join(""))}else{const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const i=parseInt(n[1],10),s=parseInt(n[2],10)/100,o=parseInt(n[3],10)/100,l=o+s*Math.min(o,1-o),c=l===0?0:2*(1-o/l);r=ka(i,c,l)}}}r&&(this.setColor(r),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:e,g:r,b:a}=Pt(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${e}, ${r}, ${a})`),this.opacitySlider.style.setProperty("--base-color-transparent",`rgba(${e}, ${r}, ${a}, 0)`)}queueChange(){this.changeRafId===void 0&&(this.changeRafId=window.requestAnimationFrame(()=>{this.changeRafId=void 0,this.onColorChange(this.currentColor,this.currentOpacity)}))}flushChange(){this.changeRafId!==void 0&&(cancelAnimationFrame(this.changeRafId),this.changeRafId=void 0),this.onColorChange(this.currentColor,this.currentOpacity)}applyPendingExternal(){if(!this.pendingExternalUpdate)return;const{color:e,opacity:r}=this.pendingExternalUpdate;this.pendingExternalUpdate=void 0,this.initFromColor(e,r)}initFromColor(e,r){var l;const a=this.sanitizeColor(e);this.currentColor=a,this.currentOpacity=this.clampOpacity(r);const{h:n,s:i,v:s}=ya(a),o=n>=360?n%360:n;this.hueMarker.style.left=`${o/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
26
- linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var e;this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this))}getElement(){return this.element}updateColor(e,r){if(this.isDragging){this.pendingExternalUpdate={color:e,opacity:r};return}this.initFromColor(e,r)}}const Qt=class Qt extends Le{constructor(e={}){const r=typeof e.default=="string"?void 0:e.default;super({...e,title:e.title||"Color",default:r}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.sharedStopColorPicker=null,this.colorPickerStopIndex=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=a=>{var u;if(!this.popoverEl||!this.isPopoverOpen)return;const n=a.target,i=this.popoverEl.contains(n),s=(u=this.element)==null?void 0:u.contains(n),o=document.querySelectorAll(".custom-color-picker"),l=Array.from(o).some(p=>p.contains(n)),c=n.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),f=n.classList.contains("color-picker-backdrop"),h=n.classList.contains("gradient-popover-backdrop");!i&&!s&&!l&&!c&&!f&&!h&&this.closePopover()},this.handlePopoverKeydown=a=>{var n,i;if(this.isPopoverOpen){if(a.key==="Escape"){if(a.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(a.key==="Enter"){const s=a.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;if(a.preventDefault(),(i=this.sharedStopColorPicker)!=null&&i.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=e.detectChange,this.variant=e.variant??"default",this.originalDefault=e.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(e){if(e.startsWith("var(--")){const r=e.replace("var(--","").replace(")","");return(Le.GlobalVariables||{})[r]||e}return e}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new gf(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(e){var a,n;if(!e){this.linkedGlobalVariable=null;return}const r=typeof e=="string"?e:((n=(a=e.stops)==null?void 0:a[0])==null?void 0:n.color)??null;this.linkedGlobalVariable=r&&r.startsWith("var(--")?r:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var e,r;this.isBoundToGlobal()&&((r=(e=this.value)==null?void 0:e.stops)!=null&&r.length&&(this.value.stops=this.value.stops.map(a=>({...a,color:this.resolveGlobalVarColor(a.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var e;!this.isBoundToGlobal()||!this.value||((e=this.value.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const e=this.originalDefault;if(typeof e=="string"){if(e.startsWith("var(--"))return Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]});const a=Nt(e);if(a)return Cr(a)}return Cr(e&&typeof e=="object"?e:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(e){let r=null;typeof e=="string"?e.startsWith("var(--")?r=Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]}):r=Nt(e):e&&typeof e=="object"&&(r=Cr(e)),r||(r=this.defaultValue()),this.value=r,this.setLinkedGlobalVariableFrom(e??r),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const e=this.value.stops[0],r=e.opacity??100,a=this.resolveGlobalVarColor(e.color);this.previewEl.style.background=Pi(a,r)}else{const e=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=qt(e)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const r=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");this.inputEl.value=`Linked: ${r}`}else this.inputEl.value=Bn(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(e){return{...e,stops:e.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const e=this.isBoundToGlobal();e?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(e?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:qt(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const e=document.createElement("div");if(e.className="gradient-setting-wrapper",this.props.title){const a=document.createElement("div");a.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,a.appendChild(n),e.appendChild(a)}const r=document.createElement("div");return r.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?qt(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?Bn(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const a=this.value.stops[0];if(a){const i=this.resolveGlobalVarColor(a.color).toUpperCase(),s=a.opacity??100;if(s===100)this.inputEl.value=i;else{const l=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${i}${l}`}}}else this.inputEl.value=qt(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=Bn(this.value))}),this.inputEl.addEventListener("paste",a=>this.handlePaste(a)),this.inputEl.addEventListener("input",a=>this.handleTextInput(a)),this.inputEl.addEventListener("keydown",a=>{a.key==="Enter"&&(this.handleTextInput(a),this.inputEl.blur()),a.key==="Escape"&&(this.value&&(this.inputEl.value=qt(this.value)),this.inputEl.blur())}),r.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=mf,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.breakGlobalBinding()}),r.appendChild(this.unlinkButton),r.appendChild(this.inputEl),e.appendChild(r),this.createPopover(),this.element=e,this.updateUnlinkButtonVisibility(),e}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const e=document.createElement("div");e.className="gradient-popover-header",e.style.cursor="move";let r=null;if(this.variant!=="global"){r=document.createElement("div"),r.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const c=document.createElement("button");c.className="color-tab",c.textContent="Global",r.appendChild(l),r.appendChild(c),e.appendChild(r)}else{const l=document.createElement("div");e.appendChild(l)}const a=document.createElement("button");a.type="button",a.className="gradient-popover-close",a.innerHTML=v0,a.addEventListener("click",()=>this.closePopover()),e.appendChild(a),Qi(e,this.popoverEl,(l,c)=>{this.popoverPosition={left:l,top:c}});const n=document.createElement("div");n.className="gradient-editor";const i=document.createElement("div");i.className="type-tabs-wrapper";const s=this.createTypeTabs();i.appendChild(s),n.appendChild(i);const o=document.createElement("div");if(o.className="gradient-editor-content",this.updatePopoverContent(o),n.appendChild(o),this.variant!=="global"&&r){const l=r.children[0],c=r.children[1],f=h=>{this.currentMode=h,h==="custom"?(l.classList.add("active"),c.classList.remove("active"),i.style.display="block"):(c.classList.add("active"),l.classList.remove("active"),i.style.display="none"),this.updatePopoverContent(o)};l.addEventListener("click",()=>f("custom")),c.addEventListener("click",()=>f("global")),this.isBoundToGlobal()?(this.currentMode="global",f("global")):(this.currentMode="custom",f("custom"))}this.popoverEl.appendChild(e),this.popoverEl.appendChild(n),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var n,i;const e=document.createElement("div");e.className="gradient-type-tabs";const r=document.createElement("button");r.type="button",r.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)==="solid"?"active":""}`,r.innerHTML=df,r.addEventListener("click",()=>this.switchType("solid"));const a=document.createElement("button");return a.type="button",a.className=`gradient-type-tab ${((i=this.value)==null?void 0:i.type)!=="solid"?"active":""}`,a.innerHTML=pf,a.addEventListener("click",()=>{var o,l;const s=((o=this.value)==null?void 0:o.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(s)}),e.appendChild(r),e.appendChild(a),e}switchType(e,r=!1){var l,c;if(!this.value)return;const a=this.value.type,n=this.isBoundToGlobal(),i=this.linkedGlobalVariable;this.value.type=e;let s=!1;if(n&&i&&a==="solid"!=(e==="solid")){const f=this.resolveGlobalVarColor(i),h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100,u=Nt(f);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type,this.linkedGlobalVariable=null,s=!0):((l=this.value.stops)!=null&&l.length&&(this.value.stops=this.value.stops.map(p=>({...p,color:p.color.startsWith("var(--")?this.resolveGlobalVarColor(p.color):p.color}))),!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:f,position:0,opacity:h}]:this.value.stops[0]={...this.value.stops[0],color:f,opacity:h},this.linkedGlobalVariable=null,s=!0)}if(e!=="solid"&&(this.pendingSolidColor=null),e!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),e!=="solid"&&this.value.stops.length===1){const h=this.value.stops[0].color;if(h.startsWith("var(--")){const u=this.resolveGlobalVarColor(h),p=Nt(u);p&&p.type!=="solid"&&p.stops.length>=2?(this.value.stops=p.stops,this.value.angle=p.angle,this.value.type=p.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else if(h.startsWith("linear-gradient")||h.startsWith("radial-gradient")){const u=Nt(h);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type):(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}],this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(e!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(e==="solid"&&n&&i){const f=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:i,position:0,opacity:f}],this.value.angle=0}if(this.popoverEl){const f=this.popoverEl.querySelectorAll(".gradient-type-tab");f.forEach(p=>p.classList.remove("active"));const h=f[0],u=f[1];e==="solid"?h==null||h.classList.add("active"):u==null||u.classList.add("active")}const o=(c=this.popoverEl)==null?void 0:c.querySelector(".gradient-editor-content");o&&this.updatePopoverContent(o),this.updateUI(),(r||s||a!==e)&&this.triggerChange()}updatePopoverContent(e){if(e.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(e);return}this.value.type==="solid"?this.renderSolid(e):this.renderGradient(e)}}renderGlobalColors(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=h=>{h.innerHTML="";let u={};try{u=Le.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!u||Object.keys(u).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.fontSize="12px",g.style.color="#666",g.style.padding="8px",h.appendChild(g);return}const p=Le.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],m=this.globalSearchQuery.toLowerCase();let d;this.globalLayoutMode==="list"?(d=document.createElement("div"),d.className="global-colors-list"):(d=document.createElement("div"),d.className="global-colors-grid"),h.appendChild(d),p.forEach(g=>{const x=Object.entries(u).filter(([w])=>!g.keys.includes(w)&&g.title!=="Global Colors"?!1:g.keys.includes(w)&&w.toLowerCase().includes(m));x.length!==0&&x.forEach(([w,v])=>{if(this.globalLayoutMode==="list"){const F=document.createElement("div");F.className="global-color-row";const N=document.createElement("div");N.className="global-color-circle";const A=this.resolveGlobalVarColor(v);N.style.background=A,(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&N.classList.add("selected");const P=document.createElement("span");P.className="global-color-label",P.textContent=w.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),F.appendChild(N),F.appendChild(P),F.addEventListener("click",I=>{I.preventDefault();const z=`var(--${w})`;this.setValue(z),this.pendingSolidColor=z,a(h)}),d.appendChild(F)}else{const F=document.createElement("div");F.className="global-color-circle";const N=this.resolveGlobalVarColor(v);F.style.background=N,F.title=w.split("-").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&F.classList.add("selected"),F.addEventListener("click",y=>{y.preventDefault();const P=`var(--${w})`;this.setValue(P),this.pendingSolidColor=P,a(h)}),d.appendChild(F)}})})},n=document.createElement("div");n.className="global-controls-row";const i=document.createElement("div");i.className="global-search-container";const s=document.createElement("span");s.className="global-search-icon",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const o=document.createElement("input");o.type="text",o.className="global-search-input",o.placeholder="Search",o.value=this.globalSearchQuery;const l=document.createElement("div");o.addEventListener("input",h=>{this.globalSearchQuery=h.target.value,a(l)}),i.appendChild(s),i.appendChild(o);const c=document.createElement("button");c.className="global-layout-toggle",c.type="button";const f=()=>{c.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};f(),c.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",f(),a(l)}),n.appendChild(i),n.appendChild(c),e.appendChild(n),e.appendChild(l),a(l)}renderSolid(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=new xf({initialColor:r.color.startsWith("var(--")?this.resolveGlobalVarColor(r.color):r.color,initialOpacity:r.opacity??100,onColorChange:(n,i)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const s=Nt(n);if(s&&s.type!=="solid"){this.value=s,this.switchType(s.type,!0);return}this.value.stops[0].color=n,this.value.stops[0].opacity=i,this.updateUI(),this.triggerChange(),this.pendingSolidColor=n}}});this.solidPicker=a,e.appendChild(a.getElement())}renderGradient(e){this.solidPicker=null;let r=null;{const f=document.createElement("div");f.className="gradient-subtype-inline";const h=document.createElement("select");h.className="gradient-subtype-select";const u=document.createElement("option");u.value="linear",u.textContent="Linear";const p=document.createElement("option");p.value="radial",p.textContent="Radial",h.appendChild(u),h.appendChild(p),h.value=this.value.type==="radial"?"radial":"linear",r=document.createElement("input"),r.type="text",r.inputMode="numeric",r.className="gradient-degree-input",r.value=`${this.value.angle??90}°`,r.style.width="75px",r.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,r.value="90°");const m=document.createElement("button");m.type="button",m.className="gradient-flip-btn",m.innerHTML=hf,h.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(h.value==="radial"?"radial":"linear",!0),r&&this.updateDegreeVisibility(r)}),r.addEventListener("focus",d=>{const g=d.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),r.addEventListener("input",d=>{this.clearGlobalBindingForCustomChange();const g=parseInt(d.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),r.addEventListener("blur",d=>{var w;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=d.target;let x=parseInt(g.value);Number.isNaN(x)&&(x=((w=this.value)==null?void 0:w.angle)??0),x=Math.max(0,Math.min(360,x)),this.value&&(this.value.angle=x),g.value=`${x}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(d=>{d.position=100-d.position}),this.value.stops.sort((d,g)=>d.position-g.position),this.updateGradientPreview(a),this.createHandles(n,a),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),f.appendChild(h),f.appendChild(r),f.appendChild(m),e.appendChild(f),this.updateDegreeVisibility(r)}const a=document.createElement("div");a.className="gradient-preview",this.updateGradientPreview(a);const n=document.createElement("div");n.className="gradient-handles",a.appendChild(n),e.appendChild(a),this.createHandles(n,a),a.addEventListener("click",f=>{var d;const h=f.target;if(h.classList.contains("gstop-handle")||h.classList.contains("gstop-chip"))return;const u=a.getBoundingClientRect(),m=(f.clientX-u.left)/u.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(m),this.updateStopsList(),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((d=document.activeElement)==null?void 0:d.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const i=document.createElement("div");i.className="gradient-stops-header";const s=document.createElement("span");s.textContent="Stops";const o=document.createElement("button");o.type="button",o.className="gradient-add-stop",o.textContent="+",i.appendChild(s),i.appendChild(o);const l=document.createElement("div");l.className="gradient-stops",e.appendChild(i),e.appendChild(l),this.updateStopsList(l);const c=es(f=>{const h=Nt(f);h&&(this.clearGlobalBindingForCustomChange(),this.value=h,this.switchType(h.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=c.refresh,e.appendChild(c.container),o.addEventListener("click",()=>{var f;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(e){var r;e&&(((r=this.value)==null?void 0:r.type)==="radial"?(e.disabled=!0,e.style.opacity="0.5"):(e.disabled=!1,e.style.opacity="1"))}updateGradientPreview(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-preview"));if(r&&this.value)if(this.value.type==="solid")r.style.background=qt(this.value);else{const n=this.value.stops.map(i=>`${Pi(i.color,i.opacity??100)} ${i.position}%`).join(", ");r.style.background=`linear-gradient(90deg, ${n})`}}debouncedPreviewUpdate(e){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(e),this.previewUpdateTimeout=null},16)}createHandles(e,r){e.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((a,n)=>{const i=document.createElement("div");i.className="gstop-handle",i.style.left=`${Math.max(0,Math.min(100,a.position))}%`,i.style.top="0%";const s=document.createElement("div");s.className="gstop-chip";const o=this.resolveGlobalVarColor(a.color);s.style.backgroundColor=o,i.appendChild(s);let l=!1,c=!1,f=0,h=0;const u=d=>{l=!0,c=!1,f=d.clientX,h=this.value.stops[n].position,i.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),d.preventDefault(),d.stopPropagation()},p=d=>{if(!l||!this.value)return;const g=d.clientX-f;if(Math.abs(g)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const x=r.getBoundingClientRect();let w=h+g/x.width*100;w=Math.max(0,Math.min(100,w)),this.value.stops[n].position=Math.round(w),i.style.left=`${w}%`,this.updateGradientPreview()}},m=d=>{var g;if(l)if(l=!1,i.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((x,w)=>x.position-w.position),this.createHandles(e,r),this.updateStopsList()),this.updateUI(),this.triggerChange();else{d.stopPropagation();const x=(g=this.value)==null?void 0:g.stops[n];x&&setTimeout(()=>{const w=this.getSharedStopColorPicker();w.getIsOpen()&&w.close(!1),this.colorPickerStopIndex=n,w.setOnChange((F,N)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[n]&&(this.value.stops[n].color=F,N!==void 0&&(this.value.stops[n].opacity=N),s.style.backgroundColor=F,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const v=this.resolveGlobalVarColor(x.color);w.open(v,s,x.opacity??100)},0)}};i.addEventListener("mousedown",u),e.appendChild(i)})}updateStopsList(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-stops"));!r||!this.value||this.value.type==="solid"||!this.value.stops||(r.innerHTML="",this.value.stops.forEach((n,i)=>{var F,N;const s=document.createElement("div");s.className="gstop-row";const o=document.createElement("div");o.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${n.position}%`,l.style.width="60px",o.appendChild(l);const c=document.createElement("div");c.className="gstop-color-container";const f=this.resolveGlobalVarColor(n.color),h=document.createElement("div");h.className="gstop-color-preview",h.style.backgroundColor=f;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=f.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",c.appendChild(h),c.appendChild(u),c.appendChild(p);const m=document.createElement("button");m.type="button",m.className="gstop-del",m.innerHTML=uf,m.disabled=(((N=(F=this.value)==null?void 0:F.stops)==null?void 0:N.length)||0)<=2,s.appendChild(o),s.appendChild(c),s.appendChild(m),r.appendChild(s);const d=document.createElement("span");d.className="gstop-opacity-label",d.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const x=document.createElement("input");x.type="range",x.className="gstop-opacity-slider",x.min="0",x.max="100",x.value=String(n.opacity??100);const w=Pt(f);x.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${w.r}, ${w.g}, ${w.b}, 0)`);const v=document.createElement("span");v.className="gstop-opacity-value",v.textContent=`${n.opacity??100}%`,g.appendChild(x),g.appendChild(v),u.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const y=this.getSharedStopColorPicker();y.getIsOpen()&&y.close(!1),this.colorPickerStopIndex=i,y.setOnChange((I,z)=>{this.clearGlobalBindingForCustomChange(),u.value=I.replace("#","").toUpperCase(),h.style.backgroundColor=I,this.value.stops[i].color=I,z!==void 0&&(this.value.stops[i].opacity=z,x.value=String(z),v.textContent=`${z}%`);const V=Pt(I);x.style.setProperty("--slider-color",`rgb(${V.r}, ${V.g}, ${V.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${V.r}, ${V.g}, ${V.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const P=this.resolveGlobalVarColor(n.color);y.open(P,u,n.opacity??100)}),u.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=u.value.trim(),y=A.startsWith("#")?A:`#${A}`;if(/^#[0-9A-Fa-f]{6}$/.test(y)){this.value.stops[i].color=y,h.style.backgroundColor=y;const P=Pt(y);x.style.setProperty("--slider-color",`rgb(${P.r}, ${P.g}, ${P.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${P.r}, ${P.g}, ${P.b}, 0)`),this.debouncedPreviewUpdate()}}),u.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async A=>{A.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),l.addEventListener("focus",A=>{const y=A.target;y.value=y.value.replace("%",""),y.select()}),l.addEventListener("input",A=>{this.clearGlobalBindingForCustomChange();const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(P)){const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",A=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(Number.isNaN(P))y.value=`${this.value.stops[i].position}%`;else{const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{var A,y;(this.value.stops.length||0)<=2||((A=this.sharedStopColorPicker)!=null&&A.getIsOpen()&&this.colorPickerStopIndex===i?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>i&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(i,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),x.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=parseInt(x.value,10);this.value.stops[i].opacity=Math.max(0,Math.min(100,A)),v.textContent=`${this.value.stops[i].opacity}%`,this.debouncedPreviewUpdate()}),x.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=this.value.stops.map(n=>n.position).sort((n,i)=>n-i);let r=50,a=0;for(let n=0;n<e.length-1;n++){const i=e[n+1]-e[n];i>a&&(a=i,r=e[n]+i/2)}this.addStopAtPosition(r)}addStopAtPosition(e){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const r=Math.max(0,Math.min(100,e)),a=[...this.value.stops].sort((c,f)=>c.position-f.position);let n=a[0],i=a[a.length-1];for(let c=0;c<a.length-1;c++)if(a[c].position<=r&&a[c+1].position>=r){n=a[c],i=a[c+1];break}let s,o;if(n===i||n.position===i.position)s=n.color,o=n.opacity??100;else{const c=(r-n.position)/(i.position-n.position),f=Pt(n.color),h=Pt(i.color),u=Math.round(f.r+(h.r-f.r)*c),p=Math.round(f.g+(h.g-f.g)*c),m=Math.round(f.b+(h.b-f.b)*c);s=`#${u.toString(16).padStart(2,"0")}${p.toString(16).padStart(2,"0")}${m.toString(16).padStart(2,"0")}`.toUpperCase(),o=Math.round((n.opacity??100)+((i.opacity??100)-(n.opacity??100))*c)}const l={position:Math.round(r),color:s,opacity:o};this.value.stops.push(l),this.value.stops.sort((c,f)=>c.position-f.position)}openPopover(){if(this.popoverEl&&(Qt.openInstance&&Qt.openInstance!==this&&Qt.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,Qt.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const e=this.element.getBoundingClientRect(),r=306,a=window.innerWidth,n=window.innerHeight,i=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const s=this.popoverEl.offsetHeight;let o=e.right+8,l=e.top;const c=a-e.right,f=e.left,h=r+i;c<h&&f>c+100&&(o=e.left-r-8);const u=n-e.bottom,p=e.top;p>=s+i?l=e.top-s-8:u>=s+i?l=e.bottom+8:p>u?(l=e.top-s-8,l<i&&(l=i)):(l=e.bottom+8,l+s>n-i&&(l=n-s-i)),this.popoverEl.style.left=`${o}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:o,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var e;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((e=document.activeElement)==null?void 0:e.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const r=this.element.getBoundingClientRect(),a=306,n=window.innerWidth,i=window.innerHeight,s=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let l=r.right+8,c=r.top;const f=n-r.right,h=r.left,u=a+s;f<u&&h>f+100&&(l=r.left-a-8);const p=i-r.bottom,m=r.top;m>=o+s?c=r.top-o-8:p>=o+s?c=r.bottom+8:m>p?(c=r.top-o-8,c<s&&(c=s)):(c=r.bottom+8,c+o>i-s&&(c=i-o-s)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${c}px`})}}refreshPopoverContent(){var i,s;if(!this.popoverEl)return;const e=this.popoverEl.querySelectorAll(".gradient-type-tab");e.forEach(o=>o.classList.remove("active"));const r=e[0],a=e[1];((i=this.value)==null?void 0:i.type)==="solid"?r.classList.add("active"):(a.classList.add("active"),(s=this.recentGradientRefresh)==null||s.call(this)),this.popoverEl.offsetHeight;const n=this.popoverEl.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n)}closePopover(){var e,r;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(e=this.sharedStopColorPicker)!=null&&e.getIsOpen()&&(this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null),this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const a=qt(this.value);ra.addColor(a,"gradient"),(r=this.recentGradientRefresh)==null||r.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),Qt.openInstance===this&&(Qt.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():ra.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(e){var a;e.preventDefault();const r=((a=e.clipboardData)==null?void 0:a.getData("text"))||"";this.parseAndSet(r)}handleTextInput(e){const r=e.target;this.parseAndSet(r.value)}parseAndSet(e){let r=e.trim();r&&!r.startsWith("#")&&!r.startsWith("var(")&&!r.startsWith("rgb")&&!r.startsWith("hsl")&&!r.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(r)&&(r="#"+r,this.inputEl&&(this.inputEl.value=r));const a=Nt(r);a&&this.setValue(a)}getChangePayload(){var e;if(this.value)return this.isBoundToGlobal()?((e=this.value.stops)==null?void 0:e.some(a=>a.opacity!==void 0&&a.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const e=this.getChangePayload();e!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var r,a;(r=this.onChange)==null||r.call(this,e),(a=this.detectChange)==null||a.call(this,e),this.changeDebounceTimeout=null},Qt.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};Qt.openInstance=null,Qt.CHANGE_DEBOUNCE_DELAY=150;let aa=Qt;function zr(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=t[r];e(r,a)}}function Di(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>Di(e));if(typeof t=="object"){const e={};for(const[r,a]of Object.entries(t))r!=="$id"&&(e[r]=Di(a));return e}return t}const ni=class ni{constructor(e){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.isSettingValue=!1,this.suppressOnChange=!1,console.log("🔨 [SettingsGroup Created]",e.title||"Unnamed Group"),this.suppressOnChange=!0,this.id=e.id||Un(),this.title=e.title,this.settings=e.settings,this.isCollapsed=e.collapsed??!1,this.isMain=e.main??!1,this.custom=e.custom??!1,this.nestingLevel=0,this.includeGetJson=e.includeGetJson??!0,this.addItemCfg=e.addItem,this.deleteItemCfg=e.deleteItem,this.dataProps=e.dataProps,this.dataPropsPath=e.dataProps||"",this.hide=e.hide??!1,Object.assign(this,e.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath(),this.propagateComponentPaths(),this.suppressOnChange=!1}propagateNestingLevel(){const e=this.nestingLevel+1;zr(this.settings,(r,a)=>{$e(a)&&(a.nestingLevel=e,a.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(e){this.nestingLevel=e,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(e){if(this.title=e,this.elementRef){const r=this.elementRef.querySelector(".setting-group-title h3");r&&(r.textContent=e)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(e){this.dataPropsPath=e,this.propagateDataPropsPath()}propagateDataPropsPath(){zr(this.settings,(e,r)=>{const a=String(e),n=this.dataPropsPath?`${this.dataPropsPath}_${a}`:a;($e(r)||dr(r)&&typeof r.setDataPropsPath=="function")&&r.setDataPropsPath(n)})}propagateComponentPaths(e=""){zr(this.settings,(r,a)=>{var i;const n=String(r);if($e(a)){const s=e?`${e} > ${a.title}`:a.title;a.propagateComponentPaths(s)}else if(dr(a)&&typeof a.setComponentPath=="function"){const s=((i=a.props)==null?void 0:i.title)||n,o=e?`${e} > ${s}`:s;a.setComponentPath(o)}})}updateNestingStyles(){this.elementRef&&(Dn(this.elementRef,this.nestingLevel),Ni(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([e,r])=>{try{if($e(r)){const a=r.getValues();r.setValue(a)}else if(typeof r.setValue=="function"){const a=r.value;a!==void 0&&r.setValue(a)}}catch(a){console.warn(`Error refreshing UI for setting ${e}:`,a)}})}removeSetting(e){var n;const r=this.settings[e];if(!r)return;if(delete this.settings[e],this.elementRef){const i=this.elementRef.querySelector(".setting-group-content");if(i){const s=Array.from(i.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const o of s){const l=o.id,c=o.getAttribute("data-setting-id");if(l&&"id"in r&&typeof r.id=="string"&&l.includes(r.id)){o.remove();break}if(c&&"id"in r&&typeof r.id=="string"&&c===r.id){o.remove();break}}}}typeof r.cleanup=="function"&&r.cleanup(),this.updateNestingStyles();const a=this.getValues();this.initialValues=a,this.suppressOnChange||(n=this.onChange)==null||n.call(this,a)}updateVisibility(){this.elementRef}updateSettings(e,r){var l;const a=(r==null?void 0:r.preserveValues)??!0,n=new Set(Object.keys(this.settings)),i=Object.keys(e),s={};a&&i.forEach(c=>{const f=this.settings[c];f&&($e(f)?s[c]=f.getValues():dr(f)?s[c]=f.value:typeof f.getValues=="function"?s[c]=f.getValues():f.value!==void 0&&(s[c]=f.value))}),n.forEach(c=>{i.includes(c)||this.removeSetting(c)}),i.forEach(c=>{var u;const f=e[c],h=this.settings[c];if(h!==f&&(h&&this.removeSetting(c),this.addSetting(c,f),a&&c in s)){const p=s[c];try{$e(f)?f.setValue(p):dr(f)?(u=f.setValue)==null||u.call(f,p):f.setValue&&f.setValue(p)}catch(m){console.warn(`Could not preserve value for setting ${c}:`,m)}}}),this.settings=e,this.propagateNestingLevel(),this.propagateDataPropsPath();const o=this.getValues();this.initialValues=o,this.suppressOnChange||(l=this.onChange)==null||l.call(this,o)}clone(){const e={};zr(this.settings,(n,i)=>{const s=String(n);typeof i.clone=="function"?e[s]=i.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),e[s]=i)});const r={title:this.title,settings:e,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},a=w0(r);return a.suppressOnChange=!0,a.initialValues=this.getValues(),a.suppressOnChange=!1,a}resetDefault(){const e=this.originalDefaultValues;this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues())}setMobileValues(e){!e||typeof e!="object"||(Object.entries(e).forEach(([r,a])=>{const n=this.settings[r];n&&($e(n)||dr(n))&&typeof n.setMobileValue=="function"&&n.setMobileValue(a)}),this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues()))}getMobileValues(e){if(e===void 0){const r={};for(const a in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,a)){const n=this.settings[a];if($e(n))r[a]=n.getMobileValues();else{const i=n;r[a]=i.mobileValue!==void 0?i.mobileValue:i.value}}return r}else{const r=this.settings[e];if(!r)return;if($e(r))return r.getMobileValues();const a=r;return a.mobileValue!==void 0?a.mobileValue:a.value}}setOnChange(e){this.onChange=e;const r=()=>{this.isHandlingChange||this.suppressOnChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const a=this.getValues(),n=this.calculateChanges(this.initialValues,a);Object.keys(n).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=a,this.suppressOnChange||e(a),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),zr(this.settings,(a,n)=>{var i;if($e(n))n.setOnChange(()=>{if(this.suppressOnChange)return;const s=this.getValues();this.initialValues=s,e(s)}),this.changeHandlers.add(()=>e(this.getValues()));else if(dr(n)){const s=()=>r();this.changeHandlers.add(s),n.setOnChange(s)}else{const s=()=>r();this.changeHandlers.add(s),(i=n.setOnChange)==null||i.call(n,s)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear(),zr(this.settings,(e,r)=>{const a=r;try{typeof a.cleanup=="function"?a.cleanup():typeof a.destroy=="function"&&a.destroy()}catch{}})}setValue(e){if(!(!e||typeof e!="object")&&!this.isSettingValue){this.isSettingValue=!0;try{Object.entries(e).forEach(([a,n])=>{let i=this.settings[a];if(!i&&this.addItemCfg&&a.startsWith(this.addItemCfg.keyPrefix)){const s=a.slice(this.addItemCfg.keyPrefix.length),o=Number(s);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);Mi(l)&&(this.addSetting(a,l),i=l)}}i&&($e(i)||dr(i))&&typeof i.setValue=="function"&&i.setValue(n)});const r=this.getValues();this.initialValues=r,this.onChange&&!this.suppressOnChange&&this.onChange(r)}finally{this.isSettingValue=!1}}}wireChild(e){var a;const r=()=>{var i;if(this.suppressOnChange)return;const n=this.getValues();this.initialValues=n,(i=this.onChange)==null||i.call(this,n),this.updateVisibility()};$e(e)?e.setOnChange(()=>r()):dr(e)?e.setOnChange(()=>r()):(a=e.setOnChange)==null||a.call(e,()=>r())}addSetting(e,r){var n,i;if(this.settings[e]=r,this.wireChild(r),this.elementRef){const s=this.elementRef.querySelector(".setting-group-content");if(s){const o=s.querySelector(".setting-group-empty");o&&o.remove(),$e(r)&&typeof r.setNestingLevel=="function"&&r.setNestingLevel(this.nestingLevel+1);const l=r.draw(),c=this.deleteItemCfg??this.addItemCfg;if(c){const u=c.keyPrefix??((n=this.addItemCfg)==null?void 0:n.keyPrefix);u&&e.startsWith(u)&&this.addDeleteButtonToElement(l,e)}const f=s.querySelector(".sg-add-button-bottom");f?s.insertBefore(l,f):s.appendChild(l),Ys.trackElement(l),Dn(l,this.nestingLevel+1),Ni(l,this.nestingLevel+1);const h=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=h,this.updateNestingStyles()}}const a=this.getValues();this.initialValues=a,this.suppressOnChange||(i=this.onChange)==null||i.call(this,a)}addDeleteButtonToElement(e,r,a){let n=null;try{n=e.querySelector(":scope > .setting-group-title")}catch{n=null}if(!n){const c=Array.from(e.querySelectorAll(".setting-group-title"));for(const f of c)if(f.closest(".setting-group")===e){n=f;break}n||(n=c[0]??null)}if(!n)return;const i=n.querySelector(".actions-section");if(!i)return;const s=document.createElement("button");s.type="button",s.className="sg-delete-button",a?a.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,s.title="Delete",s.style.cssText=`
26
+ linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var e;this.recentScope==="solid"&&(ra.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this))}getElement(){return this.element}updateColor(e,r){if(this.isDragging){this.pendingExternalUpdate={color:e,opacity:r};return}this.initFromColor(e,r)}}const Qt=class Qt extends Le{constructor(e={}){const r=typeof e.default=="string"?void 0:e.default;super({...e,title:e.title||"Color",default:r}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.sharedStopColorPicker=null,this.colorPickerStopIndex=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=a=>{var u;if(!this.popoverEl||!this.isPopoverOpen)return;const n=a.target,i=this.popoverEl.contains(n),s=(u=this.element)==null?void 0:u.contains(n),o=document.querySelectorAll(".custom-color-picker"),l=Array.from(o).some(p=>p.contains(n)),c=n.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),f=n.classList.contains("color-picker-backdrop"),h=n.classList.contains("gradient-popover-backdrop");!i&&!s&&!l&&!c&&!f&&!h&&this.closePopover()},this.handlePopoverKeydown=a=>{var n,i;if(this.isPopoverOpen){if(a.key==="Escape"){if(a.preventDefault(),(n=this.sharedStopColorPicker)!=null&&n.getIsOpen()){this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null;return}this.closePopover();return}if(a.key==="Enter"){const s=a.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;if(a.preventDefault(),(i=this.sharedStopColorPicker)!=null&&i.getIsOpen()){this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null;return}this.closePopover()}}},this.detectChange=e.detectChange,this.variant=e.variant??"default",this.originalDefault=e.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(e){if(e.startsWith("var(--")){const r=e.replace("var(--","").replace(")","");return(Le.GlobalVariables||{})[r]||e}return e}getSharedStopColorPicker(){return this.sharedStopColorPicker||(this.sharedStopColorPicker=new gf(void 0,"solid")),this.sharedStopColorPicker}setLinkedGlobalVariableFrom(e){var a,n;if(!e){this.linkedGlobalVariable=null;return}const r=typeof e=="string"?e:((n=(a=e.stops)==null?void 0:a[0])==null?void 0:n.color)??null;this.linkedGlobalVariable=r&&r.startsWith("var(--")?r:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var e,r;this.isBoundToGlobal()&&((r=(e=this.value)==null?void 0:e.stops)!=null&&r.length&&(this.value.stops=this.value.stops.map(a=>({...a,color:this.resolveGlobalVarColor(a.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var e;!this.isBoundToGlobal()||!this.value||((e=this.value.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const e=this.originalDefault;if(typeof e=="string"){if(e.startsWith("var(--"))return Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]});const a=Nt(e);if(a)return Cr(a)}return Cr(e&&typeof e=="object"?e:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(e){let r=null;typeof e=="string"?e.startsWith("var(--")?r=Cr({type:"solid",angle:0,stops:[{color:e,position:0,opacity:100}]}):r=Nt(e):e&&typeof e=="object"&&(r=Cr(e)),r||(r=this.defaultValue()),this.value=r,this.setLinkedGlobalVariableFrom(e??r),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const e=this.value.stops[0],r=e.opacity??100,a=this.resolveGlobalVarColor(e.color);this.previewEl.style.background=Pi(a,r)}else{const e=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=qt(e)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const r=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");this.inputEl.value=`Linked: ${r}`}else this.inputEl.value=Bn(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(e){return{...e,stops:e.stops.map(r=>({...r,color:this.resolveGlobalVarColor(r.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const e=this.isBoundToGlobal();e?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(e?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:qt(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const e=document.createElement("div");if(e.className="gradient-setting-wrapper",this.props.title){const a=document.createElement("div");a.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,a.appendChild(n),e.appendChild(a)}const r=document.createElement("div");return r.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?qt(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?Bn(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const a=this.value.stops[0];if(a){const i=this.resolveGlobalVarColor(a.color).toUpperCase(),s=a.opacity??100;if(s===100)this.inputEl.value=i;else{const l=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${i}${l}`}}}else this.inputEl.value=qt(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=Bn(this.value))}),this.inputEl.addEventListener("paste",a=>this.handlePaste(a)),this.inputEl.addEventListener("input",a=>this.handleTextInput(a)),this.inputEl.addEventListener("keydown",a=>{a.key==="Enter"&&(this.handleTextInput(a),this.inputEl.blur()),a.key==="Escape"&&(this.value&&(this.inputEl.value=qt(this.value)),this.inputEl.blur())}),r.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=mf,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.breakGlobalBinding()}),r.appendChild(this.unlinkButton),r.appendChild(this.inputEl),e.appendChild(r),this.createPopover(),this.element=e,this.updateUnlinkButtonVisibility(),e}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const e=document.createElement("div");e.className="gradient-popover-header",e.style.cursor="move";let r=null;if(this.variant!=="global"){r=document.createElement("div"),r.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const c=document.createElement("button");c.className="color-tab",c.textContent="Global",r.appendChild(l),r.appendChild(c),e.appendChild(r)}else{const l=document.createElement("div");e.appendChild(l)}const a=document.createElement("button");a.type="button",a.className="gradient-popover-close",a.innerHTML=v0,a.addEventListener("click",()=>this.closePopover()),e.appendChild(a),Qi(e,this.popoverEl,(l,c)=>{this.popoverPosition={left:l,top:c}});const n=document.createElement("div");n.className="gradient-editor";const i=document.createElement("div");i.className="type-tabs-wrapper";const s=this.createTypeTabs();i.appendChild(s),n.appendChild(i);const o=document.createElement("div");if(o.className="gradient-editor-content",this.updatePopoverContent(o),n.appendChild(o),this.variant!=="global"&&r){const l=r.children[0],c=r.children[1],f=h=>{this.currentMode=h,h==="custom"?(l.classList.add("active"),c.classList.remove("active"),i.style.display="block"):(c.classList.add("active"),l.classList.remove("active"),i.style.display="none"),this.updatePopoverContent(o)};l.addEventListener("click",()=>f("custom")),c.addEventListener("click",()=>f("global")),this.isBoundToGlobal()?(this.currentMode="global",f("global")):(this.currentMode="custom",f("custom"))}this.popoverEl.appendChild(e),this.popoverEl.appendChild(n),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var n,i;const e=document.createElement("div");e.className="gradient-type-tabs";const r=document.createElement("button");r.type="button",r.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)==="solid"?"active":""}`,r.innerHTML=df,r.addEventListener("click",()=>this.switchType("solid"));const a=document.createElement("button");return a.type="button",a.className=`gradient-type-tab ${((i=this.value)==null?void 0:i.type)!=="solid"?"active":""}`,a.innerHTML=pf,a.addEventListener("click",()=>{var o,l;const s=((o=this.value)==null?void 0:o.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(s)}),e.appendChild(r),e.appendChild(a),e}switchType(e,r=!1){var l,c;if(!this.value)return;const a=this.value.type,n=this.isBoundToGlobal(),i=this.linkedGlobalVariable;this.value.type=e;let s=!1;if(n&&i&&a==="solid"!=(e==="solid")){const f=this.resolveGlobalVarColor(i),h=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100,u=Nt(f);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type,this.linkedGlobalVariable=null,s=!0):((l=this.value.stops)!=null&&l.length&&(this.value.stops=this.value.stops.map(p=>({...p,color:p.color.startsWith("var(--")?this.resolveGlobalVarColor(p.color):p.color}))),!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:f,position:0,opacity:h}]:this.value.stops[0]={...this.value.stops[0],color:f,opacity:h},this.linkedGlobalVariable=null,s=!0)}if(e!=="solid"&&(this.pendingSolidColor=null),e!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),e!=="solid"&&this.value.stops.length===1){const h=this.value.stops[0].color;if(h.startsWith("var(--")){const u=this.resolveGlobalVarColor(h),p=Nt(u);p&&p.type!=="solid"&&p.stops.length>=2?(this.value.stops=p.stops,this.value.angle=p.angle,this.value.type=p.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else if(h.startsWith("linear-gradient")||h.startsWith("radial-gradient")){const u=Nt(h);u&&u.type!=="solid"&&u.stops.length>=2?(this.value.stops=u.stops,this.value.angle=u.angle,this.value.type=u.type):(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}],this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(e!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(e==="solid"&&n&&i){const f=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:i,position:0,opacity:f}],this.value.angle=0}if(this.popoverEl){const f=this.popoverEl.querySelectorAll(".gradient-type-tab");f.forEach(p=>p.classList.remove("active"));const h=f[0],u=f[1];e==="solid"?h==null||h.classList.add("active"):u==null||u.classList.add("active")}const o=(c=this.popoverEl)==null?void 0:c.querySelector(".gradient-editor-content");o&&this.updatePopoverContent(o),this.updateUI(),(r||s||a!==e)&&this.triggerChange()}updatePopoverContent(e){if(e.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(e);return}this.value.type==="solid"?this.renderSolid(e):this.renderGradient(e)}}renderGlobalColors(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=h=>{h.innerHTML="";let u={};try{u=Le.GlobalVariables||{}}catch(g){console.warn("Could not access Setting.GlobalVariables",g)}if(!u||Object.keys(u).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.fontSize="12px",g.style.color="#666",g.style.padding="8px",h.appendChild(g);return}const p=Le.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],m=this.globalSearchQuery.toLowerCase();let d;this.globalLayoutMode==="list"?(d=document.createElement("div"),d.className="global-colors-list"):(d=document.createElement("div"),d.className="global-colors-grid"),h.appendChild(d),p.forEach(g=>{const x=Object.entries(u).filter(([w])=>!g.keys.includes(w)&&g.title!=="Global Colors"?!1:g.keys.includes(w)&&w.toLowerCase().includes(m));x.length!==0&&x.forEach(([w,v])=>{if(this.globalLayoutMode==="list"){const F=document.createElement("div");F.className="global-color-row";const N=document.createElement("div");N.className="global-color-circle";const A=this.resolveGlobalVarColor(v);N.style.background=A,(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&N.classList.add("selected");const P=document.createElement("span");P.className="global-color-label",P.textContent=w.split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),F.appendChild(N),F.appendChild(P),F.addEventListener("click",I=>{I.preventDefault();const z=`var(--${w})`;this.setValue(z),this.pendingSolidColor=z,a(h)}),d.appendChild(F)}else{const F=document.createElement("div");F.className="global-color-circle";const N=this.resolveGlobalVarColor(v);F.style.background=N,F.title=w.split("-").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${w})`||r.color===`var(--${w})`)&&F.classList.add("selected"),F.addEventListener("click",y=>{y.preventDefault();const P=`var(--${w})`;this.setValue(P),this.pendingSolidColor=P,a(h)}),d.appendChild(F)}})})},n=document.createElement("div");n.className="global-controls-row";const i=document.createElement("div");i.className="global-search-container";const s=document.createElement("span");s.className="global-search-icon",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const o=document.createElement("input");o.type="text",o.className="global-search-input",o.placeholder="Search",o.value=this.globalSearchQuery;const l=document.createElement("div");o.addEventListener("input",h=>{this.globalSearchQuery=h.target.value,a(l)}),i.appendChild(s),i.appendChild(o);const c=document.createElement("button");c.className="global-layout-toggle",c.type="button";const f=()=>{c.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};f(),c.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",f(),a(l)}),n.appendChild(i),n.appendChild(c),e.appendChild(n),e.appendChild(l),a(l)}renderSolid(e){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const r=this.value.stops[0],a=new xf({initialColor:r.color.startsWith("var(--")?this.resolveGlobalVarColor(r.color):r.color,initialOpacity:r.opacity??100,onColorChange:(n,i)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const s=Nt(n);if(s&&s.type!=="solid"){this.value=s,this.switchType(s.type,!0);return}this.value.stops[0].color=n,this.value.stops[0].opacity=i,this.updateUI(),this.triggerChange(),this.pendingSolidColor=n}}});this.solidPicker=a,e.appendChild(a.getElement())}renderGradient(e){this.solidPicker=null;let r=null;{const f=document.createElement("div");f.className="gradient-subtype-inline";const h=document.createElement("select");h.className="gradient-subtype-select";const u=document.createElement("option");u.value="linear",u.textContent="Linear";const p=document.createElement("option");p.value="radial",p.textContent="Radial",h.appendChild(u),h.appendChild(p),h.value=this.value.type==="radial"?"radial":"linear",r=document.createElement("input"),r.type="text",r.inputMode="numeric",r.className="gradient-degree-input",r.value=`${this.value.angle??90}°`,r.style.width="75px",r.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,r.value="90°");const m=document.createElement("button");m.type="button",m.className="gradient-flip-btn",m.innerHTML=hf,h.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(h.value==="radial"?"radial":"linear",!0),r&&this.updateDegreeVisibility(r)}),r.addEventListener("focus",d=>{const g=d.target;g.value=g.value.replace(/[^0-9-]/g,""),setTimeout(()=>g.select(),0)}),r.addEventListener("input",d=>{this.clearGlobalBindingForCustomChange();const g=parseInt(d.target.value);!Number.isNaN(g)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,g)),this.debouncedPreviewUpdate())}),r.addEventListener("blur",d=>{var w;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const g=d.target;let x=parseInt(g.value);Number.isNaN(x)&&(x=((w=this.value)==null?void 0:w.angle)??0),x=Math.max(0,Math.min(360,x)),this.value&&(this.value.angle=x),g.value=`${x}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(d=>{d.position=100-d.position}),this.value.stops.sort((d,g)=>d.position-g.position),this.updateGradientPreview(a),this.createHandles(n,a),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),f.appendChild(h),f.appendChild(r),f.appendChild(m),e.appendChild(f),this.updateDegreeVisibility(r)}const a=document.createElement("div");a.className="gradient-preview",this.updateGradientPreview(a);const n=document.createElement("div");n.className="gradient-handles",a.appendChild(n),e.appendChild(a),this.createHandles(n,a),a.addEventListener("click",f=>{var d;const h=f.target;if(h.classList.contains("gstop-handle")||h.classList.contains("gstop-chip"))return;const u=a.getBoundingClientRect(),m=(f.clientX-u.left)/u.width*100;this.clearGlobalBindingForCustomChange(),this.addStopAtPosition(m),this.updateStopsList(),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((d=document.activeElement)==null?void 0:d.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()});const i=document.createElement("div");i.className="gradient-stops-header";const s=document.createElement("span");s.textContent="Stops";const o=document.createElement("button");o.type="button",o.className="gradient-add-stop",o.textContent="+",i.appendChild(s),i.appendChild(o);const l=document.createElement("div");l.className="gradient-stops",e.appendChild(i),e.appendChild(l),this.updateStopsList(l);const c=es(f=>{const h=Nt(f);h&&(this.clearGlobalBindingForCustomChange(),this.value=h,this.switchType(h.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=c.refresh,e.appendChild(c.container),o.addEventListener("click",()=>{var f;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(a),this.createHandles(n,a),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(e){var r;e&&(((r=this.value)==null?void 0:r.type)==="radial"?(e.disabled=!0,e.style.opacity="0.5"):(e.disabled=!1,e.style.opacity="1"))}updateGradientPreview(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-preview"));if(r&&this.value)if(this.value.type==="solid")r.style.background=qt(this.value);else{const n=this.value.stops.map(i=>`${Pi(i.color,i.opacity??100)} ${i.position}%`).join(", ");r.style.background=`linear-gradient(90deg, ${n})`}}debouncedPreviewUpdate(e){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(e),this.previewUpdateTimeout=null},16)}createHandles(e,r){e.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((a,n)=>{const i=document.createElement("div");i.className="gstop-handle",i.style.left=`${Math.max(0,Math.min(100,a.position))}%`,i.style.top="0%";const s=document.createElement("div");s.className="gstop-chip";const o=this.resolveGlobalVarColor(a.color);s.style.backgroundColor=o,i.appendChild(s);let l=!1,c=!1,f=0,h=0;const u=d=>{l=!0,c=!1,f=d.clientX,h=this.value.stops[n].position,i.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),d.preventDefault(),d.stopPropagation()},p=d=>{if(!l||!this.value)return;const g=d.clientX-f;if(Math.abs(g)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const x=r.getBoundingClientRect();let w=h+g/x.width*100;w=Math.max(0,Math.min(100,w)),this.value.stops[n].position=Math.round(w),i.style.left=`${w}%`,this.updateGradientPreview()}},m=d=>{var g;if(l)if(l=!1,i.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((x,w)=>x.position-w.position),this.createHandles(e,r),this.updateStopsList()),this.updateUI(),this.triggerChange();else{d.stopPropagation();const x=(g=this.value)==null?void 0:g.stops[n];x&&setTimeout(()=>{const w=this.getSharedStopColorPicker();w.getIsOpen()&&w.close(!1),this.colorPickerStopIndex=n,w.setOnChange((F,N)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[n]&&(this.value.stops[n].color=F,N!==void 0&&(this.value.stops[n].opacity=N),s.style.backgroundColor=F,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())});const v=this.resolveGlobalVarColor(x.color);w.open(v,s,x.opacity??100)},0)}};i.addEventListener("mousedown",u),e.appendChild(i)})}updateStopsList(e){var a;const r=e||((a=this.popoverEl)==null?void 0:a.querySelector(".gradient-stops"));!r||!this.value||this.value.type==="solid"||!this.value.stops||(r.innerHTML="",this.value.stops.forEach((n,i)=>{var F,N;const s=document.createElement("div");s.className="gstop-row";const o=document.createElement("div");o.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${n.position}%`,l.style.width="60px",o.appendChild(l);const c=document.createElement("div");c.className="gstop-color-container";const f=this.resolveGlobalVarColor(n.color),h=document.createElement("div");h.className="gstop-color-preview",h.style.backgroundColor=f;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=f.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",c.appendChild(h),c.appendChild(u),c.appendChild(p);const m=document.createElement("button");m.type="button",m.className="gstop-del",m.innerHTML=uf,m.disabled=(((N=(F=this.value)==null?void 0:F.stops)==null?void 0:N.length)||0)<=2,s.appendChild(o),s.appendChild(c),s.appendChild(m),r.appendChild(s);const d=document.createElement("span");d.className="gstop-opacity-label",d.textContent="Opacity";const g=document.createElement("div");g.className="gstop-opacity-group";const x=document.createElement("input");x.type="range",x.className="gstop-opacity-slider",x.min="0",x.max="100",x.value=String(n.opacity??100);const w=Pt(f);x.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${w.r}, ${w.g}, ${w.b}, 0)`);const v=document.createElement("span");v.className="gstop-opacity-value",v.textContent=`${n.opacity??100}%`,g.appendChild(x),g.appendChild(v),u.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation();const y=this.getSharedStopColorPicker();y.getIsOpen()&&y.close(!1),this.colorPickerStopIndex=i,y.setOnChange((I,z)=>{this.clearGlobalBindingForCustomChange(),u.value=I.replace("#","").toUpperCase(),h.style.backgroundColor=I,this.value.stops[i].color=I,z!==void 0&&(this.value.stops[i].opacity=z,x.value=String(z),v.textContent=`${z}%`);const V=Pt(I);x.style.setProperty("--slider-color",`rgb(${V.r}, ${V.g}, ${V.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${V.r}, ${V.g}, ${V.b}, 0)`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()});const P=this.resolveGlobalVarColor(n.color);y.open(P,u,n.opacity??100)}),u.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=u.value.trim(),y=A.startsWith("#")?A:`#${A}`;if(/^#[0-9A-Fa-f]{6}$/.test(y)){this.value.stops[i].color=y,h.style.backgroundColor=y;const P=Pt(y);x.style.setProperty("--slider-color",`rgb(${P.r}, ${P.g}, ${P.b})`),x.style.setProperty("--slider-color-transparent",`rgba(${P.r}, ${P.g}, ${P.b}, 0)`),this.debouncedPreviewUpdate()}}),u.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async A=>{A.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),l.addEventListener("focus",A=>{const y=A.target;y.value=y.value.replace("%",""),y.select()}),l.addEventListener("input",A=>{this.clearGlobalBindingForCustomChange();const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(P)){const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",A=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const y=A.target,P=parseInt(y.value.replace(/[^\d]/g,""),10);if(Number.isNaN(P))y.value=`${this.value.stops[i].position}%`;else{const I=Math.max(0,Math.min(100,P));this.value.stops[i].position=I,y.value=`${I}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",()=>{var A,y;(this.value.stops.length||0)<=2||((A=this.sharedStopColorPicker)!=null&&A.getIsOpen()&&this.colorPickerStopIndex===i?(this.sharedStopColorPicker.close(!1),this.colorPickerStopIndex=null):this.colorPickerStopIndex!==null&&this.colorPickerStopIndex>i&&this.colorPickerStopIndex--,this.clearGlobalBindingForCustomChange(),this.value.stops.splice(i,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),x.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const A=parseInt(x.value,10);this.value.stops[i].opacity=Math.max(0,Math.min(100,A)),v.textContent=`${this.value.stops[i].opacity}%`,this.debouncedPreviewUpdate()}),x.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const e=this.value.stops.map(n=>n.position).sort((n,i)=>n-i);let r=50,a=0;for(let n=0;n<e.length-1;n++){const i=e[n+1]-e[n];i>a&&(a=i,r=e[n]+i/2)}this.addStopAtPosition(r)}addStopAtPosition(e){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const r=Math.max(0,Math.min(100,e)),a=[...this.value.stops].sort((c,f)=>c.position-f.position);let n=a[0],i=a[a.length-1];for(let c=0;c<a.length-1;c++)if(a[c].position<=r&&a[c+1].position>=r){n=a[c],i=a[c+1];break}let s,o;if(n===i||n.position===i.position)s=n.color,o=n.opacity??100;else{const c=(r-n.position)/(i.position-n.position),f=Pt(n.color),h=Pt(i.color),u=Math.round(f.r+(h.r-f.r)*c),p=Math.round(f.g+(h.g-f.g)*c),m=Math.round(f.b+(h.b-f.b)*c);s=`#${u.toString(16).padStart(2,"0")}${p.toString(16).padStart(2,"0")}${m.toString(16).padStart(2,"0")}`.toUpperCase(),o=Math.round((n.opacity??100)+((i.opacity??100)-(n.opacity??100))*c)}const l={position:Math.round(r),color:s,opacity:o};this.value.stops.push(l),this.value.stops.sort((c,f)=>c.position-f.position)}openPopover(){if(this.popoverEl&&(Qt.openInstance&&Qt.openInstance!==this&&Qt.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,Qt.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const e=this.element.getBoundingClientRect(),r=306,a=window.innerWidth,n=window.innerHeight,i=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const s=this.popoverEl.offsetHeight;let o=e.right+8,l=e.top;const c=a-e.right,f=e.left,h=r+i;c<h&&f>c+100&&(o=e.left-r-8);const u=n-e.bottom,p=e.top;p>=s+i?l=e.top-s-8:u>=s+i?l=e.bottom+8:p>u?(l=e.top-s-8,l<i&&(l=i)):(l=e.bottom+8,l+s>n-i&&(l=n-s-i)),this.popoverEl.style.left=`${o}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:o,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var e;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((e=document.activeElement)==null?void 0:e.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const r=this.element.getBoundingClientRect(),a=306,n=window.innerWidth,i=window.innerHeight,s=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let l=r.right+8,c=r.top;const f=n-r.right,h=r.left,u=a+s;f<u&&h>f+100&&(l=r.left-a-8);const p=i-r.bottom,m=r.top;m>=o+s?c=r.top-o-8:p>=o+s?c=r.bottom+8:m>p?(c=r.top-o-8,c<s&&(c=s)):(c=r.bottom+8,c+o>i-s&&(c=i-o-s)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${c}px`})}}refreshPopoverContent(){var i,s;if(!this.popoverEl)return;const e=this.popoverEl.querySelectorAll(".gradient-type-tab");e.forEach(o=>o.classList.remove("active"));const r=e[0],a=e[1];((i=this.value)==null?void 0:i.type)==="solid"?r.classList.add("active"):(a.classList.add("active"),(s=this.recentGradientRefresh)==null||s.call(this)),this.popoverEl.offsetHeight;const n=this.popoverEl.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n)}closePopover(){var e,r;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,(e=this.sharedStopColorPicker)!=null&&e.getIsOpen()&&(this.sharedStopColorPicker.close(!0),this.colorPickerStopIndex=null),this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const a=qt(this.value);ra.addColor(a,"gradient"),(r=this.recentGradientRefresh)==null||r.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),Qt.openInstance===this&&(Qt.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():ra.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(e){var a;e.preventDefault();const r=((a=e.clipboardData)==null?void 0:a.getData("text"))||"";this.parseAndSet(r)}handleTextInput(e){const r=e.target;this.parseAndSet(r.value)}parseAndSet(e){let r=e.trim();r&&!r.startsWith("#")&&!r.startsWith("var(")&&!r.startsWith("rgb")&&!r.startsWith("hsl")&&!r.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(r)&&(r="#"+r,this.inputEl&&(this.inputEl.value=r));const a=Nt(r);a&&this.setValue(a)}getChangePayload(){var e;if(this.value)return this.isBoundToGlobal()?((e=this.value.stops)==null?void 0:e.some(a=>a.opacity!==void 0&&a.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const e=this.getChangePayload();e!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var r,a;(r=this.onChange)==null||r.call(this,e),(a=this.detectChange)==null||a.call(this,e),this.changeDebounceTimeout=null},Qt.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSValue(){const e=this.getChangePayload();return e?typeof e=="string"?e:qt(e):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};Qt.openInstance=null,Qt.CHANGE_DEBOUNCE_DELAY=150;let aa=Qt;function zr(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=t[r];e(r,a)}}function Di(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>Di(e));if(typeof t=="object"){const e={};for(const[r,a]of Object.entries(t))r!=="$id"&&(e[r]=Di(a));return e}return t}const ni=class ni{constructor(e){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.isSettingValue=!1,this.suppressOnChange=!1,this.suppressOnChange=!0,this.id=e.id||Un(),this.title=e.title,this.settings=e.settings,this.isCollapsed=e.collapsed??!1,this.isMain=e.main??!1,this.custom=e.custom??!1,this.nestingLevel=0,this.includeGetJson=e.includeGetJson??!0,this.addItemCfg=e.addItem,this.deleteItemCfg=e.deleteItem,this.dataProps=e.dataProps,this.dataPropsPath=e.dataProps||"",this.hide=e.hide??!1,Object.assign(this,e.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath(),this.propagateComponentPaths(),this.suppressOnChange=!1}propagateNestingLevel(){const e=this.nestingLevel+1;zr(this.settings,(r,a)=>{$e(a)&&(a.nestingLevel=e,a.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(e){this.nestingLevel=e,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(e){if(this.title=e,this.elementRef){const r=this.elementRef.querySelector(".setting-group-title h3");r&&(r.textContent=e)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(e){this.dataPropsPath=e,this.propagateDataPropsPath()}propagateDataPropsPath(){zr(this.settings,(e,r)=>{const a=String(e),n=this.dataPropsPath?`${this.dataPropsPath}_${a}`:a;($e(r)||dr(r)&&typeof r.setDataPropsPath=="function")&&r.setDataPropsPath(n)})}propagateComponentPaths(e=""){zr(this.settings,(r,a)=>{var i;const n=String(r);if($e(a)){const s=e?`${e} > ${a.title}`:a.title;a.propagateComponentPaths(s)}else if(dr(a)&&typeof a.setComponentPath=="function"){const s=((i=a.props)==null?void 0:i.title)||n,o=e?`${e} > ${s}`:s;a.setComponentPath(o)}})}updateNestingStyles(){this.elementRef&&(Dn(this.elementRef,this.nestingLevel),Ni(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([e,r])=>{try{if($e(r)){const a=r.getValues();r.setValue(a)}else if(typeof r.setValue=="function"){const a=r.value;a!==void 0&&r.setValue(a)}}catch(a){console.warn(`Error refreshing UI for setting ${e}:`,a)}})}removeSetting(e){var n;const r=this.settings[e];if(!r)return;if(delete this.settings[e],this.elementRef){const i=this.elementRef.querySelector(".setting-group-content");if(i){const s=Array.from(i.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const o of s){const l=o.id,c=o.getAttribute("data-setting-id");if(l&&"id"in r&&typeof r.id=="string"&&l.includes(r.id)){o.remove();break}if(c&&"id"in r&&typeof r.id=="string"&&c===r.id){o.remove();break}}}}typeof r.cleanup=="function"&&r.cleanup(),this.updateNestingStyles();const a=this.getValues();this.initialValues=a,this.suppressOnChange||(n=this.onChange)==null||n.call(this,a)}updateVisibility(){this.elementRef}updateSettings(e,r){var l;const a=(r==null?void 0:r.preserveValues)??!0,n=new Set(Object.keys(this.settings)),i=Object.keys(e),s={};a&&i.forEach(c=>{const f=this.settings[c];f&&($e(f)?s[c]=f.getValues():dr(f)?s[c]=f.value:typeof f.getValues=="function"?s[c]=f.getValues():f.value!==void 0&&(s[c]=f.value))}),n.forEach(c=>{i.includes(c)||this.removeSetting(c)}),i.forEach(c=>{var u;const f=e[c],h=this.settings[c];if(h!==f&&(h&&this.removeSetting(c),this.addSetting(c,f),a&&c in s)){const p=s[c];try{$e(f)?f.setValue(p):dr(f)?(u=f.setValue)==null||u.call(f,p):f.setValue&&f.setValue(p)}catch(m){console.warn(`Could not preserve value for setting ${c}:`,m)}}}),this.settings=e,this.propagateNestingLevel(),this.propagateDataPropsPath();const o=this.getValues();this.initialValues=o,this.suppressOnChange||(l=this.onChange)==null||l.call(this,o)}clone(){const e={};zr(this.settings,(n,i)=>{const s=String(n);typeof i.clone=="function"?e[s]=i.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),e[s]=i)});const r={title:this.title,settings:e,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},a=w0(r);return a.suppressOnChange=!0,a.initialValues=this.getValues(),a.suppressOnChange=!1,a}resetDefault(){const e=this.originalDefaultValues;this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues())}setMobileValues(e){!e||typeof e!="object"||(Object.entries(e).forEach(([r,a])=>{const n=this.settings[r];n&&($e(n)||dr(n))&&typeof n.setMobileValue=="function"&&n.setMobileValue(a)}),this.setValue(e),this.onChange&&!this.suppressOnChange&&this.onChange(this.getValues()))}getMobileValues(e){if(e===void 0){const r={};for(const a in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,a)){const n=this.settings[a];if($e(n))r[a]=n.getMobileValues();else{const i=n;r[a]=i.mobileValue!==void 0?i.mobileValue:i.value}}return r}else{const r=this.settings[e];if(!r)return;if($e(r))return r.getMobileValues();const a=r;return a.mobileValue!==void 0?a.mobileValue:a.value}}setOnChange(e){this.onChange=e;const r=()=>{this.isHandlingChange||this.suppressOnChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const a=this.getValues(),n=this.calculateChanges(this.initialValues,a);Object.keys(n).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=a,this.suppressOnChange||e(a),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),zr(this.settings,(a,n)=>{var i;if($e(n))n.setOnChange(()=>{if(this.suppressOnChange)return;const s=this.getValues();this.initialValues=s,e(s)}),this.changeHandlers.add(()=>e(this.getValues()));else if(dr(n)){const s=()=>r();this.changeHandlers.add(s),n.setOnChange(s)}else{const s=()=>r();this.changeHandlers.add(s),(i=n.setOnChange)==null||i.call(n,s)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear(),zr(this.settings,(e,r)=>{const a=r;try{typeof a.cleanup=="function"?a.cleanup():typeof a.destroy=="function"&&a.destroy()}catch{}})}setValue(e){if(!(!e||typeof e!="object")&&!this.isSettingValue){this.isSettingValue=!0;try{Object.entries(e).forEach(([a,n])=>{let i=this.settings[a];if(!i&&this.addItemCfg&&a.startsWith(this.addItemCfg.keyPrefix)){const s=a.slice(this.addItemCfg.keyPrefix.length),o=Number(s);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);Mi(l)&&(this.addSetting(a,l),i=l)}}i&&($e(i)||dr(i))&&typeof i.setValue=="function"&&i.setValue(n)});const r=this.getValues();this.initialValues=r,this.onChange&&!this.suppressOnChange&&this.onChange(r)}finally{this.isSettingValue=!1}}}wireChild(e){var a;const r=()=>{var i;if(this.suppressOnChange)return;const n=this.getValues();this.initialValues=n,(i=this.onChange)==null||i.call(this,n),this.updateVisibility()};$e(e)?e.setOnChange(()=>r()):dr(e)?e.setOnChange(()=>r()):(a=e.setOnChange)==null||a.call(e,()=>r())}addSetting(e,r){var n,i;if(this.settings[e]=r,this.wireChild(r),this.elementRef){const s=this.elementRef.querySelector(".setting-group-content");if(s){const o=s.querySelector(".setting-group-empty");o&&o.remove(),$e(r)&&typeof r.setNestingLevel=="function"&&r.setNestingLevel(this.nestingLevel+1);const l=r.draw(),c=this.deleteItemCfg??this.addItemCfg;if(c){const u=c.keyPrefix??((n=this.addItemCfg)==null?void 0:n.keyPrefix);u&&e.startsWith(u)&&this.addDeleteButtonToElement(l,e)}const f=s.querySelector(".sg-add-button-bottom");f?s.insertBefore(l,f):s.appendChild(l),Ys.trackElement(l),Dn(l,this.nestingLevel+1),Ni(l,this.nestingLevel+1);const h=l.style.display;l.style.display="none",l.offsetHeight,l.style.display=h,this.updateNestingStyles()}}const a=this.getValues();this.initialValues=a,this.suppressOnChange||(i=this.onChange)==null||i.call(this,a)}addDeleteButtonToElement(e,r,a){let n=null;try{n=e.querySelector(":scope > .setting-group-title")}catch{n=null}if(!n){const c=Array.from(e.querySelectorAll(".setting-group-title"));for(const f of c)if(f.closest(".setting-group")===e){n=f;break}n||(n=c[0]??null)}if(!n)return;const i=n.querySelector(".actions-section");if(!i)return;const s=document.createElement("button");s.type="button",s.className="sg-delete-button",a?a.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,s.title="Delete",s.style.cssText=`
27
27
  background: none;
28
28
  border: none;
29
29
  cursor: pointer;
@@ -104,7 +104,7 @@
104
104
  xmlns="http://www.w3.org/2000/svg">
105
105
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
106
106
  strokeWidth="1.5" strokeLinecap="round"/>
107
- </svg>`;f.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,f.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const p=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),m=this.addItemCfg.createItem(p);if(Mi(m)){const d=`${this.addItemCfg.keyPrefix}${p}`;this.addSetting(d,m)}}),o.appendChild(f)}return r.appendChild(a),r.appendChild(i),e.appendChild(r),e.appendChild(o),this.elementRef=e,Ys.trackElement(e),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),e}collapse(){if(!this.elementRef||this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!0,e.classList.add("collapsed"),r.classList.add("rotated"),a.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!1,e.classList.remove("collapsed"),r.classList.remove("rotated"),a.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(e){try{const r=JSON.parse(e);let a=r;const n=Object.keys(this.settings),i=Object.keys(r);if(!n.some(o=>i.includes(o))&&i.length===1){const o=i[0];a=r[o]}this.setValue(a)}catch(r){throw console.error("Invalid JSON provided to setJson:",r),new Error("Invalid JSON format")}}};ni.hiddenElements=new Set;let ir=ni;function vf(t){return new ts(t)}class ts extends ir{constructor(e){super(e);const r=Object.keys(this.settings)[0];this.activeTabId=r||""}getActiveTabId(){return this.activeTabId}switchToTab(e){if(!this.settings[e]||this.activeTabId===e)return;this.activeTabId=e,this.updateTabUI();const r=this.getValues();this.initialValues=r}getValues(e){return e!==void 0?super.getValues(e):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(r=>{r.getAttribute("data-tab-id")===this.activeTabId?r.classList.add("active"):r.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([r,a])=>{r===this.activeTabId?a.classList.add("active"):a.classList.remove("active")})}draw(){const e=super.draw();e.classList.add("tabs-settings-container");const r=e.querySelector(".setting-group-content");if(!r)return e;r.innerHTML="";const a=document.createElement("div");a.className="tabs-title";const n=document.createElement("h3");n.textContent=this.title,a.appendChild(n);const i=document.createElement("div");i.className="tabs-header",this.tabsContainer=i;const s=document.createElement("div");if(s.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const c=document.createElement("button");c.className="tab-button",c.type="button",c.setAttribute("data-tab-id",o),c.textContent=o,c.addEventListener("click",()=>this.switchToTab(o)),i.appendChild(c);const f=document.createElement("div");f.className="tab-panel",this.contentContainers[o]=f;const h=this.settings[o];h&&($e(h)&&typeof h.setNestingLevel=="function"&&h.setNestingLevel(this.getNestingLevel()+1),f.appendChild(h.draw())),s.appendChild(f),l===0&&!this.activeTabId&&(this.activeTabId=o)}),r.appendChild(a),r.appendChild(i),r.appendChild(s),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),e}}function w0(t){return new ir(t)}function Ef(t){return t}class C0 extends Le{constructor(e={}){super(e),this.inputType="text",e.onChange&&this.setOnChange(e.onChange)}draw(){const e=r=>{this.props.maxLength!==void 0&&(r.maxLength=this.props.maxLength),this.props.className&&r.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e})}}const wf="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' strokeLinecap='round' strokeLinejoin='round'/></svg>";class Zt extends C0{constructor(e){super({...e,icon:e.icon||wf,title:e.title||"Color",default:e.default?Zt.normalizeColorValue(e.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=e.detectChange}static normalizeColorValue(e){return e.startsWith("var(--")?e:e.startsWith("#")?Zt.normalizeHexValue(e):e.includes(",")?Zt.rgbToHexStatic(e):Zt.normalizeHexValue(e)}static normalizeHexValue(e){return e=e.replace("#",""),e.length===3&&(e=e.split("").map(r=>r+r).join("")),e.length!==6?(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(e)?`#${e.toLowerCase()}`:(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000")}static rgbToHexStatic(e){const r=e.split(",").map(f=>parseInt(f.trim()));if(r.length!==3||r.some(isNaN))return console.warn(`Invalid RGB value "${e}", using default "#000000"`),"#000000";const[a,n,i]=r,s=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,i)),c=f=>{const h=f.toString(16);return h.length===1?"0"+h:h};return`#${c(s)}${c(o)}${c(l)}`}setValue(e){if(e===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof e=="string"){const r=Zt.normalizeColorValue(e);this.value=r,this.colorInputEl&&(this.colorInputEl.value=r),this.textInputEl&&(this.textInputEl.value=r),this.onChange&&this.onChange(r),this.props.detectChange&&this.props.detectChange(r)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(e){e=e.replace("#","");const r=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return`${r}, ${a}, ${n}`}draw(){const e=document.createElement("div");if(e.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const d=document.createElement("div");if(d.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,d.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,d.appendChild(g)}e.appendChild(d)}const r=document.createElement("div");r.className="color-input-wrapper";const a=document.createElement("div");a.className="color-setting-tabs",a.style.display="flex",a.style.marginBottom="8px",a.style.gap="4px";const n=document.createElement("button");n.className="color-tab active",n.textContent="Solid";const i=document.createElement("button");i.className="color-tab",i.textContent="Global",a.appendChild(n),a.appendChild(i);const s=document.createElement("div");s.className="color-content-solid";const o=document.createElement("div");o.className="color-content-global",o.style.display="none",o.style.display="grid",o.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",o.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),o.innerHTML="",!Le){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",o.appendChild(g);return}const d=Le.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",d),!d||Object.keys(d).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.gridColumn="1 / -1",g.style.fontSize="12px",g.style.color="#666",o.appendChild(g);return}Object.entries(d).forEach(([g,x])=>{const w=document.createElement("button");w.className="global-color-btn",w.title=g,w.style.width="30px",w.style.height="30px",w.style.borderRadius="50%",w.style.border="1px solid #ddd",w.style.backgroundColor=x,w.style.cursor="pointer",this.value===`var(--${g})`&&(w.style.border="2px solid #2196f3"),w.addEventListener("click",v=>{var N,A;v.preventDefault();const F=`var(--${g})`;this.value=F,(N=this.onChange)==null||N.call(this,F),(A=this.detectChange)==null||A.call(this,F),Array.from(o.children).forEach(y=>{y.style.border="1px solid #ddd"}),w.style.border="2px solid #2196f3",h.style.backgroundColor=x}),o.appendChild(w)})}catch(d){console.error("ColorSetting: Error in renderGlobalOptions",d),o.innerHTML="Error loading global options"}};l(),n.addEventListener("click",d=>{d.preventDefault(),n.classList.add("active"),i.classList.remove("active"),s.style.display="flex",o.style.display="none",this.value&&this.value.startsWith("var(--")}),i.addEventListener("click",d=>{d.preventDefault(),i.classList.add("active"),n.classList.remove("active"),s.style.display="none",o.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?i.click():n.click();const c=d=>{const g=d.value.trim();if(!g)return r.classList.remove("error"),!0;const w=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return w?r.classList.remove("error"):r.classList.add("error"),w},f=document.createElement("input");f.type="color",f.className="color-picker",f.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",f.setAttribute("aria-label","Choose color"),f.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&f.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=f;const h=document.createElement("div");h.className="color-preview";let u=this.value||"#000000";if(u.startsWith("var(--")){const d=u.replace("var(--","").replace(")","");u=(Le.GlobalVariables||{})[d]||"#000000"}h.style.backgroundColor=u;const p=document.createElement("input");p.type="text",p.className="color-text-input",p.value=this.value||"",p.placeholder="#000000",p.setAttribute("pattern","#[0-9A-Fa-f]{6}"),p.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),p.setAttribute("aria-label","Hex color value"),p.setAttribute("maxlength","7"),this.getDataPropsPath()&&p.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=p;const m=d=>{var x,w;let g=d.trim();if(g&&!g.startsWith("#")&&!g.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(g)&&(g="#"+g,this.textInputEl&&(this.textInputEl.value=g)),this.textInputEl&&c(this.textInputEl)){const v=Zt.normalizeColorValue(g);this.value=v,(x=this.onChange)==null||x.call(this,v),(w=this.detectChange)==null||w.call(this,v),this.colorInputEl&&(this.colorInputEl.value=v),h.style.backgroundColor=v}};return this.textInputEl.addEventListener("input",d=>{const g=d.target.value;m(g)}),this.textInputEl.addEventListener("paste",d=>{var x;d.preventDefault();const g=((x=d.clipboardData)==null?void 0:x.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),m(g))}),this.textInputEl.addEventListener("keydown",d=>{var g,x,w;d.key==="Enter"&&(d.preventDefault(),m(((g=this.textInputEl)==null?void 0:g.value)||""),(x=this.textInputEl)==null||x.blur()),d.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(w=this.textInputEl)==null||w.blur(),r.classList.remove("error"))}),this.colorInputEl.addEventListener("input",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x,r.classList.remove("error")}),this.colorInputEl.addEventListener("change",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x}),s.appendChild(f),s.appendChild(h),s.appendChild(p),r.appendChild(a),r.appendChild(s),r.appendChild(o),e.appendChild(r),this.element=e,e}getElement(){return this.element}getNormalizedValue(){return this.value?Zt.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Cf=`
107
+ </svg>`;f.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,f.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const p=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),m=this.addItemCfg.createItem(p);if(Mi(m)){const d=`${this.addItemCfg.keyPrefix}${p}`;this.addSetting(d,m)}}),o.appendChild(f)}return r.appendChild(a),r.appendChild(i),e.appendChild(r),e.appendChild(o),this.elementRef=e,Ys.trackElement(e),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),e}collapse(){if(!this.elementRef||this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!0,e.classList.add("collapsed"),r.classList.add("rotated"),a.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const e=this.elementRef.querySelector(".setting-group-content"),r=this.elementRef.querySelector(".setting-group-arrow"),a=this.elementRef.querySelector(".setting-group-title");e&&r&&a&&(this.isCollapsed=!1,e.classList.remove("collapsed"),r.classList.remove("rotated"),a.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(e){try{const r=JSON.parse(e);let a=r;const n=Object.keys(this.settings),i=Object.keys(r);if(!n.some(o=>i.includes(o))&&i.length===1){const o=i[0];a=r[o]}this.setValue(a)}catch(r){throw console.error("Invalid JSON provided to setJson:",r),new Error("Invalid JSON format")}}};ni.hiddenElements=new Set;let ir=ni;function vf(t){return new ts(t)}class ts extends ir{constructor(e){super(e);const r=Object.keys(this.settings)[0];this.activeTabId=r||""}getActiveTabId(){return this.activeTabId}switchToTab(e){if(!this.settings[e]||this.activeTabId===e)return;this.activeTabId=e,this.updateTabUI();const r=this.getValues();this.initialValues=r}getValues(e){return e!==void 0?super.getValues(e):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(r=>{r.getAttribute("data-tab-id")===this.activeTabId?r.classList.add("active"):r.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([r,a])=>{r===this.activeTabId?a.classList.add("active"):a.classList.remove("active")})}draw(){const e=super.draw();e.classList.add("tabs-settings-container");const r=e.querySelector(".setting-group-content");if(!r)return e;r.innerHTML="";const a=document.createElement("div");a.className="tabs-title";const n=document.createElement("h3");n.textContent=this.title,a.appendChild(n);const i=document.createElement("div");i.className="tabs-header",this.tabsContainer=i;const s=document.createElement("div");if(s.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const c=document.createElement("button");c.className="tab-button",c.type="button",c.setAttribute("data-tab-id",o),c.textContent=o,c.addEventListener("click",()=>this.switchToTab(o)),i.appendChild(c);const f=document.createElement("div");f.className="tab-panel",this.contentContainers[o]=f;const h=this.settings[o];h&&($e(h)&&typeof h.setNestingLevel=="function"&&h.setNestingLevel(this.getNestingLevel()+1),f.appendChild(h.draw())),s.appendChild(f),l===0&&!this.activeTabId&&(this.activeTabId=o)}),r.appendChild(a),r.appendChild(i),r.appendChild(s),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),e}}function w0(t){return new ir(t)}function Ef(t){return t}class C0 extends Le{constructor(e={}){super(e),this.inputType="text",e.onChange&&this.setOnChange(e.onChange)}draw(){const e=r=>{this.props.maxLength!==void 0&&(r.maxLength=this.props.maxLength),this.props.className&&r.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e})}}const wf="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' strokeLinecap='round' strokeLinejoin='round'/></svg>";class Zt extends C0{constructor(e){super({...e,icon:e.icon||wf,title:e.title||"Color",default:e.default?Zt.normalizeColorValue(e.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=e.detectChange}static normalizeColorValue(e){return e.startsWith("var(--")?e:e.startsWith("#")?Zt.normalizeHexValue(e):e.includes(",")?Zt.rgbToHexStatic(e):Zt.normalizeHexValue(e)}static normalizeHexValue(e){return e=e.replace("#",""),e.length===3&&(e=e.split("").map(r=>r+r).join("")),e.length!==6?(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(e)?`#${e.toLowerCase()}`:(console.warn(`Invalid hex value "${e}", using default "#000000"`),"#000000")}static rgbToHexStatic(e){const r=e.split(",").map(f=>parseInt(f.trim()));if(r.length!==3||r.some(isNaN))return console.warn(`Invalid RGB value "${e}", using default "#000000"`),"#000000";const[a,n,i]=r,s=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,i)),c=f=>{const h=f.toString(16);return h.length===1?"0"+h:h};return`#${c(s)}${c(o)}${c(l)}`}setValue(e){if(e===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof e=="string"){const r=Zt.normalizeColorValue(e);this.value=r,this.colorInputEl&&(this.colorInputEl.value=r),this.textInputEl&&(this.textInputEl.value=r),this.onChange&&this.onChange(r),this.props.detectChange&&this.props.detectChange(r)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(e){e=e.replace("#","");const r=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return`${r}, ${a}, ${n}`}draw(){const e=document.createElement("div");if(e.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const d=document.createElement("div");if(d.className="icon-container",this.props.icon){const g=document.createElement("span");g.className="input-icon",g.innerHTML=this.props.icon,d.appendChild(g)}if(this.props.title){const g=document.createElement("span");g.className="input-label",g.textContent=this.props.title,d.appendChild(g)}e.appendChild(d)}const r=document.createElement("div");r.className="color-input-wrapper";const a=document.createElement("div");a.className="color-setting-tabs",a.style.display="flex",a.style.marginBottom="8px",a.style.gap="4px";const n=document.createElement("button");n.className="color-tab active",n.textContent="Solid";const i=document.createElement("button");i.className="color-tab",i.textContent="Global",a.appendChild(n),a.appendChild(i);const s=document.createElement("div");s.className="color-content-solid";const o=document.createElement("div");o.className="color-content-global",o.style.display="none",o.style.display="grid",o.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",o.style.gap="8px";const l=()=>{try{if(o.innerHTML="",!Le){console.error("ColorSetting: Setting class is undefined");const g=document.createElement("div");g.textContent="Error: System error (Setting undefined)",o.appendChild(g);return}const d=Le.GlobalVariables||{};if(!d||Object.keys(d).length===0){const g=document.createElement("div");g.textContent="No global colors defined",g.style.gridColumn="1 / -1",g.style.fontSize="12px",g.style.color="#666",o.appendChild(g);return}Object.entries(d).forEach(([g,x])=>{const w=document.createElement("button");w.className="global-color-btn",w.title=g,w.style.width="30px",w.style.height="30px",w.style.borderRadius="50%",w.style.border="1px solid #ddd",w.style.backgroundColor=x,w.style.cursor="pointer",this.value===`var(--${g})`&&(w.style.border="2px solid #2196f3"),w.addEventListener("click",v=>{var N,A;v.preventDefault();const F=`var(--${g})`;this.value=F,(N=this.onChange)==null||N.call(this,F),(A=this.detectChange)==null||A.call(this,F),Array.from(o.children).forEach(y=>{y.style.border="1px solid #ddd"}),w.style.border="2px solid #2196f3",h.style.backgroundColor=x}),o.appendChild(w)})}catch(d){console.error("ColorSetting: Error in renderGlobalOptions",d),o.innerHTML="Error loading global options"}};l(),n.addEventListener("click",d=>{d.preventDefault(),n.classList.add("active"),i.classList.remove("active"),s.style.display="flex",o.style.display="none",this.value&&this.value.startsWith("var(--")}),i.addEventListener("click",d=>{d.preventDefault(),i.classList.add("active"),n.classList.remove("active"),s.style.display="none",o.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?i.click():n.click();const c=d=>{const g=d.value.trim();if(!g)return r.classList.remove("error"),!0;const w=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(g);return w?r.classList.remove("error"):r.classList.add("error"),w},f=document.createElement("input");f.type="color",f.className="color-picker",f.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",f.setAttribute("aria-label","Choose color"),f.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&f.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=f;const h=document.createElement("div");h.className="color-preview";let u=this.value||"#000000";if(u.startsWith("var(--")){const d=u.replace("var(--","").replace(")","");u=(Le.GlobalVariables||{})[d]||"#000000"}h.style.backgroundColor=u;const p=document.createElement("input");p.type="text",p.className="color-text-input",p.value=this.value||"",p.placeholder="#000000",p.setAttribute("pattern","#[0-9A-Fa-f]{6}"),p.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),p.setAttribute("aria-label","Hex color value"),p.setAttribute("maxlength","7"),this.getDataPropsPath()&&p.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=p;const m=d=>{var x,w;let g=d.trim();if(g&&!g.startsWith("#")&&!g.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(g)&&(g="#"+g,this.textInputEl&&(this.textInputEl.value=g)),this.textInputEl&&c(this.textInputEl)){const v=Zt.normalizeColorValue(g);this.value=v,(x=this.onChange)==null||x.call(this,v),(w=this.detectChange)==null||w.call(this,v),this.colorInputEl&&(this.colorInputEl.value=v),h.style.backgroundColor=v}};return this.textInputEl.addEventListener("input",d=>{const g=d.target.value;m(g)}),this.textInputEl.addEventListener("paste",d=>{var x;d.preventDefault();const g=((x=d.clipboardData)==null?void 0:x.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=g.trim(),m(g))}),this.textInputEl.addEventListener("keydown",d=>{var g,x,w;d.key==="Enter"&&(d.preventDefault(),m(((g=this.textInputEl)==null?void 0:g.value)||""),(x=this.textInputEl)==null||x.blur()),d.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(w=this.textInputEl)==null||w.blur(),r.classList.remove("error"))}),this.colorInputEl.addEventListener("input",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x,r.classList.remove("error")}),this.colorInputEl.addEventListener("change",d=>{var w,v;const g=d.target.value,x=Zt.normalizeColorValue(g);this.value=x,(w=this.onChange)==null||w.call(this,x),(v=this.detectChange)==null||v.call(this,x),this.textInputEl&&(this.textInputEl.value=x),h.style.backgroundColor=x}),s.appendChild(f),s.appendChild(h),s.appendChild(p),r.appendChild(a),r.appendChild(s),r.appendChild(o),e.appendChild(r),this.element=e,e}getElement(){return this.element}getNormalizedValue(){return this.value?Zt.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Cf=`
108
108
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
109
109
  <path d="M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z" stroke="#667085" strokeLinecap="round" strokeLinejoin="round"/>
110
110
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" strokeWidth="0.5" strokeLinecap="round" strokeLinejoin="round" opacity="0.5"/>
@@ -138,7 +138,7 @@
138
138
  <path d="M13.5 15C14.1989 15 14.5484 15 14.824 14.8858C15.1916 14.7336 15.4836 14.4416 15.6358 14.074C15.75 13.7984 15.75 13.4489 15.75 12.75C15.75 12.0511 15.75 11.7016 15.6358 11.426C15.4836 11.0584 15.1916 10.7664 14.824 10.6142C14.5484 10.5 14.1989 10.5 13.5 10.5H4.5C3.80109 10.5 3.45163 10.5 3.17598 10.6142C2.80843 10.7664 2.51642 11.0584 2.36418 11.426C2.25 11.7016 2.25 12.0511 2.25 12.75C2.25 13.4489 2.25 13.7984 2.36418 14.074C2.51642 14.4416 2.80843 14.7336 3.17597 14.8858C3.45163 15 3.80109 15 4.5 15L13.5 15Z"
139
139
  stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
140
140
  </svg>
141
- `}].forEach(i=>{const s=document.createElement("button");s.className="align-option-button",s.innerHTML=i.icon,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${i.name}`),this.value===i.name&&s.classList.add("selected"),s.addEventListener("click",()=>{var o;a.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),s.classList.add("selected"),this.value=i.name,(o=this.onChange)==null||o.call(this,this.value)}),a.appendChild(s)}),e.appendChild(a),e}}class Tf extends Le{constructor(e){super(e),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const e=document.createElement("button");e.className="button-setting "+(this.props.className||""),e.textContent=this.props.label,e.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)",this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath());const r=this.props.backgroundColor||"rgba(0,0,0,0)",a=this.props.textColor||"black";e.style.backgroundColor=r,e.style.color=a;let n=r;const i=r.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(i){let o=+i[1],l=+i[2],c=+i[3],f=+i[4];f>=1?(o=Math.round(o*.9),l=Math.round(l*.9),c=Math.round(c*.9)):f=Math.min(1,f+.12),n=`rgba(${o},${l},${c},${f})`}e.addEventListener("mouseenter",()=>{console.log("hoverBg",n),e.style.setProperty("background-color",n,"important")}),e.addEventListener("mouseleave",()=>{e.style.setProperty("background-color",r,"important")}),e.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const s=document.createElement("div");return s.className="button-setting-wrapper "+(this.props.wrapperClassName||""),s.appendChild(e),s}}class Sf extends Le{constructor(e={}){super(e),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const r=e.width||0,a=e.height||0;this.value||(this.value={width:r,height:a}),this.minWidth=e.minWidth??0,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight??0,this.maxHeight=e.maxHeight,this.locked=e.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new sr({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:bf}),this.heightSetting=new sr({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:Ff}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minWidth,e),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth),this.isUpdating=!0;try{let r=e,a=this.value.height;this.locked&&this.aspectRatio>0&&(a=Math.round(r/this.aspectRatio),this.maxHeight&&a>this.maxHeight&&(a=this.maxHeight,r=Math.round(a*this.aspectRatio),this.maxWidth&&r>this.maxWidth&&(r=this.maxWidth,a>0&&(this.aspectRatio=r/a)))),this.value={width:r,height:a},this.widthSetting.setValue(r),this.locked&&this.heightSetting.setValue(a),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minHeight,e),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.isUpdating=!0;try{let r=e,a=this.value.width;this.locked&&this.aspectRatio>0&&(a=Math.round(r*this.aspectRatio),this.maxWidth&&a>this.maxWidth&&(a=this.maxWidth,r=Math.round(a/this.aspectRatio),this.maxHeight&&r>this.maxHeight&&(r=this.maxHeight,r>0&&(this.aspectRatio=a/r)))),this.value={width:a,height:r},this.locked&&this.widthSetting.setValue(a),this.heightSetting.setValue(r),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(e){if(this.locked=!this.locked,this.locked&&this.value){const{width:a,height:n}=this.value;n>0&&(this.aspectRatio=a/n)}e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const r=e.closest(".dimension-setting-container");r&&(this.locked?r.classList.add("aspect-locked"):r.classList.remove("aspect-locked")),e.style.transform="scale(0.9)",setTimeout(()=>{e.style.transform="scale(1)"},100)}getLockSVG(e){return e?`
141
+ `}].forEach(i=>{const s=document.createElement("button");s.className="align-option-button",s.innerHTML=i.icon,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${i.name}`),this.value===i.name&&s.classList.add("selected"),s.addEventListener("click",()=>{var o;a.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),s.classList.add("selected"),this.value=i.name,(o=this.onChange)==null||o.call(this,this.value)}),a.appendChild(s)}),e.appendChild(a),e}}class Tf extends Le{constructor(e){super(e),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const e=document.createElement("button");e.className="button-setting "+(this.props.className||""),e.textContent=this.props.label,e.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)",this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath());const r=this.props.backgroundColor||"rgba(0,0,0,0)",a=this.props.textColor||"black";e.style.backgroundColor=r,e.style.color=a;let n=r;const i=r.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(i){let o=+i[1],l=+i[2],c=+i[3],f=+i[4];f>=1?(o=Math.round(o*.9),l=Math.round(l*.9),c=Math.round(c*.9)):f=Math.min(1,f+.12),n=`rgba(${o},${l},${c},${f})`}e.addEventListener("mouseenter",()=>{e.style.setProperty("background-color",n,"important")}),e.addEventListener("mouseleave",()=>{e.style.setProperty("background-color",r,"important")}),e.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const s=document.createElement("div");return s.className="button-setting-wrapper "+(this.props.wrapperClassName||""),s.appendChild(e),s}}class Sf extends Le{constructor(e={}){super(e),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const r=e.width||0,a=e.height||0;this.value||(this.value={width:r,height:a}),this.minWidth=e.minWidth??0,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight??0,this.maxHeight=e.maxHeight,this.locked=e.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new sr({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:bf}),this.heightSetting=new sr({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:Ff}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minWidth,e),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth),this.isUpdating=!0;try{let r=e,a=this.value.height;this.locked&&this.aspectRatio>0&&(a=Math.round(r/this.aspectRatio),this.maxHeight&&a>this.maxHeight&&(a=this.maxHeight,r=Math.round(a*this.aspectRatio),this.maxWidth&&r>this.maxWidth&&(r=this.maxWidth,a>0&&(this.aspectRatio=r/a)))),this.value={width:r,height:a},this.widthSetting.setValue(r),this.locked&&this.heightSetting.setValue(a),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(e){if(!this.isUpdating&&!(isNaN(e)||e<0)){e=Math.max(this.minHeight,e),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.isUpdating=!0;try{let r=e,a=this.value.width;this.locked&&this.aspectRatio>0&&(a=Math.round(r*this.aspectRatio),this.maxWidth&&a>this.maxWidth&&(a=this.maxWidth,r=Math.round(a/this.aspectRatio),this.maxHeight&&r>this.maxHeight&&(r=this.maxHeight,r>0&&(this.aspectRatio=a/r)))),this.value={width:a,height:r},this.locked&&this.widthSetting.setValue(a),this.heightSetting.setValue(r),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(e){if(this.locked=!this.locked,this.locked&&this.value){const{width:a,height:n}=this.value;n>0&&(this.aspectRatio=a/n)}e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const r=e.closest(".dimension-setting-container");r&&(this.locked?r.classList.add("aspect-locked"):r.classList.remove("aspect-locked")),e.style.transform="scale(0.9)",setTimeout(()=>{e.style.transform="scale(1)"},100)}getLockSVG(e){return e?`
142
142
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
143
143
  <path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25C6.00786 1.25 6.84859 1.96573 7.04162 2.91667M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round"/>
144
144
  </svg>`:`
@@ -417,7 +417,7 @@
417
417
  `),l.push(` </office:body>
418
418
  `),o.bookType=="fods"?l.push("</office:document>"):l.push("</office:document-content>"),l.join("")}}();function Ic(t,e){if(e.bookType=="fods")return h0(t,e);var r=fs(),a="",n=[],i=[];return a="mimetype",ye(r,a,"application/vnd.oasis.opendocument.spreadsheet"),a="content.xml",ye(r,a,h0(t,e)),n.push([a,"text/xml"]),i.push([a,"ContentFile"]),a="styles.xml",ye(r,a,U4(t,e)),n.push([a,"text/xml"]),i.push([a,"StylesFile"]),a="meta.xml",ye(r,a,tt+El()),n.push([a,"text/xml"]),i.push([a,"MetadataFile"]),a="manifest.rdf",ye(r,a,m1(i)),n.push([a,"application/rdf+xml"]),a="META-INF/manifest.xml",ye(r,a,d1(n)),r}/*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */function ca(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ji(t){return typeof TextDecoder<"u"?new TextDecoder().decode(t):Re(Vr(t))}function H4(t){return typeof TextEncoder<"u"?new TextEncoder().encode(t):Dt(pr(t))}function W4(t,e){e:for(var r=0;r<=t.length-e.length;++r){for(var a=0;a<e.length;++a)if(t[r+a]!=e[a])continue e;return!0}return!1}function Br(t){var e=t.reduce(function(n,i){return n+i.length},0),r=new Uint8Array(e),a=0;return t.forEach(function(n){r.set(n,a),a+=n.length}),r}function u0(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>>24}function $4(t,e){for(var r=(t[e+15]&127)<<7|t[e+14]>>1,a=t[e+14]&1,n=e+13;n>=e;--n)a=a*256+t[n];return(t[e+15]&128?-a:a)*Math.pow(10,r-6176)}function G4(t,e,r){var a=Math.floor(r==0?0:Math.LOG10E*Math.log(Math.abs(r)))+6176-20,n=r/Math.pow(10,a-6176);t[e+15]|=a>>7,t[e+14]|=(a&127)<<1;for(var i=0;n>=1;++i,n/=256)t[e+i]=n&255;t[e+15]|=r>=0?0:128}function un(t,e){var r=e?e[0]:0,a=t[r]&127;e:if(t[r++]>=128&&(a|=(t[r]&127)<<7,t[r++]<128||(a|=(t[r]&127)<<14,t[r++]<128)||(a|=(t[r]&127)<<21,t[r++]<128)||(a+=(t[r]&127)*Math.pow(2,28),++r,t[r++]<128)||(a+=(t[r]&127)*Math.pow(2,35),++r,t[r++]<128)||(a+=(t[r]&127)*Math.pow(2,42),++r,t[r++]<128)))break e;return e&&(e[0]=r),a}function Me(t){var e=new Uint8Array(7);e[0]=t&127;var r=1;e:if(t>127){if(e[r-1]|=128,e[r]=t>>7&127,++r,t<=16383||(e[r-1]|=128,e[r]=t>>14&127,++r,t<=2097151)||(e[r-1]|=128,e[r]=t>>21&127,++r,t<=268435455)||(e[r-1]|=128,e[r]=t/256>>>21&127,++r,t<=34359738367)||(e[r-1]|=128,e[r]=t/65536>>>21&127,++r,t<=4398046511103))break e;e[r-1]|=128,e[r]=t/16777216>>>21&127,++r}return e.slice(0,r)}function Ye(t){var e=0,r=t[e]&127;e:if(t[e++]>=128){if(r|=(t[e]&127)<<7,t[e++]<128||(r|=(t[e]&127)<<14,t[e++]<128)||(r|=(t[e]&127)<<21,t[e++]<128))break e;r|=(t[e]&127)<<28}return r}function Ne(t){for(var e=[],r=[0];r[0]<t.length;){var a=r[0],n=un(t,r),i=n&7;n=Math.floor(n/8);var s=0,o;if(n==0)break;switch(i){case 0:{for(var l=r[0];t[r[0]++]>=128;);o=t.slice(l,r[0])}break;case 5:s=4,o=t.slice(r[0],r[0]+s),r[0]+=s;break;case 1:s=8,o=t.slice(r[0],r[0]+s),r[0]+=s;break;case 2:s=un(t,r),o=t.slice(r[0],r[0]+s),r[0]+=s;break;case 3:case 4:default:throw new Error("PB Type ".concat(i," for Field ").concat(n," at offset ").concat(a))}var c={data:o,type:i};e[n]==null?e[n]=[c]:e[n].push(c)}return e}function ut(t){var e=[];return t.forEach(function(r,a){r.forEach(function(n){n.data&&(e.push(Me(a*8+n.type)),n.type==2&&e.push(Me(n.data.length)),e.push(n.data))})}),Br(e)}function Rs(t,e){return(t==null?void 0:t.map(function(r){return e(r.data)}))||[]}function $t(t){for(var e,r=[],a=[0];a[0]<t.length;){var n=un(t,a),i=Ne(t.slice(a[0],a[0]+n));a[0]+=n;var s={id:Ye(i[1][0].data),messages:[]};i[2].forEach(function(o){var l=Ne(o.data),c=Ye(l[3][0].data);s.messages.push({meta:l,data:t.slice(a[0],a[0]+c)}),a[0]+=c}),(e=i[3])!=null&&e[0]&&(s.merge=Ye(i[3][0].data)>>>0>0),r.push(s)}return r}function xa(t){var e=[];return t.forEach(function(r){var a=[];a[1]=[{data:Me(r.id),type:0}],a[2]=[],r.merge!=null&&(a[3]=[{data:Me(+!!r.merge),type:0}]);var n=[];r.messages.forEach(function(s){n.push(s.data),s.meta[3]=[{type:0,data:Me(s.data.length)}],a[2].push({data:ut(s.meta),type:2})});var i=ut(a);e.push(Me(i.length)),e.push(i),n.forEach(function(s){return e.push(s)})}),Br(e)}function z4(t,e){if(t!=0)throw new Error("Unexpected Snappy chunk type ".concat(t));for(var r=[0],a=un(e,r),n=[];r[0]<e.length;){var i=e[r[0]]&3;if(i==0){var s=e[r[0]++]>>2;if(s<60)++s;else{var o=s-59;s=e[r[0]],o>1&&(s|=e[r[0]+1]<<8),o>2&&(s|=e[r[0]+2]<<16),o>3&&(s|=e[r[0]+3]<<24),s>>>=0,s++,r[0]+=o}n.push(e.slice(r[0],r[0]+s)),r[0]+=s;continue}else{var l=0,c=0;if(i==1?(c=(e[r[0]]>>2&7)+4,l=(e[r[0]++]&224)<<3,l|=e[r[0]++]):(c=(e[r[0]++]>>2)+1,i==2?(l=e[r[0]]|e[r[0]+1]<<8,r[0]+=2):(l=(e[r[0]]|e[r[0]+1]<<8|e[r[0]+2]<<16|e[r[0]+3]<<24)>>>0,r[0]+=4)),n=[Br(n)],l==0)throw new Error("Invalid offset 0");if(l>n[0].length)throw new Error("Invalid offset beyond length");if(c>=l)for(n.push(n[0].slice(-l)),c-=l;c>=n[n.length-1].length;)n.push(n[n.length-1]),c-=n[n.length-1].length;n.push(n[0].slice(-l,-l+c))}}var f=Br(n);if(f.length!=a)throw new Error("Unexpected length: ".concat(f.length," != ").concat(a));return f}function Gt(t){for(var e=[],r=0;r<t.length;){var a=t[r++],n=t[r]|t[r+1]<<8|t[r+2]<<16;r+=3,e.push(z4(a,t.slice(r,r+n))),r+=n}if(r!==t.length)throw new Error("data is not a valid framed stream!");return Br(e)}function va(t){for(var e=[],r=0;r<t.length;){var a=Math.min(t.length-r,268435455),n=new Uint8Array(4);e.push(n);var i=Me(a),s=i.length;e.push(i),a<=60?(s++,e.push(new Uint8Array([a-1<<2]))):a<=256?(s+=2,e.push(new Uint8Array([240,a-1&255]))):a<=65536?(s+=3,e.push(new Uint8Array([244,a-1&255,a-1>>8&255]))):a<=16777216?(s+=4,e.push(new Uint8Array([248,a-1&255,a-1>>8&255,a-1>>16&255]))):a<=4294967296&&(s+=5,e.push(new Uint8Array([252,a-1&255,a-1>>8&255,a-1>>16&255,a-1>>>24&255]))),e.push(t.slice(r,r+a)),s+=a,n[0]=0,n[1]=s&255,n[2]=s>>8&255,n[3]=s>>16&255,r+=a}return Br(e)}function X4(t,e,r,a){var n=ca(t),i=n.getUint32(4,!0),s=(a>1?12:8)+u0(i&(a>1?3470:398))*4,o=-1,l=-1,c=NaN,f=new Date(2001,0,1);i&512&&(o=n.getUint32(s,!0),s+=4),s+=u0(i&(a>1?12288:4096))*4,i&16&&(l=n.getUint32(s,!0),s+=4),i&32&&(c=n.getFloat64(s,!0),s+=8),i&64&&(f.setTime(f.getTime()+n.getFloat64(s,!0)*1e3),s+=8);var h;switch(t[2]){case 0:break;case 2:h={t:"n",v:c};break;case 3:h={t:"s",v:e[l]};break;case 5:h={t:"d",v:f};break;case 6:h={t:"b",v:c>0};break;case 7:h={t:"n",v:c/86400};break;case 8:h={t:"e",v:0};break;case 9:if(o>-1)h={t:"s",v:r[o]};else if(l>-1)h={t:"s",v:e[l]};else if(!isNaN(c))h={t:"n",v:c};else throw new Error("Unsupported cell type ".concat(t.slice(0,4)));break;default:throw new Error("Unsupported cell type ".concat(t.slice(0,4)))}return h}function j4(t,e,r){var a=ca(t),n=a.getUint32(8,!0),i=12,s=-1,o=-1,l=NaN,c=NaN,f=new Date(2001,0,1);n&1&&(l=$4(t,i),i+=16),n&2&&(c=a.getFloat64(i,!0),i+=8),n&4&&(f.setTime(f.getTime()+a.getFloat64(i,!0)*1e3),i+=8),n&8&&(o=a.getUint32(i,!0),i+=4),n&16&&(s=a.getUint32(i,!0),i+=4);var h;switch(t[1]){case 0:break;case 2:h={t:"n",v:l};break;case 3:h={t:"s",v:e[o]};break;case 5:h={t:"d",v:f};break;case 6:h={t:"b",v:c>0};break;case 7:h={t:"n",v:c/86400};break;case 8:h={t:"e",v:0};break;case 9:if(s>-1)h={t:"s",v:r[s]};else throw new Error("Unsupported cell type ".concat(t[1]," : ").concat(n&31," : ").concat(t.slice(0,4)));break;case 10:h={t:"n",v:l};break;default:throw new Error("Unsupported cell type ".concat(t[1]," : ").concat(n&31," : ").concat(t.slice(0,4)))}return h}function Fi(t,e){var r=new Uint8Array(32),a=ca(r),n=12,i=0;switch(r[0]=5,t.t){case"n":r[1]=2,G4(r,n,t.v),i|=1,n+=16;break;case"b":r[1]=6,a.setFloat64(n,t.v?1:0,!0),i|=2,n+=8;break;case"s":if(e.indexOf(t.v)==-1)throw new Error("Value ".concat(t.v," missing from SST!"));r[1]=3,a.setUint32(n,e.indexOf(t.v),!0),i|=8,n+=4;break;default:throw"unsupported cell type "+t.t}return a.setUint32(8,i,!0),r.slice(0,n)}function Li(t,e){var r=new Uint8Array(32),a=ca(r),n=12,i=0;switch(r[0]=3,t.t){case"n":r[2]=2,a.setFloat64(n,t.v,!0),i|=32,n+=8;break;case"b":r[2]=6,a.setFloat64(n,t.v?1:0,!0),i|=32,n+=8;break;case"s":if(e.indexOf(t.v)==-1)throw new Error("Value ".concat(t.v," missing from SST!"));r[2]=3,a.setUint32(n,e.indexOf(t.v),!0),i|=16,n+=4;break;default:throw"unsupported cell type "+t.t}return a.setUint32(4,i,!0),r.slice(0,n)}function K4(t,e,r){switch(t[0]){case 0:case 1:case 2:case 3:return X4(t,e,r,t[0]);case 5:return j4(t,e,r);default:throw new Error("Unsupported payload version ".concat(t[0]))}}function xt(t){var e=Ne(t);return un(e[1][0].data)}function d0(t,e){var r=Ne(e.data),a=Ye(r[1][0].data),n=r[3],i=[];return(n||[]).forEach(function(s){var o=Ne(s.data),l=Ye(o[1][0].data)>>>0;switch(a){case 1:i[l]=Ji(o[3][0].data);break;case 8:{var c=t[xt(o[9][0].data)][0],f=Ne(c.data),h=t[xt(f[1][0].data)][0],u=Ye(h.meta[1][0].data);if(u!=2001)throw new Error("2000 unexpected reference to ".concat(u));var p=Ne(h.data);i[l]=p[3].map(function(m){return Ji(m.data)}).join("")}break}}),i}function Y4(t,e){var r,a,n,i,s,o,l,c,f,h,u,p,m,d,g=Ne(t),x=Ye(g[1][0].data)>>>0,w=Ye(g[2][0].data)>>>0,v=((a=(r=g[8])==null?void 0:r[0])==null?void 0:a.data)&&Ye(g[8][0].data)>0||!1,F,N;if((i=(n=g[7])==null?void 0:n[0])!=null&&i.data&&e!=0)F=(o=(s=g[7])==null?void 0:s[0])==null?void 0:o.data,N=(c=(l=g[6])==null?void 0:l[0])==null?void 0:c.data;else if((h=(f=g[4])==null?void 0:f[0])!=null&&h.data&&e!=1)F=(p=(u=g[4])==null?void 0:u[0])==null?void 0:p.data,N=(d=(m=g[3])==null?void 0:m[0])==null?void 0:d.data;else throw"NUMBERS Tile missing ".concat(e," cell storage");for(var A=v?4:1,y=ca(F),P=[],I=0;I<F.length/2;++I){var z=y.getUint16(I*2,!0);z<65535&&P.push([I,z])}if(P.length!=w)throw"Expected ".concat(w," cells, found ").concat(P.length);var V=[];for(I=0;I<P.length-1;++I)V[P[I][0]]=N.subarray(P[I][1]*A,P[I+1][1]*A);return P.length>=1&&(V[P[P.length-1][0]]=N.subarray(P[P.length-1][1]*A)),{R:x,cells:V}}function J4(t,e){var r,a=Ne(e.data),n=(r=a==null?void 0:a[7])!=null&&r[0]?Ye(a[7][0].data)>>>0>0?1:0:-1,i=Rs(a[5],function(s){return Y4(s,n)});return{nrows:Ye(a[4][0].data)>>>0,data:i.reduce(function(s,o){return s[o.R]||(s[o.R]=[]),o.cells.forEach(function(l,c){if(s[o.R][c])throw new Error("Duplicate cell r=".concat(o.R," c=").concat(c));s[o.R][c]=l}),s},[])}}function q4(t,e,r){var a,n=Ne(e.data),i={s:{r:0,c:0},e:{r:0,c:0}};if(i.e.r=(Ye(n[6][0].data)>>>0)-1,i.e.r<0)throw new Error("Invalid row varint ".concat(n[6][0].data));if(i.e.c=(Ye(n[7][0].data)>>>0)-1,i.e.c<0)throw new Error("Invalid col varint ".concat(n[7][0].data));r["!ref"]=Ce(i);var s=Ne(n[4][0].data),o=d0(t,t[xt(s[4][0].data)][0]),l=(a=s[17])!=null&&a[0]?d0(t,t[xt(s[17][0].data)][0]):[],c=Ne(s[3][0].data),f=0;c[1].forEach(function(h){var u=Ne(h.data),p=t[xt(u[2][0].data)][0],m=Ye(p.meta[1][0].data);if(m!=6002)throw new Error("6001 unexpected reference to ".concat(m));var d=J4(t,p);d.data.forEach(function(g,x){g.forEach(function(w,v){var F=ge({r:f+x,c:v}),N=K4(w,o,l);N&&(r[F]=N)})}),f+=d.nrows})}function Z4(t,e){var r=Ne(e.data),a={"!ref":"A1"},n=t[xt(r[2][0].data)],i=Ye(n[0].meta[1][0].data);if(i!=6001)throw new Error("6000 unexpected reference to ".concat(i));return q4(t,n[0],a),a}function Q4(t,e){var r,a=Ne(e.data),n={name:(r=a[1])!=null&&r[0]?Ji(a[1][0].data):"",sheets:[]},i=Rs(a[2],xt);return i.forEach(function(s){t[s].forEach(function(o){var l=Ye(o.meta[1][0].data);l==6e3&&n.sheets.push(Z4(t,o))})}),n}function e3(t,e){var r=Ws(),a=Ne(e.data),n=Rs(a[1],xt);if(n.forEach(function(i){t[i].forEach(function(s){var o=Ye(s.meta[1][0].data);if(o==2){var l=Q4(t,s);l.sheets.forEach(function(c,f){$s(r,c,f==0?l.name:l.name+"_"+f,!0)})}})}),r.SheetNames.length==0)throw new Error("Empty NUMBERS file");return r}function Ai(t){var e,r,a,n,i={},s=[];if(t.FullPaths.forEach(function(l){if(l.match(/\.iwpv2/))throw new Error("Unsupported password protection")}),t.FileIndex.forEach(function(l){if(l.name.match(/\.iwa$/)){var c;try{c=Gt(l.content)}catch(h){return console.log("?? "+l.content.length+" "+(h.message||h))}var f;try{f=$t(c)}catch(h){return console.log("## "+(h.message||h))}f.forEach(function(h){i[h.id]=h.messages,s.push(h.id)})}}),!s.length)throw new Error("File has no messages");var o=((n=(a=(r=(e=i==null?void 0:i[1])==null?void 0:e[0])==null?void 0:r.meta)==null?void 0:a[1])==null?void 0:n[0].data)&&Ye(i[1][0].meta[1][0].data)==1&&i[1][0];if(o||s.forEach(function(l){i[l].forEach(function(c){var f=Ye(c.meta[1][0].data)>>>0;if(f==1)if(!o)o=c;else throw new Error("Document has multiple roots")})}),!o)throw new Error("Cannot find Document root");return e3(i,o)}function t3(t,e,r){var a,n,i,s;if(!((a=t[6])!=null&&a[0])||!((n=t[7])!=null&&n[0]))throw"Mutation only works on post-BNC storages!";var o=((s=(i=t[8])==null?void 0:i[0])==null?void 0:s.data)&&Ye(t[8][0].data)>0||!1;if(o)throw"Math only works with normal offsets";for(var l=0,c=ca(t[7][0].data),f=0,h=[],u=ca(t[4][0].data),p=0,m=[],d=0;d<e.length;++d){if(e[d]==null){c.setUint16(d*2,65535,!0),u.setUint16(d*2,65535);continue}c.setUint16(d*2,f,!0),u.setUint16(d*2,p,!0);var g,x;switch(typeof e[d]){case"string":g=Fi({t:"s",v:e[d]},r),x=Li({t:"s",v:e[d]},r);break;case"number":g=Fi({t:"n",v:e[d]},r),x=Li({t:"n",v:e[d]},r);break;case"boolean":g=Fi({t:"b",v:e[d]},r),x=Li({t:"b",v:e[d]},r);break;default:throw new Error("Unsupported value "+e[d])}h.push(g),f+=g.length,m.push(x),p+=x.length,++l}for(t[2][0].data=Me(l);d<t[7][0].data.length/2;++d)c.setUint16(d*2,65535,!0),u.setUint16(d*2,65535,!0);return t[6][0].data=Br(h),t[3][0].data=Br(m),l}function r3(t,e){if(!e||!e.numbers)throw new Error("Must pass a `numbers` option -- check the README");var r=t.Sheets[t.SheetNames[0]];t.SheetNames.length>1&&console.error("The Numbers writer currently writes only the first table");var a=At(r["!ref"]);a.s.r=a.s.c=0;var n=!1;a.e.c>9&&(n=!0,a.e.c=9),a.e.r>49&&(n=!0,a.e.r=49),n&&console.error("The Numbers writer is currently limited to ".concat(Ce(a)));var i=ai(r,{range:a,header:1}),s=["~Sh33tJ5~"];i.forEach(function(D){return D.forEach(function(M){typeof M=="string"&&s.push(M)})});var o={},l=[],c=de.read(e.numbers,{type:"base64"});c.FileIndex.map(function(D,M){return[D,c.FullPaths[M]]}).forEach(function(D){var M=D[0],O=D[1];if(M.type==2&&M.name.match(/\.iwa/)){var K=M.content,te=Gt(K),re=$t(te);re.forEach(function(Q){l.push(Q.id),o[Q.id]={deps:[],location:O,type:Ye(Q.messages[0].meta[1][0].data)}})}}),l.sort(function(D,M){return D-M});var f=l.filter(function(D){return D>1}).map(function(D){return[D,Me(D)]});c.FileIndex.map(function(D,M){return[D,c.FullPaths[M]]}).forEach(function(D){var M=D[0];if(D[1],!!M.name.match(/\.iwa/)){var O=$t(Gt(M.content));O.forEach(function(K){K.messages.forEach(function(te){f.forEach(function(re){K.messages.some(function(Q){return Ye(Q.meta[1][0].data)!=11006&&W4(Q.data,re[1])})&&o[re[0]].deps.push(K.id)})})})}});for(var h=de.find(c,o[1].location),u=$t(Gt(h.content)),p,m=0;m<u.length;++m){var d=u[m];d.id==1&&(p=d)}var g=xt(Ne(p.messages[0].data)[1][0].data);for(h=de.find(c,o[g].location),u=$t(Gt(h.content)),m=0;m<u.length;++m)d=u[m],d.id==g&&(p=d);for(g=xt(Ne(p.messages[0].data)[2][0].data),h=de.find(c,o[g].location),u=$t(Gt(h.content)),m=0;m<u.length;++m)d=u[m],d.id==g&&(p=d);for(g=xt(Ne(p.messages[0].data)[2][0].data),h=de.find(c,o[g].location),u=$t(Gt(h.content)),m=0;m<u.length;++m)d=u[m],d.id==g&&(p=d);var x=Ne(p.messages[0].data);{x[6][0].data=Me(a.e.r+1),x[7][0].data=Me(a.e.c+1);var w=xt(x[46][0].data),v=de.find(c,o[w].location),F=$t(Gt(v.content));{for(var N=0;N<F.length&&F[N].id!=w;++N);if(F[N].id!=w)throw"Bad ColumnRowUIDMapArchive";var A=Ne(F[N].messages[0].data);A[1]=[],A[2]=[],A[3]=[];for(var y=0;y<=a.e.c;++y){var P=[];P[1]=P[2]=[{type:0,data:Me(y+420690)}],A[1].push({type:2,data:ut(P)}),A[2].push({type:0,data:Me(y)}),A[3].push({type:0,data:Me(y)})}A[4]=[],A[5]=[],A[6]=[];for(var I=0;I<=a.e.r;++I)P=[],P[1]=P[2]=[{type:0,data:Me(I+726270)}],A[4].push({type:2,data:ut(P)}),A[5].push({type:0,data:Me(I)}),A[6].push({type:0,data:Me(I)});F[N].messages[0].data=ut(A)}v.content=va(xa(F)),v.size=v.content.length,delete x[46];var z=Ne(x[4][0].data);{z[7][0].data=Me(a.e.r+1);var V=Ne(z[1][0].data),R=xt(V[2][0].data);v=de.find(c,o[R].location),F=$t(Gt(v.content));{if(F[0].id!=R)throw"Bad HeaderStorageBucket";var J=Ne(F[0].messages[0].data);for(I=0;I<i.length;++I){var le=Ne(J[2][0].data);le[1][0].data=Me(I),le[4][0].data=Me(i[I].length),J[2][I]={type:J[2][0].type,data:ut(le)}}F[0].messages[0].data=ut(J)}v.content=va(xa(F)),v.size=v.content.length;var ie=xt(z[2][0].data);v=de.find(c,o[ie].location),F=$t(Gt(v.content));{if(F[0].id!=ie)throw"Bad HeaderStorageBucket";for(J=Ne(F[0].messages[0].data),y=0;y<=a.e.c;++y)le=Ne(J[2][0].data),le[1][0].data=Me(y),le[4][0].data=Me(a.e.r+1),J[2][y]={type:J[2][0].type,data:ut(le)};F[0].messages[0].data=ut(J)}v.content=va(xa(F)),v.size=v.content.length;var ue=xt(z[4][0].data);(function(){for(var D=de.find(c,o[ue].location),M=$t(Gt(D.content)),O,K=0;K<M.length;++K){var te=M[K];te.id==ue&&(O=te)}var re=Ne(O.messages[0].data);{re[3]=[];var Q=[];s.forEach(function(b,Ve){Q[1]=[{type:0,data:Me(Ve)}],Q[2]=[{type:0,data:Me(1)}],Q[3]=[{type:2,data:H4(b)}],re[3].push({type:2,data:ut(Q)})})}O.messages[0].data=ut(re);var q=xa(M),ke=va(q);D.content=ke,D.size=D.content.length})();var ce=Ne(z[3][0].data);{var De=ce[1][0];delete ce[2];var G=Ne(De.data);{var pe=xt(G[2][0].data);(function(){for(var D=de.find(c,o[pe].location),M=$t(Gt(D.content)),O,K=0;K<M.length;++K){var te=M[K];te.id==pe&&(O=te)}var re=Ne(O.messages[0].data);{delete re[6],delete ce[7];var Q=new Uint8Array(re[5][0].data);re[5]=[];for(var q=0,ke=0;ke<=a.e.r;++ke){var b=Ne(Q);q+=t3(b,i[ke],s),b[1][0].data=Me(ke),re[5].push({data:ut(b),type:2})}re[1]=[{type:0,data:Me(a.e.c+1)}],re[2]=[{type:0,data:Me(a.e.r+1)}],re[3]=[{type:0,data:Me(q)}],re[4]=[{type:0,data:Me(a.e.r+1)}]}O.messages[0].data=ut(re);var Ve=xa(M),Fe=va(Ve);D.content=Fe,D.size=D.content.length})()}De.data=ut(G)}z[3][0].data=ut(ce)}x[4][0].data=ut(z)}p.messages[0].data=ut(x);var Ee=xa(u),L=va(Ee);return h.content=L,h.size=h.content.length,c}function Nc(t){return function(r){for(var a=0;a!=t.length;++a){var n=t[a];r[n[0]]===void 0&&(r[n[0]]=n[1]),n[2]==="n"&&(r[n[0]]=Number(r[n[0]]))}}}function Bs(t){Nc([["cellNF",!1],["cellHTML",!0],["cellFormula",!0],["cellStyles",!1],["cellText",!0],["cellDates",!1],["sheetStubs",!1],["sheetRows",0,"n"],["bookDeps",!1],["bookSheets",!1],["bookProps",!1],["bookFiles",!1],["bookVBA",!1],["password",""],["WTF",!1]])(t)}function Vs(t){Nc([["cellDates",!1],["bookSST",!1],["bookType","xlsx"],["compression",!1],["WTF",!1]])(t)}function a3(t){return Se.WS.indexOf(t)>-1?"sheet":t==Se.CS?"chart":t==Se.DS?"dialog":t==Se.MS?"macro":t&&t.length?t:"sheet"}function n3(t,e){if(!t)return 0;try{t=e.map(function(a){return a.id||(a.id=a.strRelID),[a.name,t["!id"][a.id].Target,a3(t["!id"][a.id].Type)]})}catch{return null}return!t||t.length===0?null:t}function i3(t,e,r,a,n,i,s,o,l,c,f,h){try{i[a]=ja(Rt(t,r,!0),e);var u=at(t,e),p;switch(o){case"sheet":p=b5(u,e,n,l,i[a],c,f,h);break;case"chart":if(p=F5(u,e,n,l,i[a],c,f,h),!p||!p["!drawel"])break;var m=$a(p["!drawel"].Target,e),d=sn(m),g=p2(Rt(t,m,!0),ja(Rt(t,d,!0),m)),x=$a(g,m),w=sn(x);p=t5(Rt(t,x,!0),x,l,ja(Rt(t,w,!0),x),c,p);break;case"macro":p=L5(u,e,n,l,i[a],c,f,h);break;case"dialog":p=A5(u,e,n,l,i[a],c,f,h);break;default:throw new Error("Unrecognized sheet type "+o)}s[a]=p;var v=[];i&&i[a]&&Je(i[a]).forEach(function(F){var N="";if(i[a][F].Type==Se.CMNT){N=$a(i[a][F].Target,e);var A=O5(at(t,N,!0),N,l);if(!A||!A.length)return;Zo(p,A,!1)}i[a][F].Type==Se.TCMNT&&(N=$a(i[a][F].Target,e),v=v.concat(g2(at(t,N,!0),l)))}),v&&v.length&&Zo(p,v,!0,l.people||[])}catch(F){if(l.WTF)throw F}}function Ht(t){return t.charAt(0)=="/"?t.slice(1):t}function s3(t,e){if(Na(),e=e||{},Bs(e),zt(t,"META-INF/manifest.xml")||zt(t,"objectdata.xml"))return c0(t,e);if(zt(t,"Index/Document.iwa")){if(typeof Uint8Array>"u")throw new Error("NUMBERS file parsing requires Uint8Array support");if(typeof Ai<"u"){if(t.FileIndex)return Ai(t);var r=de.utils.cfb_new();return Eo(t).forEach(function(le){ye(r,le,xu(t,le))}),Ai(r)}throw new Error("Unsupported NUMBERS file")}if(!zt(t,"[Content_Types].xml"))throw zt(t,"index.xml.gz")?new Error("Unsupported NUMBERS 08 file"):zt(t,"index.xml")?new Error("Unsupported NUMBERS 09 file"):new Error("Unsupported ZIP file");var a=Eo(t),n=f1(Rt(t,"[Content_Types].xml")),i=!1,s,o;if(n.workbooks.length===0&&(o="xl/workbook.xml",at(t,o,!0)&&n.workbooks.push(o)),n.workbooks.length===0){if(o="xl/workbook.bin",!at(t,o,!0))throw new Error("Could not find workbook");n.workbooks.push(o),i=!0}n.workbooks[0].slice(-3)=="bin"&&(i=!0);var l={},c={};if(!e.bookSheets&&!e.bookProps){if(Ka=[],n.sst)try{Ka=M5(at(t,Ht(n.sst)),n.sst,e)}catch(le){if(e.WTF)throw le}e.cellStyles&&n.themes.length&&(l=N5(Rt(t,n.themes[0].replace(/^\//,""),!0)||"",n.themes[0],e)),n.style&&(c=I5(at(t,Ht(n.style)),n.style,l,e))}n.links.map(function(le){try{var ie=ja(Rt(t,sn(Ht(le))),le);return D5(at(t,Ht(le)),ie,le,e)}catch{}});var f=S5(at(t,Ht(n.workbooks[0])),n.workbooks[0],e),h={},u="";n.coreprops.length&&(u=at(t,Ht(n.coreprops[0]),!0),u&&(h=wl(u)),n.extprops.length!==0&&(u=at(t,Ht(n.extprops[0]),!0),u&&x1(u,h,e)));var p={};(!e.bookSheets||e.bookProps)&&n.custprops.length!==0&&(u=Rt(t,Ht(n.custprops[0]),!0),u&&(p=E1(u,e)));var m={};if((e.bookSheets||e.bookProps)&&(f.Sheets?s=f.Sheets.map(function(ie){return ie.name}):h.Worksheets&&h.SheetNames.length>0&&(s=h.SheetNames),e.bookProps&&(m.Props=h,m.Custprops=p),e.bookSheets&&typeof s<"u"&&(m.SheetNames=s),e.bookSheets?m.SheetNames:e.bookProps))return m;s={};var d={};e.bookDeps&&n.calcchain&&(d=P5(at(t,Ht(n.calcchain)),n.calcchain));var g=0,x={},w,v;{var F=f.Sheets;h.Worksheets=F.length,h.SheetNames=[];for(var N=0;N!=F.length;++N)h.SheetNames[N]=F[N].name}var A=i?"bin":"xml",y=n.workbooks[0].lastIndexOf("/"),P=(n.workbooks[0].slice(0,y+1)+"_rels/"+n.workbooks[0].slice(y+1)+".rels").replace(/^\//,"");zt(t,P)||(P="xl/_rels/workbook."+A+".rels");var I=ja(Rt(t,P,!0),P.replace(/_rels.*/,"s5s"));(n.metadata||[]).length>=1&&(e.xlmeta=R5(at(t,Ht(n.metadata[0])),n.metadata[0],e)),(n.people||[]).length>=1&&(e.people=v2(at(t,Ht(n.people[0])),e)),I&&(I=n3(I,f.Sheets));var z=at(t,"xl/worksheets/sheet.xml",!0)?1:0;e:for(g=0;g!=h.Worksheets;++g){var V="sheet";if(I&&I[g]?(w="xl/"+I[g][1].replace(/[\/]?xl\//,""),zt(t,w)||(w=I[g][1]),zt(t,w)||(w=P.replace(/_rels\/.*$/,"")+I[g][1]),V=I[g][2]):(w="xl/worksheets/sheet"+(g+1-z)+"."+A,w=w.replace(/sheet0\./,"sheet.")),v=w.replace(/^(.*)(\/)([^\/]*)$/,"$1/_rels/$3.rels"),e&&e.sheets!=null)switch(typeof e.sheets){case"number":if(g!=e.sheets)continue e;break;case"string":if(h.SheetNames[g].toLowerCase()!=e.sheets.toLowerCase())continue e;break;default:if(Array.isArray&&Array.isArray(e.sheets)){for(var R=!1,J=0;J!=e.sheets.length;++J)typeof e.sheets[J]=="number"&&e.sheets[J]==g&&(R=1),typeof e.sheets[J]=="string"&&e.sheets[J].toLowerCase()==h.SheetNames[g].toLowerCase()&&(R=1);if(!R)continue e}}i3(t,w,v,h.SheetNames[g],g,x,s,V,e,f,l,c)}return m={Directory:n,Workbook:f,Props:h,Custprops:p,Deps:d,Sheets:s,SheetNames:h.SheetNames,Strings:Ka,Styles:c,Themes:l,SSF:We(me)},e&&e.bookFiles&&(t.files?(m.keys=a,m.files=t.files):(m.keys=[],m.files={},t.FullPaths.forEach(function(le,ie){le=le.replace(/^Root Entry[\/]/,""),m.keys.push(le),m.files[le]=t.FileIndex[ie]}))),e&&e.bookVBA&&(n.vba.length>0?m.vbaraw=at(t,Ht(n.vba[0]),!0):n.defaults&&n.defaults.bin===S2&&(m.vbaraw=at(t,"xl/vbaProject.bin",!0))),m}function o3(t,e){var r=e||{},a="Workbook",n=de.find(t,a);try{if(a="/!DataSpaces/Version",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);if(Rp(n.content),a="/!DataSpaces/DataSpaceMap",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);var i=Vp(n.content);if(i.length!==1||i[0].comps.length!==1||i[0].comps[0].t!==0||i[0].name!=="StrongEncryptionDataSpace"||i[0].comps[0].v!=="EncryptedPackage")throw new Error("ECMA-376 Encrypted file bad "+a);if(a="/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);var s=Up(n.content);if(s.length!=1||s[0]!="StrongEncryptionTransform")throw new Error("ECMA-376 Encrypted file bad "+a);if(a="/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);Wp(n.content)}catch{}if(a="/EncryptionInfo",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);var o=$p(n.content);if(a="/EncryptedPackage",n=de.find(t,a),!n||!n.content)throw new Error("ECMA-376 Encrypted file missing "+a);if(o[0]==4&&typeof decrypt_agile<"u")return decrypt_agile(o[1],n.content,r.password||"",r);if(o[0]==2&&typeof decrypt_std76<"u")return decrypt_std76(o[1],n.content,r.password||"",r);throw new Error("File is password-protected")}function l3(t,e){return e.bookType=="ods"?Ic(t,e):e.bookType=="numbers"?r3(t,e):e.bookType=="xlsb"?c3(t,e):f3(t,e)}function c3(t,e){Ca=1024,t&&!t.SSF&&(t.SSF=We(me)),t&&t.SSF&&(Na(),si(t.SSF),e.revssf=li(t.SSF),e.revssf[t.SSF[65535]]=0,e.ssf=t.SSF),e.rels={},e.wbrels={},e.Strings=[],e.Strings.Count=0,e.Strings.Unique=0,Ya?e.revStrings=new Map:(e.revStrings={},e.revStrings.foo=[],delete e.revStrings.foo);var r=e.bookType=="xlsb"?"bin":"xml",a=ic.indexOf(e.bookType)>-1,n=_s();Vs(e=e||{});var i=fs(),s="",o=0;if(e.cellXfs=[],Hr(e.cellXfs,{},{revssf:{General:0}}),t.Props||(t.Props={}),s="docProps/core.xml",ye(i,s,Cl(t.Props,e)),n.coreprops.push(s),Oe(e.rels,2,s,Se.CORE_PROPS),s="docProps/app.xml",!(t.Props&&t.Props.SheetNames))if(!t.Workbook||!t.Workbook.Sheets)t.Props.SheetNames=t.SheetNames;else{for(var l=[],c=0;c<t.SheetNames.length;++c)(t.Workbook.Sheets[c]||{}).Hidden!=2&&l.push(t.SheetNames[c]);t.Props.SheetNames=l}for(t.Props.Worksheets=t.Props.SheetNames.length,ye(i,s,_l(t.Props)),n.extprops.push(s),Oe(e.rels,3,s,Se.EXT_PROPS),t.Custprops!==t.Props&&Je(t.Custprops||{}).length>0&&(s="docProps/custom.xml",ye(i,s,Tl(t.Custprops)),n.custprops.push(s),Oe(e.rels,4,s,Se.CUST_PROPS)),o=1;o<=t.SheetNames.length;++o){var f={"!id":{}},h=t.Sheets[t.SheetNames[o-1]],u=(h||{})["!type"]||"sheet";switch(u){case"chart":default:s="xl/worksheets/sheet"+o+"."+r,ye(i,s,V5(o-1,s,e,t,f)),n.sheets.push(s),Oe(e.wbrels,-1,"worksheets/sheet"+o+"."+r,Se.WS[0])}if(h){var p=h["!comments"],m=!1,d="";p&&p.length>0&&(d="xl/comments"+o+"."+r,ye(i,d,W5(p,d)),n.comments.push(d),Oe(f,-1,"../comments"+o+"."+r,Se.CMNT),m=!0),h["!legacy"]&&m&&ye(i,"xl/drawings/vmlDrawing"+o+".vml",ac(o,h["!comments"])),delete h["!comments"],delete h["!legacy"]}f["!id"].rId1&&ye(i,sn(s),Ta(f))}return e.Strings!=null&&e.Strings.length>0&&(s="xl/sharedStrings."+r,ye(i,s,H5(e.Strings,s,e)),n.strs.push(s),Oe(e.wbrels,-1,"sharedStrings."+r,Se.SST)),s="xl/workbook."+r,ye(i,s,B5(t,s)),n.workbooks.push(s),Oe(e.rels,1,s,Se.WB),s="xl/theme/theme1.xml",ye(i,s,As(t.Themes,e)),n.themes.push(s),Oe(e.wbrels,-1,"theme/theme1.xml",Se.THEME),s="xl/styles."+r,ye(i,s,U5(t,s,e)),n.styles.push(s),Oe(e.wbrels,-1,"styles."+r,Se.STY),t.vbaraw&&a&&(s="xl/vbaProject.bin",ye(i,s,t.vbaraw),n.vba.push(s),Oe(e.wbrels,-1,"vbaProject.bin",Se.VBA)),s="xl/metadata."+r,ye(i,s,$5(s)),n.metadata.push(s),Oe(e.wbrels,-1,"metadata."+r,Se.XLMETA),ye(i,"[Content_Types].xml",vl(n,e)),ye(i,"_rels/.rels",Ta(e.rels)),ye(i,"xl/_rels/workbook."+r+".rels",Ta(e.wbrels)),delete e.revssf,delete e.ssf,i}function f3(t,e){Ca=1024,t&&!t.SSF&&(t.SSF=We(me)),t&&t.SSF&&(Na(),si(t.SSF),e.revssf=li(t.SSF),e.revssf[t.SSF[65535]]=0,e.ssf=t.SSF),e.rels={},e.wbrels={},e.Strings=[],e.Strings.Count=0,e.Strings.Unique=0,Ya?e.revStrings=new Map:(e.revStrings={},e.revStrings.foo=[],delete e.revStrings.foo);var r="xml",a=ic.indexOf(e.bookType)>-1,n=_s();Vs(e=e||{});var i=fs(),s="",o=0;if(e.cellXfs=[],Hr(e.cellXfs,{},{revssf:{General:0}}),t.Props||(t.Props={}),s="docProps/core.xml",ye(i,s,Cl(t.Props,e)),n.coreprops.push(s),Oe(e.rels,2,s,Se.CORE_PROPS),s="docProps/app.xml",!(t.Props&&t.Props.SheetNames))if(!t.Workbook||!t.Workbook.Sheets)t.Props.SheetNames=t.SheetNames;else{for(var l=[],c=0;c<t.SheetNames.length;++c)(t.Workbook.Sheets[c]||{}).Hidden!=2&&l.push(t.SheetNames[c]);t.Props.SheetNames=l}t.Props.Worksheets=t.Props.SheetNames.length,ye(i,s,_l(t.Props)),n.extprops.push(s),Oe(e.rels,3,s,Se.EXT_PROPS),t.Custprops!==t.Props&&Je(t.Custprops||{}).length>0&&(s="docProps/custom.xml",ye(i,s,Tl(t.Custprops)),n.custprops.push(s),Oe(e.rels,4,s,Se.CUST_PROPS));var f=["SheetJ5"];for(e.tcid=0,o=1;o<=t.SheetNames.length;++o){var h={"!id":{}},u=t.Sheets[t.SheetNames[o-1]],p=(u||{})["!type"]||"sheet";switch(p){case"chart":default:s="xl/worksheets/sheet"+o+"."+r,ye(i,s,gc(o-1,e,t,h)),n.sheets.push(s),Oe(e.wbrels,-1,"worksheets/sheet"+o+"."+r,Se.WS[0])}if(u){var m=u["!comments"],d=!1,g="";if(m&&m.length>0){var x=!1;m.forEach(function(w){w[1].forEach(function(v){v.T==!0&&(x=!0)})}),x&&(g="xl/threadedComments/threadedComment"+o+"."+r,ye(i,g,x2(m,f,e)),n.threadedcomments.push(g),Oe(h,-1,"../threadedComments/threadedComment"+o+"."+r,Se.TCMNT)),g="xl/comments"+o+"."+r,ye(i,g,nc(m)),n.comments.push(g),Oe(h,-1,"../comments"+o+"."+r,Se.CMNT),d=!0}u["!legacy"]&&d&&ye(i,"xl/drawings/vmlDrawing"+o+".vml",ac(o,u["!comments"])),delete u["!comments"],delete u["!legacy"]}h["!id"].rId1&&ye(i,sn(s),Ta(h))}return e.Strings!=null&&e.Strings.length>0&&(s="xl/sharedStrings."+r,ye(i,s,zl(e.Strings,e)),n.strs.push(s),Oe(e.wbrels,-1,"sharedStrings."+r,Se.SST)),s="xl/workbook."+r,ye(i,s,Cc(t)),n.workbooks.push(s),Oe(e.rels,1,s,Se.WB),s="xl/theme/theme1.xml",ye(i,s,As(t.Themes,e)),n.themes.push(s),Oe(e.wbrels,-1,"theme/theme1.xml",Se.THEME),s="xl/styles."+r,ye(i,s,Ql(t,e)),n.styles.push(s),Oe(e.wbrels,-1,"styles."+r,Se.STY),t.vbaraw&&a&&(s="xl/vbaProject.bin",ye(i,s,t.vbaraw),n.vba.push(s),Oe(e.wbrels,-1,"vbaProject.bin",Se.VBA)),s="xl/metadata."+r,ye(i,s,rc()),n.metadata.push(s),Oe(e.wbrels,-1,"metadata."+r,Se.XLMETA),f.length>1&&(s="xl/persons/person.xml",ye(i,s,E2(f)),n.people.push(s),Oe(e.wbrels,-1,"persons/person.xml",Se.PEOPLE)),ye(i,"[Content_Types].xml",vl(n,e)),ye(i,"_rels/.rels",Ta(e.rels)),ye(i,"xl/_rels/workbook."+r+".rels",Ta(e.wbrels)),delete e.revssf,delete e.ssf,i}function Us(t,e){var r="";switch((e||{}).type||"base64"){case"buffer":return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]];case"base64":r=Bt(t.slice(0,12));break;case"binary":r=t;break;case"array":return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]];default:throw new Error("Unrecognized type "+(e&&e.type||"undefined"))}return[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3),r.charCodeAt(4),r.charCodeAt(5),r.charCodeAt(6),r.charCodeAt(7)]}function h3(t,e){return de.find(t,"EncryptedPackage")?o3(t,e):Tc(t,e)}function u3(t,e){var r,a=t,n=e||{};return n.type||(n.type=_e&&Buffer.isBuffer(t)?"buffer":"base64"),r=j0(a,n),s3(r,n)}function Mc(t,e){var r=0;e:for(;r<t.length;)switch(t.charCodeAt(r)){case 10:case 13:case 32:++r;break;case 60:return Ki(t.slice(r),e);default:break e}return La.to_workbook(t,e)}function d3(t,e){var r="",a=Us(t,e);switch(e.type){case"base64":r=Bt(t);break;case"binary":r=t;break;case"buffer":r=t.toString("binary");break;case"array":r=ia(t);break;default:throw new Error("Unrecognized type "+e.type)}return a[0]==239&&a[1]==187&&a[2]==191&&(r=Re(r)),e.type="binary",Mc(r,e)}function p3(t,e){var r=t;return e.type=="base64"&&(r=Bt(r)),r=Vi.utils.decode(1200,r.slice(2),"str"),e.type="binary",Mc(r,e)}function m3(t){return t.match(/[^\x00-\x7F]/)?pr(t):t}function Ii(t,e,r,a){return a?(r.type="string",La.to_workbook(t,r)):La.to_workbook(e,r)}function qi(t,e){is();var r=e||{};if(typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer)return qi(new Uint8Array(t),(r=We(r),r.type="array",r));typeof Uint8Array<"u"&&t instanceof Uint8Array&&!r.type&&(r.type=typeof Deno<"u"?"buffer":"array");var a=t,n=[0,0,0,0],i=!1;if(r.cellStyles&&(r.cellNF=!0,r.sheetStubs=!0),ba={},r.dateNF&&(ba.dateNF=r.dateNF),r.type||(r.type=_e&&Buffer.isBuffer(t)?"buffer":"base64"),r.type=="file"&&(r.type=_e?"buffer":"binary",a=cu(t),typeof Uint8Array<"u"&&!_e&&(r.type="array")),r.type=="string"&&(i=!0,r.type="binary",r.codepage=65001,a=m3(t)),r.type=="array"&&typeof Uint8Array<"u"&&t instanceof Uint8Array&&typeof ArrayBuffer<"u"){var s=new ArrayBuffer(3),o=new Uint8Array(s);if(o.foo="bar",!o.foo)return r=We(r),r.type="array",qi(ss(a),r)}switch((n=Us(a,r))[0]){case 208:if(n[1]===207&&n[2]===17&&n[3]===224&&n[4]===161&&n[5]===177&&n[6]===26&&n[7]===225)return h3(de.read(a,r),r);break;case 9:if(n[1]<=8)return Tc(a,r);break;case 60:return Ki(a,r);case 73:if(n[1]===73&&n[2]===42&&n[3]===0)throw new Error("TIFF Image File is not a spreadsheet");if(n[1]===68)return wp(a,r);break;case 84:if(n[1]===65&&n[2]===66&&n[3]===76)return $l.to_workbook(a,r);break;case 80:return n[1]===75&&n[2]<9&&n[3]<9?u3(a,r):Ii(t,a,r,i);case 239:return n[3]===60?Ki(a,r):Ii(t,a,r,i);case 255:if(n[1]===254)return p3(a,r);if(n[1]===0&&n[2]===2&&n[3]===0)return Qr.to_workbook(a,r);break;case 0:if(n[1]===0&&(n[2]>=2&&n[3]===0||n[2]===0&&(n[3]===8||n[3]===9)))return Qr.to_workbook(a,r);break;case 3:case 131:case 139:case 140:return ji.to_workbook(a,r);case 123:if(n[1]===92&&n[2]===114&&n[3]===116)return Jl.to_workbook(a,r);break;case 10:case 13:case 32:return d3(a,r);case 137:if(n[1]===80&&n[2]===78&&n[3]===71)throw new Error("PNG Image File is not a spreadsheet");break}return Ep.indexOf(n[0])>-1&&n[2]<=12&&n[3]<=31?ji.to_workbook(a,r):Ii(t,a,r,i)}function Oc(t,e){switch(e.type){case"base64":case"binary":break;case"buffer":case"array":e.type="";break;case"file":return pn(e.file,de.write(t,{type:_e?"buffer":""}));case"string":throw new Error("'string' output type invalid for '"+e.bookType+"' files");default:throw new Error("Unrecognized type "+e.type)}return de.write(t,e)}function g3(t,e){var r=We(e||{}),a=l3(t,r);return x3(a,r)}function x3(t,e){var r={},a=_e?"nodebuffer":typeof Uint8Array<"u"?"array":"string";if(e.compression&&(r.compression="DEFLATE"),e.password)r.type=a;else switch(e.type){case"base64":r.type="base64";break;case"binary":r.type="string";break;case"string":throw new Error("'string' output type invalid for '"+e.bookType+"' files");case"buffer":case"file":r.type=a;break;default:throw new Error("Unrecognized type "+e.type)}var n=t.FullPaths?de.write(t,{fileType:"zip",type:{nodebuffer:"buffer",string:"binary"}[r.type]||r.type,compression:!!e.compression}):t.generate(r);if(typeof Deno<"u"&&typeof n=="string"){if(e.type=="binary"||e.type=="base64")return n;n=new Uint8Array(ii(n))}return e.password&&typeof encrypt_agile<"u"?Oc(encrypt_agile(n,e.password),e):e.type==="file"?pn(e.file,n):e.type=="string"?Re(n):n}function v3(t,e){var r=e||{},a=m4(t,r);return Oc(a,r)}function ur(t,e,r){r||(r="");var a=r+t;switch(e.type){case"base64":return en(pr(a));case"binary":return pr(a);case"string":return t;case"file":return pn(e.file,a,"utf8");case"buffer":return _e?br(a,"utf8"):typeof TextEncoder<"u"?new TextEncoder().encode(a):ur(a,{type:"binary"}).split("").map(function(n){return n.charCodeAt(0)})}throw new Error("Unrecognized type "+e.type)}function E3(t,e){switch(e.type){case"base64":return en(t);case"binary":return t;case"string":return t;case"file":return pn(e.file,t,"binary");case"buffer":return _e?br(t,"binary"):t.split("").map(function(r){return r.charCodeAt(0)})}throw new Error("Unrecognized type "+e.type)}function Mn(t,e){switch(e.type){case"string":case"base64":case"binary":for(var r="",a=0;a<t.length;++a)r+=String.fromCharCode(t[a]);return e.type=="base64"?en(r):e.type=="string"?Re(r):r;case"file":return pn(e.file,t);case"buffer":return t;default:throw new Error("Unrecognized type "+e.type)}}function Pc(t,e){is(),h5(t);var r=We(e||{});if(r.cellStyles&&(r.cellNF=!0,r.sheetStubs=!0),r.type=="array"){r.type="binary";var a=Pc(t,r);return r.type="array",ii(a)}var n=0;if(r.sheet&&(typeof r.sheet=="number"?n=r.sheet:n=t.SheetNames.indexOf(r.sheet),!t.SheetNames[n]))throw new Error("Sheet not found: "+r.sheet+" : "+typeof r.sheet);switch(r.bookType||"xlsb"){case"xml":case"xlml":return ur(l4(t,r),r);case"slk":case"sylk":return ur(Wl.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"htm":case"html":return ur(bc(t.Sheets[t.SheetNames[n]],r),r);case"txt":return E3(Dc(t.Sheets[t.SheetNames[n]],r),r);case"csv":return ur(Hs(t.Sheets[t.SheetNames[n]],r),r,"\uFEFF");case"dif":return ur($l.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"dbf":return Mn(ji.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"prn":return ur(La.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"rtf":return ur(Jl.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"eth":return ur(Gl.from_sheet(t.Sheets[t.SheetNames[n]],r),r);case"fods":return ur(Ic(t,r),r);case"wk1":return Mn(Qr.sheet_to_wk1(t.Sheets[t.SheetNames[n]],r),r);case"wk3":return Mn(Qr.book_to_wk3(t,r),r);case"biff2":r.biff||(r.biff=2);case"biff3":r.biff||(r.biff=3);case"biff4":return r.biff||(r.biff=4),Mn(Sc(t,r),r);case"biff5":r.biff||(r.biff=5);case"biff8":case"xla":case"xls":return r.biff||(r.biff=8),v3(t,r);case"xlsx":case"xlsm":case"xlam":case"xlsb":case"numbers":case"ods":return g3(t,r);default:throw new Error("Unrecognized bookType |"+r.bookType+"|")}}function w3(t){if(!t.bookType){var e={xls:"biff8",htm:"html",slk:"sylk",socialcalc:"eth",Sh33tJS:"WTF"},r=t.file.slice(t.file.lastIndexOf(".")).toLowerCase();r.match(/^\.[a-z]+$/)&&(t.bookType=r.slice(1)),t.bookType=e[t.bookType]||t.bookType}}function C3(t,e,r){var a={};return a.type="file",a.file=e,w3(a),Pc(t,a)}function y3(t,e,r,a,n,i,s,o){var l=et(r),c=o.defval,f=o.raw||!Object.prototype.hasOwnProperty.call(o,"raw"),h=!0,u=n===1?[]:{};if(n!==1)if(Object.defineProperty)try{Object.defineProperty(u,"__rowNum__",{value:r,enumerable:!1})}catch{u.__rowNum__=r}else u.__rowNum__=r;if(!s||t[r])for(var p=e.s.c;p<=e.e.c;++p){var m=s?t[r][p]:t[a[p]+l];if(m===void 0||m.t===void 0){if(c===void 0)continue;i[p]!=null&&(u[i[p]]=c);continue}var d=m.v;switch(m.t){case"z":if(d==null)break;continue;case"e":d=d==0?null:void 0;break;case"s":case"d":case"b":case"n":break;default:throw new Error("unrecognized type "+m.t)}if(i[p]!=null){if(d==null)if(m.t=="e"&&d===null)u[i[p]]=null;else if(c!==void 0)u[i[p]]=c;else if(f&&d===null)u[i[p]]=null;else continue;else u[i[p]]=f&&(m.t!=="n"||m.t==="n"&&o.rawNumbers!==!1)?d:Sr(m,d,o);d!=null&&(h=!1)}}return{row:u,isempty:h}}function ai(t,e){if(t==null||t["!ref"]==null)return[];var r={t:"n",v:0},a=0,n=1,i=[],s=0,o="",l={s:{r:0,c:0},e:{r:0,c:0}},c=e||{},f=c.range!=null?c.range:t["!ref"];switch(c.header===1?a=1:c.header==="A"?a=2:Array.isArray(c.header)?a=3:c.header==null&&(a=0),typeof f){case"string":l=Ie(f);break;case"number":l=Ie(t["!ref"]),l.s.r=f;break;default:l=f}a>0&&(n=0);var h=et(l.s.r),u=[],p=[],m=0,d=0,g=Array.isArray(t),x=l.s.r,w=0,v={};g&&!t[x]&&(t[x]=[]);var F=c.skipHidden&&t["!cols"]||[],N=c.skipHidden&&t["!rows"]||[];for(w=l.s.c;w<=l.e.c;++w)if(!(F[w]||{}).hidden)switch(u[w]=Xe(w),r=g?t[x][w]:t[u[w]+h],a){case 1:i[w]=w-l.s.c;break;case 2:i[w]=u[w];break;case 3:i[w]=c.header[w-l.s.c];break;default:if(r==null&&(r={w:"__EMPTY",t:"s"}),o=s=Sr(r,null,c),d=v[s]||0,!d)v[s]=1;else{do o=s+"_"+d++;while(v[o]);v[s]=d,v[o]=1}i[w]=o}for(x=l.s.r+n;x<=l.e.r;++x)if(!(N[x]||{}).hidden){var A=y3(t,l,x,u,a,i,g,c);(A.isempty===!1||(a===1?c.blankrows!==!1:c.blankrows))&&(p[m++]=A.row)}return p.length=m,p}var p0=/"/g;function k3(t,e,r,a,n,i,s,o){for(var l=!0,c=[],f="",h=et(r),u=e.s.c;u<=e.e.c;++u)if(a[u]){var p=o.dense?(t[r]||[])[u]:t[a[u]+h];if(p==null)f="";else if(p.v!=null){l=!1,f=""+(o.rawNumbers&&p.t=="n"?p.v:Sr(p,null,o));for(var m=0,d=0;m!==f.length;++m)if((d=f.charCodeAt(m))===n||d===i||d===34||o.forceQuotes){f='"'+f.replace(p0,'""')+'"';break}f=="ID"&&(f='"ID"')}else p.f!=null&&!p.F?(l=!1,f="="+p.f,f.indexOf(",")>=0&&(f='"'+f.replace(p0,'""')+'"')):f="";c.push(f)}return o.blankrows===!1&&l?null:c.join(s)}function Hs(t,e){var r=[],a=e??{};if(t==null||t["!ref"]==null)return"";var n=Ie(t["!ref"]),i=a.FS!==void 0?a.FS:",",s=i.charCodeAt(0),o=a.RS!==void 0?a.RS:`
419
419
  `,l=o.charCodeAt(0),c=new RegExp((i=="|"?"\\|":i)+"+$"),f="",h=[];a.dense=Array.isArray(t);for(var u=a.skipHidden&&t["!cols"]||[],p=a.skipHidden&&t["!rows"]||[],m=n.s.c;m<=n.e.c;++m)(u[m]||{}).hidden||(h[m]=Xe(m));for(var d=0,g=n.s.r;g<=n.e.r;++g)(p[g]||{}).hidden||(f=k3(t,n,g,h,s,l,i,a),f!=null&&(a.strip&&(f=f.replace(c,"")),(f||a.blankrows!==!1)&&r.push((d++?o:"")+f)));return delete a.dense,r.join("")}function Dc(t,e){e||(e={}),e.FS=" ",e.RS=`
420
- `;var r=Hs(t,e);return r}function _3(t){var e="",r,a="";if(t==null||t["!ref"]==null)return[];var n=Ie(t["!ref"]),i="",s=[],o,l=[],c=Array.isArray(t);for(o=n.s.c;o<=n.e.c;++o)s[o]=Xe(o);for(var f=n.s.r;f<=n.e.r;++f)for(i=et(f),o=n.s.c;o<=n.e.c;++o)if(e=s[o]+i,r=c?(t[f]||[])[o]:t[e],a="",r!==void 0){if(r.F!=null){if(e=r.F,!r.f)continue;a=r.f,e.indexOf(":")==-1&&(e=e+":"+e)}if(r.f!=null)a=r.f;else{if(r.t=="z")continue;if(r.t=="n"&&r.v!=null)a=""+r.v;else if(r.t=="b")a=r.v?"TRUE":"FALSE";else if(r.w!==void 0)a="'"+r.w;else{if(r.v===void 0)continue;r.t=="s"?a="'"+r.v:a=""+r.v}}l[l.length]=e+"="+a}return l}function Rc(t,e,r){var a=r||{},n=+!a.skipHeader,i=t||{},s=0,o=0;if(i&&a.origin!=null)if(typeof a.origin=="number")s=a.origin;else{var l=typeof a.origin=="string"?je(a.origin):a.origin;s=l.r,o=l.c}var c,f={s:{c:0,r:0},e:{c:o,r:s+e.length-1+n}};if(i["!ref"]){var h=Ie(i["!ref"]);f.e.c=Math.max(f.e.c,h.e.c),f.e.r=Math.max(f.e.r,h.e.r),s==-1&&(s=h.e.r+1,f.e.r=s+e.length-1+n)}else s==-1&&(s=0,f.e.r=e.length-1+n);var u=a.header||[],p=0;e.forEach(function(d,g){Je(d).forEach(function(x){(p=u.indexOf(x))==-1&&(u[p=u.length]=x);var w=d[x],v="z",F="",N=ge({c:o+p,r:s+g+n});c=dn(i,N),w&&typeof w=="object"&&!(w instanceof Date)?i[N]=w:(typeof w=="number"?v="n":typeof w=="boolean"?v="b":typeof w=="string"?v="s":w instanceof Date?(v="d",a.cellDates||(v="n",w=ot(w)),F=a.dateNF||me[14]):w===null&&a.nullError&&(v="e",w=0),c?(c.t=v,c.v=w,delete c.w,delete c.R,F&&(c.z=F)):i[N]=c={t:v,v:w},F&&(c.z=F))})}),f.e.c=Math.max(f.e.c,o+u.length-1);var m=et(s);if(n)for(p=0;p<u.length;++p)i[Xe(p+o)+m]={t:"s",v:u[p]};return i["!ref"]=Ce(f),i}function T3(t,e){return Rc(null,t,e)}function dn(t,e,r){if(typeof e=="string"){if(Array.isArray(t)){var a=je(e);return t[a.r]||(t[a.r]=[]),t[a.r][a.c]||(t[a.r][a.c]={t:"z"})}return t[e]||(t[e]={t:"z"})}return typeof e!="number"?dn(t,ge(e)):dn(t,ge({r:e,c:r||0}))}function S3(t,e){if(typeof e=="number"){if(e>=0&&t.SheetNames.length>e)return e;throw new Error("Cannot find sheet # "+e)}else if(typeof e=="string"){var r=t.SheetNames.indexOf(e);if(r>-1)return r;throw new Error("Cannot find sheet name |"+e+"|")}else throw new Error("Cannot find sheet |"+e+"|")}function Ws(){return{SheetNames:[],Sheets:{}}}function $s(t,e,r,a){var n=1;if(!r)for(;n<=65535&&t.SheetNames.indexOf(r="Sheet"+n)!=-1;++n,r=void 0);if(!r||t.SheetNames.length>=65535)throw new Error("Too many worksheets");if(a&&t.SheetNames.indexOf(r)>=0){var i=r.match(/(^.*?)(\d+)$/);n=i&&+i[2]||0;var s=i&&i[1]||r;for(++n;n<=65535&&t.SheetNames.indexOf(r=s+n)!=-1;++n);}if(wc(r),t.SheetNames.indexOf(r)>=0)throw new Error("Worksheet with name |"+r+"| already exists!");return t.SheetNames.push(r),t.Sheets[r]=e,r}function b3(t,e,r){t.Workbook||(t.Workbook={}),t.Workbook.Sheets||(t.Workbook.Sheets=[]);var a=S3(t,e);switch(t.Workbook.Sheets[a]||(t.Workbook.Sheets[a]={}),r){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+r)}t.Workbook.Sheets[a].Hidden=r}function F3(t,e){return t.z=e,t}function Bc(t,e,r){return e?(t.l={Target:e},r&&(t.l.Tooltip=r)):delete t.l,t}function L3(t,e,r){return Bc(t,"#"+e,r)}function A3(t,e,r){t.c||(t.c=[]),t.c.push({t:e,a:r||"SheetJS"})}function I3(t,e,r,a){for(var n=typeof e!="string"?e:Ie(e),i=typeof e=="string"?e:Ce(e),s=n.s.r;s<=n.e.r;++s)for(var o=n.s.c;o<=n.e.c;++o){var l=dn(t,s,o);l.t="n",l.F=i,delete l.v,s==n.s.r&&o==n.s.c&&(l.f=r,a&&(l.D=!0))}return t}var On={encode_col:Xe,encode_row:et,encode_cell:ge,encode_range:Ce,decode_col:vs,decode_row:xs,split_cell:Hu,decode_cell:je,decode_range:At,format_cell:Sr,sheet_add_aoa:hl,sheet_add_json:Rc,sheet_add_dom:Fc,aoa_to_sheet:Ma,json_to_sheet:T3,table_to_sheet:Lc,table_to_book:R4,sheet_to_csv:Hs,sheet_to_txt:Dc,sheet_to_json:ai,sheet_to_html:bc,sheet_to_formulae:_3,sheet_to_row_object_array:ai,sheet_get_cell:dn,book_new:Ws,book_append_sheet:$s,book_set_sheet_visibility:b3,cell_set_number_format:F3,cell_set_hyperlink:Bc,cell_set_internal_link:L3,cell_add_comment:A3,sheet_set_array_formula:I3,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};class Zi{static exportToExcel(e,r,a="translations.xlsx"){const n={};e.forEach(h=>{const p=h.id.split(" > ")[0]||"unknown";n[p]||(n[p]=[]),n[p].push(h)});const i=[],s=["Component","Title",...r];i.push(s),i.push([]),Object.keys(n).sort().forEach((h,u)=>{const p=n[h];p.sort((m,d)=>(m.title||"").localeCompare(d.title||"")),u>0&&i.push([]),p.forEach((m,d)=>{const g=[d===0?h:"",m.title||m.id];r.forEach(x=>{g.push(m.value[x]||"")}),i.push(g)})});const l=On.aoa_to_sheet(i),c=[{wch:18},{wch:30},...r.map(()=>({wch:22}))];l["!cols"]=c;const f=On.book_new();On.book_append_sheet(f,l,"Translations"),C3(f,a)}static async importFromExcel(e,r){return new Promise((a,n)=>{const i=new FileReader;i.onload=s=>{var o;try{const l=(o=s.target)==null?void 0:o.result,c=qi(l,{type:"binary"}),f=c.SheetNames[0],h=c.Sheets[f],u=On.sheet_to_json(h,{header:1});if(u.length<2){n(new Error("Excel file is empty or invalid"));return}const p=u[0],m=p.indexOf("Component"),d=p.indexOf("Title"),g=p.indexOf("Component Path");if(d===-1&&g===-1){n(new Error("Excel file must have 'Title' or 'Component Path' column"));return}const x={};r.forEach(F=>{const N=p.indexOf(F);N!==-1&&(x[F]=N)});const w=[];let v="";for(let F=1;F<u.length;F++){const N=u[F];if(!(!N||N.length===0))if(m!==-1){const A=N[m],y=typeof A=="string"?A.trim():"";y&&(v=y);const P=N[d],I=typeof P=="string"?P.trim():"";if(!I)continue;const z=v?`${v} > ${I}`:I,V={};r.forEach(R=>{const J=x[R];J!==void 0&&(V[R]=N[J]||"")}),w.push({id:z,title:I,value:V})}else{const A=N[0],y=typeof A=="string"?A.trim():"";if(!y)continue;if(y.startsWith("[")&&y.endsWith("]")){v=y.slice(1,-1);continue}if(!r.some(J=>{const le=x[J];return le!==void 0&&N[le]})&&N.length<=1){v=y;continue}const I=g!==-1?N[g]:N[d],z=typeof I=="string"?I.trim():String(I||"");if(!z)continue;const V=v?`${v} > ${z}`:z,R={};r.forEach(J=>{const le=x[J];le!==void 0&&(R[J]=N[le]||"")}),w.push({id:V,title:z,value:R})}}a(w)}catch(l){n(l)}},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsBinaryString(e)})}static isMultiLanguageValue(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=Object.keys(e),a=/^[a-z]{2}(-[a-z]{2})?$/i,n=r.filter(s=>!s.startsWith("$"));if(n.length===0)return!1;const i=n.filter(s=>a.test(s)&&typeof e[s]=="string");return i.length>0&&i.length>=n.length*.5}static extractMultiLanguageValues(e,r,a=""){const n=[];for(const[i,s]of Object.entries(e)){const o=a?`${a} > ${i}`:i,l=`${r} > ${o}`;if(this.isMultiLanguageValue(s)){const c={};for(const[f,h]of Object.entries(s))!f.startsWith("$")&&typeof h=="string"&&(c[f]=h);n.push({id:l,title:o,value:c})}else if(s&&typeof s=="object"&&!Array.isArray(s)){const c=this.extractMultiLanguageValues(s,r,o);n.push(...c)}else Array.isArray(s)&&s.forEach((c,f)=>{if(c&&typeof c=="object"){const h=this.extractMultiLanguageValues(c,r,`${o}[${f}]`);n.push(...h)}})}return n}static exportFromComponentInstances(e,r="translations.xlsx"){const a=[],n=new Set;if(e.forEach(s=>{if(!s.currentSettings)return;this.extractMultiLanguageValues(s.currentSettings,s.component).forEach(l=>{a.push(l),Object.keys(l.value).forEach(c=>n.add(c))})}),a.length===0){console.warn("No translations found in the provided components");return}const i=Array.from(n).sort();this.exportToExcel(a,i,r)}static async importToComponentInstances(e,r){const a=new Set;r.forEach(l=>{if(!l.currentSettings)return;this.extractMultiLanguageValues(l.currentSettings,l.component).forEach(f=>{Object.keys(f.value).forEach(h=>a.add(h))})});const n=Array.from(a).sort(),i=await this.importFromExcel(e,n),s=new Map;return i.forEach(l=>{s.set(l.id,l.value)}),r.map(l=>{const c=this.updateSettingsWithTranslations(JSON.parse(JSON.stringify(l.currentSettings)),l.component,s);return{...l,currentSettings:c}})}static updateSettingsWithTranslations(e,r,a,n=""){const i={};for(const[s,o]of Object.entries(e)){const l=n?`${n} > ${s}`:s,c=`${r} > ${l}`;if(this.isMultiLanguageValue(o)){const f=a.get(c);if(f){const h={...f};for(const[u,p]of Object.entries(o))u.startsWith("$")&&(h[u]=p);i[s]=h}else i[s]=o}else o&&typeof o=="object"&&!Array.isArray(o)?i[s]=this.updateSettingsWithTranslations(o,r,a,l):Array.isArray(o)?i[s]=o.map((f,h)=>f&&typeof f=="object"?this.updateSettingsWithTranslations(f,r,a,`${l}[${h}]`):f):i[s]=o}return i}}const er=class er extends Le{constructor(e){super(e),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,this.componentPath="",this.$id="",this.isDerty=!1,this.instanceId=Un(),this.componentPath=e.title||this.instanceId,e.default?this.value=e.default:this.value||(this.value={}),this.value.$id=this.$id=Un(),this.messageHandler=n=>{const{type:i,data:s}=n.data||{};i==="TEXT_ELEMENT_CLICKED"&&s.$id==this.$id&&this.showPopup()};const r=er.messageListeners.get(this.instanceId);r&&window.removeEventListener("message",r),er.messageListeners.set(this.instanceId,this.messageHandler),window.addEventListener("message",this.messageHandler),this.defaultLanguage=this.resolveDefaultLanguage();const a=e.multiImg?e.defaultValue||"":e.defaultValue||Vn(this.defaultLanguage);e.languages.forEach(n=>{var i,s;n in(this.value||{})||(this.value||(this.value={}),n===this.defaultLanguage&&a?this.value[n]=((i=e.default)==null?void 0:i[n])||a:this.value[n]=((s=e.default)==null?void 0:s[n])||"")})}normalizeLanguageCode(e){return(e||"").trim().toLowerCase()}findLanguageMatch(e){const r=this.normalizeLanguageCode(e);return this.props.languages.find(a=>this.normalizeLanguageCode(a)===r)}resolveDefaultLanguage(){const e=this.findLanguageMatch(Le.DefaultLanguage),r=Le.HasExplicitCurrentLanguage()&&Le.CurrentLanguage()?this.findLanguageMatch(Le.CurrentLanguage()):void 0;return e||r||this.props.languages[0]}createTextareaRowForLanguage(e,r=!1){var o;const a=((o=this.value)==null?void 0:o[e])||"",n=Vn(e,this.props.placeholder||Bi),i=this.uploadSettings.get(e);if(this.props.multiImg&&!i){const l=new Qa({defaultUrl:a||"",title:"",id:`${this.id}_upload_${e}`});l.setOnChange(c=>{this.updateLanguageValue(e,c),e===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(c)}),this.uploadSettings.set(e,l)}const s=this.getDataPropsPath()?`${this.getDataPropsPath()}_${e}`:void 0;return L0({languageCode:e,value:a,placeholder:n,isDefaultLanguage:e===this.defaultLanguage,isPopupMode:r,multiImg:this.props.multiImg||!1,onInput:(l,c)=>{this.updateLanguageValue(l,c),l===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(c)},uploadSetting:this.uploadSettings.get(e),dataTestId:s})}updateLanguageValue(e,r){this.value||(this.value={});const a={...this.value,[e]:r};this.setValue(a)}updateOtherLanguagePlaceholders(e){!this.container&&!this.popup||this.props.languages.forEach(r=>{if(r===this.defaultLanguage)return;const a=e||Vn(r,this.props.placeholder||Bi);[this.container,this.popup].forEach(n=>{const i=n==null?void 0:n.querySelector(`#textarea-${r}`);i&&(!i.value||i.value.trim()==="")&&(i.setAttribute("data-full-placeholder",a),Kr(i,a))})})}renderContent(e){const r=e.querySelector(".simple-multi-language-content");if(!r)return;r.innerHTML="";const a=Le.HasExplicitCurrentLanguage(),n=Le.CurrentLanguage();if(!a||!n||!this.props.languages.includes(n))this.props.languages.forEach(i=>{const s=this.createTextareaRowForLanguage(i,!1);r.appendChild(s)});else{const i=this.createTextareaRowForLanguage(n,!1);r.appendChild(i);const s=r.querySelector(".simple-language-textarea");if(s){const o=s.getAttribute("data-full-placeholder")||"";o&&Kr(s,o)}}}showPopup(){var e;this.popup||(this.props.multiImg&&this.props.languages.forEach(r=>{var a;if(!this.uploadSettings.has(r)){const n=((a=this.value)==null?void 0:a[r])||"",i=new Qa({defaultUrl:n,title:"",id:`${this.id}_upload_${r}`});i.setOnChange(s=>{this.updateLanguageValue(r,s),r===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(s)}),this.uploadSettings.set(r,i)}}),this.popup=Ah({languages:this.props.languages,values:this.value||{},placeholder:this.props.placeholder,multiImg:this.props.multiImg||!1,onClose:()=>this.closePopup(),onInput:(r,a)=>{this.updateLanguageValue(r,a),r===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)},uploadSettings:this.uploadSettings,dataTestPath:this.getDataPropsPath()}),document.body.appendChild(this.popup),this.updateOtherLanguagePlaceholders(((e=this.value)==null?void 0:e[this.defaultLanguage])||""))}closePopup(){this.popup&&(document.body.removeChild(this.popup),this.popup=null)}draw(){const e=document.createElement("div");e.classList.add("simple-multi-language-wrapper"),this.defaultLanguage=this.resolveDefaultLanguage();const r=Fh({title:this.props.title??"",onEyeIconClick:()=>this.showPopup()});e.appendChild(r);const a=document.createElement("div");return a.classList.add("simple-multi-language-content"),e.appendChild(a),this.container=e,this.renderContent(e),this.languageChangeUnsubscribe=Le.onLanguageChange(n=>{this.container&&this.renderContent(this.container)}),this.resizeHandler=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(i=>{const s=i.getAttribute("data-full-placeholder")||"";s&&Kr(i,s)})},window.addEventListener("resize",this.resizeHandler),e}setValue(e){e.$id||(e.$id=this.$id),e.$id!=this.$id&&(this.$id=e.$id),super.setValue(e),this.container&&this.props.languages.forEach(r=>{var a;if(this.props.multiImg){const n=this.uploadSettings.get(r);n&&n.setValue((e==null?void 0:e[r])||"")}else{const n=(a=this.container)==null?void 0:a.querySelector(`#textarea-${r}`);if(n){n.value=(e==null?void 0:e[r])||"",rs(n,3);const i=n.getAttribute("data-full-placeholder")||"";i&&Kr(n,i)}}})}static exportAllToExcel(e="translations.xlsx"){const r=[],a=new Set;if(this.instances.forEach((i,s)=>{if(!i.value)return;i.props.languages.forEach(l=>a.add(l));const o={};i.props.languages.forEach(l=>{var c;o[l]=((c=i.value)==null?void 0:c[l])||""}),r.push({id:s,title:i.props.title||s,value:o})}),r.length===0){console.warn("No translations to export");return}const n=Array.from(a).sort();Zi.exportToExcel(r,n,e)}static async importFromExcel(e){const r=new Set;this.instances.forEach(n=>{n.props.languages.forEach(i=>r.add(i))});const a=Array.from(r).sort();try{const n=await Zi.importFromExcel(e,a);let i=0;n.forEach(s=>{const o=this.instances.get(s.id)||this.findInstanceByLeaf(s.id);o?(o.setValue(s.value),i++):console.warn(`No matching component found for translation id "${s.id}". Ensure the Excel uses the setting title or full component path.`)}),console.log(`Successfully imported ${i} translations`)}catch(n){throw console.error("Failed to import translations:",n),n}}static getAllInstances(){return new Map(this.instances)}static clearRegistry(){this.instances.clear()}static findInstanceByLeaf(e){const r=(e||"").trim().toLowerCase();if(!r)return;const a=[];if(this.instances.forEach((n,i)=>{const s=i.split(">");s[s.length-1].trim().toLowerCase()===r&&a.push(n)}),a.length===1)return a[0];a.length>1&&console.warn(`Multiple components matched the title "${e}". Please use the full component path in the Excel file to disambiguate.`)}setComponentPath(e){this.componentPath&&er.instances.get(this.componentPath)===this&&er.instances.delete(this.componentPath),this.componentPath=e,er.instances.set(e,this)}getComponentPath(){return this.componentPath}cleanup(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=void 0),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=void 0),this.languageChangeUnsubscribe&&(this.languageChangeUnsubscribe(),this.languageChangeUnsubscribe=void 0),this.closePopup(),this.instanceId&&this.messageHandler&&(er.messageListeners.get(this.instanceId)===this.messageHandler&&er.messageListeners.delete(this.instanceId),window.removeEventListener("message",this.messageHandler),this.messageHandler=void 0)}};er.instances=new Map,er.messageListeners=new Map;let Jr=er;class N3{constructor(e={}){this.container=null,this.options=e}draw(){const e=document.createElement("div");e.className="translation-manager";const r=document.createElement("h3");r.className="translation-manager-title",r.textContent="Translation Management",e.appendChild(r);const a=document.createElement("div");a.className="translation-manager-buttons";const n=document.createElement("button");n.type="button",n.className="translation-manager-button export-button",n.innerHTML=`
420
+ `;var r=Hs(t,e);return r}function _3(t){var e="",r,a="";if(t==null||t["!ref"]==null)return[];var n=Ie(t["!ref"]),i="",s=[],o,l=[],c=Array.isArray(t);for(o=n.s.c;o<=n.e.c;++o)s[o]=Xe(o);for(var f=n.s.r;f<=n.e.r;++f)for(i=et(f),o=n.s.c;o<=n.e.c;++o)if(e=s[o]+i,r=c?(t[f]||[])[o]:t[e],a="",r!==void 0){if(r.F!=null){if(e=r.F,!r.f)continue;a=r.f,e.indexOf(":")==-1&&(e=e+":"+e)}if(r.f!=null)a=r.f;else{if(r.t=="z")continue;if(r.t=="n"&&r.v!=null)a=""+r.v;else if(r.t=="b")a=r.v?"TRUE":"FALSE";else if(r.w!==void 0)a="'"+r.w;else{if(r.v===void 0)continue;r.t=="s"?a="'"+r.v:a=""+r.v}}l[l.length]=e+"="+a}return l}function Rc(t,e,r){var a=r||{},n=+!a.skipHeader,i=t||{},s=0,o=0;if(i&&a.origin!=null)if(typeof a.origin=="number")s=a.origin;else{var l=typeof a.origin=="string"?je(a.origin):a.origin;s=l.r,o=l.c}var c,f={s:{c:0,r:0},e:{c:o,r:s+e.length-1+n}};if(i["!ref"]){var h=Ie(i["!ref"]);f.e.c=Math.max(f.e.c,h.e.c),f.e.r=Math.max(f.e.r,h.e.r),s==-1&&(s=h.e.r+1,f.e.r=s+e.length-1+n)}else s==-1&&(s=0,f.e.r=e.length-1+n);var u=a.header||[],p=0;e.forEach(function(d,g){Je(d).forEach(function(x){(p=u.indexOf(x))==-1&&(u[p=u.length]=x);var w=d[x],v="z",F="",N=ge({c:o+p,r:s+g+n});c=dn(i,N),w&&typeof w=="object"&&!(w instanceof Date)?i[N]=w:(typeof w=="number"?v="n":typeof w=="boolean"?v="b":typeof w=="string"?v="s":w instanceof Date?(v="d",a.cellDates||(v="n",w=ot(w)),F=a.dateNF||me[14]):w===null&&a.nullError&&(v="e",w=0),c?(c.t=v,c.v=w,delete c.w,delete c.R,F&&(c.z=F)):i[N]=c={t:v,v:w},F&&(c.z=F))})}),f.e.c=Math.max(f.e.c,o+u.length-1);var m=et(s);if(n)for(p=0;p<u.length;++p)i[Xe(p+o)+m]={t:"s",v:u[p]};return i["!ref"]=Ce(f),i}function T3(t,e){return Rc(null,t,e)}function dn(t,e,r){if(typeof e=="string"){if(Array.isArray(t)){var a=je(e);return t[a.r]||(t[a.r]=[]),t[a.r][a.c]||(t[a.r][a.c]={t:"z"})}return t[e]||(t[e]={t:"z"})}return typeof e!="number"?dn(t,ge(e)):dn(t,ge({r:e,c:r||0}))}function S3(t,e){if(typeof e=="number"){if(e>=0&&t.SheetNames.length>e)return e;throw new Error("Cannot find sheet # "+e)}else if(typeof e=="string"){var r=t.SheetNames.indexOf(e);if(r>-1)return r;throw new Error("Cannot find sheet name |"+e+"|")}else throw new Error("Cannot find sheet |"+e+"|")}function Ws(){return{SheetNames:[],Sheets:{}}}function $s(t,e,r,a){var n=1;if(!r)for(;n<=65535&&t.SheetNames.indexOf(r="Sheet"+n)!=-1;++n,r=void 0);if(!r||t.SheetNames.length>=65535)throw new Error("Too many worksheets");if(a&&t.SheetNames.indexOf(r)>=0){var i=r.match(/(^.*?)(\d+)$/);n=i&&+i[2]||0;var s=i&&i[1]||r;for(++n;n<=65535&&t.SheetNames.indexOf(r=s+n)!=-1;++n);}if(wc(r),t.SheetNames.indexOf(r)>=0)throw new Error("Worksheet with name |"+r+"| already exists!");return t.SheetNames.push(r),t.Sheets[r]=e,r}function b3(t,e,r){t.Workbook||(t.Workbook={}),t.Workbook.Sheets||(t.Workbook.Sheets=[]);var a=S3(t,e);switch(t.Workbook.Sheets[a]||(t.Workbook.Sheets[a]={}),r){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+r)}t.Workbook.Sheets[a].Hidden=r}function F3(t,e){return t.z=e,t}function Bc(t,e,r){return e?(t.l={Target:e},r&&(t.l.Tooltip=r)):delete t.l,t}function L3(t,e,r){return Bc(t,"#"+e,r)}function A3(t,e,r){t.c||(t.c=[]),t.c.push({t:e,a:r||"SheetJS"})}function I3(t,e,r,a){for(var n=typeof e!="string"?e:Ie(e),i=typeof e=="string"?e:Ce(e),s=n.s.r;s<=n.e.r;++s)for(var o=n.s.c;o<=n.e.c;++o){var l=dn(t,s,o);l.t="n",l.F=i,delete l.v,s==n.s.r&&o==n.s.c&&(l.f=r,a&&(l.D=!0))}return t}var On={encode_col:Xe,encode_row:et,encode_cell:ge,encode_range:Ce,decode_col:vs,decode_row:xs,split_cell:Hu,decode_cell:je,decode_range:At,format_cell:Sr,sheet_add_aoa:hl,sheet_add_json:Rc,sheet_add_dom:Fc,aoa_to_sheet:Ma,json_to_sheet:T3,table_to_sheet:Lc,table_to_book:R4,sheet_to_csv:Hs,sheet_to_txt:Dc,sheet_to_json:ai,sheet_to_html:bc,sheet_to_formulae:_3,sheet_to_row_object_array:ai,sheet_get_cell:dn,book_new:Ws,book_append_sheet:$s,book_set_sheet_visibility:b3,cell_set_number_format:F3,cell_set_hyperlink:Bc,cell_set_internal_link:L3,cell_add_comment:A3,sheet_set_array_formula:I3,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};class Zi{static exportToExcel(e,r,a="translations.xlsx"){const n={};e.forEach(h=>{const p=h.id.split(" > ")[0]||"unknown";n[p]||(n[p]=[]),n[p].push(h)});const i=[],s=["Component","Title",...r];i.push(s),i.push([]),Object.keys(n).sort().forEach((h,u)=>{const p=n[h];p.sort((m,d)=>(m.title||"").localeCompare(d.title||"")),u>0&&i.push([]),p.forEach((m,d)=>{const g=[d===0?h:"",m.title||m.id];r.forEach(x=>{g.push(m.value[x]||"")}),i.push(g)})});const l=On.aoa_to_sheet(i),c=[{wch:18},{wch:30},...r.map(()=>({wch:22}))];l["!cols"]=c;const f=On.book_new();On.book_append_sheet(f,l,"Translations"),C3(f,a)}static async importFromExcel(e,r){return new Promise((a,n)=>{const i=new FileReader;i.onload=s=>{var o;try{const l=(o=s.target)==null?void 0:o.result,c=qi(l,{type:"binary"}),f=c.SheetNames[0],h=c.Sheets[f],u=On.sheet_to_json(h,{header:1});if(u.length<2){n(new Error("Excel file is empty or invalid"));return}const p=u[0],m=p.indexOf("Component"),d=p.indexOf("Title"),g=p.indexOf("Component Path");if(d===-1&&g===-1){n(new Error("Excel file must have 'Title' or 'Component Path' column"));return}const x={};r.forEach(F=>{const N=p.indexOf(F);N!==-1&&(x[F]=N)});const w=[];let v="";for(let F=1;F<u.length;F++){const N=u[F];if(!(!N||N.length===0))if(m!==-1){const A=N[m],y=typeof A=="string"?A.trim():"";y&&(v=y);const P=N[d],I=typeof P=="string"?P.trim():"";if(!I)continue;const z=v?`${v} > ${I}`:I,V={};r.forEach(R=>{const J=x[R];J!==void 0&&(V[R]=N[J]||"")}),w.push({id:z,title:I,value:V})}else{const A=N[0],y=typeof A=="string"?A.trim():"";if(!y)continue;if(y.startsWith("[")&&y.endsWith("]")){v=y.slice(1,-1);continue}if(!r.some(J=>{const le=x[J];return le!==void 0&&N[le]})&&N.length<=1){v=y;continue}const I=g!==-1?N[g]:N[d],z=typeof I=="string"?I.trim():String(I||"");if(!z)continue;const V=v?`${v} > ${z}`:z,R={};r.forEach(J=>{const le=x[J];le!==void 0&&(R[J]=N[le]||"")}),w.push({id:V,title:z,value:R})}}a(w)}catch(l){n(l)}},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsBinaryString(e)})}static isMultiLanguageValue(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=Object.keys(e),a=/^[a-z]{2}(-[a-z]{2})?$/i,n=r.filter(s=>!s.startsWith("$"));if(n.length===0)return!1;const i=n.filter(s=>a.test(s)&&typeof e[s]=="string");return i.length>0&&i.length>=n.length*.5}static extractMultiLanguageValues(e,r,a=""){const n=[];for(const[i,s]of Object.entries(e)){const o=a?`${a} > ${i}`:i,l=`${r} > ${o}`;if(this.isMultiLanguageValue(s)){const c={};for(const[f,h]of Object.entries(s))!f.startsWith("$")&&typeof h=="string"&&(c[f]=h);n.push({id:l,title:o,value:c})}else if(s&&typeof s=="object"&&!Array.isArray(s)){const c=this.extractMultiLanguageValues(s,r,o);n.push(...c)}else Array.isArray(s)&&s.forEach((c,f)=>{if(c&&typeof c=="object"){const h=this.extractMultiLanguageValues(c,r,`${o}[${f}]`);n.push(...h)}})}return n}static exportFromComponentInstances(e,r="translations.xlsx"){const a=[],n=new Set;if(e.forEach(s=>{if(!s.currentSettings)return;this.extractMultiLanguageValues(s.currentSettings,s.component).forEach(l=>{a.push(l),Object.keys(l.value).forEach(c=>n.add(c))})}),a.length===0){console.warn("No translations found in the provided components");return}const i=Array.from(n).sort();this.exportToExcel(a,i,r)}static async importToComponentInstances(e,r){const a=new Set;r.forEach(l=>{if(!l.currentSettings)return;this.extractMultiLanguageValues(l.currentSettings,l.component).forEach(f=>{Object.keys(f.value).forEach(h=>a.add(h))})});const n=Array.from(a).sort(),i=await this.importFromExcel(e,n),s=new Map;return i.forEach(l=>{s.set(l.id,l.value)}),r.map(l=>{const c=this.updateSettingsWithTranslations(JSON.parse(JSON.stringify(l.currentSettings)),l.component,s);return{...l,currentSettings:c}})}static updateSettingsWithTranslations(e,r,a,n=""){const i={};for(const[s,o]of Object.entries(e)){const l=n?`${n} > ${s}`:s,c=`${r} > ${l}`;if(this.isMultiLanguageValue(o)){const f=a.get(c);if(f){const h={...f};for(const[u,p]of Object.entries(o))u.startsWith("$")&&(h[u]=p);i[s]=h}else i[s]=o}else o&&typeof o=="object"&&!Array.isArray(o)?i[s]=this.updateSettingsWithTranslations(o,r,a,l):Array.isArray(o)?i[s]=o.map((f,h)=>f&&typeof f=="object"?this.updateSettingsWithTranslations(f,r,a,`${l}[${h}]`):f):i[s]=o}return i}}const er=class er extends Le{constructor(e){super(e),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,this.componentPath="",this.$id="",this.isDerty=!1,this.instanceId=Un(),this.componentPath=e.title||this.instanceId,e.default?this.value=e.default:this.value||(this.value={}),this.value.$id=this.$id=Un(),this.messageHandler=n=>{const{type:i,data:s}=n.data||{};i==="TEXT_ELEMENT_CLICKED"&&s.$id==this.$id&&this.showPopup()};const r=er.messageListeners.get(this.instanceId);r&&window.removeEventListener("message",r),er.messageListeners.set(this.instanceId,this.messageHandler),window.addEventListener("message",this.messageHandler),this.defaultLanguage=this.resolveDefaultLanguage();const a=e.multiImg?e.defaultValue||"":e.defaultValue||Vn(this.defaultLanguage);e.languages.forEach(n=>{var i,s;n in(this.value||{})||(this.value||(this.value={}),n===this.defaultLanguage&&a?this.value[n]=((i=e.default)==null?void 0:i[n])||a:this.value[n]=((s=e.default)==null?void 0:s[n])||"")})}normalizeLanguageCode(e){return(e||"").trim().toLowerCase()}findLanguageMatch(e){const r=this.normalizeLanguageCode(e);return this.props.languages.find(a=>this.normalizeLanguageCode(a)===r)}resolveDefaultLanguage(){const e=this.findLanguageMatch(Le.DefaultLanguage),r=Le.HasExplicitCurrentLanguage()&&Le.CurrentLanguage()?this.findLanguageMatch(Le.CurrentLanguage()):void 0;return e||r||this.props.languages[0]}createTextareaRowForLanguage(e,r=!1){var o;const a=((o=this.value)==null?void 0:o[e])||"",n=Vn(e,this.props.placeholder||Bi),i=this.uploadSettings.get(e);if(this.props.multiImg&&!i){const l=new Qa({defaultUrl:a||"",title:"",id:`${this.id}_upload_${e}`});l.setOnChange(c=>{this.updateLanguageValue(e,c),e===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(c)}),this.uploadSettings.set(e,l)}const s=this.getDataPropsPath()?`${this.getDataPropsPath()}_${e}`:void 0;return L0({languageCode:e,value:a,placeholder:n,isDefaultLanguage:e===this.defaultLanguage,isPopupMode:r,multiImg:this.props.multiImg||!1,onInput:(l,c)=>{this.updateLanguageValue(l,c),l===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(c)},uploadSetting:this.uploadSettings.get(e),dataTestId:s})}updateLanguageValue(e,r){this.value||(this.value={});const a={...this.value,[e]:r};this.setValue(a)}updateOtherLanguagePlaceholders(e){!this.container&&!this.popup||this.props.languages.forEach(r=>{if(r===this.defaultLanguage)return;const a=e||Vn(r,this.props.placeholder||Bi);[this.container,this.popup].forEach(n=>{const i=n==null?void 0:n.querySelector(`#textarea-${r}`);i&&(!i.value||i.value.trim()==="")&&(i.setAttribute("data-full-placeholder",a),Kr(i,a))})})}renderContent(e){const r=e.querySelector(".simple-multi-language-content");if(!r)return;r.innerHTML="";const a=Le.HasExplicitCurrentLanguage(),n=Le.CurrentLanguage();if(!a||!n||!this.props.languages.includes(n))this.props.languages.forEach(i=>{const s=this.createTextareaRowForLanguage(i,!1);r.appendChild(s)});else{const i=this.createTextareaRowForLanguage(n,!1);r.appendChild(i);const s=r.querySelector(".simple-language-textarea");if(s){const o=s.getAttribute("data-full-placeholder")||"";o&&Kr(s,o)}}}showPopup(){var e;this.popup||(this.props.multiImg&&this.props.languages.forEach(r=>{var a;if(!this.uploadSettings.has(r)){const n=((a=this.value)==null?void 0:a[r])||"",i=new Qa({defaultUrl:n,title:"",id:`${this.id}_upload_${r}`});i.setOnChange(s=>{this.updateLanguageValue(r,s),r===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(s)}),this.uploadSettings.set(r,i)}}),this.popup=Ah({languages:this.props.languages,values:this.value||{},placeholder:this.props.placeholder,multiImg:this.props.multiImg||!1,onClose:()=>this.closePopup(),onInput:(r,a)=>{this.updateLanguageValue(r,a),r===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)},uploadSettings:this.uploadSettings,dataTestPath:this.getDataPropsPath()}),document.body.appendChild(this.popup),this.updateOtherLanguagePlaceholders(((e=this.value)==null?void 0:e[this.defaultLanguage])||""))}closePopup(){this.popup&&(document.body.removeChild(this.popup),this.popup=null)}draw(){const e=document.createElement("div");e.classList.add("simple-multi-language-wrapper"),this.defaultLanguage=this.resolveDefaultLanguage();const r=Fh({title:this.props.title??"",onEyeIconClick:()=>this.showPopup()});e.appendChild(r);const a=document.createElement("div");return a.classList.add("simple-multi-language-content"),e.appendChild(a),this.container=e,this.renderContent(e),this.languageChangeUnsubscribe=Le.onLanguageChange(n=>{this.container&&this.renderContent(this.container)}),this.resizeHandler=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(i=>{const s=i.getAttribute("data-full-placeholder")||"";s&&Kr(i,s)})},window.addEventListener("resize",this.resizeHandler),e}setValue(e){(!e.$id||e.$id!=this.$id)&&(e.$id=this.$id),super.setValue(e),this.container&&this.props.languages.forEach(r=>{var a;if(this.props.multiImg){const n=this.uploadSettings.get(r);n&&n.setValue((e==null?void 0:e[r])||"")}else{const n=(a=this.container)==null?void 0:a.querySelector(`#textarea-${r}`);if(n){n.value=(e==null?void 0:e[r])||"",rs(n,3);const i=n.getAttribute("data-full-placeholder")||"";i&&Kr(n,i)}}})}static exportAllToExcel(e="translations.xlsx"){const r=[],a=new Set;if(this.instances.forEach((i,s)=>{if(!i.value)return;i.props.languages.forEach(l=>a.add(l));const o={};i.props.languages.forEach(l=>{var c;o[l]=((c=i.value)==null?void 0:c[l])||""}),r.push({id:s,title:i.props.title||s,value:o})}),r.length===0){console.warn("No translations to export");return}const n=Array.from(a).sort();Zi.exportToExcel(r,n,e)}static async importFromExcel(e){const r=new Set;this.instances.forEach(n=>{n.props.languages.forEach(i=>r.add(i))});const a=Array.from(r).sort();try{const n=await Zi.importFromExcel(e,a);let i=0;n.forEach(s=>{const o=this.instances.get(s.id)||this.findInstanceByLeaf(s.id);o?(o.setValue(s.value),i++):console.warn(`No matching component found for translation id "${s.id}". Ensure the Excel uses the setting title or full component path.`)}),console.log(`Successfully imported ${i} translations`)}catch(n){throw console.error("Failed to import translations:",n),n}}static getAllInstances(){return new Map(this.instances)}static clearRegistry(){this.instances.clear()}static findInstanceByLeaf(e){const r=(e||"").trim().toLowerCase();if(!r)return;const a=[];if(this.instances.forEach((n,i)=>{const s=i.split(">");s[s.length-1].trim().toLowerCase()===r&&a.push(n)}),a.length===1)return a[0];a.length>1&&console.warn(`Multiple components matched the title "${e}". Please use the full component path in the Excel file to disambiguate.`)}setComponentPath(e){this.componentPath&&er.instances.get(this.componentPath)===this&&er.instances.delete(this.componentPath),this.componentPath=e,er.instances.set(e,this)}getComponentPath(){return this.componentPath}cleanup(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=void 0),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=void 0),this.languageChangeUnsubscribe&&(this.languageChangeUnsubscribe(),this.languageChangeUnsubscribe=void 0),this.closePopup(),this.instanceId&&this.messageHandler&&(er.messageListeners.get(this.instanceId)===this.messageHandler&&er.messageListeners.delete(this.instanceId),window.removeEventListener("message",this.messageHandler),this.messageHandler=void 0)}};er.instances=new Map,er.messageListeners=new Map;let Jr=er;class N3{constructor(e={}){this.container=null,this.options=e}draw(){const e=document.createElement("div");e.className="translation-manager";const r=document.createElement("h3");r.className="translation-manager-title",r.textContent="Translation Management",e.appendChild(r);const a=document.createElement("div");a.className="translation-manager-buttons";const n=document.createElement("button");n.type="button",n.className="translation-manager-button export-button",n.innerHTML=`
421
421
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
422
422
  <path d="M8 2V10M8 10L11 7M8 10L5 7M3 12V13C3 13.5523 3.44772 14 4 14H12C12.5523 14 13 13.5523 13 13V12" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
423
423
  </svg>
@@ -189,14 +189,7 @@ const lt = class lt {
189
189
  setComponentPath(e) {
190
190
  }
191
191
  setValue(e) {
192
- console.log(
193
- "📤 [setValue]",
194
- this.title || this.id,
195
- ":",
196
- this.value,
197
- "→",
198
- e
199
- ), this.value = e, this.inputEl && (this.inputEl.value = String(e)), this.onChange && this.onChange(e), this.props.detectChange && this.props.detectChange(e);
192
+ this.value = e, this.inputEl && (this.inputEl.value = String(e)), this.onChange && this.onChange(e), this.props.detectChange && this.props.detectChange(e);
200
193
  }
201
194
  clone() {
202
195
  const e = this.constructor, r = Un(this.props), a = new e(r);
@@ -1955,10 +1948,7 @@ function Oi(t) {
1955
1948
  const ai = class ai {
1956
1949
  constructor(e) {
1957
1950
  this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastChangeTime = 0, this.handleBlur = () => {
1958
- }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.isSettingValue = !1, this.suppressOnChange = !1, console.log(
1959
- "🔨 [SettingsGroup Created]",
1960
- e.title || "Unnamed Group"
1961
- ), this.suppressOnChange = !0, this.id = e.id || Vn(), this.title = e.title, this.settings = e.settings, this.isCollapsed = e.collapsed ?? !1, this.isMain = e.main ?? !1, this.custom = e.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = e.includeGetJson ?? !0, this.addItemCfg = e.addItem, this.deleteItemCfg = e.deleteItem, this.dataProps = e.dataProps, this.dataPropsPath = e.dataProps || "", this.hide = e.hide ?? !1, Object.assign(this, e.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath(), this.propagateComponentPaths(), this.suppressOnChange = !1;
1951
+ }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.isSettingValue = !1, this.suppressOnChange = !1, this.suppressOnChange = !0, this.id = e.id || Vn(), this.title = e.title, this.settings = e.settings, this.isCollapsed = e.collapsed ?? !1, this.isMain = e.main ?? !1, this.custom = e.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = e.includeGetJson ?? !0, this.addItemCfg = e.addItem, this.deleteItemCfg = e.deleteItem, this.dataProps = e.dataProps, this.dataPropsPath = e.dataProps || "", this.hide = e.hide ?? !1, Object.assign(this, e.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath(), this.propagateComponentPaths(), this.suppressOnChange = !1;
1962
1952
  }
1963
1953
  propagateNestingLevel() {
1964
1954
  const e = this.nestingLevel + 1;
@@ -2758,14 +2748,14 @@ class lr extends df {
2758
2748
  o.className = "color-content-global", o.style.display = "none", o.style.display = "grid", o.style.gridTemplateColumns = "repeat(auto-fill, minmax(30px, 1fr))", o.style.gap = "8px";
2759
2749
  const l = () => {
2760
2750
  try {
2761
- if (console.log("ColorSetting: renderGlobalOptions called"), o.innerHTML = "", !Le) {
2751
+ if (o.innerHTML = "", !Le) {
2762
2752
  console.error("ColorSetting: Setting class is undefined");
2763
2753
  const g = document.createElement("div");
2764
2754
  g.textContent = "Error: System error (Setting undefined)", o.appendChild(g);
2765
2755
  return;
2766
2756
  }
2767
2757
  const d = Le.GlobalVariables || {};
2768
- if (console.log("ColorSetting: GlobalVariables:", d), !d || Object.keys(d).length === 0) {
2758
+ if (!d || Object.keys(d).length === 0) {
2769
2759
  const g = document.createElement("div");
2770
2760
  g.textContent = "No global colors defined", g.style.gridColumn = "1 / -1", g.style.fontSize = "12px", g.style.color = "#666", o.appendChild(g);
2771
2761
  return;
@@ -3299,7 +3289,7 @@ class O3 extends Le {
3299
3289
  f >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), c = Math.round(c * 0.9)) : f = Math.min(1, f + 0.12), n = `rgba(${o},${l},${c},${f})`;
3300
3290
  }
3301
3291
  e.addEventListener("mouseenter", () => {
3302
- console.log("hoverBg", n), e.style.setProperty("background-color", n, "important");
3292
+ e.style.setProperty("background-color", n, "important");
3303
3293
  }), e.addEventListener("mouseleave", () => {
3304
3294
  e.style.setProperty("background-color", r, "important");
3305
3295
  }), e.addEventListener("click", () => {
@@ -29985,7 +29975,7 @@ const Qt = class Qt extends Le {
29985
29975
  }, window.addEventListener("resize", this.resizeHandler), e;
29986
29976
  }
29987
29977
  setValue(e) {
29988
- e.$id || (e.$id = this.$id), e.$id != this.$id && (this.$id = e.$id), super.setValue(e), this.container && this.props.languages.forEach((r) => {
29978
+ (!e.$id || e.$id != this.$id) && (e.$id = this.$id), super.setValue(e), this.container && this.props.languages.forEach((r) => {
29989
29979
  var a;
29990
29980
  if (this.props.multiImg) {
29991
29981
  const n = this.uploadSettings.get(r);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "builder-settings-types",
3
3
  "description": "builder settings",
4
- "version": "0.0.406",
4
+ "version": "0.0.408",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",